From 3dbf4f225516910575d10cc907cdeda54b7e5a85 Mon Sep 17 00:00:00 2001 From: oxmox Date: Sun, 12 Feb 2023 16:12:01 +0100 Subject: [PATCH] custom imgui window title! --- src/doompanning.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/doompanning.cc b/src/doompanning.cc index 5f257a9..3ca24b0 100644 --- a/src/doompanning.cc +++ b/src/doompanning.cc @@ -4,6 +4,8 @@ #include #include +#include +#include #include #include #include @@ -35,11 +37,6 @@ struct ControllerContext void show_ui(ControllerContext *ctx) { - const ImGuiViewport* main_viewport = ImGui::GetMainViewport(); - ImGui::SetNextWindowPos(ImVec2(main_viewport->WorkPos.x + 20, main_viewport->WorkPos.y + 20), ImGuiCond_FirstUseEver); - ImGui::SetNextWindowSize(ImVec2(550, 340), ImGuiCond_FirstUseEver); - ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar; - #ifndef IMGUI_DISABLE_DEBUG_TOOLS const bool has_debug_tools = true; #else @@ -53,8 +50,19 @@ void show_ui(ControllerContext *ctx) if (show_app_debug_log) ImGui::ShowDebugLogWindow(&show_app_debug_log); - // Main body of the Demo window starts here. - if (!ImGui::Begin("doompanning controls", nullptr, window_flags)) + const ImGuiViewport* main_viewport = ImGui::GetMainViewport(); + ImGui::SetNextWindowPos(ImVec2(main_viewport->WorkPos.x + 20, main_viewport->WorkPos.y + 20), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowSize(ImVec2(550, 340), ImGuiCond_FirstUseEver); + ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar; + + auto &io = ImGui::GetIO(); + std::array windowTitle; + std::snprintf(windowTitle.data(), windowTitle.size(), + "doompanning - #dooms=%zu, %.2f ms/frame (%.1f fps)###doompanning", + 0ul, 1000.0f / io.Framerate, io.Framerate); + + // Main body of the doompanning window starts here. + if (!ImGui::Begin(windowTitle.data(), nullptr, window_flags)) { // Early out if the window is collapsed, as an optimization. ImGui::End();