mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:47:45 +00:00
LibGUI+WindowServer: Flash menubar menu when using a keyboard shortcut
Briefly flash the menubar menu containing the keyboard shortcut action to give the user immediate visual feedback on their interaction with the system.
This commit is contained in:
parent
ed0f4bdfaf
commit
6c049ea4c4
11 changed files with 88 additions and 1 deletions
|
@ -23,6 +23,26 @@ public:
|
|||
layout_menu(menu, window_rect);
|
||||
}
|
||||
|
||||
bool flash_menu(Menu* flashed_submenu)
|
||||
{
|
||||
Menu* const old_flashed_menu = m_flashed_menu;
|
||||
m_flashed_menu = nullptr;
|
||||
|
||||
if (flashed_submenu) {
|
||||
for_each_menu([&](Menu& menu) {
|
||||
if ((&menu) == flashed_submenu || menu.is_menu_ancestor_of(*flashed_submenu)) {
|
||||
m_flashed_menu = &menu;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
||||
return (old_flashed_menu != m_flashed_menu);
|
||||
}
|
||||
|
||||
Menu* flashed_menu() const { return m_flashed_menu; }
|
||||
|
||||
bool has_menus()
|
||||
{
|
||||
return !m_menus.is_empty();
|
||||
|
@ -40,6 +60,7 @@ private:
|
|||
void layout_menu(Menu&, Gfx::IntRect window_rect);
|
||||
|
||||
Vector<Menu&> m_menus;
|
||||
Menu* m_flashed_menu { nullptr };
|
||||
|
||||
// FIXME: This doesn't support removing menus from a menubar or inserting a
|
||||
// menu in the middle.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue