From a19e434e9b8d2e25b67ecb474b42c494431ed835 Mon Sep 17 00:00:00 2001 From: "Skyth (Asilkan)" <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:16:42 +0300 Subject: [PATCH] Implement scroll bar animation in options menu. (#238) --- UnleashedRecomp/ui/options_menu.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 9afcb4d..4f80d6f 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -62,6 +62,7 @@ static int32_t g_firstVisibleRowIndex; static int32_t g_prevSelectedRowIndex; static int32_t g_selectedRowIndex; static double g_rowSelectionTime; +static float g_prevOffsetRatio; static bool g_leftWasHeld; static bool g_upWasHeld; @@ -406,6 +407,7 @@ static void ResetSelection() g_selectedRowIndex = 0; g_prevSelectedRowIndex = 0; g_rowSelectionTime = ImGui::GetTime(); + g_prevOffsetRatio = 0.0f; g_leftWasHeld = false; g_upWasHeld = false; g_rightWasHeld = false; @@ -1144,7 +1146,11 @@ static void DrawConfigOptions() { float totalHeight = (clipRectMax.y - clipRectMin.y); float heightRatio = float(visibleRowCount) / float(rowCount); + float offsetRatio = float(g_firstVisibleRowIndex) / float(rowCount); + offsetRatio = Lerp(g_prevOffsetRatio, offsetRatio, 1.0f - exp(-16.0f * ImGui::GetIO().DeltaTime)); + g_prevOffsetRatio = offsetRatio; + float minY = offsetRatio * totalHeight + clipRectMin.y; drawList->AddRectFilled