mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-07 20:15:32 +00:00
FullscreenUI: Fix popup item border going outside of window
This commit is contained in:
parent
ea3774cece
commit
f80a77fa27
@ -1264,6 +1264,7 @@ void FullscreenUI::DoResume()
|
|||||||
s_state.save_state_selector_loading = true;
|
s_state.save_state_selector_loading = true;
|
||||||
s_state.save_state_selector_open = true;
|
s_state.save_state_selector_open = true;
|
||||||
s_state.save_state_selector_resuming = true;
|
s_state.save_state_selector_resuming = true;
|
||||||
|
QueueResetFocus(FocusResetType::PopupOpened);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullscreenUI::DoStartFile()
|
void FullscreenUI::DoStartFile()
|
||||||
@ -7336,6 +7337,7 @@ void FullscreenUI::DrawResumeStateSelector()
|
|||||||
if (!is_open)
|
if (!is_open)
|
||||||
{
|
{
|
||||||
ClearSaveStateEntryList();
|
ClearSaveStateEntryList();
|
||||||
|
QueueResetFocus(FocusResetType::PopupClosed);
|
||||||
s_state.save_state_selector_open = false;
|
s_state.save_state_selector_open = false;
|
||||||
s_state.save_state_selector_loading = false;
|
s_state.save_state_selector_loading = false;
|
||||||
s_state.save_state_selector_resuming = false;
|
s_state.save_state_selector_resuming = false;
|
||||||
@ -7573,16 +7575,6 @@ void FullscreenUI::DrawGameListWindow()
|
|||||||
|
|
||||||
EndFullscreenWindow();
|
EndFullscreenWindow();
|
||||||
|
|
||||||
if (!AreAnyDialogsOpen())
|
|
||||||
{
|
|
||||||
if (ImGui::IsKeyPressed(ImGuiKey_NavGamepadMenu, false) || ImGui::IsKeyPressed(ImGuiKey_F4, false))
|
|
||||||
s_state.game_list_view = (s_state.game_list_view == GameListView::Grid) ? GameListView::List : GameListView::Grid;
|
|
||||||
else if (ImGui::IsKeyPressed(ImGuiKey_GamepadBack, false) || ImGui::IsKeyPressed(ImGuiKey_F2, false))
|
|
||||||
SwitchToSettings();
|
|
||||||
else if (ImGui::IsKeyPressed(ImGuiKey_GamepadStart, false) || ImGui::IsKeyPressed(ImGuiKey_F3, false))
|
|
||||||
DoResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (s_state.game_list_view)
|
switch (s_state.game_list_view)
|
||||||
{
|
{
|
||||||
case GameListView::Grid:
|
case GameListView::Grid:
|
||||||
@ -7595,6 +7587,17 @@ void FullscreenUI::DrawGameListWindow()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// note: has to come afterwards
|
||||||
|
if (!AreAnyDialogsOpen())
|
||||||
|
{
|
||||||
|
if (ImGui::IsKeyPressed(ImGuiKey_NavGamepadMenu, false) || ImGui::IsKeyPressed(ImGuiKey_F4, false))
|
||||||
|
s_state.game_list_view = (s_state.game_list_view == GameListView::Grid) ? GameListView::List : GameListView::Grid;
|
||||||
|
else if (ImGui::IsKeyPressed(ImGuiKey_GamepadBack, false) || ImGui::IsKeyPressed(ImGuiKey_F2, false))
|
||||||
|
SwitchToSettings();
|
||||||
|
else if (ImGui::IsKeyPressed(ImGuiKey_GamepadStart, false) || ImGui::IsKeyPressed(ImGuiKey_F3, false))
|
||||||
|
DoResume();
|
||||||
|
}
|
||||||
|
|
||||||
if (IsGamepadInputSource())
|
if (IsGamepadInputSource())
|
||||||
{
|
{
|
||||||
SetFullscreenFooterText(std::array{std::make_pair(ICON_PF_XBOX_DPAD, FSUI_VSTR("Select Game")),
|
SetFullscreenFooterText(std::array{std::make_pair(ICON_PF_XBOX_DPAD, FSUI_VSTR("Select Game")),
|
||||||
|
@ -793,8 +793,11 @@ bool ImGuiFullscreen::ResetFocusHere()
|
|||||||
// If this is a popup closing, we don't want to reset the current nav item, since we were presumably opened by one.
|
// If this is a popup closing, we don't want to reset the current nav item, since we were presumably opened by one.
|
||||||
if (s_state.focus_reset_queued != FocusResetType::PopupClosed)
|
if (s_state.focus_reset_queued != FocusResetType::PopupClosed)
|
||||||
ImGui::NavInitWindow(window, true);
|
ImGui::NavInitWindow(window, true);
|
||||||
|
else
|
||||||
|
ImGui::SetNavWindow(window);
|
||||||
|
|
||||||
s_state.focus_reset_queued = FocusResetType::None;
|
s_state.focus_reset_queued = FocusResetType::None;
|
||||||
|
ResetMenuButtonFrame();
|
||||||
|
|
||||||
// only do the active selection magic when we're using keyboard/gamepad
|
// only do the active selection magic when we're using keyboard/gamepad
|
||||||
return (GImGui->NavInputSource == ImGuiInputSource_Keyboard || GImGui->NavInputSource == ImGuiInputSource_Gamepad);
|
return (GImGui->NavInputSource == ImGuiInputSource_Keyboard || GImGui->NavInputSource == ImGuiInputSource_Gamepad);
|
||||||
@ -1151,7 +1154,7 @@ void ImGuiFullscreen::DrawFullscreenFooter()
|
|||||||
|
|
||||||
void ImGuiFullscreen::PrerenderMenuButtonBorder()
|
void ImGuiFullscreen::PrerenderMenuButtonBorder()
|
||||||
{
|
{
|
||||||
if (!s_state.had_hovered_menu_item)
|
if (!s_state.had_hovered_menu_item || GImGui->CurrentWindow != GImGui->NavWindow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// updating might finish the animation
|
// updating might finish the animation
|
||||||
@ -1169,8 +1172,10 @@ void ImGuiFullscreen::PrerenderMenuButtonBorder()
|
|||||||
s_state.rendered_menu_item_border = true;
|
s_state.rendered_menu_item_border = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiFullscreen::BeginMenuButtons(u32 num_items, float y_align, float x_padding, float y_padding,
|
void ImGuiFullscreen::BeginMenuButtons(u32 num_items /* = 0 */, float y_align /* = 0.0f */,
|
||||||
float item_height)
|
float x_padding /* = LAYOUT_MENU_BUTTON_X_PADDING */,
|
||||||
|
float y_padding /* = LAYOUT_MENU_BUTTON_Y_PADDING */,
|
||||||
|
float item_height /* = LAYOUT_MENU_BUTTON_HEIGHT */)
|
||||||
{
|
{
|
||||||
s_state.menu_button_index = 0;
|
s_state.menu_button_index = 0;
|
||||||
|
|
||||||
@ -1327,7 +1332,7 @@ void ImGuiFullscreen::DrawMenuButtonFrame(const ImVec2& p_min, const ImVec2& p_m
|
|||||||
ImVec2 frame_max = p_max;
|
ImVec2 frame_max = p_max;
|
||||||
|
|
||||||
const ImGuiIO& io = ImGui::GetIO();
|
const ImGuiIO& io = ImGui::GetIO();
|
||||||
if (s_state.smooth_scrolling && io.NavVisible)
|
if (s_state.smooth_scrolling && io.NavVisible && GImGui->CurrentWindow == GImGui->NavWindow)
|
||||||
{
|
{
|
||||||
if (!s_state.had_hovered_menu_item || io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f)
|
if (!s_state.had_hovered_menu_item || io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f)
|
||||||
{
|
{
|
||||||
@ -2635,10 +2640,11 @@ void ImGuiFullscreen::DrawChoiceDialog()
|
|||||||
ImGui::PushStyleColor(ImGuiCol_Text, UIStyle.BackgroundTextColor);
|
ImGui::PushStyleColor(ImGuiCol_Text, UIStyle.BackgroundTextColor);
|
||||||
|
|
||||||
ResetFocusHere();
|
ResetFocusHere();
|
||||||
BeginMenuButtons();
|
|
||||||
|
|
||||||
if (s_state.choice_dialog_checkable)
|
if (s_state.choice_dialog_checkable)
|
||||||
{
|
{
|
||||||
|
BeginMenuButtons();
|
||||||
|
|
||||||
for (s32 i = 0; i < static_cast<s32>(s_state.choice_dialog_options.size()); i++)
|
for (s32 i = 0; i < static_cast<s32>(s_state.choice_dialog_options.size()); i++)
|
||||||
{
|
{
|
||||||
auto& option = s_state.choice_dialog_options[i];
|
auto& option = s_state.choice_dialog_options[i];
|
||||||
@ -2651,23 +2657,41 @@ void ImGuiFullscreen::DrawChoiceDialog()
|
|||||||
option.second = !option.second;
|
option.second = !option.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EndMenuButtons();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// draw background first, because otherwise it'll obscure the frame border
|
||||||
for (s32 i = 0; i < static_cast<s32>(s_state.choice_dialog_options.size()); i++)
|
for (s32 i = 0; i < static_cast<s32>(s_state.choice_dialog_options.size()); i++)
|
||||||
{
|
{
|
||||||
auto& option = s_state.choice_dialog_options[i];
|
auto& option = s_state.choice_dialog_options[i];
|
||||||
if (ActiveButtonWithRightText(option.first.c_str(), option.second ? ICON_FA_CHECK : nullptr, option.second,
|
if (!option.second)
|
||||||
true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
continue;
|
||||||
|
|
||||||
|
ImVec2 pos, size;
|
||||||
|
GetMenuButtonFrameBounds(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, &pos, &size);
|
||||||
|
pos.y += size.y * static_cast<float>(i);
|
||||||
|
ImGui::RenderFrame(pos, pos + size, ImGui::GetColorU32(UIStyle.PrimaryColor), false,
|
||||||
|
LayoutScale(MENU_ITEM_BORDER_ROUNDING));
|
||||||
|
}
|
||||||
|
|
||||||
|
BeginMenuButtons();
|
||||||
|
|
||||||
|
for (s32 i = 0; i < static_cast<s32>(s_state.choice_dialog_options.size()); i++)
|
||||||
|
{
|
||||||
|
auto& option = s_state.choice_dialog_options[i];
|
||||||
|
if (ActiveButtonWithRightText(option.first.c_str(), option.second ? ICON_FA_CHECK : nullptr, false, true,
|
||||||
|
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
||||||
{
|
{
|
||||||
choice = i;
|
choice = i;
|
||||||
for (s32 j = 0; j < static_cast<s32>(s_state.choice_dialog_options.size()); j++)
|
for (s32 j = 0; j < static_cast<s32>(s_state.choice_dialog_options.size()); j++)
|
||||||
s_state.choice_dialog_options[j].second = (j == i);
|
s_state.choice_dialog_options[j].second = (j == i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
EndMenuButtons();
|
EndMenuButtons();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::PopStyleColor(1);
|
ImGui::PopStyleColor(1);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user