diff options
author | HawDevelopment <hawdevelopment@gmail.com> | 2022-12-28 11:54:51 +0100 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2022-12-28 14:49:05 -0500 |
commit | a21703f1df33c06b3db05a9da554c7a4b116c0dc (patch) | |
tree | 64df2cf3d250e6def621c37240e3f131fadc0eca /Userland | |
parent | e8e1d1905e0e1ceef055cb4e25d69f2796f2a599 (diff) | |
download | serenity-a21703f1df33c06b3db05a9da554c7a4b116c0dc.zip |
Demos: Add ability to use scroll wheel in starfield
This change adds the ability to use the scroll wheel to change
the speed in starfield.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Demos/Starfield/Starfield.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Demos/Starfield/Starfield.cpp b/Userland/Demos/Starfield/Starfield.cpp index acc0388ce6..ab96f3d82e 100644 --- a/Userland/Demos/Starfield/Starfield.cpp +++ b/Userland/Demos/Starfield/Starfield.cpp @@ -46,6 +46,7 @@ private: virtual void paint_event(GUI::PaintEvent&) override; virtual void timer_event(Core::TimerEvent&) override; virtual void keydown_event(GUI::KeyEvent&) override; + virtual void mousewheel_event(GUI::MouseEvent&) override; Vector<Coordinate> m_stars; int m_sweep_plane = 2000; @@ -89,6 +90,16 @@ void Starfield::keydown_event(GUI::KeyEvent& event) } } +void Starfield::mousewheel_event(GUI::MouseEvent& event) +{ + if (event.wheel_delta_y() == 0) + return; + + m_speed += event.wheel_delta_y() > 0 ? -1 : 1; + if (m_speed < 1) + m_speed = 1; +} + void Starfield::paint_event(GUI::PaintEvent& event) { GUI::Painter painter(*this); |