mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibGUI: Add Widget focus policies
Every widget now has a GUI::FocusPolicy that determines how it can receive focus: - NoFocus: The widget is not focusable (default) - TabFocus: The widget can be focused using the tab key. - ClickFocus: The widget can be focused by clicking on it. - StrongFocus: Both of the above. For widgets that have a focus proxy, getting/setting the focus policy will affect the proxy instead.
This commit is contained in:
parent
34014fa838
commit
aef56159a8
32 changed files with 64 additions and 40 deletions
|
@ -88,6 +88,13 @@ private:
|
|||
Function<NonnullRefPtr<Widget>()> m_factory;
|
||||
};
|
||||
|
||||
enum class FocusPolicy {
|
||||
NoFocus = 0,
|
||||
TabFocus = 0x1,
|
||||
ClickFocus = 0x2,
|
||||
StrongFocus = TabFocus | ClickFocus,
|
||||
};
|
||||
|
||||
class Widget : public Core::Object {
|
||||
C_OBJECT(Widget)
|
||||
public:
|
||||
|
@ -155,8 +162,6 @@ public:
|
|||
void update();
|
||||
void update(const Gfx::IntRect&);
|
||||
|
||||
virtual bool accepts_focus() const { return false; }
|
||||
|
||||
bool is_focused() const;
|
||||
void set_focus(bool, FocusSource = FocusSource::Programmatic);
|
||||
|
||||
|
@ -164,6 +169,9 @@ public:
|
|||
const Widget* focus_proxy() const { return m_focus_proxy; }
|
||||
void set_focus_proxy(Widget*);
|
||||
|
||||
void set_focus_policy(FocusPolicy policy);
|
||||
FocusPolicy focus_policy() const;
|
||||
|
||||
enum class ShouldRespectGreediness { No = 0,
|
||||
Yes };
|
||||
struct HitTestResult {
|
||||
|
@ -362,6 +370,7 @@ private:
|
|||
NonnullRefPtr<Gfx::PaletteImpl> m_palette;
|
||||
|
||||
WeakPtr<Widget> m_focus_proxy;
|
||||
FocusPolicy m_focus_policy { FocusPolicy::NoFocus };
|
||||
|
||||
Gfx::StandardCursor m_override_cursor { Gfx::StandardCursor::None };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue