1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +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

@ -19,6 +19,13 @@ class Button : public AbstractButton {
C_OBJECT(Button);
public:
enum MenuPosition {
TopLeft,
TopRight,
BottomLeft,
BottomRight
};
virtual ~Button() override;
void set_icon(RefPtr<Gfx::Bitmap>);
@ -59,6 +66,9 @@ 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:
@ -78,6 +88,7 @@ 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 {