From fca877b9b62e191b6ff4328b269c40721eafd1ca Mon Sep 17 00:00:00 2001 From: philmoz Date: Fri, 5 Apr 2024 21:31:19 +1100 Subject: [PATCH] Fix rebase. --- radio/src/gui/colorlcd/CMakeLists.txt | 1 - radio/src/gui/colorlcd/input_edit.cpp | 100 +++++++++++++----------- radio/src/gui/colorlcd/input_source.cpp | 2 +- 3 files changed, 57 insertions(+), 46 deletions(-) diff --git a/radio/src/gui/colorlcd/CMakeLists.txt b/radio/src/gui/colorlcd/CMakeLists.txt index 23f8cde4606..6c5c7571494 100644 --- a/radio/src/gui/colorlcd/CMakeLists.txt +++ b/radio/src/gui/colorlcd/CMakeLists.txt @@ -69,7 +69,6 @@ set(GUI_SRC curveedit.cpp fm_matrix.cpp gvar_numberedit.cpp - input_edit_adv.cpp input_edit.cpp input_source.cpp mixer_edit_adv.cpp diff --git a/radio/src/gui/colorlcd/input_edit.cpp b/radio/src/gui/colorlcd/input_edit.cpp index 4dfa26d0beb..274a7415b38 100644 --- a/radio/src/gui/colorlcd/input_edit.cpp +++ b/radio/src/gui/colorlcd/input_edit.cpp @@ -29,9 +29,18 @@ #include "opentx.h" #include "switches.h" +#include "switchchoice.h" #define SET_DIRTY() storageDirty(EE_MODEL) +#if LCD_W > LCD_H +constexpr coord_t INPUT_EDIT_CURVE_WIDTH = 140; +constexpr coord_t INPUT_EDIT_CURVE_HEIGHT = INPUT_EDIT_CURVE_WIDTH; +#else +constexpr coord_t INPUT_EDIT_CURVE_WIDTH = 176; +constexpr coord_t INPUT_EDIT_CURVE_HEIGHT = 132; +#endif + // Grid description for inner and outer grids static const lv_coord_t col_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; @@ -43,8 +52,10 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) : { ExpoData* inputData = expoAddress(index); - header.setTitle(STR_MENUINPUTS); - headerSwitchName = header.setTitle2(""); + body->padAll(PAD_ZERO); + + header->setTitle(STR_MENUINPUTS); + headerSwitchName = header->setTitle2(""); lv_obj_set_style_text_color(headerSwitchName->getLvObj(), makeLvColor(COLOR_THEME_ACTIVE), LV_STATE_USER_1); lv_obj_set_style_text_font(headerSwitchName->getLvObj(), getFont(FONT(BOLD)), LV_STATE_USER_1); @@ -54,14 +65,14 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) : setTitle(); // Outer grid form - auto form = new FormWindow(&body, rect_t{}); - form->padAll(0); + auto form = new Window(body, rect_t{}); + form->padAll(PAD_ZERO); form->setFlexLayout(); FlexGridLayout grid(col_dsc, row_dsc); - auto line = form->newLine(&grid); - line->padAll(0); + auto line = form->newLine(grid); + line->padAll(PAD_ZERO); #if LCD_H > LCD_W // portrait lv_obj_set_flex_flow(line->getLvObj(), LV_FLEX_FLOW_COLUMN); @@ -71,8 +82,8 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) : #if LCD_W > LCD_H // landscape (preview on left) // Preview grid box - force width and height - auto box = new Window(line, rect_t{0, 0, INPUT_EDIT_CURVE_WIDTH + 8, body.height()}); - box->padAll(0); + auto box = new Window(line, rect_t{0, 0, INPUT_EDIT_CURVE_WIDTH + 8, body->height()}); + box->padAll(PAD_ZERO); // Add preview and buttons buildPreview(box, inputData); @@ -80,19 +91,20 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) : // Inner box for main controls - force width and height #if LCD_H > LCD_W // portrait - auto box = new Window(line, rect_t{0, 0, body.width(), body.height() - INPUT_EDIT_CURVE_HEIGHT - 68}); + auto box = new Window(line, rect_t{0, 0, body->width(), body->height() - INPUT_EDIT_CURVE_HEIGHT - 68}); #else - box = new Window(line, rect_t{0, 0, body.width() - INPUT_EDIT_CURVE_WIDTH - 12, body.height()}); + box = new Window(line, rect_t{0, 0, body->width() - INPUT_EDIT_CURVE_WIDTH - 12, body->height()}); #endif - box->padAll(0); + box->padAll(PAD_ZERO); + etx_scrollbar(box->getLvObj()); // Add main controls buildBody(box, inputData); #if LCD_H > LCD_W // portrait (preview below) // Preview grid box - force width and height - box = new Window(line, rect_t{0, 0, body.width(), INPUT_EDIT_CURVE_HEIGHT + 62}); - box->padAll(0); + box = new Window(line, rect_t{0, 0, body->width(), INPUT_EDIT_CURVE_HEIGHT + 62}); + box->padAll(PAD_ZERO); // Add preview and buttons buildPreview(box, inputData); @@ -129,7 +141,7 @@ void InputEditWindow::checkEvents() if ((ed->srcRaw == inputData->srcRaw) && getSwitch(ed->swtch)) { if (lastActiveIdx != i) { lastActiveIdx = i; - preview->invalidate(); + preview->update(); break; } } @@ -170,16 +182,16 @@ static const lv_coord_t b_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2), LV_GRID_TEM void InputEditWindow::buildBody(Window* box, ExpoData* inputData) { lv_obj_set_scrollbar_mode(box->getLvObj(), LV_SCROLLBAR_MODE_AUTO); - auto form = new FormWindow(box, rect_t{}); - form->padAll(0); + auto form = new Window(box, rect_t{}); + form->padAll(PAD_ZERO); form->setFlexLayout(); - FlexGridLayout grid(b_col_dsc, row_dsc, 4); + FlexGridLayout grid(b_col_dsc, row_dsc, PAD_SMALL); // Input Name - auto line = form->newLine(&grid); + auto line = form->newLine(grid); auto inputName = g_model.inputNames[inputData->chn]; - new StaticText(line, rect_t{}, STR_INPUTNAME, 0, COLOR_THEME_PRIMARY1); + new StaticText(line, rect_t{}, STR_INPUTNAME); auto nameFld = new ModelTextEdit(line, rect_t{0, 0, LCD_W*3/10-8, 0}, inputName, LEN_INPUT_NAME); nameFld->setChangeHandler([=]() { setTitle(); @@ -187,57 +199,57 @@ void InputEditWindow::buildBody(Window* box, ExpoData* inputData) }); // Line Name - line = form->newLine(&grid); - new StaticText(line, rect_t{}, STR_EXPONAME, 0, COLOR_THEME_PRIMARY1); + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_EXPONAME); new ModelTextEdit(line, rect_t{0, 0, LCD_W*3/10-8, 0}, inputData->name, LEN_EXPOMIX_NAME); // Source - line = form->newLine(&grid); - new StaticText(line, rect_t{}, STR_SOURCE, 0, COLOR_THEME_PRIMARY1); + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_SOURCE); new InputSource(line, inputData); // Switch - line = form->newLine(&grid); - new StaticText(line, rect_t{}, STR_SWITCH, 0, COLOR_THEME_PRIMARY1); + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_SWITCH); new SwitchChoice(line, rect_t{}, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, GET_SET_DEFAULT(inputData->swtch)); // Weight - line = form->newLine(&grid); - new StaticText(line, rect_t{}, STR_WEIGHT, 0, COLOR_THEME_PRIMARY1); + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_WEIGHT); auto gvar = new GVarNumberEdit(line, rect_t{}, -100, 100, GET_DEFAULT(inputData->weight), [=](int32_t newValue) { inputData->weight = newValue; - preview->invalidate(); + preview->update(); SET_DIRTY(); }); gvar->setSuffix("%"); // Offset - line = form->newLine(&grid); - new StaticText(line, rect_t{}, STR_OFFSET, 0, COLOR_THEME_PRIMARY1); + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_OFFSET); gvar = new GVarNumberEdit(line, rect_t{}, -100, 100, GET_DEFAULT(inputData->offset), [=](int32_t newValue) { inputData->offset = newValue; - preview->invalidate(); + preview->update(); SET_DIRTY(); }); gvar->setSuffix("%"); // Curve - line = form->newLine(&grid); - new StaticText(line, rect_t{}, STR_CURVE, 0, COLOR_THEME_PRIMARY1); + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_CURVE); new CurveParam(line, rect_t{}, &inputData->curve, [=](int32_t newValue) { inputData->curve.value = newValue; - preview->invalidate(); + preview->update(); SET_DIRTY(); }); // Trim - line = form->newLine(&grid); - new StaticText(line, rect_t{}, STR_TRIM, 0, COLOR_THEME_PRIMARY1); + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_TRIM); const auto trimLast = TRIM_OFF + keysGetMaxTrims() - 1; auto c = new Choice(line, rect_t{}, -TRIM_OFF, trimLast, GET_VALUE(-inputData->trimSource), @@ -250,8 +262,8 @@ void InputEditWindow::buildBody(Window* box, ExpoData* inputData) }); // Flight modes - line = form->newLine(&grid); - new StaticText(line, rect_t{}, STR_FLMODE, 0, COLOR_THEME_PRIMARY1); + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_FLMODE); new FMMatrix(line, rect_t{}, inputData, 3); #if LCD_W > LCD_H @@ -266,11 +278,11 @@ void InputEditWindow::buildPreview(Window* box, ExpoData* inputData) static bool showActive = true; auto aBtn = new TextButton(box, rect_t{xo, yo, INPUT_EDIT_CURVE_WIDTH, 24}, STR_SHOW_ACTIVE); - aBtn->padAll(0); + aBtn->padAll(PAD_ZERO); aBtn->check(showActive); aBtn->setPressHandler([=]() { showActive = !showActive; - preview->invalidate(); + preview->update(); return showActive; }); @@ -287,10 +299,10 @@ void InputEditWindow::buildPreview(Window* box, ExpoData* inputData) [=]() -> int { return getValue(expoAddress(index)->srcRaw); }); 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]); - sBtn1->padAll(0); + sBtn1->padAll(PAD_ZERO); 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]); - sBtn2->padAll(0); + sBtn2->padAll(PAD_ZERO); sBtn1->setPressHandler([=]() { if (sBtn1->checked()) { @@ -301,7 +313,7 @@ void InputEditWindow::buildPreview(Window* box, ExpoData* inputData) inputData->mode = inputData->mode | 1; } SET_DIRTY(); - preview->invalidate(); + preview->update(); sBtn2->check(inputData->mode & 2); return (inputData->mode & 1) != 0; }); @@ -315,7 +327,7 @@ void InputEditWindow::buildPreview(Window* box, ExpoData* inputData) inputData->mode = inputData->mode | 2; } SET_DIRTY(); - preview->invalidate(); + preview->update(); sBtn1->check(inputData->mode & 1); return (inputData->mode & 2) != 0; }); diff --git a/radio/src/gui/colorlcd/input_source.cpp b/radio/src/gui/colorlcd/input_source.cpp index ceeffbb3051..0d4429f7fd3 100644 --- a/radio/src/gui/colorlcd/input_source.cpp +++ b/radio/src/gui/colorlcd/input_source.cpp @@ -93,7 +93,7 @@ InputSource::InputSource(Window *parent, ExpoData *input) : { padAll(PAD_TINY); lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_COLUMN); - lv_obj_set_size(lvobj, lv_pct(100), LV_SIZE_CONTENT); + lv_obj_set_size(lvobj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); new SourceChoice(this, rect_t{}, INPUTSRC_FIRST, INPUTSRC_LAST, GET_DEFAULT(input->srcRaw), [=](int32_t newValue) {