mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:07:45 +00:00
Demos+LibDesktop: Centralize screensaver logic
We have 3 demos with pretty similar window logic and quitting behavior on user activity, so centralize that into `Desktop::Screensaver`.
This commit is contained in:
parent
379e4a2432
commit
18b6bdb563
11 changed files with 108 additions and 99 deletions
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibDesktop/Screensaver.h>
|
||||
#include <LibGL/GLContext.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibGfx/Vector3.h>
|
||||
|
||||
enum class Direction : u8 {
|
||||
|
@ -31,7 +31,7 @@ struct Tube {
|
|||
double progress_to_target { 0 };
|
||||
};
|
||||
|
||||
class Tubes final : public GUI::Widget {
|
||||
class Tubes final : public Desktop::Screensaver {
|
||||
C_OBJECT(Tubes)
|
||||
public:
|
||||
virtual ~Tubes() override = default;
|
||||
|
@ -51,14 +51,10 @@ private:
|
|||
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent& event) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent& event) override;
|
||||
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
FixedArray<u8> m_grid;
|
||||
OwnPtr<GL::GLContext> m_gl_context;
|
||||
Gfx::IntPoint m_mouse_origin;
|
||||
u64 m_ticks { 0 };
|
||||
Vector<Tube> m_tubes;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue