diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-12 02:53:27 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-12 02:53:27 +0200 |
commit | 054c9821819de22d1522021978959e50f8fc6382 (patch) | |
tree | 7673e6d859fe6cfb26c28d944724ef8d53f0be99 /Servers/WindowServer/WSMenuItem.cpp | |
parent | 32e5c8c6890a27acb268cd43f087731e11f99d79 (diff) | |
download | serenity-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.cpp | 20 |
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(); +} |