From f1c2dc7f63d490cb5e59232834c6ea9ea2f59377 Mon Sep 17 00:00:00 2001 From: blankie Date: Thu, 5 Jan 2023 16:05:09 +0700 Subject: [PATCH] Move debug stuff into another window --- event_loop.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/event_loop.cpp b/event_loop.cpp index ded68d6..aceb9b8 100644 --- a/event_loop.cpp +++ b/event_loop.cpp @@ -25,17 +25,14 @@ static inline void settings_window(Config& config, float* config_write_timer, bo ImGui::End(); } -static inline void main_window(Config& active_config, bool* show_demo_window, - bool* show_settings_window, bool* exit_requested_rev) { +static inline void main_window(Config& active_config, bool* show_settings_window, bool* exit_requested_rev) { if (!ImGui::Begin("LogMeow", exit_requested_rev)) { ImGui::End(); return; } - ImGui::Checkbox("Show Dear ImGui Demo Window", show_demo_window); if (ImGui::Button("Settings")) { *show_settings_window = true; } - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); ImGui::End(); } @@ -56,15 +53,25 @@ static inline void exit_modal_if_necessary(bool* run_event_loop) { ImGui::EndPopup(); } -void event_loop(Config& config, float* config_write_timer, bool* run_event_loop) { +static inline void debug_window() { static bool show_demo_window = false; - static bool show_settings_window = false; - static bool exit_requested_rev = true; - if (show_demo_window) { ImGui::ShowDemoWindow(&show_demo_window); } + if (!ImGui::Begin("LogMeow Debug")) { + ImGui::End(); + return; + } + ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); + ImGui::Checkbox("Show Dear ImGui Demo Window", &show_demo_window); + ImGui::End(); +} + +void event_loop(Config& config, float* config_write_timer, bool* run_event_loop) { + static bool show_settings_window = false; + static bool exit_requested_rev = true; + if (show_settings_window) { settings_window(config, config_write_timer, &show_settings_window); } @@ -80,5 +87,6 @@ void event_loop(Config& config, float* config_write_timer, bool* run_event_loop) exit_requested_rev = true; } exit_modal_if_necessary(run_event_loop); - main_window(config, &show_demo_window, &show_settings_window, &exit_requested_rev); + main_window(config, &show_settings_window, &exit_requested_rev); + debug_window(); }