mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:07: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
|
@ -135,6 +135,14 @@ void Action::activate(Core::Object* activator)
|
|||
m_activator = nullptr;
|
||||
}
|
||||
|
||||
void Action::flash_menubar_menu()
|
||||
{
|
||||
if (auto* app = Application::the())
|
||||
if (auto* window = app->active_window())
|
||||
for (auto& menu_item : m_menu_items)
|
||||
window->flash_menubar_menu_for(*menu_item);
|
||||
}
|
||||
|
||||
void Action::register_button(Badge<Button>, Button& button)
|
||||
{
|
||||
m_buttons.set(&button);
|
||||
|
|
|
@ -92,6 +92,7 @@ public:
|
|||
Function<void(Action&)> on_activation;
|
||||
|
||||
void activate(Core::Object* activator = nullptr);
|
||||
void flash_menubar_menu();
|
||||
|
||||
bool is_enabled() const { return m_enabled; }
|
||||
void set_enabled(bool);
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
bool is_default() const { return m_default; }
|
||||
void set_default(bool);
|
||||
|
||||
int menu_id() const { return m_menu_id; }
|
||||
void set_menu_id(Badge<Menu>, unsigned menu_id);
|
||||
void set_identifier(Badge<Menu>, unsigned identifier);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Desktop.h>
|
||||
#include <LibGUI/Event.h>
|
||||
#include <LibGUI/MenuItem.h>
|
||||
#include <LibGUI/Menubar.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
@ -1204,6 +1205,15 @@ Menu& Window::add_menu(String name)
|
|||
return *menu;
|
||||
}
|
||||
|
||||
void Window::flash_menubar_menu_for(const MenuItem& menu_item)
|
||||
{
|
||||
auto menu_id = menu_item.menu_id();
|
||||
if (menu_id < 0)
|
||||
return;
|
||||
|
||||
WindowServerConnection::the().async_flash_menubar_menu(m_window_id, menu_id);
|
||||
}
|
||||
|
||||
bool Window::is_modified() const
|
||||
{
|
||||
if (!m_window_id)
|
||||
|
|
|
@ -211,6 +211,7 @@ public:
|
|||
|
||||
Menu& add_menu(String name);
|
||||
ErrorOr<NonnullRefPtr<Menu>> try_add_menu(String name);
|
||||
void flash_menubar_menu_for(const MenuItem&);
|
||||
|
||||
void flush_pending_paints_immediately();
|
||||
|
||||
|
|
|
@ -172,6 +172,7 @@ void WindowServerConnection::key_down(i32 window_id, u32 code_point, u32 key, u3
|
|||
|
||||
if (auto* action = action_for_key_event(*window, *key_event)) {
|
||||
if (action->is_enabled()) {
|
||||
action->flash_menubar_menu();
|
||||
action->activate();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue