Skip to content

Commit

Permalink
Fix rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Jun 7, 2024
1 parent 341ae7b commit b6b5566
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 56 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
12 changes: 4 additions & 8 deletions radio/src/gui/colorlcd/fm_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ template<class T>
FMMatrix<T>::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);

Expand All @@ -42,10 +38,10 @@ FMMatrix<T>::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 <class T>
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/fm_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExpoData>;
Expand Down
96 changes: 50 additions & 46 deletions radio/src/gui/colorlcd/input_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "opentx.h"
#include "switches.h"
#include "switchchoice.h"

#define SET_DIRTY() storageDirty(EE_MODEL)

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -71,28 +74,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 +133,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 +174,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);
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),
Expand All @@ -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<ExpoData>(line, rect_t{}, inputData, 3);

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

Expand All @@ -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()) {
Expand All @@ -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;
});
Expand All @@ -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;
});
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),
Expand Down

0 comments on commit b6b5566

Please sign in to comment.