Move debug stuff into another window

This commit is contained in:
blankie 2023-01-05 16:05:09 +07:00
parent dfdb631b63
commit f1c2dc7f63
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 17 additions and 9 deletions

View File

@ -25,17 +25,14 @@ static inline void settings_window(Config& config, float* config_write_timer, bo
ImGui::End(); ImGui::End();
} }
static inline void main_window(Config& active_config, bool* show_demo_window, static inline void main_window(Config& active_config, bool* show_settings_window, bool* exit_requested_rev) {
bool* show_settings_window, bool* exit_requested_rev) {
if (!ImGui::Begin("LogMeow", exit_requested_rev)) { if (!ImGui::Begin("LogMeow", exit_requested_rev)) {
ImGui::End(); ImGui::End();
return; return;
} }
ImGui::Checkbox("Show Dear ImGui Demo Window", show_demo_window);
if (ImGui::Button("Settings")) { if (ImGui::Button("Settings")) {
*show_settings_window = true; *show_settings_window = true;
} }
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::End(); ImGui::End();
} }
@ -56,15 +53,25 @@ static inline void exit_modal_if_necessary(bool* run_event_loop) {
ImGui::EndPopup(); 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_demo_window = false;
static bool show_settings_window = false;
static bool exit_requested_rev = true;
if (show_demo_window) { if (show_demo_window) {
ImGui::ShowDemoWindow(&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) { if (show_settings_window) {
settings_window(config, config_write_timer, &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_requested_rev = true;
} }
exit_modal_if_necessary(run_event_loop); 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();
} }