1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#pragma once
#include "StarWidget.hpp"
namespace Star {
STAR_CLASS(Widget);
STAR_CLASS(Pane);
STAR_EXCEPTION(WidgetParserException, StarException);
struct WidgetConstructResult {
WidgetConstructResult();
WidgetConstructResult(WidgetPtr obj, String const& name, float zlevel);
WidgetPtr obj;
String name;
float zlevel;
};
typedef std::function<WidgetConstructResult(String const& name, Json const& config)> ConstuctorFunc;
class WidgetParser {
public:
WidgetParser();
virtual ~WidgetParser() {}
virtual void construct(Json const& config, Widget* widget = nullptr);
void registerCallback(String const& name, WidgetCallbackFunc callback);
WidgetPtr makeSingle(String const& name, Json const& config);
protected:
void constructImpl(Json const& config, Widget* widget);
List<WidgetConstructResult> constructor(Json const& config);
// Parents
WidgetConstructResult stackHandler(String const& name, Json const& config);
WidgetConstructResult scrollAreaHandler(String const& name, Json const& config);
// Interactive
WidgetConstructResult radioGroupHandler(String const& name, Json const& config);
WidgetConstructResult buttonHandler(String const& name, Json const& config);
WidgetConstructResult spinnerHandler(String const& name, Json const& config);
WidgetConstructResult textboxHandler(String const& name, Json const& config);
WidgetConstructResult itemSlotHandler(String const& name, Json const& config);
WidgetConstructResult itemGridHandler(String const& name, Json const& config);
WidgetConstructResult listHandler(String const& name, Json const& config);
WidgetConstructResult sliderHandler(String const& name, Json const& config);
WidgetConstructResult largeCharPlateHandler(String const& name, Json const& config);
WidgetConstructResult tabSetHandler(String const& name, Json const& config);
// Non-interactive
WidgetConstructResult widgetHandler(String const& name, Json const& config);
WidgetConstructResult imageHandler(String const& name, Json const& config);
WidgetConstructResult imageStretchHandler(String const& name, Json const& config);
WidgetConstructResult portraitHandler(String const& name, Json const& config);
WidgetConstructResult labelHandler(String const& name, Json const& config);
WidgetConstructResult canvasHandler(String const& name, Json const& config);
WidgetConstructResult fuelGaugeHandler(String const& name, Json const& config);
WidgetConstructResult progressHandler(String const& name, Json const& config);
WidgetConstructResult containerHandler(String const& name, Json const& config);
WidgetConstructResult layoutHandler(String const& name, Json const& config);
// Utilities
void common(WidgetPtr widget, Json const& config);
ImageStretchSet parseImageStretchSet(Json const& config);
Pane* m_pane;
StringMap<ConstuctorFunc> m_constructors;
StringMap<WidgetCallbackFunc> m_callbacks;
};
}
|