summaryrefslogtreecommitdiff
path: root/Servers/WindowServer/WSMenuItem.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-12 02:53:27 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-12 02:53:27 +0200
commit054c9821819de22d1522021978959e50f8fc6382 (patch)
tree7673e6d859fe6cfb26c28d944724ef8d53f0be99 /Servers/WindowServer/WSMenuItem.cpp
parent32e5c8c6890a27acb268cd43f087731e11f99d79 (diff)
downloadserenity-054c9821819de22d1522021978959e50f8fc6382.zip
LibGUI+WindowServer: Add support for enabled/disabled actions.
The enabled state of a GAction now propagates both to any toolbar buttons and any menu items linked to the action. Toolbar buttons are painted in a grayed out style when disabled. Menu items are gray when disabled. :^)
Diffstat (limited to 'Servers/WindowServer/WSMenuItem.cpp')
-rw-r--r--Servers/WindowServer/WSMenuItem.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/Servers/WindowServer/WSMenuItem.cpp b/Servers/WindowServer/WSMenuItem.cpp
index 49041e0034..95823c86ac 100644
--- a/Servers/WindowServer/WSMenuItem.cpp
+++ b/Servers/WindowServer/WSMenuItem.cpp
@@ -1,18 +1,30 @@
#include "WSMenuItem.h"
+#include "WSMenu.h"
-WSMenuItem::WSMenuItem(unsigned identifier, const String& text, const String& shortcut_text)
- : m_type(Text)
+WSMenuItem::WSMenuItem(WSMenu& menu, unsigned identifier, const String& text, const String& shortcut_text, bool enabled)
+ : m_menu(menu)
+ , m_type(Text)
+ , m_enabled(enabled)
, m_identifier(identifier)
, m_text(text)
, m_shortcut_text(shortcut_text)
{
}
-WSMenuItem::WSMenuItem(Type type)
- : m_type(type)
+WSMenuItem::WSMenuItem(WSMenu& menu, Type type)
+ : m_menu(menu)
+ , m_type(type)
{
}
WSMenuItem::~WSMenuItem()
{
}
+
+void WSMenuItem::set_enabled(bool enabled)
+{
+ if (m_enabled == enabled)
+ return;
+ m_enabled = enabled;
+ m_menu.redraw();
+}