From 075fe0220e6d48bf9438ae874715d1f2e2b6e419 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 21 Nov 2014 13:24:57 +0000 Subject: [PATCH] MouseWheel input is normalized --- imgui.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 07b02a0f..bb1a785d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1414,12 +1414,13 @@ void ImGui::NewFrame() if (g.HoveredWindow && g.IO.MouseWheel != 0) { ImGuiWindow* window = g.HoveredWindow; + const int mouse_wheel_dir = g.IO.MouseWheel > 0 ? +1 : -1; if (g.IO.KeyCtrl) { if (g.IO.FontAllowUserScaling) { // Zoom / Scale window - float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f); + float new_font_scale = ImClamp(window->FontWindowScale + mouse_wheel_dir * 0.10f, 0.50f, 2.50f); float scale = new_font_scale / window->FontWindowScale; window->FontWindowScale = new_font_scale; @@ -1434,7 +1435,7 @@ void ImGui::NewFrame() { // Scroll const int scroll_lines = (window->Flags & ImGuiWindowFlags_ComboBox) ? 3 : 5; - window->NextScrollY -= g.IO.MouseWheel * window->FontSize() * scroll_lines; + window->NextScrollY -= mouse_wheel_dir * window->FontSize() * scroll_lines; } }