From b6b5566adad6982d748872d1be09db76c6a856fb 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/fm_matrix.cpp | 12 ++-- radio/src/gui/colorlcd/fm_matrix.h | 1 + radio/src/gui/colorlcd/input_edit.cpp | 96 +++++++++++++------------ radio/src/gui/colorlcd/input_source.cpp | 2 +- 5 files changed, 56 insertions(+), 56 deletions(-) diff --git a/radio/src/gui/colorlcd/CMakeLists.txt b/radio/src/gui/colorlcd/CMakeLists.txt index 7fb1a4e74c4..da541cfa67d 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/fm_matrix.cpp b/radio/src/gui/colorlcd/fm_matrix.cpp index 4dbe9ffa80e..5dd19ab7ad3 100644 --- a/radio/src/gui/colorlcd/fm_matrix.cpp +++ b/radio/src/gui/colorlcd/fm_matrix.cpp @@ -28,11 +28,7 @@ template FMMatrix::FMMatrix(Window* parent, const rect_t& r, T* input, uint8_t columns) : ButtonMatrix(parent, r), input(input) { -#if LCD_W > LCD_H - if (columns == 0) columns = 5; -#else - if (columns == 0) columns = 3; -#endif + if (columns == 0) columns = DEF_COLS; initBtnMap(columns, MAX_FLIGHT_MODES); @@ -42,10 +38,10 @@ FMMatrix::FMMatrix(Window* parent, const rect_t& r, T* input, uint8_t columns update(); - lv_obj_set_width(lvobj, columns * 51 + 3); - lv_obj_set_height(lvobj, ((MAX_FLIGHT_MODES + columns- 1) / columns) * 35 + 3); + lv_obj_set_width(lvobj, columns * (FM_BTN_W + 3) + 3); + lv_obj_set_height(lvobj, ((MAX_FLIGHT_MODES + columns- 1) / columns) * (EdgeTxStyles::UI_ELEMENT_HEIGHT + 3) + 3); - padAll(PAD_SMALL); + padAll(PAD_TINY); } template diff --git a/radio/src/gui/colorlcd/fm_matrix.h b/radio/src/gui/colorlcd/fm_matrix.h index 1ebac45bcab..a999e36e38f 100644 --- a/radio/src/gui/colorlcd/fm_matrix.h +++ b/radio/src/gui/colorlcd/fm_matrix.h @@ -35,6 +35,7 @@ struct FMMatrix : public ButtonMatrix { void setTextAndState(uint8_t btn_id); static LAYOUT_VAL(FM_BTN_W, 48, 48) + static LAYOUT_VAL(DEF_COLS, 5, 3) }; extern template struct FMMatrix; diff --git a/radio/src/gui/colorlcd/input_edit.cpp b/radio/src/gui/colorlcd/input_edit.cpp index 4dfa26d0beb..a2bfd5c7954 100644 --- a/radio/src/gui/colorlcd/input_edit.cpp +++ b/radio/src/gui/colorlcd/input_edit.cpp @@ -29,6 +29,7 @@ #include "opentx.h" #include "switches.h" +#include "switchchoice.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -43,8 +44,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 +57,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 +74,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 +83,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 +133,7 @@ void InputEditWindow::checkEvents() if ((ed->srcRaw == inputData->srcRaw) && getSwitch(ed->swtch)) { if (lastActiveIdx != i) { lastActiveIdx = i; - preview->invalidate(); + preview->update(); break; } } @@ -170,16 +174,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 +191,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); - auto gvar = new GVarNumberEdit(line, rect_t{}, -100, 100, + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_WEIGHT); + auto gvar = new GVarNumberEdit(line, -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); - gvar = new GVarNumberEdit(line, rect_t{}, -100, 100, + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_OFFSET); + gvar = new GVarNumberEdit(line, -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 +254,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 +270,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 +291,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 +305,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 +319,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 2eb58a67e1d..b256179c161 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),