Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizontal mouse wheel support #1463

Merged

Conversation

tseeker
Copy link
Contributor

@tseeker tseeker commented Nov 27, 2017

This patch adds support for the horizontal mouse wheel in ImGui. It affects windows that can be scrolled, as long as the Ctrl key is not being pressed.

The scrolling speed has been set empirically so that it matches the scrolling speed on the Firefox browser when the horizontal wheel is used.

Internally, it adds a MouseHorizWheel to ImGuiIO, which is then used in NewFrame to scroll the current window. This field should be set by the backend.

The SDL/GL2, SDL/GL3, GLFW/GL2 and GLFW/GL3 examples have been modified to use it.

This patch adds support for the horizontal mouse wheel in ImGui. It
affects windows that can be scrolled, as long as the Ctrl key is not
being pressed.

The scrolling speed has been set empirically so that it matches the
scrolling speed on the Firefox browser when the horizontal wheel is
used.

Internally, it adds a MouseHorizWheel to ImGuiIO, which is then used in
NewFrame to scroll the current window.

The SDL/GL2, SDL/GL3, GLFW/GL2 and GLFW/GL3 examples has been modified
to use it.
@tseeker
Copy link
Contributor Author

tseeker commented Nov 28, 2017

Regarding examples I didn't modify for various reasons:

  • DirectX - it would seem that there is a WM_MOUSEHWHEEL event for the horizontal wheel that works exactly like its cousin WM_MOUSEWHEEL (https://msdn.microsoft.com/en-us/library/ms645614(VS.85).aspx)
  • Regarding the Apple version, the example already receives (and handles, in part) a horizontal mouse wheel value, it would probably be sufficient to set the new ImGuiIO field in the same way, but the mystery scaling factor required may be different.
  • Allegro apparently sends this value for the ALLEGRO_EVENT_MOUSE_AXES event, in the field called dw.
  • Marmalade doesn't support it as far as I can tell.
  • And of course the Vulkan example which should work exactly like the other 2 glfw-based examples.

@ocornut
Copy link
Owner

ocornut commented Nov 28, 2017

Thanks Emmanuel for this PR and all the precision! Looking good :)
(I am a little busy this week with other stuff, will probably look at it a little later)

@ocornut
Copy link
Owner

ocornut commented Jan 20, 2018

@tseeker I am working on this now.

Any reason why for the speed you used g.IO.MouseHorizWheel * 10.f and the same code float scroll_amount = 5 * scroll_window->CalcFontSize(); ?

Would you say that using CalcFontSize() would be a better amount than 5 * CalcFontSize() ?

@ocornut ocornut merged commit 77a3107 into ocornut:master Jan 20, 2018
ocornut added a commit that referenced this pull request Jan 20, 2018
… Reorganized the code in NewFrame(). Examples: Updated GLFW+GL and SDL+GL accordingly. (#1463)
ocornut added a commit that referenced this pull request Jan 20, 2018
@ocornut
Copy link
Owner

ocornut commented Jan 20, 2018

I merged this with some renaming/tweaks/simplifications of the example code. The field is called io.MouseWheelH. Let me know if it works all properly for you @tseeker, and thanks again!

It's not well tested and don't know what a proper scrolling is either, I used FontSize to be consistent with the vertical wheel, so I'm thinking maybe the base scale factor should be used specified.

@tseeker
Copy link
Contributor Author

tseeker commented Jan 20, 2018

Sorry for the late reply.
I don't remember the details exactly, but from memory, it needed to be scaled up quite a bit to be useful; if not the scrolling would be really sluggish.
I'll test it this evening.
Thanks!

ocornut added a commit that referenced this pull request Mar 28, 2018
ocornut added a commit that referenced this pull request Jul 22, 2018
… window if ImGuiWindowFlags_NoScrollWithMouse is set. (#1463, #1380, #1502)
ocornut added a commit that referenced this pull request Mar 25, 2019
…tAllowUserScaling feature (probably should be made obsolete, but until then best fixed)
ocornut added a commit that referenced this pull request Aug 10, 2020
ocornut added a commit that referenced this pull request Feb 1, 2023
…direction consistent accross backends/os. (#4019, #6096, #1463)

Documented assumptions.
ocornut added a commit that referenced this pull request Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants