mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
WindowServer: Add Menu::is_open() to improve readability
"menu.is_open()" instead of "MenuManager::the().is_open(menu)"
This commit is contained in:
parent
dfb2178519
commit
5d0c3bd564
4 changed files with 11 additions and 3 deletions
|
@ -658,4 +658,9 @@ void Menu::set_hovered_index(int index, bool make_input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Menu::is_open() const
|
||||||
|
{
|
||||||
|
return MenuManager::the().is_open(*this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ public:
|
||||||
const ClientConnection* client() const { return m_client; }
|
const ClientConnection* client() const { return m_client; }
|
||||||
int menu_id() const { return m_menu_id; }
|
int menu_id() const { return m_menu_id; }
|
||||||
|
|
||||||
|
bool is_open() const;
|
||||||
|
|
||||||
u32 alt_shortcut_character() const { return m_alt_shortcut_character; }
|
u32 alt_shortcut_character() const { return m_alt_shortcut_character; }
|
||||||
|
|
||||||
bool is_empty() const { return m_items.is_empty(); }
|
bool is_empty() const { return m_items.is_empty(); }
|
||||||
|
|
|
@ -291,7 +291,7 @@ void MenuManager::set_hovered_menu(Menu* menu)
|
||||||
|
|
||||||
void MenuManager::open_menu(Menu& menu, bool as_current_menu)
|
void MenuManager::open_menu(Menu& menu, bool as_current_menu)
|
||||||
{
|
{
|
||||||
if (is_open(menu)) {
|
if (menu.is_open()) {
|
||||||
if (as_current_menu || current_menu() != &menu) {
|
if (as_current_menu || current_menu() != &menu) {
|
||||||
// This menu is already open. If requested, or if the current
|
// This menu is already open. If requested, or if the current
|
||||||
// window doesn't match this one, then set it to this
|
// window doesn't match this one, then set it to this
|
||||||
|
|
|
@ -293,9 +293,10 @@ void WindowFrame::paint_menubar(Gfx::Painter& painter)
|
||||||
m_window.menubar()->for_each_menu([&](Menu& menu) {
|
m_window.menubar()->for_each_menu([&](Menu& menu) {
|
||||||
auto text_rect = menu.rect_in_window_menubar();
|
auto text_rect = menu.rect_in_window_menubar();
|
||||||
Color text_color = palette.window_text();
|
Color text_color = palette.window_text();
|
||||||
if (MenuManager::the().is_open(menu))
|
auto is_open = menu.is_open();
|
||||||
|
if (is_open)
|
||||||
text_rect.translate_by(1, 1);
|
text_rect.translate_by(1, 1);
|
||||||
bool paint_as_pressed = MenuManager::the().is_open(menu);
|
bool paint_as_pressed = is_open;
|
||||||
bool paint_as_hovered = !paint_as_pressed && &menu == MenuManager::the().hovered_menu();
|
bool paint_as_hovered = !paint_as_pressed && &menu == MenuManager::the().hovered_menu();
|
||||||
if (paint_as_pressed || paint_as_hovered) {
|
if (paint_as_pressed || paint_as_hovered) {
|
||||||
Gfx::StylePainter::paint_button(painter, menu.rect_in_window_menubar(), palette, Gfx::ButtonStyle::Coolbar, paint_as_pressed, paint_as_hovered);
|
Gfx::StylePainter::paint_button(painter, menu.rect_in_window_menubar(), palette, Gfx::ButtonStyle::Coolbar, paint_as_pressed, paint_as_hovered);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue