mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-08 04:25:37 +00:00
FullscreenUI: Fix long lists not scrolling to selected item
This commit is contained in:
parent
52f8a347c7
commit
83f755055b
@ -2809,13 +2809,12 @@ void ImGuiFullscreen::ChoiceDialog::Draw()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetFocusHere();
|
|
||||||
|
|
||||||
s32 choice = -1;
|
s32 choice = -1;
|
||||||
|
|
||||||
if (m_checkable)
|
if (m_checkable)
|
||||||
{
|
{
|
||||||
BeginMenuButtons();
|
BeginMenuButtons();
|
||||||
|
ResetFocusHere();
|
||||||
|
|
||||||
for (s32 i = 0; i < static_cast<s32>(m_options.size()); i++)
|
for (s32 i = 0; i < static_cast<s32>(m_options.size()); i++)
|
||||||
{
|
{
|
||||||
@ -2835,6 +2834,7 @@ void ImGuiFullscreen::ChoiceDialog::Draw()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// draw background first, because otherwise it'll obscure the frame border
|
// draw background first, because otherwise it'll obscure the frame border
|
||||||
|
bool found_selected = false;
|
||||||
for (s32 i = 0; i < static_cast<s32>(m_options.size()); i++)
|
for (s32 i = 0; i < static_cast<s32>(m_options.size()); i++)
|
||||||
{
|
{
|
||||||
const auto& option = m_options[i];
|
const auto& option = m_options[i];
|
||||||
@ -2846,13 +2846,19 @@ void ImGuiFullscreen::ChoiceDialog::Draw()
|
|||||||
pos.y += size.y * static_cast<float>(i);
|
pos.y += size.y * static_cast<float>(i);
|
||||||
ImGui::RenderFrame(pos, pos + size, ImGui::GetColorU32(UIStyle.PrimaryColor), false,
|
ImGui::RenderFrame(pos, pos + size, ImGui::GetColorU32(UIStyle.PrimaryColor), false,
|
||||||
LayoutScale(MENU_ITEM_BORDER_ROUNDING));
|
LayoutScale(MENU_ITEM_BORDER_ROUNDING));
|
||||||
|
if (!found_selected)
|
||||||
|
found_selected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginMenuButtons();
|
BeginMenuButtons();
|
||||||
|
ResetFocusHere();
|
||||||
|
|
||||||
|
const bool appearing = ImGui::IsWindowAppearing();
|
||||||
|
|
||||||
for (s32 i = 0; i < static_cast<s32>(m_options.size()); i++)
|
for (s32 i = 0; i < static_cast<s32>(m_options.size()); i++)
|
||||||
{
|
{
|
||||||
auto& option = m_options[i];
|
auto& option = m_options[i];
|
||||||
|
|
||||||
if (option.second ? MenuButtonWithValue(option.first.c_str(), nullptr, ICON_FA_CHECK, true,
|
if (option.second ? MenuButtonWithValue(option.first.c_str(), nullptr, ICON_FA_CHECK, true,
|
||||||
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) :
|
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) :
|
||||||
MenuButtonWithoutSummary(option.first.c_str()))
|
MenuButtonWithoutSummary(option.first.c_str()))
|
||||||
@ -2861,6 +2867,12 @@ void ImGuiFullscreen::ChoiceDialog::Draw()
|
|||||||
for (s32 j = 0; j < static_cast<s32>(m_options.size()); j++)
|
for (s32 j = 0; j < static_cast<s32>(m_options.size()); j++)
|
||||||
m_options[j].second = (j == i);
|
m_options[j].second = (j == i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (option.second && appearing)
|
||||||
|
{
|
||||||
|
ImGui::SetItemDefaultFocus();
|
||||||
|
ImGui::SetScrollHereY(0.5f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EndMenuButtons();
|
EndMenuButtons();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user