1 | // Aseprite |
2 | // Copyright (C) 2020-2022 Igara Studio S.A. |
3 | // Copyright (C) 2001-2017 David Capello |
4 | // |
5 | // This program is distributed under the terms of |
6 | // the End-User License Agreement for Aseprite. |
7 | |
8 | #ifndef APP_UI_APP_MENUITEM_H_INCLUDED |
9 | #define |
10 | #pragma once |
11 | |
12 | #include "app/commands/params.h" |
13 | #include "app/ui/key.h" |
14 | #include "os/menus.h" |
15 | #include "os/shortcut.h" |
16 | #include "ui/menu.h" |
17 | |
18 | #include <memory> |
19 | |
20 | namespace app { |
21 | |
22 | // A widget that represent a menu item of the application. |
23 | // |
24 | // It's like a MenuItme, but it has a extra properties: the name of |
25 | // the command to be executed when it's clicked (also that command is |
26 | // used to check the availability of the command). |
27 | class : public ui::MenuItem { |
28 | public: |
29 | struct { |
30 | os::MenuItemRef = nullptr; |
31 | os::Shortcut ; |
32 | app::KeyContext = app::KeyContext::Any; |
33 | }; |
34 | |
35 | (const std::string& text, |
36 | const std::string& commandId = std::string(), |
37 | const Params& params = Params()); |
38 | (const std::string& text, std::nullptr_t) = delete; |
39 | |
40 | KeyPtr () { return m_key; } |
41 | void (const KeyPtr& key); |
42 | |
43 | void (bool state) { m_isRecentFileItem = state; } |
44 | bool () const { return m_isRecentFileItem; } |
45 | |
46 | std::string getCommandId() const { return m_commandId; } |
47 | Command* getCommand() const; |
48 | const Params& () const { return m_params; } |
49 | |
50 | Native* () const { return m_native.get(); } |
51 | void (const Native& native); |
52 | void (); |
53 | void (); |
54 | |
55 | static void (const Params& params); |
56 | |
57 | protected: |
58 | bool (ui::Message* msg) override; |
59 | void (ui::SizeHintEvent& ev) override; |
60 | void () override; |
61 | void () override; |
62 | |
63 | private: |
64 | KeyPtr ; |
65 | std::string m_commandId; |
66 | Params ; |
67 | bool ; |
68 | std::unique_ptr<Native> ; |
69 | |
70 | static Params ; |
71 | }; |
72 | |
73 | } // namespace app |
74 | |
75 | #endif |
76 | |