diff --git a/dep/imgui/include/imgui_internal.h b/dep/imgui/include/imgui_internal.h index b1e5b808bb..d57c438d8a 100644 --- a/dep/imgui/include/imgui_internal.h +++ b/dep/imgui/include/imgui_internal.h @@ -2255,6 +2255,7 @@ struct ImGuiContext ImGuiComboPreviewData ComboPreviewData; ImRect WindowResizeBorderExpectedRect; // Expected border rect, switch to relative edit if moving bool WindowResizeRelativeMode; + unsigned char ScrollbarHeld; // Is the scrollbar scrolling the window? short ScrollbarSeekMode; // 0: relative, -1/+1: prev/next page. float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage? float SliderGrabClickOffset; @@ -2478,6 +2479,7 @@ struct ImGuiContext ColorEditSavedHue = ColorEditSavedSat = 0.0f; ColorEditSavedColor = 0; WindowResizeRelativeMode = false; + ScrollbarHeld = false; ScrollbarSeekMode = 0; ScrollbarClickDeltaToGrabCenter = 0.0f; SliderGrabClickOffset = 0.0f; diff --git a/dep/imgui/src/imgui.cpp b/dep/imgui/src/imgui.cpp index 5c21824325..c28020d4b4 100644 --- a/dep/imgui/src/imgui.cpp +++ b/dep/imgui/src/imgui.cpp @@ -4792,6 +4792,7 @@ void ImGui::NewFrame() g.HoveredId = 0; g.HoveredIdAllowOverlap = false; g.HoveredIdIsDisabled = false; + g.ScrollbarHeld >>= 1; // Clear ActiveID if the item is not alive anymore. // In 1.87, the common most call to KeepAliveID() was moved from GetID() to ItemAdd(). @@ -10802,7 +10803,7 @@ static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window) else scroll[axis] -= ImMin(-diff, (-diff / (style.ScrollSmooth * multiplier))); - scroll[axis] = window->Appearing ? window->ScrollExpected[axis] : scroll[axis]; + scroll[axis] = (window->Appearing || g.ScrollbarHeld & 1) ? window->ScrollExpected[axis] : scroll[axis]; } } return scroll; diff --git a/dep/imgui/src/imgui_widgets.cpp b/dep/imgui/src/imgui_widgets.cpp index 8e52da89ea..b7dd1d0fa1 100644 --- a/dep/imgui/src/imgui_widgets.cpp +++ b/dep/imgui/src/imgui_widgets.cpp @@ -1001,7 +1001,7 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6 { // On initial click calculate the distance between mouse and the center of the grab g.ScrollbarSeekMode = (short)held_dir; - g.ScrollbarClickDeltaToGrabCenter = (g.ScrollbarSeekMode == 0.0f) ? clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f : 0.0f; + g.ScrollbarClickDeltaToGrabCenter = (g.ScrollbarSeekMode == 0) ? clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f : 0.0f; } // Apply scroll (p_scroll_v will generally point on one member of window->Scroll) @@ -1025,6 +1025,7 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6 // Update values for rendering scroll_ratio = ImSaturate((float)*p_scroll_v / (float)scroll_max); grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; + g.ScrollbarHeld |= 2; // Update distance to grab now that we have seek'ed and saturated //if (seek_absolute)