| 1 | // LAF OS Library |
| 2 | // Copyright (C) 2020 Igara Studio S.A. |
| 3 | // Copyright (C) 2017 David Capello |
| 4 | // |
| 5 | // This file is released under the terms of the MIT license. |
| 6 | // Read LICENSE.txt for more information. |
| 7 | |
| 8 | #ifndef OS_MENUS_H_INCLUDED |
| 9 | #define |
| 10 | #pragma once |
| 11 | |
| 12 | #include "os/keys.h" |
| 13 | #include "os/ref.h" |
| 14 | #include "os/shortcut.h" |
| 15 | |
| 16 | #include <functional> |
| 17 | #include <string> |
| 18 | |
| 19 | namespace os { |
| 20 | class MenuItem; |
| 21 | |
| 22 | struct { |
| 23 | enum { |
| 24 | , |
| 25 | |
| 26 | }; |
| 27 | |
| 28 | enum { |
| 29 | , |
| 30 | |
| 31 | // macOS standard commands |
| 32 | , |
| 33 | , |
| 34 | , |
| 35 | , |
| 36 | , |
| 37 | , |
| 38 | }; |
| 39 | |
| 40 | Type ; |
| 41 | Action ; |
| 42 | std::string ; |
| 43 | Shortcut ; |
| 44 | std::function<void()> ; |
| 45 | std::function<void(os::MenuItem*)> ; |
| 46 | |
| 47 | explicit (const Type type = Normal, |
| 48 | const Action action = UserDefined) |
| 49 | : type(type) |
| 50 | , action(action) { |
| 51 | } |
| 52 | |
| 53 | explicit (const std::string& text, |
| 54 | const Action action = UserDefined) |
| 55 | : type(Normal) |
| 56 | , action(action) |
| 57 | , text(text) { |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | class Menu; |
| 62 | class MenuItem; |
| 63 | class Menus; |
| 64 | |
| 65 | using = Ref<MenuItem>; |
| 66 | using = Ref<Menu>; |
| 67 | using = Ref<Menus>; |
| 68 | |
| 69 | class : public RefCount { |
| 70 | public: |
| 71 | virtual () { } |
| 72 | virtual void (const std::string& text) = 0; |
| 73 | virtual void (const MenuRef& ) = 0; |
| 74 | virtual void (bool state) = 0; |
| 75 | virtual void (bool state) = 0; |
| 76 | virtual void (const Shortcut& shortcut) = 0; |
| 77 | }; |
| 78 | |
| 79 | class : public RefCount { |
| 80 | public: |
| 81 | virtual () { } |
| 82 | virtual void (const MenuItemRef& item) = 0; |
| 83 | virtual void (const int index, const MenuItemRef& item) = 0; |
| 84 | virtual void (const MenuItemRef& item) = 0; |
| 85 | }; |
| 86 | |
| 87 | class : public RefCount { |
| 88 | public: |
| 89 | virtual () { } |
| 90 | virtual MenuRef () = 0; |
| 91 | virtual MenuItemRef (const MenuItemInfo& info) = 0; |
| 92 | virtual void (const MenuRef& ) = 0; |
| 93 | }; |
| 94 | |
| 95 | } // namespace os |
| 96 | |
| 97 | #endif |
| 98 | |