-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlayout.hpp
135 lines (114 loc) · 3.99 KB
/
layout.hpp
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// clang-format off
// AUTOGENERATED FILE, DO NOT EDIT
// Generated by https://roboticsbrno.github.io/Esp32-RBGridUI-Designer/
// Layout: {"cols":12,"rows":18,"enableSplitting":true,"widgets":[{"uuid":55497,"type":"Led","state":{"id":"ledRed","x":1,"y":1,"w":1,"h":1,"css":{},"color":"#FF0000","on":true}},{"uuid":35310,"type":"Checkbox","state":{"id":"boxBlack","x":4.5,"y":2.5,"w":4,"h":1,"css":{},"fontSize":14,"checked":true,"color":"#000000","text":"ChkBox"}},{"uuid":21890,"type":"Led","state":{"id":"ledBlue","x":3,"y":1,"w":1,"h":1,"css":{},"color":"#0010ff","on":false}},{"uuid":59221,"type":"Checkbox","state":{"id":"boxGreen","x":8,"y":1,"w":4,"h":1,"css":{},"fontSize":17.5,"checked":false,"color":"#00d805","text":"TestBox"}},{"uuid":6032,"type":"Joystick","state":{"id":"Joystick1","x":5,"y":11.5,"w":5.5,"h":5,"css":{},"color":"#FF0000","keys":"wasd ","text":"Fire!"}},{"uuid":59246,"type":"Button","state":{"id":"Button1","x":4.5,"y":5,"w":3,"h":1,"css":{},"text":"Button"}},{"uuid":46846,"type":"Button","state":{"id":"Button2","x":0,"y":11.5,"w":3,"h":1,"css":{"border":"3px solid black","text-transform":"uppercase"},"text":"BUTTON"}}]}
// Usage: include this file, where needed, and in *one* .cpp file,
// define also GRIDUI_LAYOUT_DEFINITION just before the layout like this:
//
// #define GRIDUI_LAYOUT_DEFINITION
// #include "layout.h"
// using namespace gridui;
//
// The layout.h should also be the last included header. Then, in your code:
//
// auto builder = Layout.begin();
// builder.Button1.onPress([](Button&) { ... })
// ...
// builder.commit();
#pragma once
#include <esp_log.h>
#include "gridui.h"
namespace gridui {
#ifndef RB_GRIDUI_VERSION
#define RB_GRIDUI_VERSION 0x040000
#endif
static_assert(RB_GRIDUI_VERSION >= 0x040000,
"Your RBGridUi library version is too low for this layout, please update to 040000.");
class _Layout;
namespace builder {
class _LayoutBuilder {
friend class gridui::_Layout;
_LayoutBuilder() :
ledRed(
UI.led(1, 1, 1, 1, 55497)
.on(true)
),
boxBlack(
UI.checkbox(4.5, 2.5, 4, 1, 35310)
.checked(true)
.text("ChkBox")
),
ledBlue(
UI.led(3, 1, 1, 1, 21890)
.color("#0010ff")
),
boxGreen(
UI.checkbox(8, 1, 4, 1, 59221)
.fontSize(17.5)
.color("#00d805")
.text("TestBox")
),
Joystick1(
UI.joystick(5, 11.5, 5.5, 5, 6032)
.keys("wasd ")
.text("Fire!")
),
Button1(
UI.button(4.5, 5, 3, 1, 59246)
),
Button2(
UI.button(0, 11.5, 3, 1, 46846)
.css("border", "3px solid black")
.css("text-transform", "uppercase")
.text("BUTTON")
)
{
}
public:
void commit();
Led& ledRed;
Checkbox& boxBlack;
Led& ledBlue;
Checkbox& boxGreen;
Joystick& Joystick1;
Button& Button1;
Button& Button2;
};
}; // namespace builder
class _Layout {
friend class builder::_LayoutBuilder;
public:
_Layout() {}
builder::_LayoutBuilder begin() {
static bool called = false;
if(called) {
ESP_LOGE("GridUILayout", "Layout.begin() was called more than once, this is an error!");
}
called = true;
return builder::_LayoutBuilder();
}
Led ledRed;
Checkbox boxBlack;
Led ledBlue;
Checkbox boxGreen;
Joystick Joystick1;
Button Button1;
Button Button2;
};
extern _Layout Layout;
#ifdef GRIDUI_LAYOUT_DEFINITION
_Layout Layout;
#endif
namespace builder {
void _LayoutBuilder::commit() {
Layout.ledRed = ledRed.finish();
Layout.boxBlack = boxBlack.finish();
Layout.ledBlue = ledBlue.finish();
Layout.boxGreen = boxGreen.finish();
Layout.Joystick1 = Joystick1.finish();
Layout.Button1 = Button1.finish();
Layout.Button2 = Button2.finish();
UI.commit();
}
};
};