From aa66d4b9e739fb0a1c9521448c89ff404007ec67 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 23 Jul 2023 18:22:53 +0200 Subject: [PATCH] impr: Insert short delay before opening popups so the animation finishes --- main/source/window/window.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/main/source/window/window.cpp b/main/source/window/window.cpp index 63371b511..dfdd3d517 100644 --- a/main/source/window/window.cpp +++ b/main/source/window/window.cpp @@ -568,17 +568,26 @@ namespace hex { static bool popupDisplaying = false; static bool positionSet = false; static bool sizeSet = false; + static double popupDelay = -2.0; static std::unique_ptr currPopup; static LangEntry name(""); if (auto &popups = impl::PopupBase::getOpenPopups(); !popups.empty()) { if (!ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId)) { - currPopup = std::move(popups.back()); - name = LangEntry(currPopup->getUnlocalizedName()); + if (popupDelay <= -1.0) { + popupDelay = 200; + } else { + popupDelay -= this->m_lastFrameTime; + if (popupDelay < 0) { + popupDelay = -2.0; + currPopup = std::move(popups.back()); + name = LangEntry(currPopup->getUnlocalizedName()); - ImGui::OpenPopup(name); - popups.pop_back(); + ImGui::OpenPopup(name); + popups.pop_back(); + } + } } }