New UI windows behavior to clear workspace on ESC

Press ESC to toggle a 'clear workspace' mode. 
Cleanup of UserInterface rendering of output preview to enable this.
Move include to internal_imgui.h outside of ImGuiToolkit.h.
This commit is contained in:
Bruno Herbelin
2022-01-06 01:21:18 +01:00
parent 0ad844d10e
commit 3a300a4ca3
5 changed files with 713 additions and 509 deletions

View File

@@ -38,6 +38,7 @@
#include "SystemToolkit.h" #include "SystemToolkit.h"
#include "ImGuiToolkit.h" #include "ImGuiToolkit.h"
#include "imgui_internal.h"
bool tooltips_enabled = true; bool tooltips_enabled = true;
unsigned int textureicons = 0; unsigned int textureicons = 0;
@@ -77,7 +78,7 @@ bool ImGuiToolkit::ButtonSwitch(const char* label, bool* toggle, const char* sho
bool ret = false; bool ret = false;
// utility style // utility style
ImVec4* colors = ImGui::GetStyle().Colors; const ImVec4* colors = ImGui::GetStyle().Colors;
ImDrawList* draw_list = ImGui::GetWindowDrawList(); ImDrawList* draw_list = ImGui::GetWindowDrawList();
// draw position when entering // draw position when entering
@@ -622,9 +623,10 @@ bool ImGuiToolkit::SliderTiming (const char* label, uint* ms, uint v_min, uint v
#define LARGE_TICK_INCREMENT 1 #define LARGE_TICK_INCREMENT 1
#define LABEL_TICK_INCREMENT 3 #define LABEL_TICK_INCREMENT 3
void ImGuiToolkit::RenderTimeline (ImGuiWindow* window, ImRect timeline_bbox, void ImGuiToolkit::RenderTimeline (ImVec2 min_bbox, ImVec2 max_bbox, guint64 begin, guint64 end, guint64 step, bool verticalflip)
guint64 begin, guint64 end, guint64 step, bool verticalflip)
{ {
const ImRect timeline_bbox(min_bbox, max_bbox);
const ImGuiWindow* window = ImGui::GetCurrentWindow();
static guint64 optimal_tick_marks[NUM_MARKS + LABEL_TICK_INCREMENT] = { 100 * MILISECOND, 500 * MILISECOND, 1 * SECOND, 2 * SECOND, 5 * SECOND, 10 * SECOND, 20 * SECOND, 1 * MINUTE, 2 * MINUTE, 5 * MINUTE, 10 * MINUTE, 60 * MINUTE, 60 * MINUTE }; static guint64 optimal_tick_marks[NUM_MARKS + LABEL_TICK_INCREMENT] = { 100 * MILISECOND, 500 * MILISECOND, 1 * SECOND, 2 * SECOND, 5 * SECOND, 10 * SECOND, 20 * SECOND, 1 * MINUTE, 2 * MINUTE, 5 * MINUTE, 10 * MINUTE, 60 * MINUTE, 60 * MINUTE };
const ImGuiContext& g = *GImGui; const ImGuiContext& g = *GImGui;
@@ -759,13 +761,14 @@ void ImGuiToolkit::RenderTimeline (ImGuiWindow* window, ImRect timeline_bbox,
} }
void ImGuiToolkit::RenderTimelineBPM (ImGuiWindow* window, ImRect timeline_bbox, double tempo, double quantum, void ImGuiToolkit::RenderTimelineBPM (ImVec2 min_bbox, ImVec2 max_bbox, double tempo, double quantum,
guint64 begin, guint64 end, guint64 step, bool verticalflip) guint64 begin, guint64 end, guint64 step, bool verticalflip)
{ {
if (tempo<1.) if (tempo<1.)
return; return;
const ImRect timeline_bbox(min_bbox, max_bbox);
const ImGuiWindow* window = ImGui::GetCurrentWindow();
const ImGuiContext& g = *GImGui; const ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const float fontsize = g.FontSize; const float fontsize = g.FontSize;
@@ -986,9 +989,9 @@ bool ImGuiToolkit::TimelineSlider (const char* label, guint64 *time, guint64 beg
// render the timeline // render the timeline
if (tempo > 0 && quantum > 0) if (tempo > 0 && quantum > 0)
RenderTimelineBPM(window, timeline_bbox, tempo, quantum, begin, end, step); RenderTimelineBPM(timeline_bbox.Min, timeline_bbox.Max, tempo, quantum, begin, end, step);
else else
RenderTimeline(window, timeline_bbox, begin, end, step); RenderTimeline(timeline_bbox.Min, timeline_bbox.Max, begin, end, step);
// draw slider grab handle // draw slider grab handle
if (grab_slider_bb.Max.x > grab_slider_bb.Min.x) { if (grab_slider_bb.Max.x > grab_slider_bb.Min.x) {

View File

@@ -9,7 +9,6 @@
#ifndef IMGUI_DEFINE_MATH_OPERATORS #ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS
#endif #endif
#include "imgui_internal.h"
#include "rsc/fonts/IconsFontAwesome5.h" #include "rsc/fonts/IconsFontAwesome5.h"
@@ -47,8 +46,8 @@ namespace ImGuiToolkit
// sliders // sliders
bool SliderTiming (const char* label, uint *ms, uint v_min, uint v_max, uint v_step, const char* text_max = nullptr); bool SliderTiming (const char* label, uint *ms, uint v_min, uint v_max, uint v_step, const char* text_max = nullptr);
bool TimelineSlider (const char* label, guint64 *time, guint64 begin, guint64 first, guint64 end, guint64 step, const float width, double tempo = 0, double quantum = 0); bool TimelineSlider (const char* label, guint64 *time, guint64 begin, guint64 first, guint64 end, guint64 step, const float width, double tempo = 0, double quantum = 0);
void RenderTimeline (struct ImGuiWindow* window, struct ImRect timeline_bbox, guint64 begin, guint64 end, guint64 step, bool verticalflip = false); void RenderTimeline (ImVec2 min_bbox, ImVec2 max_bbox, guint64 begin, guint64 end, guint64 step, bool verticalflip = false);
void RenderTimelineBPM (struct ImGuiWindow* window, struct ImRect timeline_bbox, double tempo, double quantum, guint64 begin, guint64 end, guint64 step, bool verticalflip = false); void RenderTimelineBPM (ImVec2 min_bbox, ImVec2 max_bbox, double tempo, double quantum, guint64 begin, guint64 end, guint64 step, bool verticalflip = false);
bool InvisibleSliderInt(const char* label, uint *index, uint min, uint max, const ImVec2 size); bool InvisibleSliderInt(const char* label, uint *index, uint min, uint max, const ImVec2 size);
bool EditPlotLines(const char* label, float *array, int values_count, float values_min, float values_max, const ImVec2 size); bool EditPlotLines(const char* label, float *array, int values_count, float values_min, float values_max, const ImVec2 size);
bool EditPlotHistoLines(const char* label, float *histogram_array, float *lines_array, int values_count, float values_min, float values_max, guint64 begin, guint64 end, bool cut, bool *released, const ImVec2 size); bool EditPlotHistoLines(const char* label, float *histogram_array, float *lines_array, int values_count, float values_min, float values_max, guint64 begin, guint64 end, bool cut, bool *released, const ImVec2 size);

View File

@@ -31,6 +31,9 @@
#include <tinyxml2.h> #include <tinyxml2.h>
#include "tinyxml2Toolkit.h" #include "tinyxml2Toolkit.h"
#include "imgui.h"
#include "imgui_internal.h"
#include "defines.h" #include "defines.h"
#include "Log.h" #include "Log.h"
#include "Scene.h" #include "Scene.h"

File diff suppressed because it is too large Load Diff

View File

@@ -202,9 +202,28 @@ public:
}; };
class SourceController class WorkspaceWindow
{
static bool clear_workspace_enabled;
static std::list<WorkspaceWindow *> windows_;
public:
WorkspaceWindow(const char* name);
static void toggleClearRestoreWorkspace();
static void clearWorkspace();
static void restoreWorkspace(bool instantaneous = false);
protected:
virtual void Update();
const char *name_;
struct ImGuiProperties *impl_;
};
class SourceController : public WorkspaceWindow
{ {
bool focused_;
float min_width_; float min_width_;
float h_space_; float h_space_;
float v_space_; float v_space_;
@@ -253,48 +272,48 @@ public:
inline void Play() { play_toggle_request_ = true; } inline void Play() { play_toggle_request_ = true; }
inline void Replay() { replay_request_= true; } inline void Replay() { replay_request_= true; }
void Update();
void resetActiveSelection(); void resetActiveSelection();
void Render();
void setVisible(bool on); void setVisible(bool on);
bool Visible() const; bool Visible() const;
inline bool Foccused() const { return focused_; } void Render();
// from WorkspaceWindow
void Update() override;
}; };
class OutputPreview : public WorkspaceWindow
class UserInterface
{ {
friend class Navigator;
Navigator navigator;
ToolBox toolbox;
SourceController sourcecontrol;
HelperToolbox sessiontoolbox;
uint64_t start_time;
bool ctrl_modifier_active;
bool alt_modifier_active;
bool shift_modifier_active;
bool show_vimix_about;
bool show_imgui_about;
bool show_gst_about;
bool show_opengl_about;
int show_view_navigator;
int target_view_navigator;
unsigned int screenshot_step;
bool pending_save_on_exit;
// frame grabbers // frame grabbers
VideoRecorder *video_recorder_; VideoRecorder *video_recorder_;
// delayed trigger for recording
std::vector< std::future<VideoRecorder *> > _video_recorders;
#if defined(LINUX) #if defined(LINUX)
FrameGrabber *webcam_emulator_; FrameGrabber *webcam_emulator_;
#endif #endif
// Dialogs // dialog to select record location
DialogToolkit::OpenSessionDialog *sessionopendialog; DialogToolkit::OpenFolderDialog *recordFolderDialog;
DialogToolkit::OpenSessionDialog *sessionimportdialog;
DialogToolkit::SaveSessionDialog *sessionsavedialog; public:
OutputPreview();
void ToggleRecord(bool save_and_continue = false);
inline bool isRecording() const { return video_recorder_ != nullptr; }
void Render();
void setVisible(bool on);
bool Visible() const;
// from WorkspaceWindow
void Update() override;
};
class UserInterface
{
friend class Navigator;
friend class OutputPreview;
// Private Constructor // Private Constructor
UserInterface(); UserInterface();
@@ -336,10 +355,35 @@ public:
void fillShaderEditor(const std::string &text); void fillShaderEditor(const std::string &text);
void StartScreenshot(); void StartScreenshot();
inline bool isRecording() const { return video_recorder_ != nullptr; }
protected: protected:
// internal
uint64_t start_time;
bool ctrl_modifier_active;
bool alt_modifier_active;
bool shift_modifier_active;
bool show_vimix_about;
bool show_imgui_about;
bool show_gst_about;
bool show_opengl_about;
int show_view_navigator;
int target_view_navigator;
unsigned int screenshot_step;
bool pending_save_on_exit;
// Dialogs
DialogToolkit::OpenSessionDialog *sessionopendialog;
DialogToolkit::OpenSessionDialog *sessionimportdialog;
DialogToolkit::SaveSessionDialog *sessionsavedialog;
// objects and windows
Navigator navigator;
ToolBox toolbox;
SourceController sourcecontrol;
OutputPreview outputcontrol;
HelperToolbox sessiontoolbox;
void showMenuFile(); void showMenuFile();
void showMenuEdit(); void showMenuEdit();
bool saveOrSaveAs(bool force_versioning = false); bool saveOrSaveAs(bool force_versioning = false);
@@ -347,7 +391,6 @@ protected:
void selectOpenFilename(); void selectOpenFilename();
void RenderMetrics (bool* p_open, int* p_corner, int *p_mode); void RenderMetrics (bool* p_open, int* p_corner, int *p_mode);
void RenderPreview();
void RenderTimer(); void RenderTimer();
void RenderShaderEditor(); void RenderShaderEditor();
int RenderViewNavigator(int* shift); int RenderViewNavigator(int* shift);