mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:37:35 +00:00
LibGUI+WindowServer: Add "visible" state to GUI actions
This patch adds a visibility state to GUI::Action. All actions default to being visible. When invisible, they do not show up in toolbars on menus (and importantly, they don't occupy any space). This can be used to hide/show context-sensitive actions dynamically without rebuilding menus and toolbars. Thanks to Tim Slater for assuming that action visibility was a thing, which gave me a reason to implement it! :^)
This commit is contained in:
parent
df7c0eacd4
commit
49f5767789
13 changed files with 88 additions and 14 deletions
|
@ -23,7 +23,7 @@ public:
|
|||
Separator,
|
||||
};
|
||||
|
||||
MenuItem(Menu&, unsigned identifier, DeprecatedString const& text, DeprecatedString const& shortcut_text = {}, bool enabled = true, bool checkable = false, bool checked = false, Gfx::Bitmap const* icon = nullptr);
|
||||
MenuItem(Menu&, unsigned identifier, DeprecatedString const& text, DeprecatedString const& shortcut_text = {}, bool enabled = true, bool visible = true, bool checkable = false, bool checked = false, Gfx::Bitmap const* icon = nullptr);
|
||||
MenuItem(Menu&, Type);
|
||||
~MenuItem() = default;
|
||||
|
||||
|
@ -32,6 +32,9 @@ public:
|
|||
bool is_enabled() const { return m_enabled; }
|
||||
void set_enabled(bool);
|
||||
|
||||
bool is_visible() const { return m_visible; }
|
||||
void set_visible(bool);
|
||||
|
||||
bool is_checkable() const { return m_checkable; }
|
||||
void set_checkable(bool checkable) { m_checkable = checkable; }
|
||||
|
||||
|
@ -69,6 +72,7 @@ private:
|
|||
Menu& m_menu;
|
||||
Type m_type { None };
|
||||
bool m_enabled { true };
|
||||
bool m_visible { true };
|
||||
bool m_checkable { false };
|
||||
bool m_checked { false };
|
||||
bool m_default { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue