Browser+LibGUI+WindowServer: Open Button menus uniformly

Instead of letting buttons determine the relative position
of their menus, a workaround only used by Statusbar segments,
open them all uniformly for a nice, consistent UI.

Passing a rect to popup() now routes to open_button_menu(), an
analog to open_menubar_menu(), which adjusts the menu's popup
position in the same way. Fixes button menus obscuring the buttons
which spawn them and jutting out at odd corners depending on screen
position.
This commit is contained in:
thankyouverycool 2022-09-04 19:48:37 -04:00 committed by Linus Groh
commit 35e557c657
Notes: sideshowbarker 2024-07-17 07:21:35 +09:00
12 changed files with 34 additions and 31 deletions

View file

@ -215,22 +215,7 @@ void Button::set_menu(RefPtr<GUI::Menu> menu)
void Button::mousedown_event(MouseEvent& event)
{
if (m_menu) {
switch (m_menu_position) {
case TopLeft:
m_menu->popup(screen_relative_rect().top_left());
break;
case TopRight:
m_menu->popup(screen_relative_rect().top_right());
break;
case BottomLeft:
m_menu->popup(screen_relative_rect().bottom_left());
break;
case BottomRight:
m_menu->popup(screen_relative_rect().bottom_right());
break;
default:
VERIFY_NOT_REACHED();
}
m_menu->popup(screen_relative_rect().bottom_left(), {}, rect());
update();
return;
}