aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/interface/GUI.hpp
blob: 96bb2a2ec4be3307767ec8ab5b7f9b50950f388f (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#pragma once

#include "openvic-simulation/interface/GFX.hpp"

namespace OpenVic {
   class UIManager;
}
namespace OpenVic::GUI {
   class Scene;

   class Element : public Named<UIManager const&> {
      friend class Scene;

   public:
      enum class orientation_t {
         UPPER_LEFT, LOWER_LEFT, LOWER_RIGHT, UPPER_RIGHT, CENTER
      };

   private:
      fvec2_t PROPERTY(position);
      orientation_t PROPERTY(orientation);

   protected:
      Element();

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;
      static bool _fill_elements_key_map(
         NodeTools::case_insensitive_key_map_t& key_map, NodeTools::callback_t<std::unique_ptr<Element>&&> callback,
         UIManager const& ui_manager
      );

   public:
      Element(Element&&) = default;
      virtual ~Element() = default;

      OV_DETAIL_GET_BASE_TYPE(Element)
      OV_DETAIL_GET_TYPE
   };

   class Scene : public Named<UIManager const&> {
      friend std::unique_ptr<Scene> std::make_unique<Scene>();

      NamedInstanceRegistry<Element, UIManager const&> IDENTIFIER_REGISTRY(scene_element);

   protected:
      Scene() = default;

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;

   public:
      Scene(Scene&&) = default;
      virtual ~Scene() = default;

      OV_DETAIL_GET_TYPE

      static NodeTools::node_callback_t expect_scene(
         std::string_view scene_name, NodeTools::callback_t<std::unique_ptr<Scene>&&> callback, UIManager const& ui_manager
      );

   };

   class Window final : public Element {
      friend std::unique_ptr<Window> std::make_unique<Window>();

      NamedInstanceRegistry<Element, UIManager const&> IDENTIFIER_REGISTRY(window_element);

      fvec2_t PROPERTY(size);
      bool PROPERTY(moveable);
      bool PROPERTY(fullscreen);
      // TODO - background, dontRender, horizontalBorder, verticalBorder

   protected:
      Window();

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;

   public:
      Window(Window&&) = default;
      virtual ~Window() = default;

      OV_DETAIL_GET_TYPE
   };

   class Icon final : public Element {
      friend std::unique_ptr<Icon> std::make_unique<Icon>();

      GFX::Sprite const* PROPERTY(sprite);
      GFX::frame_t PROPERTY(frame);

   protected:
      Icon();

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;

   public:
      Icon(Icon&&) = default;
      virtual ~Icon() = default;

      OV_DETAIL_GET_TYPE
   };

   class BaseButton : public Element {
      GFX::Sprite const* PROPERTY(sprite);
      // TODO - shortcut

   protected:
      BaseButton();

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;

   public:
      BaseButton(BaseButton&&) = default;
      virtual ~BaseButton() = default;

      OV_DETAIL_GET_TYPE
   };

   class Button final : public BaseButton {
      friend std::unique_ptr<Button> std::make_unique<Button>();

      std::string PROPERTY(text);
      GFX::Font const* PROPERTY(font);

      // TODO - clicksound

   protected:
      Button();

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;

   public:
      Button(Button&&) = default;
      virtual ~Button() = default;

      OV_DETAIL_GET_TYPE
   };

   class Checkbox final : public BaseButton {
      friend std::unique_ptr<Checkbox> std::make_unique<Checkbox>();

   protected:
      Checkbox() = default;

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;

   public:
      Checkbox(Checkbox&&) = default;
      virtual ~Checkbox() = default;

      OV_DETAIL_GET_TYPE
   };

   class AlignedElement : public Element {
   public:
      enum class format_t {
         left, centre, right
      };

   private:
      format_t PROPERTY(format);

   protected:
      AlignedElement();

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;

   public:
      AlignedElement(AlignedElement&&) = default;
      virtual ~AlignedElement() = default;

      OV_DETAIL_GET_TYPE
   };

   class Text final : public AlignedElement {
      friend std::unique_ptr<Text> std::make_unique<Text>();

      std::string PROPERTY(text);
      GFX::Font const* PROPERTY(font);
      fvec2_t PROPERTY(max_size); // maxWidth, maxHeight

      // TODO - borderSize, fixedsize, textureFile

   protected:
      Text();

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;

   public:
      Text(Text&&) = default;
      virtual ~Text() = default;

      OV_DETAIL_GET_TYPE
   };

   class OverlappingElementsBox final : public AlignedElement {
      friend std::unique_ptr<OverlappingElementsBox> std::make_unique<OverlappingElementsBox>();

      fvec2_t PROPERTY(size);
      fixed_point_t PROPERTY(spacing);

   protected:
      OverlappingElementsBox();

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;

   public:
      OverlappingElementsBox(OverlappingElementsBox&&) = default;
      virtual ~OverlappingElementsBox() = default;

      OV_DETAIL_GET_TYPE
   };

   class ListBox final : public Element {
      friend std::unique_ptr<ListBox> std::make_unique<ListBox>();

      fvec2_t PROPERTY(size);

      // TODO - backGround, spacing, scrollbartype, borderSize

   protected:
      ListBox();

      bool _fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManager const& ui_manager) override;

   public:
      ListBox(ListBox&&) = default;
      virtual ~ListBox() = default;

      OV_DETAIL_GET_TYPE
   };
}