Repository navigation
Expand file tree
/
Copy pathshadows.h
More file actions
232 lines (222 loc) · 7.37 KB
/
Copy pathshadows.h
File metadata and controls
232 lines (222 loc) · 7.37 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/* -*- C++ -*- */
#ifndef RSITE_ARDUINO_MENU_SHADOWS
#define RSITE_ARDUINO_MENU_SHADOWS
#include "menuBase.h"
namespace Menu {
struct promptShadowRaw {
actionRaw a;//the hooked callback function
systemStyles sysStyles;
const char* text;
constMEM eventMask events;//registered events
styles style;
};
class promptShadow:public action {
protected:
public:
systemStyles sysStyles;
const char* text;
eventMask events;//registered events (mask)
styles style;
public:
promptShadow(const char* t,action a=doNothing,eventMask e=noEvent,styles s=noStyle,systemStyles ss=_noStyle)
:action(a),sysStyles(ss),text(t),events(e),style(s) {}
inline constText* getText() const {return (constText*)memPtr(text);}
inline systemStyles _sysStyles() const {return (systemStyles)memEnum(&sysStyles);}
inline eventMask _events() const {return (eventMask)memEnum(&events);}
inline styles _style() const {return (styles)memEnum(&style);}
};
union promptShadows {
promptShadowRaw raw;
promptShadow obj;
};
struct textFieldShadowRaw {
actionRaw a;
systemStyles sysStyles;
const char*text;
eventMask events;//registered events
styles style;
char* buffer;
const char* const* validators;
idx_t sz;
};
class textFieldShadow:public promptShadow {
protected:
public:
char* buffer;
const char* const* validators;
idx_t sz;
textFieldShadow(
const char* label,
char* b,
idx_t sz,
char* const* v,
action a=doNothing,
eventMask e=noEvent,
styles style=noStyle,
systemStyles ss=(Menu::systemStyles)(_noStyle|_canNav|_parentDraw)
):promptShadow(label,a,e,style,ss),buffer(b),validators(v),sz(sz) {}
idx_t _sz() const {return (idx_t)memIdx(sz);}
char* _buffer() const {return (char*)memPtr(buffer);}
char* const* _validators() const {return (char* const*)memPtr(validators);}
inline constText* operator[](idx_t i) const {
return (char*)memPtr(((char**)_validators())[i]);
}
};
union textFieldShadows {
textFieldShadowRaw raw;
textFieldShadow obj;
};
struct menuNodeShadowRaw {
actionRaw a;
systemStyles sysStyles;
const char* text;
eventMask events;//registered events
styles style;
idx_t sz;
prompt* constMEM* data;
};
class menuNodeShadow:public promptShadow {
protected:
public:
idx_t sz;
prompt* constMEM* data;
public:
menuNodeShadow(const char* text,idx_t sz,prompt* constMEM* data,action a,eventMask e,styles style,systemStyles ss=(systemStyles)(_menuData|_canNav))
:promptShadow(text,a,e,style,ss),sz(sz),data(data) {}
idx_t _sz() const {return (idx_t)memIdx(sz);}
prompt* constMEM* _data() const {return (prompt* constMEM*)memPtr(data);}
inline prompt& operator[](idx_t i) const {
return *(prompt*)memPtr(((prompt**)_data())[i]);
//return *(prompt*)memPtr(((prompt**)memPtr(((menuNodeShadow*)shadow)->data))[i]);
}
};
union menuNodeShadows {
menuNodeShadowRaw raw;
menuNodeShadow obj;
};
struct fieldBaseShadowRaw {
actionRaw a;
systemStyles sysStyles;
const char* text;
eventMask events;//registered events
styles style;
constText* units;
};
class fieldBaseShadow:public promptShadow {
public:
constText* units;
fieldBaseShadow(constText* text,constText*units,action a=doNothing,eventMask e=noEvent,styles s=noStyle,systemStyles ss=((Menu::systemStyles)(Menu::_canNav|Menu::_parentDraw)))
:promptShadow(text,a,e,s,ss),units(units) {}
inline constText* _units() {return (constText*)memPtr(units);}
};
template<typename T>
struct menuFieldShadowRaw {
actionRaw a;
systemStyles sysStyles;
const char* text;
eventMask events;//registered events
styles style;
constText* units;
T* value;
constMEM T low,high,step,tune;
};
template<typename T>
class menuFieldShadow:public fieldBaseShadow {
protected:
public:
T* value;
constMEM T low,high,step,tune;
public:
menuFieldShadow(T &value,constText* text,constText*units,T low,T high,T step,T tune,action a=doNothing,eventMask e=noEvent,styles s=noStyle,systemStyles ss=((Menu::systemStyles)(Menu::_canNav|Menu::_parentDraw)))
:fieldBaseShadow(text,units,a,e,s,ss),value(&value),low(low),high(high),step(step),tune(tune) {}
inline T& target() const {return *(T*)memPtr(value);}
inline T getTypeValue(const T* from) const {
//TODO: dynamic versions require change of preprocessor to virtual
#ifdef USING_PGM
T tmp;
memcpy_P(&tmp, from, sizeof(T));
return tmp;
#else
return *from;
#endif
}
inline T _low() const {return getTypeValue(&low);}
inline T _high() const {return getTypeValue(&high);}
inline T _step() const {return getTypeValue(&step);}
inline T _tune() const {return getTypeValue(&tune);}
};
template<typename T>
union menuFieldShadows {
menuFieldShadowRaw<T> raw;
menuFieldShadow<T> obj;
};
template<typename T>
struct menuValueShadowRaw {
actionRaw a;
systemStyles sysStyles;
const char* text;
eventMask events;//registered events
styles style;
T value;
};
template<typename T>
class menuValueShadow:public promptShadow {
protected:
public:
T value;
public:
inline menuValueShadow(constText* text,T value,action a=doNothing,eventMask e=noEvent)
:promptShadow(text,a,e),value(value) {}
inline T getTypeValue(const T* from) const {
//TODO: dynamic versions require change of preprocessor to virtual
#ifdef USING_PGM
T tmp;
memcpy_P(&tmp, from, sizeof(T));
return tmp;
#else
return *from;
#endif
}
inline T target() const {return getTypeValue(&value);}
};
template<typename T>
union menuValueShadows {
menuValueShadowRaw<T> raw;
menuValueShadow<T> obj;
};
template<typename T>
struct menuVariantShadowRaw {
actionRaw a;
systemStyles sysStyles;
const char* text;
constMEM eventMask events;//registered events
styles style;
idx_t sz;
prompt* constMEM* data;
//int width;//field or menu width
//int ox,oy;//coordinate origin displacement
T* value;
};
template<typename T>
class menuVariantShadow:public menuNodeShadow {
public:
T* value;
menuVariantShadow(
constText* text,
T &target,
idx_t sz,
prompt* constMEM* data,
action a,
eventMask e,
styles style,
systemStyles ss=(systemStyles)(_menuData|_canNav)
):menuNodeShadow(text,sz,data,a,e,style,ss),value(&target) {}
inline T& target() const {return *((T*)memPtr(value));}
};
template<typename T>
union menuVariantShadows {
menuVariantShadowRaw<T> raw;
menuVariantShadow<T> obj;
};
}//namespace Menu
#endif