Browse Source

Mouse wheel scrolling doesn't change speed inside Combo box (uses to slow down from 5 to 3) but instead slow down on window that are smaller than the scroll speed.

omar 7 years ago
parent
commit
457011660e
1 changed files with 4 additions and 3 deletions
  1. 4 3
      imgui.cpp

+ 4 - 3
imgui.cpp

@@ -2449,9 +2449,10 @@ void ImGui::NewFrame()
         }
         else if (!g.IO.KeyCtrl && !(window->Flags & ImGuiWindowFlags_NoScrollWithMouse))
         {
-            // Scroll
-            const int scroll_lines = (window->Flags & ImGuiWindowFlags_ComboBox) ? 3 : 5;
-            SetWindowScrollY(window, window->Scroll.y - g.IO.MouseWheel * window->CalcFontSize() * scroll_lines);
+            // Mouse wheel Scrolling
+            float scroll_amount = 5 * window->CalcFontSize();
+            scroll_amount = (float)(int)ImMin(scroll_amount, (window->ContentsRegionRect.GetHeight() + window->WindowPadding.y * 2.0f) * 0.67f);
+            SetWindowScrollY(window, window->Scroll.y - g.IO.MouseWheel * scroll_amount);
         }
     }