mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
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! :^)
This commit is contained in:
parent
df7c0eacd4
commit
49f5767789
13 changed files with 88 additions and 14 deletions
|
@ -228,6 +228,19 @@ void Action::set_enabled(bool enabled)
|
|||
});
|
||||
}
|
||||
|
||||
void Action::set_visible(bool visible)
|
||||
{
|
||||
if (m_visible == visible)
|
||||
return;
|
||||
m_visible = visible;
|
||||
for_each_toolbar_button([visible](auto& button) {
|
||||
button.set_visible(visible);
|
||||
});
|
||||
for_each_menu_item([visible](auto& item) {
|
||||
item.set_visible(visible);
|
||||
});
|
||||
}
|
||||
|
||||
void Action::set_checked(bool checked)
|
||||
{
|
||||
if (m_checked == checked)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue