Skip to content

Commit

Permalink
MouseWheel input is normalized
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed Nov 21, 2014
1 parent cf037b4 commit 075fe02
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
}

Expand Down

0 comments on commit 075fe02

Please sign in to comment.