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_image.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPUIIMAGE_H
13#define ZOAPPUIIMAGE_H
14
15#include "toymaker/sim_system.hpp"
16#include "toymaker/texture.hpp"
17
40class UIImage: public ToyMaker::SimObjectAspect<UIImage> {
41public:
46 UIImage(): SimObjectAspect<UIImage>{0} {}
47
53 inline static std::string getSimObjectAspectTypeName() { return "UIImage"; }
54
61 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
62
68 std::shared_ptr<BaseSimObjectAspect> clone() const override;
69
74 void onActivated() override;
75
81 void updateImage(const std::string& imageFilepath);
82
88 void updateDimensions(const glm::uvec2& dimensions);
89
97 void updateAnchor(const glm::vec2& anchor);
98
99private:
104 void recomputeTexture();
105
110 std::string mImageFilepath {};
111
116 glm::vec2 mAnchor {0.f, 0.f};
117
122 glm::uvec2 mDimensions { 0.f, 0.f };
123};
124
125#endif
An object containing closely related methods and data, and exposing object lifecycle and application ...
Definition sim_system.hpp:956
static std::string getSimObjectAspectTypeName()
Gets the aspect type string associated with this class.
Definition ui_image.hpp:53
static std::shared_ptr< BaseSimObjectAspect > create(const nlohmann::json &jsonAspectProperties)
Creates a new UIImage instance from its description in JSON.
Definition ui_image.cpp:9
void onActivated() override
Loads and displays the image associated with this aspect when it is added to the active scene.
Definition ui_image.cpp:44
std::shared_ptr< BaseSimObjectAspect > clone() const override
Constructs a new UIImage using this object as its blueprint.
Definition ui_image.cpp:36
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:116
glm::uvec2 mDimensions
The dimensions within which the loaded image will be displayed.
Definition ui_image.hpp:122
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:54
UIImage()
Constructs a new UIImage aspect.
Definition ui_image.hpp:46
void recomputeTexture()
Recomputes the texture associated with this object's StaticModel.
Definition ui_image.cpp:66
void updateAnchor(const glm::vec2 &anchor)
Updates the point considered the origin of this object's StaticModel.
Definition ui_image.cpp:48
void updateImage(const std::string &imageFilepath)
Updates the image associated with this object.
Definition ui_image.cpp:60
std::string mImageFilepath
The file from which the image to be displayed was loaded.
Definition ui_image.hpp:110