diff --git a/lib/libimhex/include/hex/api/imhex_api.hpp b/lib/libimhex/include/hex/api/imhex_api.hpp index 2c20c15a4..152d8bfe0 100644 --- a/lib/libimhex/include/hex/api/imhex_api.hpp +++ b/lib/libimhex/include/hex/api/imhex_api.hpp @@ -454,6 +454,9 @@ EXPORT_MODULE namespace hex { void cleanup(); + bool frameRateUnlockRequested(); + void resetFrameRateUnlockRequested(); + } /** @@ -720,6 +723,10 @@ EXPORT_MODULE namespace hex { */ void addMigrationRoutine(SemanticVersion migrationVersion, std::function function); + /** + * @brief Unlocks the frame rate temporarily, allowing animations to run smoothly + */ + void unlockFrameRate(); } /** diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 7ebaf239d..bb6e0fa0c 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -597,6 +597,14 @@ namespace hex { object->reset(); } + static bool s_frameRateUnlockRequested = false; + bool frameRateUnlockRequested() { + return s_frameRateUnlockRequested; + } + + void resetFrameRateUnlockRequested() { + s_frameRateUnlockRequested = false; + } } @@ -967,6 +975,9 @@ namespace hex { impl::s_windowResizable = resizable; } + void unlockFrameRate() { + impl::s_frameRateUnlockRequested = true; + } } diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 4328849ee..ff94abdba 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -355,8 +355,10 @@ namespace hex { if (ImGui::GetPlatformIO().Viewports.size() > 1) unlockFrameRate(); - // Unlock frame rate if there's any task running that shows a loading animation - if (TaskManager::getRunningTaskCount() > 0 || TaskManager::getRunningBlockingTaskCount() > 0) { + // Unlock frame rate if the frame rate was requested to be unlocked + if (ImHexApi::System::impl::frameRateUnlockRequested()) { + ImHexApi::System::impl::resetFrameRateUnlockRequested(); + glfwPostEmptyEvent(); unlockFrameRate(); } diff --git a/plugins/builtin/include/content/popups/popup_tasks_waiting.hpp b/plugins/builtin/include/content/popups/popup_tasks_waiting.hpp index b29d526f9..23b8291d4 100644 --- a/plugins/builtin/include/content/popups/popup_tasks_waiting.hpp +++ b/plugins/builtin/include/content/popups/popup_tasks_waiting.hpp @@ -15,6 +15,8 @@ namespace hex::plugin::builtin { m_onFinish(std::move(onFinish)){ } void drawContent() override { + ImHexApi::System::unlockFrameRate(); + ImGui::TextUnformatted("hex.builtin.popup.waiting_for_tasks.desc"_lang); ImGui::Separator(); diff --git a/plugins/builtin/source/content/ui_items.cpp b/plugins/builtin/source/content/ui_items.cpp index 822df9285..172269b3d 100644 --- a/plugins/builtin/source/content/ui_items.cpp +++ b/plugins/builtin/source/content/ui_items.cpp @@ -283,6 +283,8 @@ namespace hex::plugin::builtin { if (frontTask == nullptr) return; + ImHexApi::System::unlockFrameRate(); + const auto progress = frontTask->getMaxValue() == 0 ? -1 : float(frontTask->getValue()) / float(frontTask->getMaxValue()); ImHexApi::System::setTaskBarProgress(ImHexApi::System::TaskProgressState::Progress, ImHexApi::System::TaskProgressType::Normal, u32(progress * 100)); diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index c78d2be54..9844e946f 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -186,6 +186,8 @@ namespace hex::plugin::builtin { if (over) return; + ImHexApi::System::unlockFrameRate(); + const auto drawTile = [&](u32 x, u32 y) { drawList->AddRectFilled( {