mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
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.
This commit is contained in:
parent
e8e1d1905e
commit
a21703f1df
Notes:
sideshowbarker
2024-07-19 17:00:16 +09:00
Author: https://github.com/Gargafield 🔰 Commit: https://github.com/SerenityOS/serenity/commit/a21703f1df3 Pull-request: https://github.com/SerenityOS/serenity/pull/16693 Reviewed-by: https://github.com/trflynn89
1 changed files with 11 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue