summaryrefslogtreecommitdiff
path: root/LibGUI/GMenu.h
blob: d4a38951d1f82bbd176a212c56a0cfece580a9fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once

#include <LibGUI/GMenuItem.h>
#include <AK/Function.h>
#include <AK/Vector.h>

class GAction;

class GMenu {
public:
    explicit GMenu(const String& name);
    ~GMenu();

    static GMenu* from_menu_id(int);

    GAction* action_at(int);

    void add_action(Retained<GAction>&&);
    void add_separator();

    Function<void(unsigned)> on_item_activation;

private:
    friend class GMenuBar;
    int menu_id() const { return m_menu_id; }
    int realize_menu();
    void unrealize_menu();

    int m_menu_id { 0 };
    String m_name;
    Vector<OwnPtr<GMenuItem>> m_items;
};