Polyphase Game Engine
Loading...
Searching...
No Matches
UILoader.h
Go to the documentation of this file.
1#pragma once
2
3#include "Nodes/Node.h"
4
5#include <string>
6#include <vector>
7#include <unordered_map>
8
9class Widget;
10class UIStyleSheet;
11
12//------------------------------------------------------------
13// Event binding from XML on-* attributes
14//------------------------------------------------------------
15
17{
18 std::string mElementId;
19 std::string mEventName; // "click", "hover", "press", "release"
20 std::string mHandlerName; // Lua global function name
21};
22
23//------------------------------------------------------------
24// Data binding from {{variable}} in text content
25//------------------------------------------------------------
26
28{
29 Widget* mWidget = nullptr;
30 std::string mTemplateText; // Original text with {{var}} placeholders
31};
32
33//------------------------------------------------------------
34// Load result
35//------------------------------------------------------------
36
38{
39 NodePtr mRootNodePtr; // Owns the root widget (keeps tree alive)
40 Widget* mRootWidget = nullptr; // Raw pointer for convenience
41 std::unordered_map<std::string, Widget*> mIdMap;
42 std::unordered_map<std::string, std::vector<Widget*>> mClassMap;
43 std::vector<UIEventBinding> mEventBindings;
44 std::vector<UIDataBinding> mDataBindings;
45};
46
47//------------------------------------------------------------
48// UILoader - builds widget tree from XML + CSS
49//------------------------------------------------------------
50
52{
53public:
54
55 static bool Load(
56 const std::string& xmlSource,
57 const std::string& basePath,
58 UILoadResult& outResult);
59
60private:
61
62 UILoader() = default;
63};
Definition UILoader.h:52
static bool Load(const std::string &xmlSource, const std::string &basePath, UILoadResult &outResult)
Definition UILoader.cpp:335
Definition UIStyleSheet.h:48
Definition Widget.h:53
Definition UILoader.h:28
Widget * mWidget
Definition UILoader.h:29
std::string mTemplateText
Definition UILoader.h:30
Definition UILoader.h:17
std::string mElementId
Definition UILoader.h:18
std::string mEventName
Definition UILoader.h:19
std::string mHandlerName
Definition UILoader.h:20
Definition UILoader.h:38
std::unordered_map< std::string, std::vector< Widget * > > mClassMap
Definition UILoader.h:42
std::vector< UIDataBinding > mDataBindings
Definition UILoader.h:44
std::vector< UIEventBinding > mEventBindings
Definition UILoader.h:43
Widget * mRootWidget
Definition UILoader.h:40
NodePtr mRootNodePtr
Definition UILoader.h:39
std::unordered_map< std::string, Widget * > mIdMap
Definition UILoader.h:41