mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +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:
parent
b4f307f982
commit
cf429a788c
4 changed files with 48 additions and 8 deletions
|
@ -36,6 +36,7 @@
|
|||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Orientation.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/StandardCursor.h>
|
||||
|
||||
#define REGISTER_WIDGET(class_name) \
|
||||
extern WidgetClassRegistration registration_##class_name; \
|
||||
|
@ -277,6 +278,9 @@ public:
|
|||
|
||||
virtual Gfx::IntRect children_clip_rect() const;
|
||||
|
||||
Gfx::StandardCursor override_cursor() const { return m_override_cursor; }
|
||||
void set_override_cursor(Gfx::StandardCursor);
|
||||
|
||||
protected:
|
||||
Widget();
|
||||
|
||||
|
@ -349,6 +353,8 @@ private:
|
|||
NonnullRefPtr<Gfx::PaletteImpl> m_palette;
|
||||
|
||||
WeakPtr<Widget> m_focus_proxy;
|
||||
|
||||
Gfx::StandardCursor m_override_cursor { Gfx::StandardCursor::None };
|
||||
};
|
||||
|
||||
inline Widget* Widget::parent_widget()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue