Skip to content

Commit

Permalink
Fix rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Mitchell committed Apr 27, 2024
1 parent 79f49a0 commit 39d83af
Show file tree
Hide file tree
Showing 13 changed files with 216 additions and 251 deletions.
16 changes: 10 additions & 6 deletions radio/src/gui/colorlcd/channel_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

#define CHANNELS_LIMIT (g_model.extendedLimits ? LIMIT_EXT_MAX : LIMIT_STD_MAX)

LAYOUT_VAL1(VAL_W, 45)
LAYOUT_VAL1(VAL_H, 12)
LAYOUT_VAL1(VAL_XO, 5)
LAYOUT_VAL1(VAL_YO, -2)
LAYOUT_VAL1(VAL_XT, -54)

ChannelBar::ChannelBar(Window* parent, const rect_t& rect,
std::function<int16_t()> getValueFunc, LcdFlags barColor,
LcdFlags txtColor) :
Expand All @@ -41,13 +47,13 @@ ChannelBar::ChannelBar(Window* parent, const rect_t& rect,
lv_obj_set_pos(bar, width() / 2, 0);
lv_obj_set_size(bar, 0, height());

coord_t yo = (height() < 10) ? -1 : -2;
coord_t yo = (height() < 10) ? -1 : VAL_YO;

valText = lv_label_create(lvobj);
lv_obj_set_pos(valText, width() / 2 + 5, yo);
lv_obj_set_size(valText, 45, 12);
lv_obj_set_pos(valText, width() / 2 + VAL_XO, yo);
lv_obj_set_size(valText, VAL_W, VAL_H);
etx_obj_add_style(valText, styles->text_align_left, LV_PART_MAIN);
lv_obj_set_style_translate_x(valText, -54, LV_STATE_USER_1);
lv_obj_set_style_translate_x(valText, VAL_XT, LV_STATE_USER_1);
etx_obj_add_style(valText, styles->text_align_right, LV_STATE_USER_1);
etx_font(valText, FONT_XS_INDEX);
etx_txt_color(valText, indexFromColor(txtColor));
Expand Down Expand Up @@ -210,8 +216,6 @@ void OutputChannelBar::checkEvents()

//-----------------------------------------------------------------------------

LAYOUT_VAL1(VAL_W, 45)
LAYOUT_VAL1(VAL_H, 12)
LAYOUT_VAL3(ICON_SZ, 25, 16, 25)

ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect,
Expand Down
6 changes: 3 additions & 3 deletions radio/src/gui/colorlcd/input_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
etx_scrollbar(box_obj);

#if PORTRAIT_LCD // portrait
box->setWidth(body->width() - 2 * lv_dpx(8));
box->setWidth(body->width() - 2 * PAD_MEDIUM);
#else // landscape
box->setHeight(body->height() - 2 * lv_dpx(8));
box->setHeight(body->height() - 2 * PAD_MEDIUM);
#endif

auto form = new Window(box, rect_t{});
Expand All @@ -84,7 +84,7 @@ static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
void InputEditWindow::buildBody(Window* form)
{
FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY);
form->setFlexLayout();
form->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO);

ExpoData* input = expoAddress(index);

Expand Down
68 changes: 31 additions & 37 deletions radio/src/gui/colorlcd/list_line_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,45 +62,39 @@ void ListLineButton::checkEvents()
}

// total: 92 x 17
#define FM_CANVAS_HEIGHT 17
#define FM_CANVAS_WIDTH 92

#if LCD_W > LCD_H // Landscape

#define BTN_W 389

#define SRC_W 70
#define OPT_W 171
#define FM_X (OPT_X + OPT_W + 2)
#define FM_Y (WGT_Y + 2)

#else // Portrait

#define BTN_W 229

#define SRC_W 69
#define OPT_W 106
LAYOUT_VAL1(FM_CANVAS_HEIGHT, 17)
LAYOUT_VAL3(FM_CANVAS_WIDTH, 90, 57, 90)

LAYOUT_VAL3(BTN_W, 389, 258, 229)
LAYOUT_VAL2(SRC_W, 70, 69)
LAYOUT_VAL3(OPT_W, 171, 116, 106)
LAYOUT_VAL3(LN_X, 73, 48, 73)

#if !PORTRAIT_LCD
#define FM_X (OPT_X + OPT_W + PAD_TINY)
#define FM_Y (WGT_Y + PAD_TINY)
#else
#define FM_X 12
#define FM_Y (WGT_Y + WGT_H + 2)

#define FM_Y (WGT_Y + WGT_H + PAD_TINY)
#endif
LAYOUT_VAL3(FM_W, 8, 5, 8)

#define WGT_X 2
#define WGT_Y 2
#define WGT_W 42
#define WGT_H 21
#define SRC_X (WGT_X + WGT_W + 2)
#define WGT_X PAD_TINY
#define WGT_Y PAD_TINY
LAYOUT_VAL1(WGT_W, 42)
LAYOUT_VAL1(WGT_H, 21)
#define SRC_X (WGT_X + WGT_W + PAD_TINY)
#define SRC_Y WGT_Y
#define SRC_H WGT_H
#define OPT_X (SRC_X + SRC_W + 2)
#define OPT_X (SRC_X + SRC_W + PAD_TINY)
#define OPT_Y WGT_Y
#define OPT_H WGT_H

InputMixButtonBase::InputMixButtonBase(Window* parent, uint8_t index) :
ListLineButton(parent, index)
{
setWidth(BTN_W);
setHeight(BTN_H);
setHeight(IM_BTN_H);
padAll(PAD_ZERO);

weight = lv_label_create(lvobj);
Expand Down Expand Up @@ -146,8 +140,8 @@ void InputMixButtonBase::setFlightModes(uint16_t modes)
free(fm_buffer);
fm_canvas = nullptr;
fm_buffer = nullptr;
#if LCD_H > LCD_W
setHeight(BTN_H);
#if PORTRAIT_LCD
setHeight(IM_BTN_H);
#endif
return;
}
Expand All @@ -158,8 +152,8 @@ void InputMixButtonBase::setFlightModes(uint16_t modes)
lv_canvas_set_buffer(fm_canvas, fm_buffer, FM_CANVAS_WIDTH,
FM_CANVAS_HEIGHT, LV_IMG_CF_ALPHA_8BIT);
lv_obj_set_pos(fm_canvas, FM_X, FM_Y);
#if LCD_H > LCD_W
setHeight(BTN_H + FM_CANVAS_HEIGHT + 2);
#if PORTRAIT_LCD
setHeight(IM_BTN_H + FM_CANVAS_HEIGHT + 2);
#endif

lv_obj_set_style_img_recolor(fm_canvas, makeLvColor(COLOR_THEME_SECONDARY1),
Expand All @@ -175,7 +169,7 @@ void InputMixButtonBase::setFlightModes(uint16_t modes)

coord_t x = 0;
lv_canvas_copy_buf(fm_canvas, mask->data, x, 0, w, h);
x += 20;
x += (w + PAD_TINY);

lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc);
Expand All @@ -193,11 +187,11 @@ void InputMixButtonBase::setFlightModes(uint16_t modes)
if (fm_modes & (1 << i)) {
label_dsc.color = lv_color_make(0x7f, 0x7f, 0x7f);
} else {
lv_canvas_draw_rect(fm_canvas, x, 0, 8, 3, &rect_dsc);
lv_canvas_draw_rect(fm_canvas, x, 0, FM_W, 3, &rect_dsc);
label_dsc.color = lv_color_white();
}
lv_canvas_draw_text(fm_canvas, x, 0, 8, &label_dsc, s);
x += 8;
lv_canvas_draw_text(fm_canvas, x, 0, FM_W, &label_dsc, s);
x += FM_W;
}
}

Expand All @@ -212,7 +206,7 @@ static const lv_obj_class_t group_class = {
.destructor_cb = nullptr,
.user_data = nullptr,
.event_cb = nullptr,
.width_def = LCD_W - 12,
.width_def = IM_GRP_W,
.height_def = LV_SIZE_CONTENT,
.editable = LV_OBJ_CLASS_EDITABLE_FALSE,
.group_def = LV_OBJ_CLASS_GROUP_DEF_FALSE,
Expand All @@ -238,7 +232,7 @@ InputMixGroupBase::InputMixGroupBase(Window* parent, mixsrc_t idx) :

void InputMixGroupBase::adjustHeight()
{
if (getLineCount() == 0) setHeight(InputMixButtonBase::BTN_H + 8);
if (getLineCount() == 0) setHeight(IM_BTN_H + 8);

coord_t y = 2;
for (auto it = lines.cbegin(); it != lines.cend(); ++it) {
Expand Down
7 changes: 3 additions & 4 deletions radio/src/gui/colorlcd/list_line_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include "opentx_types.h"
#include "tabsgroup.h"

LAYOUT_VAL1(IM_BTN_H, 29)
#define IM_GRP_W (LCD_W - PAD_MEDIUM * 2)

class ListLineButton : public ButtonBase
{
public:
Expand Down Expand Up @@ -53,8 +56,6 @@ class InputMixButtonBase : public ListLineButton
void setSource(mixsrc_t idx);
void setFlightModes(uint16_t modes);

static constexpr coord_t BTN_H = 29;

virtual void updatePos(coord_t x, coord_t y) = 0;
virtual void swapLvglGroup(InputMixButtonBase* line2) = 0;

Expand Down Expand Up @@ -84,8 +85,6 @@ class InputMixGroupBase : public Window
void refresh();

protected:
static constexpr coord_t LN_X = 73;

mixsrc_t idx;
lv_obj_t* label;
std::list<InputMixButtonBase*> lines;
Expand Down
64 changes: 26 additions & 38 deletions radio/src/gui/colorlcd/model_flightmodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,42 +200,30 @@ class FlightModeEdit : public Page
uint8_t index;
};

#if LCD_W > LCD_H // Landscape

#define BTN_H 36
#define FMID_W 36
#define NAME_W 95
#define NAME_Y 8
#define SWTCH_Y 6
#define MAX_FMTRIMS 6
#define TRIM_W 30
#define TRIM_X (SWTCH_X + SWTCH_W + 2)
#define TRIM_Y 0
#define FADE_Y 6

#else // Portrait

#define BTN_H 56
#define FMID_W 46
#define NAME_W 160
#define NAME_Y 0
#define SWTCH_Y 0
#define MAX_FMTRIMS 4
#define TRIM_W 40
#define TRIM_X (FMID_X + FMID_W + 2)
#define TRIM_Y 20
#define FADE_Y 24

LAYOUT_VAL2(BTN_H, 36, 56)
#define FMID_X PAD_TINY
LAYOUT_VAL3(FMID_Y, 6, 3, 16)
LAYOUT_VAL2(FMID_W, 36, 46)
#define NAME_X (FMID_X + FMID_W + PAD_TINY)
LAYOUT_VAL3(NAME_Y, 8, 3, 0)
LAYOUT_VAL2(NAME_W, 95, 160)
#define SWTCH_X (NAME_X + NAME_W + PAD_TINY)
LAYOUT_VAL3(SWTCH_Y, 6, 3, 0)
LAYOUT_VAL1(SWTCH_W, 50)
LAYOUT_VAL3(MAX_FMTRIMS, 6, 6, 4)
#if PORTRAIT_LCD
#define TRIM_X (FMID_X + FMID_W + PAD_TINY)
#else
#define TRIM_X (SWTCH_X + SWTCH_W + PAD_TINY)
#endif

#define FMID_X 2
#define FMID_Y (BTN_H / 2 - 12)
#define NAME_X (FMID_X + FMID_W + 2)
#define SWTCH_W 50
#define SWTCH_X (NAME_X + NAME_W + 2)
LAYOUT_VAL3(TRIM_Y, 0, -1, 20)
LAYOUT_VAL2(TRIM_W, 30, 40)
#define TRIMC_W (MAX_FMTRIMS * TRIM_W)
#define FADE_W 45
#define FADE_X (TRIM_X + TRIMC_W + 2)
LAYOUT_VAL3(TRIM_H, 16, 11, 16)
#define FADE_X (TRIM_X + TRIMC_W + PAD_TINY)
LAYOUT_VAL3(FADE_Y, 6, 3, 24)
LAYOUT_VAL1(FADE_W, 45)
LAYOUT_VAL1(TRIM_CHK_H, 40)

static void fm_id_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
{
Expand Down Expand Up @@ -394,7 +382,7 @@ class FlightModeBtn : public ListLineButton
fmTrimMode[i] = etx_create(&fm_trim_mode_class, lvobj);
lv_obj_set_pos(fmTrimMode[i], TRIM_X + i * TRIM_W, TRIM_Y);
fmTrimValue[i] = etx_create(&fm_trim_value_class, lvobj);
lv_obj_set_pos(fmTrimValue[i], TRIM_X + i * TRIM_W, TRIM_Y + 16);
lv_obj_set_pos(fmTrimValue[i], TRIM_X + i * TRIM_W, TRIM_Y + TRIM_H);
}

fmFadeIn = etx_create(&fm_fade_class, lvobj);
Expand Down Expand Up @@ -502,8 +490,8 @@ void ModelFlightModesPage::build(Window* form)

for (int i = 0; i < MAX_FLIGHT_MODES; i++) {
auto btn = new FlightModeBtn(form, i);
lv_obj_set_pos(btn->getLvObj(), 6, i * (BTN_H + 3) + 4);
btn->setWidth(LCD_W - 12);
lv_obj_set_pos(btn->getLvObj(), PAD_MEDIUM, i * (BTN_H + 3) + 4);
btn->setWidth(IM_GRP_W);

btn->setPressHandler([=]() {
new FlightModeEdit(i);
Expand All @@ -512,7 +500,7 @@ void ModelFlightModesPage::build(Window* form)
}

trimCheck = new TextButton(
form, rect_t{6, MAX_FLIGHT_MODES * (BTN_H + 3) + 8, LCD_W - 12, 40}, STR_CHECKTRIMS, [&]() -> uint8_t {
form, rect_t{6, MAX_FLIGHT_MODES * (BTN_H + 3) + PAD_LARGE, IM_GRP_W, TRIM_CHK_H}, STR_CHECKTRIMS, [&]() -> uint8_t {
if (trimsCheckTimer)
trimsCheckTimer = 0;
else
Expand Down
19 changes: 9 additions & 10 deletions radio/src/gui/colorlcd/model_gvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

#define SET_DIRTY() storageDirty(EE_MODEL)

LAYOUT_VAL3(BTN_H, 38, 26, 72)
LAYOUT_VAL3(BTN_H, 38, 26, (modelFMEnabled() ? 72 : 38))
LAYOUT_VAL3(GVAR_NM_Y, 7, 4, (modelFMEnabled() ? 24 : 7))
LAYOUT_VAL2(GVAR_VAL_W, 45, 50)
LAYOUT_VAL1(GVAR_NAME_SIZE, 44)

Expand All @@ -39,8 +40,6 @@ LAYOUT_VAL1(GVAR_NAME_SIZE, 44)
#if !PORTRAIT_LCD
#define GVAR_COLS MAX_FLIGHT_MODES
#else
#define BTN_H (modelFMEnabled() ? 72 : 38)
#define GVAR_VAL_W 50
#define GVAR_COLS 5
#endif

Expand Down Expand Up @@ -73,7 +72,7 @@ static const lv_obj_class_t gv_label_class = {
.user_data = nullptr,
.event_cb = nullptr,
.width_def = GVAR_VAL_W,
.height_def = PAGE_LINE_HEIGHT - 6,
.height_def = PAGE_LINE_HEIGHT - PAD_MEDIUM,
.editable = LV_OBJ_CLASS_EDITABLE_INHERIT,
.group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT,
.instance_size = sizeof(lv_label_t),
Expand Down Expand Up @@ -164,7 +163,7 @@ class GVarButton : public ListLineButton

auto nm = lv_label_create(lvobj);
lv_label_set_text(nm, getGVarString(index));
lv_obj_set_pos(nm, 2, (BTN_H - PAGE_LINE_HEIGHT - 4) / 2);
lv_obj_set_pos(nm, PAD_TINY, GVAR_NM_Y);
lv_obj_set_size(nm, GVAR_NAME_SIZE, PAGE_LINE_HEIGHT);

if (modelFMEnabled()) {
Expand All @@ -175,12 +174,12 @@ class GVarButton : public ListLineButton

labelTexts[flightMode] = etx_create(&gv_label_class, lvobj);
lv_label_set_text(labelTexts[flightMode], label);
lv_obj_set_pos(labelTexts[flightMode], (flightMode % GVAR_COLS) * GVAR_VAL_W + GVAR_NAME_SIZE + 4,
lv_obj_set_pos(labelTexts[flightMode], (flightMode % GVAR_COLS) * GVAR_VAL_W + GVAR_NAME_SIZE + PAD_SMALL,
(flightMode / GVAR_COLS) * GVAR_VAL_H);

valueTexts[flightMode] = etx_create(&gv_value_class, lvobj);
lv_obj_set_pos(valueTexts[flightMode], (flightMode % GVAR_COLS) * GVAR_VAL_W + GVAR_NAME_SIZE + 4,
(flightMode / GVAR_COLS) * GVAR_VAL_H + PAGE_LINE_HEIGHT - 6);
lv_obj_set_pos(valueTexts[flightMode], (flightMode % GVAR_COLS) * GVAR_VAL_W + GVAR_NAME_SIZE + PAD_SMALL,
(flightMode / GVAR_COLS) * GVAR_VAL_H + PAGE_LINE_HEIGHT - PAD_MEDIUM);

if (flightMode == currentFlightMode) {
lv_obj_add_state(valueTexts[flightMode], LV_STATE_CHECKED);
Expand All @@ -191,7 +190,7 @@ class GVarButton : public ListLineButton
}
} else {
valueTexts[0] = lv_label_create(lvobj);
lv_obj_set_pos(valueTexts[0], GVAR_NAME_SIZE + 6, (BTN_H - PAGE_LINE_HEIGHT - 4) / 2);
lv_obj_set_pos(valueTexts[0], GVAR_NAME_SIZE + PAD_MEDIUM, (BTN_H - PAGE_LINE_HEIGHT - PAD_SMALL) / 2);

updateValueText(0);
}
Expand Down Expand Up @@ -484,7 +483,7 @@ void ModelGVarsPage::rebuild(Window* window)

void ModelGVarsPage::build(Window* window)
{
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY_GAP);

for (uint8_t index = 0; index < MAX_GVARS; index++) {
auto button = new GVarButton(window, rect_t{}, index);
Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/colorlcd/model_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ void ModelInputsPage::build(Window* window)
// reset clipboard
_copyMode = 0;

window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);

form = new Window(window, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);
form->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);

auto btn = new TextButton(window, rect_t{}, LV_SYMBOL_PLUS, [=]() {
newInput();
Expand Down
Loading

0 comments on commit 39d83af

Please sign in to comment.