mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 10:55:06 +00:00
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.
This commit is contained in:
parent
048f149f51
commit
70fe126d01
2 changed files with 10 additions and 1 deletions
|
@ -63,6 +63,11 @@ Menu::~Menu()
|
|||
unrealize_menu();
|
||||
}
|
||||
|
||||
void Menu::set_icon(const Gfx::Bitmap* icon)
|
||||
{
|
||||
m_icon = icon;
|
||||
}
|
||||
|
||||
void Menu::add_action(NonnullRefPtr<Action> action)
|
||||
{
|
||||
m_items.append(make<MenuItem>(m_menu_id, move(action)));
|
||||
|
@ -143,7 +148,8 @@ int Menu::realize_menu(RefPtr<Action> default_action)
|
|||
if (item.type() == MenuItem::Type::Submenu) {
|
||||
auto& submenu = *item.submenu();
|
||||
submenu.realize_if_needed(default_action);
|
||||
WindowServerConnection::the().send_sync<Messages::WindowServer::AddMenuItem>(m_menu_id, i, submenu.menu_id(), submenu.name(), true, false, false, false, "", -1, false);
|
||||
int icon_buffer_id = ensure_realized_icon(submenu);
|
||||
WindowServerConnection::the().send_sync<Messages::WindowServer::AddMenuItem>(m_menu_id, i, submenu.menu_id(), submenu.name(), true, false, false, false, "", icon_buffer_id, false);
|
||||
continue;
|
||||
}
|
||||
if (item.type() == MenuItem::Type::Action) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue