mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
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. :^)
This commit is contained in:
parent
32e5c8c689
commit
054c982181
20 changed files with 308 additions and 53 deletions
|
@ -4,6 +4,8 @@
|
|||
#include <AK/Function.h>
|
||||
#include <SharedGraphics/Rect.h>
|
||||
|
||||
class WSMenu;
|
||||
|
||||
class WSMenuItem {
|
||||
public:
|
||||
enum Type {
|
||||
|
@ -12,15 +14,20 @@ public:
|
|||
Separator,
|
||||
};
|
||||
|
||||
explicit WSMenuItem(unsigned identifier, const String& text, const String& shortcut_text = { });
|
||||
explicit WSMenuItem(Type);
|
||||
WSMenuItem(WSMenu&, unsigned identifier, const String& text, const String& shortcut_text = { }, bool enabled = true);
|
||||
WSMenuItem(WSMenu&, Type);
|
||||
~WSMenuItem();
|
||||
|
||||
Type type() const { return m_type; }
|
||||
bool enabled() const { return m_enabled; }
|
||||
|
||||
bool is_enabled() const { return m_enabled; }
|
||||
void set_enabled(bool);
|
||||
|
||||
String text() const { return m_text; }
|
||||
void set_text(const String& text) { m_text = text; }
|
||||
|
||||
String shortcut_text() const { return m_shortcut_text; }
|
||||
void set_shortcut_text(const String& text) { m_shortcut_text = text; }
|
||||
|
||||
void set_rect(const Rect& rect) { m_rect = rect; }
|
||||
Rect rect() const { return m_rect; }
|
||||
|
@ -28,6 +35,7 @@ public:
|
|||
unsigned identifier() const { return m_identifier; }
|
||||
|
||||
private:
|
||||
WSMenu& m_menu;
|
||||
Type m_type { None };
|
||||
bool m_enabled { true };
|
||||
unsigned m_identifier { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue