From 5e96c47d2e25414d0f2a182791ff049dd9393f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boldizs=C3=A1r=20Lipka?= Date: Fri, 14 Mar 2014 22:48:44 +0100 Subject: [PATCH] Support for SDL2's mouse wheel event in the GUI1 scrollbar. --- src/widgets/scrollbar.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/widgets/scrollbar.cpp b/src/widgets/scrollbar.cpp index beaf575e5267..38f761fe1a00 100644 --- a/src/widgets/scrollbar.cpp +++ b/src/widgets/scrollbar.cpp @@ -375,6 +375,21 @@ void scrollbar::handle_event(const SDL_Event& event) } break; } +#if SDL_VERSION_ATLEAST(2,0,0) + case SDL_MOUSEWHEEL: + { + const SDL_MouseWheelEvent& e = event.wheel; + int x, y; + SDL_GetMouseState(&x, &y); + bool on_groove = point_in_rect(x, y, groove); + if (on_groove && e.y < 0) { + move_position(scroll_rate_); + } else if (on_groove && e.y > 0) { + move_position(-scroll_rate_); + } + break; + } +#endif default: break; }