FullscreenUI: Enable all windows to nav-wrap

i.e. when pressing down at the end, it wraps to the top.
This commit is contained in:
Stenzek 2025-03-28 20:38:30 +10:00
parent 003518c234
commit 9ef7f54f19
No known key found for this signature in database
3 changed files with 20 additions and 3 deletions

View File

@ -107,6 +107,7 @@ using ImGuiFullscreen::EndFullscreenColumns;
using ImGuiFullscreen::EndFullscreenColumnWindow;
using ImGuiFullscreen::EndFullscreenWindow;
using ImGuiFullscreen::EndHorizontalMenu;
using ImGuiFullscreen::SetWindowNavWrapping;
using ImGuiFullscreen::EndMenuButtons;
using ImGuiFullscreen::EndNavBar;
using ImGuiFullscreen::EnumChoiceButton;
@ -7195,6 +7196,7 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading)
}
EndMenuButtons();
SetWindowNavWrapping(true, true);
ImGui::EndChild();
}
@ -7712,6 +7714,7 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
EndMenuButtons();
}
SetWindowNavWrapping(false, true);
EndFullscreenColumnWindow();
static constexpr float info_window_width = 530.0f;

View File

@ -977,13 +977,26 @@ bool ImGuiFullscreen::BeginFullscreenWindow(const ImVec2& position, const ImVec2
ImGuiWindowFlags_NoBringToFrontOnFocus | flags);
}
void ImGuiFullscreen::EndFullscreenWindow()
void ImGuiFullscreen::EndFullscreenWindow(bool allow_wrap_x, bool allow_wrap_y)
{
if (allow_wrap_x || allow_wrap_y)
SetWindowNavWrapping(allow_wrap_x, allow_wrap_y);
ImGui::End();
ImGui::PopStyleVar(3);
ImGui::PopStyleColor();
}
void ImGuiFullscreen::SetWindowNavWrapping(bool allow_wrap_x /*= false*/, bool allow_wrap_y /*= true*/)
{
DebugAssert(allow_wrap_x || allow_wrap_y);
if (ImGuiWindow* const win = ImGui::GetCurrentWindowRead(); GImGui->NavWindow == win)
{
ImGui::NavMoveRequestTryWrapping(win, (allow_wrap_x ? ImGuiNavMoveFlags_LoopX : 0) |
(allow_wrap_y ? ImGuiNavMoveFlags_LoopY : 0));
}
}
bool ImGuiFullscreen::IsGamepadInputSource()
{
return (ImGui::GetCurrentContext()->NavInputSource == ImGuiInputSource_Gamepad);
@ -2226,7 +2239,7 @@ bool ImGuiFullscreen::BeginHorizontalMenu(const char* name, const ImVec2& positi
void ImGuiFullscreen::EndHorizontalMenu()
{
ImGui::PopStyleVar(4);
EndFullscreenWindow();
EndFullscreenWindow(true, true);
}
bool ImGuiFullscreen::HorizontalMenuItem(GPUTexture* icon, const char* title, const char* description, u32 color)

View File

@ -231,7 +231,8 @@ bool BeginFullscreenWindow(float left, float top, float width, float height, con
bool BeginFullscreenWindow(const ImVec2& position, const ImVec2& size, const char* name,
const ImVec4& background = HEX_TO_IMVEC4(0x212121, 0xFF), float rounding = 0.0f,
const ImVec2& padding = ImVec2(), ImGuiWindowFlags flags = 0);
void EndFullscreenWindow();
void EndFullscreenWindow(bool allow_wrap_x = false, bool allow_wrap_y = true);
void SetWindowNavWrapping(bool allow_wrap_x = false, bool allow_wrap_y = true);
bool IsGamepadInputSource();
std::string_view GetControllerIconMapping(std::string_view icon);