ToyMaker Game Engine 0.0.2
ToyMaker is a game engine developed and maintained by Zoheb Shujauddin.
Loading...
Searching...
No Matches
ui_panel.hpp
Go to the documentation of this file.
1
11
17
23
24#ifndef ZOAPPUIPANEL_H
25#define ZOAPPUIPANEL_H
26
28
30
31namespace ToyMaker {
32
53 class UIPanel: public ToyMaker::SimObjectAspect<UIPanel> {
54 public:
59 UIPanel(): SimObjectAspect<UIPanel>{0} {}
60
67 inline static std::string getSimObjectAspectTypeName() { return "UIPanel"; }
68
75 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
76
83 std::shared_ptr<BaseSimObjectAspect> clone() const override;
84
89 void onActivated() override;
90
96 void updateContentSize(glm::vec2 contentSize);
97
104 void updateAnchor(glm::vec2 anchor);
105
111 void updateBasePanel(std::shared_ptr<NineSlicePanel> newPanel);
112
113 private:
118 void recomputeTexture();
119
124 std::shared_ptr<NineSlicePanel> mBasePanel {};
125
130 glm::vec2 mContentSize {0.f, 0.f};
131
136 glm::vec2 mAnchor {0.f, 0.f};
137 };
138
139}
140
141#endif
An object containing closely related methods and data, and exposing object lifecycle and application ...
Definition sim_system.hpp:956
void updateAnchor(glm::vec2 anchor)
Updates the point considered the new origin for this object, where (0,0) represents the top left corn...
Definition ui_panel.cpp:38
void updateContentSize(glm::vec2 contentSize)
Updates the size of the central region of the NineSlicePanel.
Definition ui_panel.cpp:33
static std::shared_ptr< BaseSimObjectAspect > create(const nlohmann::json &jsonAspectProperties)
Constructs a new UIPanel instance based on its JSON description.
Definition ui_panel.cpp:6
std::shared_ptr< NineSlicePanel > mBasePanel
The panel resource used to create this texture.
Definition ui_panel.hpp:124
UIPanel()
Constructs a new UIPanel aspect.
Definition ui_panel.hpp:59
static std::string getSimObjectAspectTypeName()
Gets the aspect type string associated with this class.
Definition ui_panel.hpp:67
void recomputeTexture()
The method responsible for actually creating the new texture through the loaded panel resource.
Definition ui_panel.cpp:63
void updateBasePanel(std::shared_ptr< NineSlicePanel > newPanel)
Changes the panel resource used to create this object's panel texture.
Definition ui_panel.cpp:43
std::shared_ptr< BaseSimObjectAspect > clone() const override
Constructs a new UIPanel instance using this one as a blueprint.
Definition ui_panel.cpp:49
glm::vec2 mContentSize
The size of the central area of the nine slice panel in which content can be displayed.
Definition ui_panel.hpp:130
glm::vec2 mAnchor
The point considered the origin of this object, where (0,0) represents the top left corner and (1,...
Definition ui_panel.hpp:136
void onActivated() override
Loads and renders the texture of a panel per its configuration.
Definition ui_panel.cpp:59
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition application.hpp:24
Contains class defining this project's implementation of nine-slice (or nine-region) resizable panels...
Classes and structs relating to the SimSystem, the system responsible for providing some level of gen...