@@ -3449,12 +3449,12 @@ void ImGui::UpdateMouseWheel()
3449
3449
return ;
3450
3450
if (g.IO .MouseWheel == 0 .0f && g.IO .MouseWheelH == 0 .0f )
3451
3451
return ;
3452
- ImGuiWindow* window = g.HoveredWindow ;
3453
3452
3454
3453
// Zoom / Scale window
3455
3454
// FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned.
3456
- if (g.IO .MouseWheel != 0 .0f && g.IO .KeyCtrl && g.IO .FontAllowUserScaling && !window ->Collapsed )
3455
+ if (g.IO .MouseWheel != 0 .0f && g.IO .KeyCtrl && g.IO .FontAllowUserScaling && !g. HoveredWindow ->Collapsed )
3457
3456
{
3457
+ ImGuiWindow* window = g.HoveredWindow ;
3458
3458
const float new_font_scale = ImClamp (window->FontWindowScale + g.IO .MouseWheel * 0 .10f , 0 .50f , 2 .50f );
3459
3459
const float scale = new_font_scale / window->FontWindowScale ;
3460
3460
window->FontWindowScale = new_font_scale;
@@ -3469,31 +3469,36 @@ void ImGui::UpdateMouseWheel()
3469
3469
}
3470
3470
3471
3471
// Mouse wheel scrolling
3472
- // If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent (unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set).
3473
- while ((window->Flags & ImGuiWindowFlags_ChildWindow) && (window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs) && window->ParentWindow )
3474
- window = window->ParentWindow ;
3475
- const bool scroll_allowed = !(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs);
3476
- if (scroll_allowed && (g.IO .MouseWheel != 0 .0f || g.IO .MouseWheelH != 0 .0f ) && !g.IO .KeyCtrl )
3477
- {
3478
- ImVec2 max_step = window->InnerRect .GetSize () * 0 .67f ;
3472
+ // If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent
3473
+ // FIXME: Lock scrolling window while not moving (see #2604)
3479
3474
3480
- // Vertical Mouse Wheel Scrolling (hold Shift to scroll horizontally)
3481
- if (g.IO .MouseWheel != 0 .0f && !g.IO .KeyShift )
3482
- {
3483
- float scroll_step = ImFloor (ImMin (5 * window->CalcFontSize (), max_step.y ));
3484
- SetWindowScrollY (window, window->Scroll .y - g.IO .MouseWheel * scroll_step);
3485
- }
3486
- else if (g.IO .MouseWheel != 0 .0f && g.IO .KeyShift )
3475
+ // Vertical Mouse Wheel scrolling
3476
+ const float wheel_y = (g.IO .MouseWheel != 0 .0f && !g.IO .KeyShift ) ? g.IO .MouseWheel : 0 .0f ;
3477
+ if (wheel_y != 0 .0f && !g.IO .KeyCtrl )
3478
+ {
3479
+ ImGuiWindow* window = g.HoveredWindow ;
3480
+ while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax .y == 0 .0f ) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
3481
+ window = window->ParentWindow ;
3482
+ if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
3487
3483
{
3488
- float scroll_step = ImFloor (ImMin (2 * window->CalcFontSize (), max_step.x ));
3489
- SetWindowScrollX (window, window->Scroll .x - g.IO .MouseWheel * scroll_step);
3484
+ float max_step = window->InnerRect .GetHeight () * 0 .67f ;
3485
+ float scroll_step = ImFloor (ImMin (5 * window->CalcFontSize (), max_step));
3486
+ SetWindowScrollY (window, window->Scroll .y - wheel_y * scroll_step);
3490
3487
}
3488
+ }
3491
3489
3492
- // Horizontal Mouse Wheel Scrolling (for hardware that supports it)
3493
- if (g.IO .MouseWheelH != 0 .0f && !g.IO .KeyShift )
3490
+ // Horizontal Mouse Wheel scrolling, or Vertical Mouse Wheel w/ Shift held
3491
+ 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 ;
3492
+ if (wheel_x != 0 .0f && !g.IO .KeyCtrl )
3493
+ {
3494
+ ImGuiWindow* window = g.HoveredWindow ;
3495
+ while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax .x == 0 .0f ) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
3496
+ window = window->ParentWindow ;
3497
+ if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
3494
3498
{
3495
- float scroll_step = ImFloor (ImMin (2 * window->CalcFontSize (), max_step.x ));
3496
- SetWindowScrollX (window, window->Scroll .x - g.IO .MouseWheelH * scroll_step);
3499
+ float max_step = window->InnerRect .GetWidth () * 0 .67f ;
3500
+ float scroll_step = ImFloor (ImMin (2 * window->CalcFontSize (), max_step));
3501
+ SetWindowScrollX (window, window->Scroll .x - wheel_x * scroll_step);
3497
3502
}
3498
3503
}
3499
3504
}
0 commit comments