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
commit 58955d37cc
Notes: sideshowbarker 2024-07-17 08:26:32 +09:00
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;
}