1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibGUI: Add Widget override cursor concept

We got ourselves into a mess by making widgets override the window
cursor whenever they wanted a custom cursor. This patch introduces a
better solution to that issue: per-widget override cursors.

Each widget now has an override cursor that overrides the window
cursor when that widget is hovered.
This commit is contained in:
Andreas Kling 2020-09-11 14:17:35 +02:00
parent b4f307f982
commit cf429a788c
4 changed files with 48 additions and 8 deletions

View file

@ -196,6 +196,8 @@ public:
void set_progress(int);
void update_cursor(Badge<Widget>) { update_cursor(); }
protected:
Window(Core::Object* parent = nullptr);
virtual void wm_event(WMEvent&);
@ -203,6 +205,8 @@ protected:
private:
virtual bool is_window() const override final { return true; }
void update_cursor();
void handle_drop_event(DropEvent&);
void handle_mouse_event(MouseEvent&);
void handle_multi_paint_event(MultiPaintEvent&);
@ -242,6 +246,7 @@ private:
Color m_background_color { Color::WarmGray };
WindowType m_window_type { WindowType::Normal };
Gfx::StandardCursor m_cursor { Gfx::StandardCursor::None };
Gfx::StandardCursor m_effective_cursor { Gfx::StandardCursor::None };
bool m_is_active { false };
bool m_is_active_input { false };
bool m_has_alpha_channel { false };