|
@@ -1042,6 +1042,7 @@ static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time
|
|
|
// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by back-end)
|
|
|
static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. Affect FindHoveredWindow().
|
|
|
static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time.
|
|
|
+static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certaint time, unless mouse moved.
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
// [SECTION] FORWARD DECLARATIONS
|
|
@@ -3465,19 +3466,45 @@ static void ImGui::UpdateMouseInputs()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void ImGui::UpdateMouseWheel()
|
|
|
+static void StartLockWheelingWindow(ImGuiWindow* window)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
- if (!g.HoveredWindow || g.HoveredWindow->Collapsed)
|
|
|
+ if (g.WheelingWindow == window)
|
|
|
return;
|
|
|
+ g.WheelingWindow = window;
|
|
|
+ g.WheelingWindowRefMousePos = g.IO.MousePos;
|
|
|
+ g.WheelingWindowTimer = WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER;
|
|
|
+}
|
|
|
+
|
|
|
+void ImGui::UpdateMouseWheel()
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+
|
|
|
+ // Reset the locked window if we move the mouse or after the timer elapses
|
|
|
+ if (g.WheelingWindow != NULL)
|
|
|
+ {
|
|
|
+ g.WheelingWindowTimer -= g.IO.DeltaTime;
|
|
|
+ if (IsMousePosValid() && ImLengthSqr(g.IO.MousePos - g.WheelingWindowRefMousePos) > g.IO.MouseDragThreshold * g.IO.MouseDragThreshold)
|
|
|
+ g.WheelingWindowTimer = 0.0f;
|
|
|
+ if (g.WheelingWindowTimer <= 0.0f)
|
|
|
+ {
|
|
|
+ g.WheelingWindow = NULL;
|
|
|
+ g.WheelingWindowTimer = 0.0f;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (g.IO.MouseWheel == 0.0f && g.IO.MouseWheelH == 0.0f)
|
|
|
return;
|
|
|
|
|
|
+ ImGuiWindow* window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow;
|
|
|
+ if (!window || window->Collapsed)
|
|
|
+ return;
|
|
|
+
|
|
|
// Zoom / Scale window
|
|
|
// FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned.
|
|
|
if (g.IO.MouseWheel != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling)
|
|
|
{
|
|
|
- ImGuiWindow* window = g.HoveredWindow;
|
|
|
+ StartLockWheelingWindow(window);
|
|
|
const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
|
|
|
const float scale = new_font_scale / window->FontWindowScale;
|
|
|
window->FontWindowScale = new_font_scale;
|
|
@@ -3493,13 +3520,12 @@ void ImGui::UpdateMouseWheel()
|
|
|
|
|
|
// Mouse wheel scrolling
|
|
|
// If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent
|
|
|
- // FIXME: Lock scrolling window while not moving (see #2604)
|
|
|
|
|
|
// Vertical Mouse Wheel scrolling
|
|
|
const float wheel_y = (g.IO.MouseWheel != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f;
|
|
|
if (wheel_y != 0.0f && !g.IO.KeyCtrl)
|
|
|
{
|
|
|
- ImGuiWindow* window = g.HoveredWindow;
|
|
|
+ StartLockWheelingWindow(window);
|
|
|
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
|
|
|
window = window->ParentWindow;
|
|
|
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
|
|
@@ -3514,7 +3540,7 @@ void ImGui::UpdateMouseWheel()
|
|
|
const float wheel_x = (g.IO.MouseWheelH != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheelH : (g.IO.MouseWheel != 0.0f && g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f;
|
|
|
if (wheel_x != 0.0f && !g.IO.KeyCtrl)
|
|
|
{
|
|
|
- ImGuiWindow* window = g.HoveredWindow;
|
|
|
+ StartLockWheelingWindow(window);
|
|
|
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.x == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
|
|
|
window = window->ParentWindow;
|
|
|
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
|