From 855fbfce1b348221d3e1344f0aef754a0aaf8054 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 1 Dec 2022 02:02:33 -0500 Subject: [PATCH] GUI: improvements to inertial scrolling --- extern/imgui_patched/imgui.cpp | 10 +++++++--- extern/imgui_patched/imgui_internal.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/extern/imgui_patched/imgui.cpp b/extern/imgui_patched/imgui.cpp index 216d7a67c..a603ac413 100644 --- a/extern/imgui_patched/imgui.cpp +++ b/extern/imgui_patched/imgui.cpp @@ -6896,13 +6896,17 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // Inertial scroll if (g.IO.ConfigFlags & ImGuiConfigFlags_InertialScrollEnable) { - if (g.HoveredWindow == window) { + if (g.IO.MouseClicked[ImGuiMouseButton_Left] && (g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow) == window) { + g.InertialScrollId = window->ID; + printf("changing the ID to %d\n",window->ID); + } + if ((g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow) == window) { if (g.IO.MouseDown[ImGuiMouseButton_Left] || g.IO.MouseReleased[ImGuiMouseButton_Left]) { // launch inertial scroll if (g.IO.MouseClicked[ImGuiMouseButton_Left]) { - g.HoveredWindow->InertialScrollSpeed=ImVec2(0.0f,0.0f); + window->InertialScrollSpeed=ImVec2(0.0f,0.0f); } else { - g.HoveredWindow->InertialScrollSpeed=ImVec2(-g.IO.MouseDelta.x,-g.IO.MouseDelta.y); + window->InertialScrollSpeed=ImVec2(window->ScrollbarX?-g.IO.MouseDelta.x:0.0f,window->ScrollbarY?-g.IO.MouseDelta.y:0.0f); } } } diff --git a/extern/imgui_patched/imgui_internal.h b/extern/imgui_patched/imgui_internal.h index 6d461076b..079ea0fdf 100644 --- a/extern/imgui_patched/imgui_internal.h +++ b/extern/imgui_patched/imgui_internal.h @@ -1817,6 +1817,7 @@ struct ImGuiContext ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window. ImVec2 WheelingWindowRefMousePos; float WheelingWindowTimer; + ImGuiID InertialScrollId; // The last window in where to apply inertial scroll // Item/widgets state and tracking information ImGuiID DebugHookIdInfo; // Will call core hooks: DebugHookIdInfo() from GetID functions, used by Stack Tool [next HoveredId/ActiveId to not pull in an extra cache-line]