Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
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
27#include "toymaker/sim_system.hpp"
28
29#include "nine_slice_panel.hpp"
30
51class UIPanel: public ToyMaker::SimObjectAspect<UIPanel> {
52public:
57 UIPanel(): SimObjectAspect<UIPanel>{0} {}
58
65 inline static std::string getSimObjectAspectTypeName() { return "UIPanel"; }
66
73 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
74
81 std::shared_ptr<BaseSimObjectAspect> clone() const override;
82
87 void onActivated() override;
88
94 void updateContentSize(glm::vec2 contentSize);
95
102 void updateAnchor(glm::vec2 anchor);
103
109 void updateBasePanel(std::shared_ptr<NineSlicePanel> newPanel);
110
111private:
116 void recomputeTexture();
117
122 std::shared_ptr<NineSlicePanel> mBasePanel {};
123
128 glm::vec2 mContentSize {0.f, 0.f};
129
134 glm::vec2 mAnchor {0.f, 0.f};
135};
136
137#endif
An object containing closely related methods and data, and exposing object lifecycle and application ...
Definition sim_system.hpp:956
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:134
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:36
void updateContentSize(glm::vec2 contentSize)
Updates the size of the central region of the NineSlicePanel.
Definition ui_panel.cpp:31
static std::shared_ptr< BaseSimObjectAspect > create(const nlohmann::json &jsonAspectProperties)
Constructs a new UIPanel instance based on its JSON description.
Definition ui_panel.cpp:4
std::shared_ptr< NineSlicePanel > mBasePanel
The panel resource used to create this texture.
Definition ui_panel.hpp:122
static std::string getSimObjectAspectTypeName()
Gets the aspect type string associated with this class.
Definition ui_panel.hpp:65
glm::vec2 mContentSize
The size of the central area of the nine slice panel in which content can be displayed.
Definition ui_panel.hpp:128
void recomputeTexture()
The method responsible for actually creating the new texture through the loaded panel resource.
Definition ui_panel.cpp:61
void updateBasePanel(std::shared_ptr< NineSlicePanel > newPanel)
Changes the panel resource used to create this object's panel texture.
Definition ui_panel.cpp:41
UIPanel()
Constructs a new UIPanel aspect.
Definition ui_panel.hpp:57
std::shared_ptr< BaseSimObjectAspect > clone() const override
Constructs a new UIPanel instance using this one as a blueprint.
Definition ui_panel.cpp:47
void onActivated() override
Loads and renders the texture of a panel per its configuration.
Definition ui_panel.cpp:57
Contains class defining this project's implementation of nine-slice (or nine-region) resizable panels...