Potato Engine
Loading...
Searching...
No Matches
Widget.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include <vector>
5
8
9class WidgetElement;
10
14class Widget : public Tickable, public UIElement
15{
16public:
24 Widget(std::string UID);
25 virtual ~Widget();
26
28 std::string GetUID() const;
29
36 template<typename ElemType>
37 ElemType* AddElement(std::string name);
38
40 const std::unordered_map<std::string, WidgetElement*>& GetAllElements() const;
42 WidgetElement* GetElement(std::string name);
43
44private:
45
46 std::unordered_map<std::string, WidgetElement*> Elements;
47
48private:
49 const std::string UID;
50
51};
52
53template<typename ElemType>
54ElemType* Widget::AddElement(std::string name) {
55 ElemType* elem = new ElemType();
56 Elements[name] = elem;
57
58 return elem;
59}
Wrapper for elements that can be rendered on screen.
Definition UIElement.hpp:12
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
ElemType * AddElement(std::string name)
Creates and adds WidgetElement to widget screen.
Definition Widget.hpp:54
WidgetElement * GetElement(std::string name)
Gets specific element by name.
Definition Widget.cpp:21
Wrapper for specialized sub-element that can be rendered by a Widget.