1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibGUI: Let Buttons set their menu popup position

The previous ButtonStyle::Tray conditional was a hack for Statusbars.
This commit is contained in:
thankyouverycool 2022-07-27 13:52:37 -04:00 committed by Andreas Kling
parent 1084eaea0b
commit 58955d37cc
3 changed files with 27 additions and 3 deletions

View file

@ -215,10 +215,22 @@ void Button::set_menu(RefPtr<GUI::Menu> menu)
void Button::mousedown_event(MouseEvent& event)
{
if (m_menu) {
if (button_style() == Gfx::ButtonStyle::Tray)
m_menu->popup(screen_relative_rect().top_right());
else
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();
}
update();
return;
}