Skip to content

Commit

Permalink
Implement horizontal scrolling with Shift+Scroll
Browse files Browse the repository at this point in the history
This is standard scrolling behaviour in most applications.
  • Loading branch information
LunaRood authored and ocornut committed Mar 25, 2019
1 parent 3d8ea35 commit 1963cc5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3296,6 +3296,13 @@ void ImGui::UpdateMouseWheel()
window->Size *= scale;
window->SizeFull *= scale;
}
else if (!g.IO.KeyCtrl && g.IO.KeyShift && scroll_allowed)
{
// Mouse wheel horizontal scrolling
float scroll_amount = 5 * scroll_window->CalcFontSize();
scroll_amount = (float)(int)ImMin(scroll_amount, (scroll_window->ContentsRegionRect.GetWidth() + scroll_window->WindowPadding.x * 2.0f) * 0.67f);
SetWindowScrollX(scroll_window, scroll_window->Scroll.x - g.IO.MouseWheel * scroll_amount);
}
else if (!g.IO.KeyCtrl && scroll_allowed)
{
// Mouse wheel vertical scrolling
Expand Down

0 comments on commit 1963cc5

Please sign in to comment.