Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
UIElement.hpp
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 */
6
7#ifndef ENGINE_UIELEMENT
8#define ENGINE_UIELEMENT
9
10#include "../Node.hpp"
11#include "../Utils.hpp"
12
13namespace Engine::UI {
14
24 class UIElement : public Engine::Node {
25 protected:
26
27 const char* m_uiTag;
28 const char* m_uiClass;
29
30 public:
31
39 UIElement(std::string name);
40
44 ~UIElement() override;
45
49 void Init() override;
50
59 void AddTheme(const char* theme);
60
79 void SetAnchor(const char* anchor);
80
86 void SetDimensions(Vec2f dimensions);
87
93 void SetOffset(Vec2f offset);
94
100 void OnEnable() override;
101
107 void OnDisable() override;
108 };
109}
110
111#endif
A single node in a game scene.
Definition Node.hpp:43
Base class for UI elements.
Definition UIElement.hpp:24
~UIElement() override
Definition UIElement.cpp:34
void SetOffset(Vec2f offset)
Sets the offset of the UI element.
Definition UIElement.cpp:62
void SetAnchor(const char *anchor)
Sets the anchor of the UI element.
Definition UIElement.cpp:49
void AddTheme(const char *theme)
Sets the theme of the UI element.
Definition UIElement.cpp:43
void Init() override
Creates the UI element and adds it to the DOM.
Definition UIElement.cpp:17
void OnDisable() override
Hides the UI element when disabled.
Definition UIElement.cpp:76
void OnEnable() override
Shows the UI element when enabled.
Definition UIElement.cpp:69
void SetDimensions(Vec2f dimensions)
Sets the dimensions of the UI element.
Definition UIElement.cpp:55
A 2D vector struct with overloaded operators.
Definition Utils.hpp:38