1 | // Aseprite |
2 | // Copyright (C) 2019-2020 Igara Studio S.A. |
3 | // Copyright (C) 2001-2018 David Capello |
4 | // |
5 | // This program is distributed under the terms of |
6 | // the End-User License Agreement for Aseprite. |
7 | |
8 | #ifndef APP_APP_MENUS_H_INCLUDED |
9 | #define |
10 | #pragma once |
11 | |
12 | #include "app/i18n/xml_translator.h" |
13 | #include "app/ui/key.h" |
14 | #include "app/widget_type_mismatch.h" |
15 | #include "base/disable_copying.h" |
16 | #include "obs/connection.h" |
17 | #include "os/menus.h" |
18 | #include "ui/base.h" |
19 | #include "ui/menu.h" |
20 | |
21 | #include <memory> |
22 | |
23 | class TiXmlElement; |
24 | class TiXmlHandle; |
25 | |
26 | namespace app { |
27 | class Command; |
28 | class Params; |
29 | |
30 | using namespace ui; |
31 | |
32 | // Class to handle/get/reload available menus in gui.xml file. |
33 | class { |
34 | (); |
35 | DISABLE_COPYING(); |
36 | |
37 | public: |
38 | static AppMenus* (); |
39 | |
40 | void (); |
41 | void (); |
42 | |
43 | // Updates the menu of recent files. |
44 | bool (); |
45 | |
46 | Menu* () { return m_rootMenu.get(); } |
47 | Menu* () { return m_tabPopupMenu.get(); } |
48 | Menu* () { return m_documentTabPopupMenu.get(); } |
49 | Menu* () { return m_layerPopupMenu.get(); } |
50 | Menu* () { return m_framePopupMenu.get(); } |
51 | Menu* () { return m_celPopupMenu.get(); } |
52 | Menu* () { return m_celMovementPopupMenu.get(); } |
53 | Menu* () { return m_tagPopupMenu.get(); } |
54 | Menu* () { return m_slicePopupMenu.get(); } |
55 | Menu* () { return m_palettePopupMenu.get(); } |
56 | Menu* () { return m_inkPopupMenu.get(); } |
57 | |
58 | void applyShortcutToMenuitemsWithCommand(Command* command, const Params& params, |
59 | const KeyPtr& key); |
60 | void (); |
61 | |
62 | // Menu item handling in groups |
63 | void (const std::string& groupId, |
64 | std::unique_ptr<MenuItem>&& ); |
65 | void removeMenuItemFromGroup(Command* cmd); |
66 | void (Widget* ); |
67 | |
68 | private: |
69 | template<typename Pred> |
70 | void (Pred pred); |
71 | |
72 | Menu* loadMenuById(TiXmlHandle& handle, const char *id); |
73 | Menu* (TiXmlElement* elem); |
74 | Widget* (TiXmlElement* elem); |
75 | void applyShortcutToMenuitemsWithCommand(Menu* , Command* command, const Params& params, |
76 | const KeyPtr& key); |
77 | void (Menu* ); |
78 | void (); |
79 | void (); |
80 | void (os::Menu* , |
81 | const ui::Menu* ); |
82 | |
83 | #ifdef ENABLE_SCRIPTING |
84 | void (ui::Menu* , |
85 | const std::string& dir, |
86 | const bool rootLevel); |
87 | #endif |
88 | |
89 | struct { |
90 | Widget* = nullptr; |
91 | WidgetsList ; |
92 | }; |
93 | |
94 | std::unique_ptr<Menu> ; |
95 | Widget* ; |
96 | MenuItem* ; |
97 | std::unique_ptr<Menu> ; |
98 | std::unique_ptr<Menu> ; |
99 | std::unique_ptr<Menu> ; |
100 | std::unique_ptr<Menu> ; |
101 | std::unique_ptr<Menu> ; |
102 | std::unique_ptr<Menu> ; |
103 | std::unique_ptr<Menu> ; |
104 | std::unique_ptr<Menu> ; |
105 | std::unique_ptr<Menu> ; |
106 | std::unique_ptr<Menu> ; |
107 | obs::scoped_connection ; |
108 | std::vector<Menu*> ; |
109 | // List of recent menu items pointing to recent files. |
110 | WidgetsList ; |
111 | // Extension points for plugins (each group is a place where new |
112 | // menu items can be added). |
113 | std::map<std::string, GroupInfo> ; |
114 | // Native main menu bar (== nullptr if the platform doesn't |
115 | // support native menus) |
116 | os::MenuRef ; |
117 | XmlTranslator ; |
118 | }; |
119 | |
120 | os::Shortcut get_os_shortcut_from_key(const Key* key); |
121 | |
122 | } // namespace app |
123 | |
124 | #endif |
125 | |