29
29
30
30
#include " opentx.h"
31
31
#include " switches.h"
32
+ #include " switchchoice.h"
32
33
33
34
#define SET_DIRTY () storageDirty(EE_MODEL)
34
35
@@ -43,8 +44,10 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
43
44
{
44
45
ExpoData* inputData = expoAddress (index );
45
46
46
- header.setTitle (STR_MENUINPUTS);
47
- headerSwitchName = header.setTitle2 (" " );
47
+ body->padAll (PAD_ZERO);
48
+
49
+ header->setTitle (STR_MENUINPUTS);
50
+ headerSwitchName = header->setTitle2 (" " );
48
51
49
52
lv_obj_set_style_text_color (headerSwitchName->getLvObj (), makeLvColor (COLOR_THEME_ACTIVE), LV_STATE_USER_1);
50
53
lv_obj_set_style_text_font (headerSwitchName->getLvObj (), getFont (FONT (BOLD)), LV_STATE_USER_1);
@@ -54,14 +57,14 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
54
57
setTitle ();
55
58
56
59
// Outer grid form
57
- auto form = new FormWindow (& body, rect_t {});
58
- form->padAll (0 );
60
+ auto form = new Window ( body, rect_t {});
61
+ form->padAll (PAD_ZERO );
59
62
form->setFlexLayout ();
60
63
61
64
FlexGridLayout grid (col_dsc, row_dsc);
62
65
63
- auto line = form->newLine (& grid);
64
- line->padAll (0 );
66
+ auto line = form->newLine (grid);
67
+ line->padAll (PAD_ZERO );
65
68
66
69
#if LCD_H > LCD_W // portrait
67
70
lv_obj_set_flex_flow (line->getLvObj (), LV_FLEX_FLOW_COLUMN);
@@ -71,28 +74,29 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
71
74
72
75
#if LCD_W > LCD_H // landscape (preview on left)
73
76
// Preview grid box - force width and height
74
- auto box = new Window (line, rect_t {0 , 0 , INPUT_EDIT_CURVE_WIDTH + 8 , body. height ()});
75
- box->padAll (0 );
77
+ auto box = new Window (line, rect_t {0 , 0 , INPUT_EDIT_CURVE_WIDTH + 8 , body-> height ()});
78
+ box->padAll (PAD_ZERO );
76
79
77
80
// Add preview and buttons
78
81
buildPreview (box, inputData);
79
82
#endif
80
83
81
84
// Inner box for main controls - force width and height
82
85
#if LCD_H > LCD_W // portrait
83
- auto box = new Window (line, rect_t {0 , 0 , body. width (), body. height () - INPUT_EDIT_CURVE_HEIGHT - 68 });
86
+ auto box = new Window (line, rect_t {0 , 0 , body-> width (), body-> height () - INPUT_EDIT_CURVE_HEIGHT - 68 });
84
87
#else
85
- box = new Window (line, rect_t {0 , 0 , body. width () - INPUT_EDIT_CURVE_WIDTH - 12 , body. height ()});
88
+ box = new Window (line, rect_t {0 , 0 , body-> width () - INPUT_EDIT_CURVE_WIDTH - 12 , body-> height ()});
86
89
#endif
87
- box->padAll (0 );
90
+ box->padAll (PAD_ZERO);
91
+ etx_scrollbar (box->getLvObj ());
88
92
89
93
// Add main controls
90
94
buildBody (box, inputData);
91
95
92
96
#if LCD_H > LCD_W // portrait (preview below)
93
97
// Preview grid box - force width and height
94
- box = new Window (line, rect_t {0 , 0 , body. width (), INPUT_EDIT_CURVE_HEIGHT + 62 });
95
- box->padAll (0 );
98
+ box = new Window (line, rect_t {0 , 0 , body-> width (), INPUT_EDIT_CURVE_HEIGHT + 62 });
99
+ box->padAll (PAD_ZERO );
96
100
97
101
// Add preview and buttons
98
102
buildPreview (box, inputData);
@@ -129,7 +133,7 @@ void InputEditWindow::checkEvents()
129
133
if ((ed->srcRaw == inputData->srcRaw ) && getSwitch (ed->swtch )) {
130
134
if (lastActiveIdx != i) {
131
135
lastActiveIdx = i;
132
- preview->invalidate ();
136
+ preview->update ();
133
137
break ;
134
138
}
135
139
}
@@ -170,74 +174,74 @@ static const lv_coord_t b_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2), LV_GRID_TEM
170
174
void InputEditWindow::buildBody (Window* box, ExpoData* inputData)
171
175
{
172
176
lv_obj_set_scrollbar_mode (box->getLvObj (), LV_SCROLLBAR_MODE_AUTO);
173
- auto form = new FormWindow (box, rect_t {});
174
- form->padAll (0 );
177
+ auto form = new Window (box, rect_t {});
178
+ form->padAll (PAD_ZERO );
175
179
form->setFlexLayout ();
176
180
177
- FlexGridLayout grid (b_col_dsc, row_dsc, 4 );
181
+ FlexGridLayout grid (b_col_dsc, row_dsc, PAD_SMALL );
178
182
179
183
// Input Name
180
- auto line = form->newLine (& grid);
184
+ auto line = form->newLine (grid);
181
185
auto inputName = g_model.inputNames [inputData->chn ];
182
- new StaticText (line, rect_t {}, STR_INPUTNAME, 0 , COLOR_THEME_PRIMARY1 );
186
+ new StaticText (line, rect_t {}, STR_INPUTNAME);
183
187
auto nameFld = new ModelTextEdit (line, rect_t {0 , 0 , LCD_W*3 /10 -8 , 0 }, inputName, LEN_INPUT_NAME);
184
188
nameFld->setChangeHandler ([=]() {
185
189
setTitle ();
186
190
SET_DIRTY ();
187
191
});
188
192
189
193
// Line Name
190
- line = form->newLine (& grid);
191
- new StaticText (line, rect_t {}, STR_EXPONAME, 0 , COLOR_THEME_PRIMARY1 );
194
+ line = form->newLine (grid);
195
+ new StaticText (line, rect_t {}, STR_EXPONAME);
192
196
new ModelTextEdit (line, rect_t {0 , 0 , LCD_W*3 /10 -8 , 0 }, inputData->name , LEN_EXPOMIX_NAME);
193
197
194
198
// Source
195
- line = form->newLine (& grid);
196
- new StaticText (line, rect_t {}, STR_SOURCE, 0 , COLOR_THEME_PRIMARY1 );
199
+ line = form->newLine (grid);
200
+ new StaticText (line, rect_t {}, STR_SOURCE);
197
201
new InputSource (line, inputData);
198
202
199
203
// Switch
200
- line = form->newLine (& grid);
201
- new StaticText (line, rect_t {}, STR_SWITCH, 0 , COLOR_THEME_PRIMARY1 );
204
+ line = form->newLine (grid);
205
+ new StaticText (line, rect_t {}, STR_SWITCH);
202
206
new SwitchChoice (line, rect_t {}, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, GET_SET_DEFAULT (inputData->swtch ));
203
207
204
208
// Weight
205
- line = form->newLine (& grid);
206
- new StaticText (line, rect_t {}, STR_WEIGHT, 0 , COLOR_THEME_PRIMARY1 );
207
- auto gvar = new GVarNumberEdit (line, rect_t {}, -100 , 100 ,
209
+ line = form->newLine (grid);
210
+ new StaticText (line, rect_t {}, STR_WEIGHT);
211
+ auto gvar = new GVarNumberEdit (line, -100 , 100 ,
208
212
GET_DEFAULT (inputData->weight ),
209
213
[=](int32_t newValue) {
210
214
inputData->weight = newValue;
211
- preview->invalidate ();
215
+ preview->update ();
212
216
SET_DIRTY ();
213
217
});
214
218
gvar->setSuffix (" %" );
215
219
216
220
// Offset
217
- line = form->newLine (& grid);
218
- new StaticText (line, rect_t {}, STR_OFFSET, 0 , COLOR_THEME_PRIMARY1 );
219
- gvar = new GVarNumberEdit (line, rect_t {}, -100 , 100 ,
221
+ line = form->newLine (grid);
222
+ new StaticText (line, rect_t {}, STR_OFFSET);
223
+ gvar = new GVarNumberEdit (line, -100 , 100 ,
220
224
GET_DEFAULT (inputData->offset ),
221
225
[=](int32_t newValue) {
222
226
inputData->offset = newValue;
223
- preview->invalidate ();
227
+ preview->update ();
224
228
SET_DIRTY ();
225
229
});
226
230
gvar->setSuffix (" %" );
227
231
228
232
// Curve
229
- line = form->newLine (& grid);
230
- new StaticText (line, rect_t {}, STR_CURVE, 0 , COLOR_THEME_PRIMARY1 );
233
+ line = form->newLine (grid);
234
+ new StaticText (line, rect_t {}, STR_CURVE);
231
235
new CurveParam (line, rect_t {}, &inputData->curve ,
232
236
[=](int32_t newValue) {
233
237
inputData->curve .value = newValue;
234
- preview->invalidate ();
238
+ preview->update ();
235
239
SET_DIRTY ();
236
240
});
237
241
238
242
// Trim
239
- line = form->newLine (& grid);
240
- new StaticText (line, rect_t {}, STR_TRIM, 0 , COLOR_THEME_PRIMARY1 );
243
+ line = form->newLine (grid);
244
+ new StaticText (line, rect_t {}, STR_TRIM);
241
245
const auto trimLast = TRIM_OFF + keysGetMaxTrims () - 1 ;
242
246
auto c = new Choice (line, rect_t {}, -TRIM_OFF, trimLast,
243
247
GET_VALUE (-inputData->trimSource ),
@@ -250,8 +254,8 @@ void InputEditWindow::buildBody(Window* box, ExpoData* inputData)
250
254
});
251
255
252
256
// Flight modes
253
- line = form->newLine (& grid);
254
- new StaticText (line, rect_t {}, STR_FLMODE, 0 , COLOR_THEME_PRIMARY1 );
257
+ line = form->newLine (grid);
258
+ new StaticText (line, rect_t {}, STR_FLMODE);
255
259
new FMMatrix<ExpoData>(line, rect_t {}, inputData, 3 );
256
260
257
261
#if LCD_W > LCD_H
@@ -266,11 +270,11 @@ void InputEditWindow::buildPreview(Window* box, ExpoData* inputData)
266
270
267
271
static bool showActive = true ;
268
272
auto aBtn = new TextButton (box, rect_t {xo, yo, INPUT_EDIT_CURVE_WIDTH, 24 }, STR_SHOW_ACTIVE);
269
- aBtn->padAll (0 );
273
+ aBtn->padAll (PAD_ZERO );
270
274
aBtn->check (showActive);
271
275
aBtn->setPressHandler ([=]() {
272
276
showActive = !showActive;
273
- preview->invalidate ();
277
+ preview->update ();
274
278
return showActive;
275
279
});
276
280
@@ -287,10 +291,10 @@ void InputEditWindow::buildPreview(Window* box, ExpoData* inputData)
287
291
[=]() -> int { return getValue (expoAddress (index )->srcRaw ); });
288
292
289
293
auto sBtn1 = new TextButton (box, rect_t {xo, yo + INPUT_EDIT_CURVE_HEIGHT + 4 + 28 , INPUT_EDIT_CURVE_WIDTH/2 - 4 , 24 }, STR_VCURVEFUNC[2 ]);
290
- sBtn1 ->padAll (0 );
294
+ sBtn1 ->padAll (PAD_ZERO );
291
295
292
296
auto sBtn2 = new TextButton (box, rect_t {xo + INPUT_EDIT_CURVE_WIDTH / 2 + 4 , yo + INPUT_EDIT_CURVE_HEIGHT + 4 + 28 , INPUT_EDIT_CURVE_WIDTH/2 -4 , 24 }, STR_VCURVEFUNC[1 ]);
293
- sBtn2 ->padAll (0 );
297
+ sBtn2 ->padAll (PAD_ZERO );
294
298
295
299
sBtn1 ->setPressHandler ([=]() {
296
300
if (sBtn1 ->checked ()) {
@@ -301,7 +305,7 @@ void InputEditWindow::buildPreview(Window* box, ExpoData* inputData)
301
305
inputData->mode = inputData->mode | 1 ;
302
306
}
303
307
SET_DIRTY ();
304
- preview->invalidate ();
308
+ preview->update ();
305
309
sBtn2 ->check (inputData->mode & 2 );
306
310
return (inputData->mode & 1 ) != 0 ;
307
311
});
@@ -315,7 +319,7 @@ void InputEditWindow::buildPreview(Window* box, ExpoData* inputData)
315
319
inputData->mode = inputData->mode | 2 ;
316
320
}
317
321
SET_DIRTY ();
318
- preview->invalidate ();
322
+ preview->update ();
319
323
sBtn1 ->check (inputData->mode & 1 );
320
324
return (inputData->mode & 2 ) != 0 ;
321
325
});
0 commit comments