summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/Button.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-04-05 14:33:13 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-05 18:09:04 +0200
commit15349a3712dabd4ab314db45d70d9279548a2762 (patch)
treefee0a1221ced696d0c88272a59902055ddde45d4 /Userland/Libraries/LibGUI/Button.h
parent9b740f218b103a5f3497a666b2655865266c8ff1 (diff)
downloadserenity-15349a3712dabd4ab314db45d70d9279548a2762.zip
LibGUI: Add ability to assign a menu to a GUI::Button
When a button has a menu, it opens the menu on mousedown and the menu gains input focus immediately. While the menu is open, the button is painted in a pressed state.
Diffstat (limited to 'Userland/Libraries/LibGUI/Button.h')
-rw-r--r--Userland/Libraries/LibGUI/Button.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/Button.h b/Userland/Libraries/LibGUI/Button.h
index e16c0dad2e..b45ef9812f 100644
--- a/Userland/Libraries/LibGUI/Button.h
+++ b/Userland/Libraries/LibGUI/Button.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -63,12 +63,16 @@ public:
int icon_spacing() const { return m_icon_spacing; }
void set_icon_spacing(int spacing) { m_icon_spacing = spacing; }
+ void set_menu(RefPtr<GUI::Menu>);
+
protected:
explicit Button(String text = {});
+ virtual void mousedown_event(MouseEvent&) override;
virtual void paint_event(PaintEvent&) override;
private:
RefPtr<Gfx::Bitmap> m_icon;
+ RefPtr<GUI::Menu> m_menu;
Gfx::ButtonStyle m_button_style { Gfx::ButtonStyle::Normal };
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
WeakPtr<Action> m_action;