Potato Engine
Loading...
Searching...
No Matches
Widget.cpp
Go to the documentation of this file.
1
2
3#include "Debug/Debug.hpp"
4#include "Widget.hpp"
5#include "WidgetElement.hpp"
6
7Widget::Widget(std::string UID) : UID(UID) {
9 SetScreenSize(Vector2(16.f, 4.f));
10 SetVisibility(true);
11
12}
13
14std::string Widget::GetUID() const {
15 return UID;
16}
17
18const std::unordered_map<std::string, WidgetElement*>& Widget::GetAllElements() const {
19 return Elements;
20}
22 if (Elements.find(name) != Elements.end()) {
23 return Elements.at(name);
24 }
25
26 return nullptr;
27}
28
29Widget::~Widget() {
30
31 for (auto it = Elements.begin(); it != Elements.end(); ) {
32 delete it->second;
33 it = Elements.erase(it);
34 }
35
36}
void SetScreenSize(const Vector2 &size)
Sets size of UI.
Definition UIElement.cpp:8
void SetScreenPosition(const Vector2 &ScreenPosition)
Sets screen position of UI.
Definition UIElement.cpp:16
void SetVisibility(bool visibility)
Sets visibility of UI.
Definition UIElement.cpp:28
const std::unordered_map< std::string, WidgetElement * > & GetAllElements() const
Gets map of all elements.
Definition Widget.cpp:18
std::string GetUID() const
Gets unique ID of widget.
Definition Widget.cpp:14
Widget(std::string UID)
Constructs widget.
Definition Widget.cpp:7
WidgetElement * GetElement(std::string name)
Gets specific element by name.
Definition Widget.cpp:21
Standard 2-dimensional vector.
Definition Vector2.hpp:11
Wrapper for specialized sub-element that can be rendered by a Widget.