From b3717e800ebf298687e1e142384fbb3a0624afe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 26 Oct 2026 16:36:43 +0100 Subject: [PATCH] ImDebugger: Make the menu bar taller on phones A "Bar height" setting in the Misc menu, 166% by default on phones. The item spacing in the bar grows along with it, so the menu titles can be hit anywhere in the bar's height. The menus themselves keep the normal style. Co-Authored-By: Claude Opus 5.5 (1M context) --- UI/ImDebugger/ImDebugger.cpp | 20 +++++++++++++++++--- UI/ImDebugger/ImDebugger.h | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 9636ebbac4..8e8f41ae02 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -2741,16 +2741,24 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw: const float rowExtra = compactMenu ? em * 0.2f : 0.0f; // Slightly taller rows for fingers. const bool hasSoftKeyboard = System_GetPropertyBool(SYSPROP_KEYBOARD_IS_SOFT); + // The bar's height follows the frame padding. The item spacing is grown to match, so that the menu titles can be + // hit anywhere in the bar's height (a selectable reaches half the item spacing beyond its text). + const ImGuiStyle &style = ImGui::GetStyle(); + const ImVec2 framePadding = style.FramePadding; + const ImVec2 itemSpacing = style.ItemSpacing; + const float barPadY = framePadding.y + ImGui::GetFrameHeight() * ((float)cfg_.barHeight / 100.0f - 1.0f) * 0.5f; + + // Menus get the normal style back. auto beginMenu = [&](const char *label) -> bool { if (!ImGui::BeginMenu(label)) { return false; } - const ImGuiStyle &st = ImGui::GetStyle(); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(st.ItemSpacing.x, st.ItemSpacing.y + rowExtra)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, framePadding); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(itemSpacing.x, itemSpacing.y + rowExtra)); return true; }; auto endMenu = [&]() { - ImGui::PopStyleVar(); // Must be popped before EndMenu(), the popup window checks the style stack. + ImGui::PopStyleVar(2); // Must be popped before EndMenu(), the popup window checks the style stack. ImGui::EndMenu(); }; auto closeDebugger = [&]() { @@ -3034,10 +3042,14 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw: ImGui::MenuItem("Compact menu", nullptr, &cfg_.compactMenu); ImGui::SetNextItemWidth(em * 10.0f); ImGui::SliderInt("Bar left margin", &cfg_.barLeftMargin, 0, 600, "%d%%"); // Percent of the text height. + ImGui::SetNextItemWidth(em * 10.0f); + ImGui::SliderInt("Bar height", &cfg_.barHeight, 100, 250, "%d%%"); endMenu(); } }; + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(framePadding.x, barPadY)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(itemSpacing.x, barPadY * 2.0f)); if (ImGui::BeginMainMenuBar()) { // Keep the first button clear of rounded screen corners / camera cutouts. if (cfg_.barLeftMargin > 0) { @@ -3107,6 +3119,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw: ImGui::EndMainMenuBar(); } + ImGui::PopStyleVar(2); UpdateSoftKeyboard(true); @@ -3634,4 +3647,5 @@ void ImConfig::SyncConfig(IniFile *ini, bool save) { sync.Sync("keyboardPersist", &keyboardPersist, true); sync.Sync("compactMenu", &compactMenu, kIsMobilePlatform); sync.Sync("barLeftMargin", &barLeftMargin, kIsMobilePlatform ? 200 : 0); + sync.Sync("barHeight", &barHeight, kIsMobilePlatform ? 166 : 100); } diff --git a/UI/ImDebugger/ImDebugger.h b/UI/ImDebugger/ImDebugger.h index bf9a437bd4..a6563b1fe8 100644 --- a/UI/ImDebugger/ImDebugger.h +++ b/UI/ImDebugger/ImDebugger.h @@ -137,6 +137,7 @@ struct ImConfig { bool forceKeyboard = false; // Keyboard currently active (toggled from the bar). Asks the platform to keep the soft keyboard up. bool showKeyboardToggle = true; // Show the keyboard button in the bar. Hiding it also turns the keyboard off. bool keyboardPersist = true; // Keep the keyboard on after switching to another app and back. + int barHeight = 100; // Menu bar height, in percent of the normal frame height (taller is easier to hit by touch). int barLeftMargin = 0; // Empty space left of the first bar button, in percent of the text height (keeps it clear of rounded screen corners). bool compactMenu = false; // Always use the single "Menu" dropdown (it's also chosen automatically on narrow screens).