summaryrefslogtreecommitdiff
path: root/Userland/Demos/Starfield/Starfield.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Demos/Starfield/Starfield.cpp')
-rw-r--r--Userland/Demos/Starfield/Starfield.cpp11
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);