FullscreenUI: More animation fixes

This commit is contained in:
Stenzek
2024-08-26 17:56:47 +10:00
parent 46a6681159
commit 940200f7f3
4 changed files with 88 additions and 68 deletions

View File

@ -593,12 +593,17 @@ bool ImGuiFullscreen::ResetFocusHere()
if (ImGui::FindBlockingModal(window))
return false;
// Only fully reset the window on window change, that way setting page changes don't spend a frame without focus.
if (s_focus_reset_queued == FocusResetType::ViewChanged)
window->LastFrameActive = 0;
s_focus_reset_queued = FocusResetType::None;
// Set the flag that we drew an active/hovered item active for a frame, because otherwise there's one frame where
// there'll be no frame drawn, which will cancel the animation. Also set the appearing flag, so that the default
// focus set does actually go through.
if (!GImGui->NavDisableHighlight && GImGui->NavDisableMouseHover)
{
window->Appearing = true;
s_has_hovered_menu_item = s_had_hovered_menu_item;
}
ImGui::SetWindowFocus();
ImGui::NavInitWindow(window, true);
@ -613,8 +618,7 @@ bool ImGuiFullscreen::IsFocusResetQueued()
bool ImGuiFullscreen::IsFocusResetFromWindowChange()
{
return (s_focus_reset_queued != FocusResetType::None && s_focus_reset_queued != FocusResetType::PopupOpened &&
s_focus_reset_queued != FocusResetType::PopupClosed);
return (s_focus_reset_queued != FocusResetType::None && s_focus_reset_queued != FocusResetType::PopupClosed);
}
ImGuiFullscreen::FocusResetType ImGuiFullscreen::GetQueuedFocusResetType()
@ -2181,6 +2185,9 @@ void ImGuiFullscreen::CloseFileSelector()
if (!s_file_selector_open)
return;
if (ImGui::IsPopupOpen(s_file_selector_title.c_str(), 0))
ImGui::ClosePopupToLevel(GImGui->OpenPopupStack.Size - 1, true);
s_file_selector_open = false;
s_file_selector_directory = false;
std::string().swap(s_file_selector_title);
@ -2220,8 +2227,8 @@ void ImGuiFullscreen::DrawFileSelector()
{
ImGui::PushStyleColor(ImGuiCol_Text, UIBackgroundTextColor);
BeginMenuButtons();
ResetFocusHere();
BeginMenuButtons();
if (!s_file_selector_current_directory.empty())
{
@ -2319,6 +2326,9 @@ void ImGuiFullscreen::CloseChoiceDialog()
if (!s_choice_dialog_open)
return;
if (ImGui::IsPopupOpen(s_choice_dialog_title.c_str(), 0))
ImGui::ClosePopupToLevel(GImGui->OpenPopupStack.Size - 1, true);
s_choice_dialog_open = false;
s_choice_dialog_checkable = false;
std::string().swap(s_choice_dialog_title);
@ -2353,7 +2363,7 @@ void ImGuiFullscreen::DrawChoiceDialog()
ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::OpenPopup(s_choice_dialog_title.c_str());
bool is_open = !WantsToCloseMenu();
bool is_open = true;
s32 choice = -1;
if (ImGui::BeginPopupModal(s_choice_dialog_title.c_str(), &is_open,
@ -2361,8 +2371,8 @@ void ImGuiFullscreen::DrawChoiceDialog()
{
ImGui::PushStyleColor(ImGuiCol_Text, UIBackgroundTextColor);
BeginMenuButtons();
ResetFocusHere();
BeginMenuButtons();
if (s_choice_dialog_checkable)
{
@ -2400,15 +2410,13 @@ void ImGuiFullscreen::DrawChoiceDialog()
ImGui::EndPopup();
}
else
{
is_open = false;
}
ImGui::PopStyleColor(3);
ImGui::PopStyleVar(3);
ImGui::PopFont();
is_open &= !WantsToCloseMenu();
if (choice >= 0)
{
const auto& option = s_choice_dialog_options[choice];
@ -2526,6 +2534,9 @@ void ImGuiFullscreen::CloseInputDialog()
if (!s_input_dialog_open)
return;
if (ImGui::IsPopupOpen(s_input_dialog_title.c_str(), 0))
ImGui::ClosePopupToLevel(GImGui->OpenPopupStack.Size - 1, true);
s_input_dialog_open = false;
s_input_dialog_title = {};
s_input_dialog_message = {};
@ -2589,6 +2600,9 @@ void ImGuiFullscreen::CloseMessageDialog()
if (!s_message_dialog_open)
return;
if (ImGui::IsPopupOpen(s_message_dialog_title.c_str(), 0))
ImGui::ClosePopupToLevel(GImGui->OpenPopupStack.Size - 1, true);
s_message_dialog_open = false;
s_message_dialog_title = {};
s_message_dialog_message = {};
@ -2626,8 +2640,8 @@ void ImGuiFullscreen::DrawMessageDialog()
if (ImGui::BeginPopupModal(win_id, &is_open, flags))
{
BeginMenuButtons();
ResetFocusHere();
BeginMenuButtons();
ImGui::TextWrapped("%s", s_message_dialog_message.c_str());
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + LayoutScale(20.0f));