diff options
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/Button.cpp | 17 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Button.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Menu.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Menu.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Statusbar.cpp | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Toolbar.cpp | 3 |
6 files changed, 5 insertions, 26 deletions
diff --git a/Userland/Libraries/LibGUI/Button.cpp b/Userland/Libraries/LibGUI/Button.cpp index 735d40e86f..20a242569f 100644 --- a/Userland/Libraries/LibGUI/Button.cpp +++ b/Userland/Libraries/LibGUI/Button.cpp @@ -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; } diff --git a/Userland/Libraries/LibGUI/Button.h b/Userland/Libraries/LibGUI/Button.h index ca8f79ff1f..efdf1b12d6 100644 --- a/Userland/Libraries/LibGUI/Button.h +++ b/Userland/Libraries/LibGUI/Button.h @@ -66,9 +66,6 @@ public: void set_mimic_pressed(bool mimic_pressed); bool is_mimic_pressed() const { return m_mimic_pressed; }; - MenuPosition menu_position() const { return m_menu_position; } - void set_menu_position(MenuPosition position) { m_menu_position = position; } - virtual Optional<UISize> calculated_min_size() const override; protected: @@ -88,7 +85,6 @@ private: int m_icon_spacing { 4 }; bool m_another_button_has_focus { false }; bool m_mimic_pressed { false }; - MenuPosition m_menu_position { MenuPosition::TopLeft }; }; class DialogButton final : public Button { diff --git a/Userland/Libraries/LibGUI/Menu.cpp b/Userland/Libraries/LibGUI/Menu.cpp index 7363688f57..11461cd476 100644 --- a/Userland/Libraries/LibGUI/Menu.cpp +++ b/Userland/Libraries/LibGUI/Menu.cpp @@ -116,10 +116,10 @@ void Menu::realize_if_needed(RefPtr<Action> const& default_action) realize_menu(default_action); } -void Menu::popup(Gfx::IntPoint const& screen_position, RefPtr<Action> const& default_action) +void Menu::popup(Gfx::IntPoint const& screen_position, RefPtr<Action> const& default_action, Gfx::IntRect const& button_rect) { realize_if_needed(default_action); - ConnectionToWindowServer::the().async_popup_menu(m_menu_id, screen_position); + ConnectionToWindowServer::the().async_popup_menu(m_menu_id, screen_position, button_rect); } void Menu::dismiss() diff --git a/Userland/Libraries/LibGUI/Menu.h b/Userland/Libraries/LibGUI/Menu.h index 79c7000e35..84defebcab 100644 --- a/Userland/Libraries/LibGUI/Menu.h +++ b/Userland/Libraries/LibGUI/Menu.h @@ -41,7 +41,7 @@ public: Menu& add_submenu(String name); void remove_all_actions(); - void popup(Gfx::IntPoint const& screen_position, RefPtr<Action> const& default_action = nullptr); + void popup(Gfx::IntPoint const& screen_position, RefPtr<Action> const& default_action = nullptr, Gfx::IntRect const& button_rect = {}); void dismiss(); void visibility_did_change(Badge<ConnectionToWindowServer>, bool visible); diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp index 0ae54eb3f8..3618cad0d6 100644 --- a/Userland/Libraries/LibGUI/Statusbar.cpp +++ b/Userland/Libraries/LibGUI/Statusbar.cpp @@ -146,7 +146,6 @@ Statusbar::Segment::Segment() set_focus_policy(GUI::FocusPolicy::NoFocus); set_button_style(Gfx::ButtonStyle::Tray); set_text_alignment(Gfx::TextAlignment::CenterLeft); - set_menu_position(GUI::Button::MenuPosition::TopRight); } void Statusbar::Segment::paint_event(PaintEvent& event) diff --git a/Userland/Libraries/LibGUI/Toolbar.cpp b/Userland/Libraries/LibGUI/Toolbar.cpp index bed8172156..5380af356a 100644 --- a/Userland/Libraries/LibGUI/Toolbar.cpp +++ b/Userland/Libraries/LibGUI/Toolbar.cpp @@ -159,7 +159,7 @@ Optional<UISize> Toolbar::calculated_min_size() const ErrorOr<void> Toolbar::create_overflow_objects() { m_overflow_action = Action::create("Overflow Menu", { Mod_Ctrl | Mod_Shift, Key_O }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/overflow-menu.png"sv)), [&](auto&) { - m_overflow_menu->popup(m_overflow_button->screen_relative_rect().bottom_left()); + m_overflow_menu->popup(m_overflow_button->screen_relative_rect().bottom_left(), {}, m_overflow_button->rect()); }); m_overflow_action->set_status_tip("Show hidden toolbar actions"); m_overflow_action->set_enabled(false); @@ -168,7 +168,6 @@ ErrorOr<void> Toolbar::create_overflow_objects() m_overflow_button = TRY(try_add_action(*m_overflow_action)); m_overflow_button->set_visible(false); - m_overflow_button->set_menu_position(Button::MenuPosition::BottomLeft); return {}; } |