Skip to content

Commit

Permalink
Add option to hide the imgui bar with a click event
Browse files Browse the repository at this point in the history
  • Loading branch information
Zedb0T committed Dec 3, 2024
1 parent e18dbb6 commit 46ede20
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions game/graphics/opengl_renderer/debug_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,28 @@ void OpenGlDebugGui::draw(const DmaStats& dma_stats) {
}

if (!Gfx::g_debug_settings.ignore_hide_imgui) {
ImGui::Text("%s", fmt::format("Toggle toolbar with {}",
sdl_util::get_keyboard_button_name(
Gfx::g_debug_settings.hide_imgui_key, InputModifiers()))
.c_str());
std::string button_text =
fmt::format("Click here or Press {} to hide Toolbar",
sdl_util::get_keyboard_button_name(Gfx::g_debug_settings.hide_imgui_key,
InputModifiers()));

ImVec2 text_size = ImGui::CalcTextSize(button_text.c_str());
float button_width = text_size.x + ImGui::GetStyle().FramePadding.x * 2;
float button_height = text_size.y + ImGui::GetStyle().FramePadding.y * 2;

ImGui::PushStyleColor(ImGuiCol_Header,
ImGui::GetStyleColorVec4(ImGuiCol_MenuBarBg));
ImGui::PushStyleColor(ImGuiCol_HeaderHovered,
ImGui::GetStyleColorVec4(ImGuiCol_HeaderHovered));
ImGui::PushStyleColor(ImGuiCol_HeaderActive,
ImGui::GetStyleColorVec4(ImGuiCol_HeaderActive));

if (ImGui::Selectable(button_text.c_str(), false, ImGuiSelectableFlags_DontClosePopups,
ImVec2(button_width, button_height))) {
std::shared_ptr<GfxDisplay> display = Display::GetMainDisplay();
display->set_imgui_visible(false);
}
ImGui::PopStyleColor(3);
}
}
ImGui::EndMainMenuBar();
Expand Down

0 comments on commit 46ede20

Please sign in to comment.