mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +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
|
@ -192,6 +192,40 @@ void ClientConnection::update_menu_item(i32 menu_id, i32 identifier, [[maybe_unu
|
|||
menu_item->set_checked(checked);
|
||||
}
|
||||
|
||||
void ClientConnection::flash_menubar_menu(i32 window_id, i32 menu_id)
|
||||
{
|
||||
auto itw = m_windows.find(window_id);
|
||||
if (itw == m_windows.end()) {
|
||||
did_misbehave("FlashMenubarMenu: Bad window ID");
|
||||
return;
|
||||
}
|
||||
auto& window = *(*itw).value;
|
||||
|
||||
auto itm = m_menus.find(menu_id);
|
||||
if (itm == m_menus.end()) {
|
||||
did_misbehave("FlashMenubarMenu: Bad menu ID");
|
||||
return;
|
||||
}
|
||||
auto& menu = *(*itm).value;
|
||||
|
||||
if (window.menubar().flash_menu(&menu)) {
|
||||
window.frame().invalidate_menubar();
|
||||
|
||||
if (m_flashed_menu_timer && m_flashed_menu_timer->is_active()) {
|
||||
m_flashed_menu_timer->on_timeout();
|
||||
m_flashed_menu_timer->stop();
|
||||
}
|
||||
|
||||
m_flashed_menu_timer = Core::Timer::create_single_shot(75, [&window] {
|
||||
window.menubar().flash_menu(nullptr);
|
||||
window.frame().invalidate_menubar();
|
||||
});
|
||||
m_flashed_menu_timer->start();
|
||||
} else if (m_flashed_menu_timer) {
|
||||
m_flashed_menu_timer->restart();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientConnection::add_menu_separator(i32 menu_id)
|
||||
{
|
||||
auto it = m_menus.find(menu_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue