aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/interface/GUI.hpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-11-13 13:42:37 +0100
committer GitHub <noreply@github.com>2023-11-13 13:42:37 +0100
commitf572664cbe1aa5ec2cb6907de3083f058c20af7e (patch)
treec9a61c5dd15fb1eae1555f47119423dbba315e76 /src/openvic-simulation/interface/GUI.hpp
parentba7bfc52803781c970d6e8afc84c7d3d3e843726 (diff)
parentce84886cb931975f622134d6c8d32a69c675d975 (diff)
Merge pull request #71 from OpenVicProject/gui-loading
GUI and GFX file loading
Diffstat (limited to 'src/openvic-simulation/interface/GUI.hpp')
-rw-r--r--src/openvic-simulation/interface/GUI.hpp235
1 files changed, 235 insertions, 0 deletions
diff --git a/src/openvic-simulation/interface/GUI.hpp b/src/openvic-simulation/interface/GUI.hpp
new file mode 100644
index 0000000..1a76ca0
--- /dev/null
+++ b/src/openvic-simulation/interface/GUI.hpp
@@ -0,0 +1,235 @@
+#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:
+ ivec2_t PROPERTY(position);
+ orientation_t PROPERTY(orientation);
+
+ protected:
+ Element();
+
+ bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+ static bool _fill_elements_key_map(
+ NodeTools::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&> elements;
+
+ protected:
+ Scene();
+
+ bool _fill_key_map(NodeTools::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
+ );
+
+ IDENTIFIER_REGISTRY_ACCESSORS(element)
+ };
+
+ class Window final : public Element {
+ friend std::unique_ptr<Window> std::make_unique<Window>();
+
+ NamedInstanceRegistry<Element, UIManager const&> elements;
+
+ ivec2_t PROPERTY(size);
+ bool PROPERTY(moveable);
+ bool PROPERTY(fullscreen);
+ // TODO - background, dontRender, horizontalBorder, verticalBorder
+
+ protected:
+ Window();
+
+ bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+
+ public:
+ Window(Window&&) = default;
+ virtual ~Window() = default;
+
+ OV_DETAIL_GET_TYPE
+
+ IDENTIFIER_REGISTRY_ACCESSORS(element)
+ };
+
+ 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::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::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::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::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::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);
+ ivec2_t PROPERTY(max_size); // maxWidth, maxHeight
+
+ // TODO - borderSize, fixedsize, textureFile
+
+ protected:
+ Text();
+
+ bool _fill_key_map(NodeTools::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>();
+
+ ivec2_t PROPERTY(size);
+
+ // TODO - spacing
+
+ protected:
+ OverlappingElementsBox();
+
+ bool _fill_key_map(NodeTools::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>();
+
+ ivec2_t PROPERTY(size);
+
+ // TODO - backGround, spacing, scrollbartype, borderSize
+
+ protected:
+ ListBox();
+
+ bool _fill_key_map(NodeTools::key_map_t& key_map, UIManager const& ui_manager) override;
+
+ public:
+ ListBox(ListBox&&) = default;
+ virtual ~ListBox() = default;
+
+ OV_DETAIL_GET_TYPE
+ };
+}