ToyMaker Game Engine 0.0.2
ToyMaker is a game engine developed and maintained by Zoheb Shujauddin.
Loading...
Searching...
No Matches
ui_container.hpp
1#ifndef TOYMAKERBUILTINS_UICONTAINER_H
2#define TOYMAKERBUILTINS_UICONTAINER_H
3
5
6namespace ToyMaker {
7
18 class IUIElement {
19 public:
29 virtual glm::vec2 getReferenceCoordinate() const = 0;
30
38 virtual glm::vec3 getOffsets() const = 0;
39
45 virtual bool allowsDescendantControl() const = 0;
46 };
47
69 class UIContainer: public ToyMaker::SimObjectAspect<UIContainer> {
70 public:
75 UIContainer(): SimObjectAspect<UIContainer>{ 0 } {}
76
83 inline static std::string getSimObjectAspectTypeName() { return "UIContainer"; }
84
93 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
94
100 std::shared_ptr<BaseSimObjectAspect> clone() const override;
101
106 void onActivated() override;
107
108 private:
114 void onViewportResized(const ViewportNode::RenderConfiguration& renderConfiguration);
115
120 glm::vec2 mContentSize { 1.f, 1.f };
121
127 *this, "onViewportResized", [this](const auto& renderConfiguration) {
128 this->onViewportResized(renderConfiguration);
129 }
130 };
131 };
132}
133
134#endif
Interface for a single UI element.
Definition ui_container.hpp:18
virtual glm::vec3 getOffsets() const =0
Returns the offsets relative to the container reference coordinates used to position this element's a...
virtual glm::vec2 getReferenceCoordinate() const =0
Returns the reference coordinate on the container relative to which this element's offsets are define...
virtual bool allowsDescendantControl() const =0
Whether the container is permitted to reposition this element's children.
A SignalObserver object, which can subscribe to Signals matching its data signature and receive signa...
Definition signals.hpp:415
An object containing closely related methods and data, and exposing object lifecycle and application ...
Definition sim_system.hpp:956
glm::vec2 mContentSize
The total dimensions spanned by this container.
Definition ui_container.hpp:120
std::shared_ptr< BaseSimObjectAspect > clone() const override
Constructs a new UIContainer instance using this one as a blueprint.
Definition ui_container.cpp:12
SignalObserver< ViewportNode::RenderConfiguration > mObservedViewportResized
Observer for viewport resize events, which calls onViewportResized.
Definition ui_container.hpp:126
void onViewportResized(const ViewportNode::RenderConfiguration &renderConfiguration)
Procedure for when the owning viewport is resized, where the container is scaled to the viewport's di...
Definition ui_container.cpp:24
void onActivated() override
Subscribes to viewport resizing signals, and adjusts positions of child UI elements.
Definition ui_container.cpp:17
static std::shared_ptr< BaseSimObjectAspect > create(const nlohmann::json &jsonAspectProperties)
Constructs a new UIContainer instance based on its JSON description.
Definition ui_container.cpp:7
static std::string getSimObjectAspectTypeName()
Gets the aspect type string associated with this class.
Definition ui_container.hpp:83
UIContainer()
Constructs a new UIContainer aspect.
Definition ui_container.hpp:75
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition application.hpp:26
Classes and structs relating to the SimSystem, the system responsible for providing some level of gen...
A collection of data that specifies the behaviour and properties of the RenderSystem and target textu...
Definition scene_system.hpp:849