ToyMaker Game Engine 0.0.2
ToyMaker is a game engine developed and maintained by Zoheb Shujauddin.
Loading...
Searching...
No Matches
ui_image.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPUIIMAGE_H
13#define ZOAPPUIIMAGE_H
14
17
18namespace ToyMaker {
19
42 class UIImage: public ToyMaker::SimObjectAspect<UIImage> {
43 public:
48 UIImage(): SimObjectAspect<UIImage>{0} {}
49
55 inline static std::string getSimObjectAspectTypeName() { return "UIImage"; }
56
63 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
64
70 std::shared_ptr<BaseSimObjectAspect> clone() const override;
71
76 void onActivated() override;
77
83 void updateImage(const std::string& imageFilepath);
84
90 void updateDimensions(const glm::uvec2& dimensions);
91
99 void updateAnchor(const glm::vec2& anchor);
100
101 private:
106 void recomputeTexture();
107
112 std::string mImageFilepath {};
113
118 glm::vec2 mAnchor {0.f, 0.f};
119
124 glm::uvec2 mDimensions { 0.f, 0.f };
125 };
126
127}
128
129#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, with (0,0) being its top left corner and (1,...
Definition ui_image.hpp:118
static std::shared_ptr< BaseSimObjectAspect > create(const nlohmann::json &jsonAspectProperties)
Creates a new UIImage instance from its description in JSON.
Definition ui_image.cpp:11
void onActivated() override
Loads and displays the image associated with this aspect when it is added to the active scene.
Definition ui_image.cpp:46
std::shared_ptr< BaseSimObjectAspect > clone() const override
Constructs a new UIImage using this object as its blueprint.
Definition ui_image.cpp:38
static std::string getSimObjectAspectTypeName()
Gets the aspect type string associated with this class.
Definition ui_image.hpp:55
UIImage()
Constructs a new UIImage aspect.
Definition ui_image.hpp:48
void updateDimensions(const glm::uvec2 &dimensions)
Changes the dimensions the loaded image should be confined or scaled to (while maintaining its origin...
Definition ui_image.cpp:56
void recomputeTexture()
Recomputes the texture associated with this object's StaticModel.
Definition ui_image.cpp:68
glm::uvec2 mDimensions
The dimensions within which the loaded image will be displayed.
Definition ui_image.hpp:124
void updateAnchor(const glm::vec2 &anchor)
Updates the point considered the origin of this object's StaticModel.
Definition ui_image.cpp:50
void updateImage(const std::string &imageFilepath)
Updates the image associated with this object.
Definition ui_image.cpp:62
std::string mImageFilepath
The file from which the image to be displayed was loaded.
Definition ui_image.hpp:112
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition application.hpp:24
Classes and structs relating to the SimSystem, the system responsible for providing some level of gen...
Header containing definitions of classes and functions related to loading and using Texture resources...