mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +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:
parent
1084eaea0b
commit
58955d37cc
Notes:
sideshowbarker
2024-07-17 08:26:32 +09:00
Author: https://github.com/thankyouverycool
Commit: 58955d37cc
Pull-request: https://github.com/SerenityOS/serenity/pull/14706
Issue: https://github.com/SerenityOS/serenity/issues/14634
Reviewed-by: https://github.com/FireFox317
3 changed files with 27 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue