summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/MenuItem.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-12-07 21:18:02 +0100
committerAndreas Kling <kling@serenityos.org>2022-12-10 14:28:38 +0100
commit49f57677893cd61b3555e5fa663b66ae53e42046 (patch)
treed1faad97ae57303781d0c396f5e3bc3de1e93e1d /Userland/Libraries/LibGUI/MenuItem.h
parentdf7c0eacd44df1b49afd60c6caa4b1ce911b4273 (diff)
downloadserenity-49f57677893cd61b3555e5fa663b66ae53e42046.zip
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! :^)
Diffstat (limited to 'Userland/Libraries/LibGUI/MenuItem.h')
-rw-r--r--Userland/Libraries/LibGUI/MenuItem.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/MenuItem.h b/Userland/Libraries/LibGUI/MenuItem.h
index c98cb94abb..574f8a3b2f 100644
--- a/Userland/Libraries/LibGUI/MenuItem.h
+++ b/Userland/Libraries/LibGUI/MenuItem.h
@@ -45,6 +45,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_default() const { return m_default; }
void set_default(bool);
@@ -61,6 +64,7 @@ private:
int m_menu_id { -1 };
unsigned m_identifier { 0 };
bool m_enabled { true };
+ bool m_visible { true };
bool m_checkable { false };
bool m_checked { false };
bool m_default { false };