From 5b5eef61d7b2d7f25eb5f42ba088a142a6ff3e56 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 17 Apr 2025 20:17:42 +1000 Subject: [PATCH] FullscreenUI: Increase spacing between menu items --- src/core/fullscreen_ui.cpp | 20 ++++++++++---------- src/util/imgui_fullscreen.cpp | 19 +++++++++++-------- src/util/imgui_fullscreen.h | 4 +++- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 2bb12d76c..4ee0565be 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -2934,7 +2934,7 @@ void FullscreenUI::DrawIntRangeSetting(SettingsInterface* bsi, std::string_view if (!IsFixedPopupDialogOpen(title) || !BeginFixedPopupDialog(LayoutScale(LAYOUT_SMALL_POPUP_PADDING), LayoutScale(LAYOUT_SMALL_POPUP_PADDING), - LayoutScale(500.0f, 194.0f))) + LayoutScale(500.0f, 200.0f))) { return; } @@ -2985,7 +2985,7 @@ void FullscreenUI::DrawFloatRangeSetting(SettingsInterface* bsi, std::string_vie if (!IsFixedPopupDialogOpen(title) || !BeginFixedPopupDialog(LayoutScale(LAYOUT_SMALL_POPUP_PADDING), LayoutScale(LAYOUT_SMALL_POPUP_PADDING), - LayoutScale(500.0f, 194.0f))) + LayoutScale(500.0f, 200.0f))) { return; } @@ -3045,7 +3045,7 @@ void FullscreenUI::DrawFloatSpinBoxSetting(SettingsInterface* bsi, std::string_v if (!IsFixedPopupDialogOpen(title) || !BeginFixedPopupDialog(LayoutScale(LAYOUT_SMALL_POPUP_PADDING), LayoutScale(LAYOUT_SMALL_POPUP_PADDING), - LayoutScale(500.0f, 194.0f))) + LayoutScale(500.0f, 200.0f))) { return; } @@ -3288,7 +3288,7 @@ void FullscreenUI::DrawIntSpinBoxSetting(SettingsInterface* bsi, std::string_vie if (!IsFixedPopupDialogOpen(title) || !BeginFixedPopupDialog(LayoutScale(LAYOUT_SMALL_POPUP_PADDING), LayoutScale(LAYOUT_SMALL_POPUP_PADDING), - LayoutScale(500.0f, 194.0f))) + LayoutScale(500.0f, 200.0f))) { return; } @@ -5091,7 +5091,7 @@ void FullscreenUI::DrawControllerSettingsPage() if (IsFixedPopupDialogOpen(freq_label) && BeginFixedPopupDialog(LayoutScale(LAYOUT_SMALL_POPUP_PADDING), LayoutScale(LAYOUT_SMALL_POPUP_PADDING), - LayoutScale(500.0f, 194.0f))) + LayoutScale(500.0f, 200.0f))) { BeginMenuButtons(); @@ -5937,7 +5937,7 @@ void FullscreenUI::DrawPostProcessingSettingsPage() if (IsFixedPopupDialogOpen(tstr) && BeginFixedPopupDialog(LayoutScale(LAYOUT_SMALL_POPUP_PADDING), LayoutScale(LAYOUT_SMALL_POPUP_PADDING), - LayoutScale(500.0f, 194.0f))) + LayoutScale(500.0f, 200.0f))) { BeginMenuButtons(); @@ -6008,7 +6008,7 @@ void FullscreenUI::DrawPostProcessingSettingsPage() if (IsFixedPopupDialogOpen(tstr) && BeginFixedPopupDialog(LayoutScale(LAYOUT_SMALL_POPUP_PADDING), LayoutScale(LAYOUT_SMALL_POPUP_PADDING), - LayoutScale(500.0f, 194.0f))) + LayoutScale(500.0f, 200.0f))) { BeginMenuButtons(); @@ -6668,7 +6668,7 @@ void FullscreenUI::DrawPatchesOrCheatsSettingsPage(bool cheats) if (IsFixedPopupDialogOpen(title) && BeginFixedPopupDialog(LayoutScale(LAYOUT_SMALL_POPUP_PADDING), LayoutScale(LAYOUT_SMALL_POPUP_PADDING), - LayoutScale(500.0f, 194.0f))) + LayoutScale(500.0f, 200.0f))) { BeginMenuButtons(); @@ -7543,7 +7543,7 @@ bool FullscreenUI::OpenLoadStateSelectorForGameResume(const GameList::Entry* ent void FullscreenUI::DrawResumeStateSelector() { - if (!BeginFixedPopupDialog(LayoutScale(30.0f), LayoutScale(40.0f), LayoutScale(820.0f, 625.0f))) + if (!BeginFixedPopupDialog(LayoutScale(30.0f), LayoutScale(40.0f), LayoutScale(820.0f, 640.0f))) { ClearSaveStateEntryList(); return; @@ -8665,7 +8665,7 @@ void FullscreenUI::CopyTextToClipboard(std::string title, std::string_view text) void FullscreenUI::DrawAboutWindow() { if (!BeginFixedPopupDialog(LayoutScale(LAYOUT_LARGE_POPUP_PADDING), LayoutScale(LAYOUT_LARGE_POPUP_ROUNDING), - LayoutScale(1020.0f, 590.0f))) + LayoutScale(1020.0f, 600.0f))) { return; } diff --git a/src/util/imgui_fullscreen.cpp b/src/util/imgui_fullscreen.cpp index 428a849da..4217d8042 100644 --- a/src/util/imgui_fullscreen.cpp +++ b/src/util/imgui_fullscreen.cpp @@ -1246,7 +1246,8 @@ void ImGuiFullscreen::PrerenderMenuButtonBorder() void ImGuiFullscreen::BeginMenuButtons(u32 num_items /* = 0 */, float y_align /* = 0.0f */, float x_padding /* = LAYOUT_MENU_BUTTON_X_PADDING */, float y_padding /* = LAYOUT_MENU_BUTTON_Y_PADDING */, - float item_height /* = LAYOUT_MENU_BUTTON_HEIGHT */) + float item_height /* = LAYOUT_MENU_BUTTON_HEIGHT */, + float item_spacing /* = LAYOUT_MENU_BUTTON_SPACING */) { s_state.menu_button_index = 0; @@ -1279,11 +1280,12 @@ void ImGuiFullscreen::BeginMenuButtons(u32 num_items /* = 0 */, float y_align /* ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, LayoutScale(x_padding, y_padding)); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, LayoutScale(1.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, LayoutScale(LAYOUT_MENU_BUTTON_SPACING))); if (y_align != 0.0f) { - const float real_item_height = LayoutScale(item_height) + (LayoutScale(y_padding) * 2.0f); + const float real_item_height = + LayoutScale(item_height) + (LayoutScale(y_padding) * 2.0f) + LayoutScale(item_spacing); const float total_size = (static_cast(num_items) * real_item_height) + (LayoutScale(y_padding) * 2.0f); const float window_height = ImGui::GetWindowHeight(); if (window_height > total_size) @@ -1919,7 +1921,7 @@ bool ImGuiFullscreen::RangeButton(std::string_view title, std::string_view summa if (IsFixedPopupDialogOpen(title) && BeginFixedPopupDialog(LayoutScale(LAYOUT_SMALL_POPUP_PADDING), LayoutScale(LAYOUT_SMALL_POPUP_PADDING), - LayoutScale(500.0f, 194.0f))) + LayoutScale(500.0f, 200.0f))) { BeginMenuButtons(); @@ -1985,7 +1987,7 @@ bool ImGuiFullscreen::RangeButton(std::string_view title, std::string_view summa if (IsFixedPopupDialogOpen(title) && BeginFixedPopupDialog(LayoutScale(LAYOUT_SMALL_POPUP_PADDING), LayoutScale(LAYOUT_SMALL_POPUP_PADDING), - LayoutScale(500.0f, 194.0f))) + LayoutScale(500.0f, 200.0f))) { BeginMenuButtons(); @@ -2812,7 +2814,8 @@ void ImGuiFullscreen::ChoiceDialog::Draw() const float title_height = UIStyle.LargeFont->FontSize + (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + (LayoutScale(10.0f) * 2.0f); const float item_height = - (LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) + LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f); + (LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) + (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + + LayoutScale(LAYOUT_MENU_BUTTON_SPACING)); const float height = title_height + (item_height * static_cast(std::min(9, m_options.size()))); if (!BeginRender(LayoutScale(10.0f), LayoutScale(20.0f), ImVec2(width, height))) @@ -2858,7 +2861,7 @@ void ImGuiFullscreen::ChoiceDialog::Draw() ImVec2 pos, size; GetMenuButtonFrameBounds(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, &pos, &size); - pos.y += size.y * static_cast(i); + pos.y += (size.y + ImGui::GetStyle().ItemSpacing.y) * static_cast(i); ImGui::RenderFrame(pos, pos + size, ImGui::GetColorU32(UIStyle.PrimaryColor), false, LayoutScale(MENU_ITEM_BORDER_ROUNDING)); if (!found_selected) @@ -3918,7 +3921,7 @@ void ImGuiFullscreen::SetTheme(std::string_view theme) // dark UIStyle.BackgroundColor = HEX_TO_IMVEC4(0x212121, 0xff); UIStyle.BackgroundTextColor = HEX_TO_IMVEC4(0xffffff, 0xff); - UIStyle.BackgroundLineColor = HEX_TO_IMVEC4(0xf0f0f0, 0xff); + UIStyle.BackgroundLineColor = HEX_TO_IMVEC4(0xaaaaaa, 0xff); UIStyle.BackgroundHighlight = HEX_TO_IMVEC4(0x4b4b4b, 0xc0); UIStyle.PopupBackgroundColor = HEX_TO_IMVEC4(0x212121, 0xf2); UIStyle.PopupFrameBackgroundColor = HEX_TO_IMVEC4(0x313131, 0xf2); diff --git a/src/util/imgui_fullscreen.h b/src/util/imgui_fullscreen.h index 7dd3cf01f..d00bf6672 100644 --- a/src/util/imgui_fullscreen.h +++ b/src/util/imgui_fullscreen.h @@ -40,6 +40,7 @@ static constexpr float LAYOUT_MENU_BUTTON_HEIGHT = 50.0f; static constexpr float LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY = 26.0f; static constexpr float LAYOUT_MENU_BUTTON_X_PADDING = 15.0f; static constexpr float LAYOUT_MENU_BUTTON_Y_PADDING = 10.0f; +static constexpr float LAYOUT_MENU_BUTTON_SPACING = 4.0f; static constexpr float LAYOUT_MENU_WINDOW_X_PADDING = 12.0f; static constexpr float LAYOUT_FOOTER_PADDING = 10.0f; static constexpr float LAYOUT_FOOTER_HEIGHT = LAYOUT_MEDIUM_FONT_SIZE + LAYOUT_FOOTER_PADDING * 2.0f; @@ -266,7 +267,8 @@ void DrawFullscreenFooter(); void PrerenderMenuButtonBorder(); void BeginMenuButtons(u32 num_items = 0, float y_align = 0.0f, float x_padding = LAYOUT_MENU_BUTTON_X_PADDING, - float y_padding = LAYOUT_MENU_BUTTON_Y_PADDING, float item_height = LAYOUT_MENU_BUTTON_HEIGHT); + float y_padding = LAYOUT_MENU_BUTTON_Y_PADDING, float item_height = LAYOUT_MENU_BUTTON_HEIGHT, + float item_spacing = LAYOUT_MENU_BUTTON_SPACING); void EndMenuButtons(); void GetMenuButtonFrameBounds(float height, ImVec2* pos, ImVec2* size); bool MenuButtonFrame(std::string_view str_id, bool enabled, float height, bool* visible, bool* hovered, ImVec2* min,