mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:37:45 +00:00
LibGUI: Make MenuBar a Core::Object
This makes it show up in Inspector with all the menus inside it. :^)
This commit is contained in:
parent
a19690170f
commit
52a250cb61
28 changed files with 36 additions and 38 deletions
|
@ -79,7 +79,7 @@ void Application::quit(int exit_code)
|
|||
m_event_loop->quit(exit_code);
|
||||
}
|
||||
|
||||
void Application::set_menubar(OwnPtr<MenuBar>&& menubar)
|
||||
void Application::set_menubar(RefPtr<MenuBar> menubar)
|
||||
{
|
||||
if (m_menubar)
|
||||
m_menubar->notify_removed_from_application({});
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
int exec();
|
||||
void quit(int = 0);
|
||||
|
||||
void set_menubar(OwnPtr<MenuBar>&&);
|
||||
void set_menubar(RefPtr<MenuBar>);
|
||||
Action* action_for_key_event(const KeyEvent&);
|
||||
|
||||
void register_global_shortcut_action(Badge<Action>, Action&);
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
private:
|
||||
OwnPtr<Core::EventLoop> m_event_loop;
|
||||
OwnPtr<MenuBar> m_menubar;
|
||||
RefPtr<MenuBar> m_menubar;
|
||||
RefPtr<Gfx::PaletteImpl> m_palette;
|
||||
RefPtr<Gfx::PaletteImpl> m_system_palette;
|
||||
HashMap<Shortcut, Action*> m_global_shortcut_actions;
|
||||
|
|
|
@ -43,14 +43,9 @@ MenuBar::~MenuBar()
|
|||
|
||||
Menu& MenuBar::add_menu(String name)
|
||||
{
|
||||
auto menu = Menu::construct(move(name));
|
||||
append_menu(menu);
|
||||
return *menu;
|
||||
}
|
||||
|
||||
void MenuBar::append_menu(NonnullRefPtr<Menu> menu)
|
||||
{
|
||||
m_menus.append(move(menu));
|
||||
auto& menu = add<Menu>(move(name));
|
||||
m_menus.append(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
int MenuBar::realize_menubar()
|
||||
|
|
|
@ -28,22 +28,25 @@
|
|||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibGUI/Forward.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class MenuBar {
|
||||
class MenuBar : public Core::Object {
|
||||
C_OBJECT(MenuBar);
|
||||
|
||||
public:
|
||||
MenuBar();
|
||||
~MenuBar();
|
||||
|
||||
Menu& add_menu(String name);
|
||||
void append_menu(NonnullRefPtr<Menu>);
|
||||
|
||||
void notify_added_to_application(Badge<Application>);
|
||||
void notify_removed_from_application(Badge<Application>);
|
||||
|
||||
private:
|
||||
MenuBar();
|
||||
|
||||
int realize_menubar();
|
||||
void unrealize_menubar();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue