mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 07:05:08 +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
|
@ -31,12 +31,12 @@ GMenu::~GMenu()
|
|||
|
||||
void GMenu::add_action(Retained<GAction>&& action)
|
||||
{
|
||||
m_items.append(make<GMenuItem>(move(action)));
|
||||
m_items.append(make<GMenuItem>(m_menu_id, move(action)));
|
||||
}
|
||||
|
||||
void GMenu::add_separator()
|
||||
{
|
||||
m_items.append(make<GMenuItem>(GMenuItem::Separator));
|
||||
m_items.append(make<GMenuItem>(m_menu_id, GMenuItem::Separator));
|
||||
}
|
||||
|
||||
int GMenu::realize_menu()
|
||||
|
@ -52,6 +52,8 @@ int GMenu::realize_menu()
|
|||
ASSERT(m_menu_id > 0);
|
||||
for (int i = 0; i < m_items.size(); ++i) {
|
||||
auto& item = *m_items[i];
|
||||
item.set_menu_id({ }, m_menu_id);
|
||||
item.set_identifier({ }, i);
|
||||
if (item.type() == GMenuItem::Separator) {
|
||||
WSAPI_ClientMessage request;
|
||||
request.type = WSAPI_ClientMessage::Type::AddMenuSeparator;
|
||||
|
@ -65,6 +67,7 @@ int GMenu::realize_menu()
|
|||
request.type = WSAPI_ClientMessage::Type::AddMenuItem;
|
||||
request.menu.menu_id = m_menu_id;
|
||||
request.menu.identifier = i;
|
||||
request.menu.enabled = action.is_enabled();
|
||||
ASSERT(action.text().length() < (ssize_t)sizeof(request.text));
|
||||
strcpy(request.text, action.text().characters());
|
||||
request.text_length = action.text().length();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue