Skip to content

Commit

Permalink
Fix rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed May 3, 2024
1 parent 1906c81 commit 9a08f95
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 46 deletions.
1 change: 0 additions & 1 deletion radio/src/gui/colorlcd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
100 changes: 56 additions & 44 deletions radio/src/gui/colorlcd/input_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -71,28 +82,29 @@ 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);
#endif

// 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);
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -170,74 +182,74 @@ 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();
SET_DIRTY();
});

// 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),
Expand All @@ -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<ExpoData>(line, rect_t{}, inputData, 3);

#if LCD_W > LCD_H
Expand All @@ -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;
});

Expand All @@ -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()) {
Expand All @@ -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;
});
Expand All @@ -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;
});
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/input_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9a08f95

Please sign in to comment.