diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2020-07-27 01:57:09 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-28 16:29:44 +0200 |
commit | 70fe126d01ef824922986c7cd23c1a8753f9ef73 (patch) | |
tree | 97156ffbabd788db7a03f54a79225160ca5fd498 /Libraries/LibGUI/Menu.h | |
parent | 048f149f5172e10c454139630aa8f34f8e2e5832 (diff) | |
download | serenity-70fe126d01ef824922986c7cd23c1a8753f9ef73.zip |
LibGUI: Enable icons for SubMenus
It doesn't make sense for a top-level menu to have an icon, however
we do not have dedicated classes to distinguish these.
Furthermore, the only other place to store an icon is MenuItem.
Storing it there would be highly confusing, as MenuItem-with-Action
then would have two icons: one in Action and one in MenuItem.
And because we need to be able to replace the icon during realization,
this would need to write-through to Action somehow.
That's why I went with Menu, not MenuItem.
Diffstat (limited to 'Libraries/LibGUI/Menu.h')
-rw-r--r-- | Libraries/LibGUI/Menu.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Libraries/LibGUI/Menu.h b/Libraries/LibGUI/Menu.h index 211e174798..1031112830 100644 --- a/Libraries/LibGUI/Menu.h +++ b/Libraries/LibGUI/Menu.h @@ -47,6 +47,8 @@ public: int menu_id() const { return m_menu_id; } const String& name() const { return m_name; } + const Gfx::Bitmap* icon() const { return m_icon.ptr(); } + void set_icon(const Gfx::Bitmap*); Action* action_at(size_t); @@ -66,6 +68,7 @@ private: int m_menu_id { -1 }; String m_name; + RefPtr<Gfx::Bitmap> m_icon; NonnullOwnPtrVector<MenuItem> m_items; WeakPtr<Action> m_last_default_action; }; |