diff --git a/ImGuiToolkit.cpp b/ImGuiToolkit.cpp index 7cd4069..dc701cf 100644 --- a/ImGuiToolkit.cpp +++ b/ImGuiToolkit.cpp @@ -798,8 +798,11 @@ void ImGuiToolkit::PushFont(ImGuiToolkit::font_style style) } -void ImGuiToolkit::ShowStats(bool *p_open, int* p_corner) +void ImGuiToolkit::ShowStats(bool *p_open, int* p_corner, bool *p_timer) { + static guint64 start_time_1_ = gst_util_get_timestamp (); + static guint64 start_time_2_ = gst_util_get_timestamp (); + if (!p_corner || !p_open) return; @@ -817,18 +820,42 @@ void ImGuiToolkit::ShowStats(bool *p_open, int* p_corner) if (ImGui::Begin("Metrics", NULL, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav)) { + int mode = (*p_timer) ? 1 : 0; + ImGui::SetNextItemWidth(250); + if (ImGui::Combo("##mode", &mode, ICON_FA_TACHOMETER_ALT " Performance\0" ICON_FA_HOURGLASS_HALF " Timers\0") ) { + (*p_timer) = mode > 0; + } - ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO); + bool dumm = true; + if (*p_timer) { + guint64 time_ = gst_util_get_timestamp (); - ImGui::Text("Window %.0f x %.0f", io.DisplaySize.x, io.DisplaySize.y); -// ImGui::Text("HiDPI (retina) %s", io.DisplayFramebufferScale.x > 1.f ? "on" : "off"); - ImGui::Text("Refresh %.1f FPS", io.Framerate); - ImGui::Text("Memory %s", SystemToolkit::byte_to_string( SystemToolkit::memory_usage()).c_str() ); - ImGui::PopFont(); + ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE); + ImGui::Text("%s", GstToolkit::time_to_string(time_-start_time_1_, GstToolkit::TIME_STRING_FIXED).c_str()); + ImGui::PopFont(); + ImGui::SameLine(0, 10); + if (ImGuiToolkit::IconToggle(11, 14, 12, 14, &dumm)) + start_time_1_ = time_; // reset timer 1 + ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE); + ImGui::Text("%s", GstToolkit::time_to_string(time_-start_time_2_, GstToolkit::TIME_STRING_FIXED).c_str()); + ImGui::PopFont(); + ImGui::SameLine(0, 10); dumm = true; + if (ImGuiToolkit::IconToggle(11, 14, 12, 14, &dumm)) + start_time_1_ = time_; // reset timer 2 + + } + else { + ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO); + ImGui::Text("Window %.0f x %.0f", io.DisplaySize.x, io.DisplaySize.y); + // ImGui::Text("HiDPI (retina) %s", io.DisplayFramebufferScale.x > 1.f ? "on" : "off"); + ImGui::Text("Refresh %.1f FPS", io.Framerate); + ImGui::Text("Memory %s", SystemToolkit::byte_to_string( SystemToolkit::memory_usage()).c_str() ); + ImGui::PopFont(); + } if (ImGui::BeginPopupContextWindow()) { - if (ImGui::MenuItem("Custom", NULL, corner == -1)) *p_corner = -1; + if (ImGui::MenuItem("Free position", NULL, corner == -1)) *p_corner = -1; if (ImGui::MenuItem("Top", NULL, corner == 1)) *p_corner = 1; if (ImGui::MenuItem("Bottom", NULL, corner == 3)) *p_corner = 3; if (p_open && ImGui::MenuItem("Close")) *p_open = false; diff --git a/ImGuiToolkit.h b/ImGuiToolkit.h index ec52746..5e2a0eb 100644 --- a/ImGuiToolkit.h +++ b/ImGuiToolkit.h @@ -56,7 +56,7 @@ namespace ImGuiToolkit void SetAccentColor (accent_color color); struct ImVec4 GetHighlightColor (); - void ShowStats (bool* p_open, int* p_corner); + void ShowStats (bool* p_open, int* p_corner, bool* p_timer); } diff --git a/Settings.cpp b/Settings.cpp index c833479..bddbc94 100644 --- a/Settings.cpp +++ b/Settings.cpp @@ -70,6 +70,7 @@ void Settings::Save() widgetsNode->SetAttribute("media_player", application.widget.media_player); widgetsNode->SetAttribute("shader_editor", application.widget.shader_editor); widgetsNode->SetAttribute("stats", application.widget.stats); + widgetsNode->SetAttribute("stats_timer", application.widget.stats_timer); widgetsNode->SetAttribute("stats_corner", application.widget.stats_corner); widgetsNode->SetAttribute("logs", application.widget.logs); widgetsNode->SetAttribute("toolbox", application.widget.toolbox); @@ -243,6 +244,7 @@ void Settings::Load() widgetsNode->QueryBoolAttribute("media_player", &application.widget.media_player); widgetsNode->QueryBoolAttribute("shader_editor", &application.widget.shader_editor); widgetsNode->QueryBoolAttribute("stats", &application.widget.stats); + widgetsNode->QueryBoolAttribute("stats_timer", &application.widget.stats_timer); widgetsNode->QueryIntAttribute("stats_corner", &application.widget.stats_corner); widgetsNode->QueryBoolAttribute("logs", &application.widget.logs); widgetsNode->QueryBoolAttribute("toolbox", &application.widget.toolbox); diff --git a/Settings.h b/Settings.h index 2604188..ee6b85f 100644 --- a/Settings.h +++ b/Settings.h @@ -15,6 +15,7 @@ struct WidgetsConfig { bool stats; int stats_corner; + bool stats_timer; bool logs; bool preview; bool history; @@ -25,6 +26,7 @@ struct WidgetsConfig WidgetsConfig() { stats = false; + stats_timer = false; stats_corner = 1; logs = false; preview = false; @@ -208,7 +210,7 @@ struct Application History recentFolders; History recentImport; - Application() : fresh_start(false), name(APP_NAME), executable(APP_NAME) { + Application() : fresh_start(false), instance_id(0), name(APP_NAME), executable(APP_NAME) { scale = 1.f; accent_color = 0; pannel_stick = false; diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 44c2401..0d51f6b 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -786,7 +786,9 @@ void UserInterface::Render() // stats in the corner if (Settings::application.widget.stats) - ImGuiToolkit::ShowStats(&Settings::application.widget.stats, &Settings::application.widget.stats_corner); + ImGuiToolkit::ShowStats(&Settings::application.widget.stats, + &Settings::application.widget.stats_corner, + &Settings::application.widget.stats_timer); // management of video_recorder FrameGrabber *rec = Mixer::manager().session()->getFrameGrabber(video_recorder_); diff --git a/defines.h b/defines.h index 3c82957..68cec60 100644 --- a/defines.h +++ b/defines.h @@ -5,7 +5,7 @@ #define APP_TITLE " -- Video Live Mixer" #define APP_SETTINGS "vimix.xml" #define APP_VERSION_MAJOR 0 -#define APP_VERSION_MINOR 3 +#define APP_VERSION_MINOR 4 #define XML_VERSION_MAJOR 0 #define XML_VERSION_MINOR 1 #define MAX_RECENT_HISTORY 20