From d99491468c1c8eb227e4dab2375125e78afe3506 Mon Sep 17 00:00:00 2001 From: philmoz Date: Fri, 26 Apr 2024 21:19:35 +1000 Subject: [PATCH] Cleanup layout code. --- radio/src/gui/colorlcd/channel_bar.cpp | 18 +- radio/src/gui/colorlcd/channel_bar.h | 17 +- radio/src/gui/colorlcd/color_editor.cpp | 27 +- radio/src/gui/colorlcd/color_editor.h | 9 + radio/src/gui/colorlcd/color_picker.cpp | 31 +- radio/src/gui/colorlcd/custom_failsafe.cpp | 4 +- radio/src/gui/colorlcd/file_carosell.cpp | 2 +- radio/src/gui/colorlcd/fm_matrix.cpp | 4 +- radio/src/gui/colorlcd/fm_matrix.h | 2 + radio/src/gui/colorlcd/gvar_numberedit.cpp | 2 - radio/src/gui/colorlcd/gvar_numberedit.h | 6 +- radio/src/gui/colorlcd/hw_inputs.cpp | 37 +-- radio/src/gui/colorlcd/hw_inputs.h | 19 ++ radio/src/gui/colorlcd/hw_serial.cpp | 3 - radio/src/gui/colorlcd/hw_serial.h | 3 + radio/src/gui/colorlcd/input_edit.cpp | 3 - radio/src/gui/colorlcd/input_edit.h | 3 + radio/src/gui/colorlcd/layout.h | 10 +- .../colorlcd/layouts/layout_factory_impl.h | 5 +- radio/src/gui/colorlcd/layouts/sliders.cpp | 36 +-- radio/src/gui/colorlcd/layouts/sliders.h | 23 +- .../src/gui/colorlcd/layouts/topbar_impl.cpp | 12 +- radio/src/gui/colorlcd/layouts/topbar_impl.h | 8 + radio/src/gui/colorlcd/layouts/trims.cpp | 42 +-- radio/src/gui/colorlcd/list_line_button.cpp | 41 +-- radio/src/gui/colorlcd/list_line_button.h | 28 +- radio/src/gui/colorlcd/listbox.h | 2 + radio/src/gui/colorlcd/menu_model.cpp | 13 - radio/src/gui/colorlcd/menu_model.h | 4 - radio/src/gui/colorlcd/mixer_edit.cpp | 8 +- radio/src/gui/colorlcd/mixer_edit.h | 3 + radio/src/gui/colorlcd/mixer_edit_adv.cpp | 6 +- radio/src/gui/colorlcd/mixer_edit_adv.h | 2 + radio/src/gui/colorlcd/model_curves.cpp | 14 +- radio/src/gui/colorlcd/model_flightmodes.cpp | 288 +++++++++--------- radio/src/gui/colorlcd/model_flightmodes.h | 2 + radio/src/gui/colorlcd/model_gvars.cpp | 114 ++++--- .../gui/colorlcd/model_logical_switches.cpp | 71 ++--- radio/src/gui/colorlcd/model_mixes.cpp | 23 +- radio/src/gui/colorlcd/model_outputs.cpp | 100 +++--- radio/src/gui/colorlcd/model_outputs.h | 17 ++ radio/src/gui/colorlcd/model_select.cpp | 42 +-- radio/src/gui/colorlcd/model_select.h | 11 + radio/src/gui/colorlcd/model_setup.cpp | 10 +- radio/src/gui/colorlcd/model_telemetry.cpp | 41 ++- radio/src/gui/colorlcd/model_telemetry.h | 2 + radio/src/gui/colorlcd/model_templates.cpp | 6 +- radio/src/gui/colorlcd/model_usbjoystick.cpp | 2 +- radio/src/gui/colorlcd/output_edit.cpp | 8 +- radio/src/gui/colorlcd/output_edit.h | 3 + radio/src/gui/colorlcd/page.cpp | 12 +- radio/src/gui/colorlcd/page.h | 3 + radio/src/gui/colorlcd/preflight_checks.cpp | 16 +- radio/src/gui/colorlcd/preview_window.cpp | 33 +- radio/src/gui/colorlcd/preview_window.h | 24 ++ radio/src/gui/colorlcd/radio_calibration.cpp | 6 +- radio/src/gui/colorlcd/radio_diagkeys.cpp | 16 +- .../colorlcd/radio_ghost_module_config.cpp | 2 +- radio/src/gui/colorlcd/radio_hardware.cpp | 2 - radio/src/gui/colorlcd/radio_hardware.h | 2 + radio/src/gui/colorlcd/radio_setup.cpp | 14 +- radio/src/gui/colorlcd/radio_theme.cpp | 56 ++-- radio/src/gui/colorlcd/radio_theme.h | 7 + radio/src/gui/colorlcd/radio_tools.cpp | 2 + radio/src/gui/colorlcd/radio_trainer.cpp | 2 - radio/src/gui/colorlcd/radio_trainer.h | 2 + radio/src/gui/colorlcd/screen_setup.cpp | 2 +- .../src/gui/colorlcd/select_fab_carousel.cpp | 23 +- radio/src/gui/colorlcd/select_fab_carousel.h | 11 +- radio/src/gui/colorlcd/special_functions.cpp | 33 +- radio/src/gui/colorlcd/special_functions.h | 22 ++ radio/src/gui/colorlcd/standalone_lua.cpp | 2 +- radio/src/gui/colorlcd/startup_shutdown.cpp | 2 +- radio/src/gui/colorlcd/tabsgroup.cpp | 51 ++-- radio/src/gui/colorlcd/tabsgroup.h | 9 +- radio/src/gui/colorlcd/theme.cpp | 3 +- radio/src/gui/colorlcd/theme.h | 6 + radio/src/gui/colorlcd/themes/etx_lv_theme.h | 68 +---- radio/src/gui/colorlcd/topbar.h | 5 - radio/src/gui/colorlcd/view_channels.cpp | 2 +- .../gui/colorlcd/view_logical_switches.cpp | 12 +- .../src/gui/colorlcd/view_logical_switches.h | 5 + .../src/gui/colorlcd/view_main_decoration.cpp | 16 +- radio/src/gui/colorlcd/view_main_menu.cpp | 10 +- radio/src/gui/colorlcd/widgets/radio_info.cpp | 40 +-- radio/src/gui/colorlcd/widgets/timer.cpp | 30 +- radio/src/gui/colorlcd/widgets/value.cpp | 4 +- radio/src/gui/colorlcd/widgets_container.h | 2 +- radio/src/lua/api_general.cpp | 2 +- radio/src/opentx.h | 2 + .../libopenui/src/bitmapbuffer_draw_extra.cpp | 4 +- radio/src/thirdparty/libopenui/src/button.cpp | 6 +- radio/src/thirdparty/libopenui/src/choice.cpp | 2 +- radio/src/thirdparty/libopenui/src/dialog.h | 2 +- .../thirdparty/libopenui/src/menutoolbar.cpp | 2 - .../thirdparty/libopenui/src/menutoolbar.h | 9 + .../thirdparty/libopenui/src/numberedit.cpp | 4 +- .../src/thirdparty/libopenui/src/numberedit.h | 2 + .../src/thirdparty/libopenui/src/progress.cpp | 2 +- .../src/thirdparty/libopenui/src/textedit.cpp | 4 +- radio/src/thirdparty/libopenui/src/textedit.h | 2 + .../thirdparty/libopenui/src/toggleswitch.cpp | 6 +- .../thirdparty/libopenui/src/toggleswitch.h | 4 +- radio/src/thirdparty/libopenui/src/window.cpp | 2 +- 104 files changed, 893 insertions(+), 906 deletions(-) diff --git a/radio/src/gui/colorlcd/channel_bar.cpp b/radio/src/gui/colorlcd/channel_bar.cpp index f7baa91733f..e9f00953690 100644 --- a/radio/src/gui/colorlcd/channel_bar.cpp +++ b/radio/src/gui/colorlcd/channel_bar.cpp @@ -29,12 +29,6 @@ #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 getValueFunc, LcdFlags barColor, LcdFlags txtColor) : @@ -216,8 +210,6 @@ void OutputChannelBar::checkEvents() //----------------------------------------------------------------------------- -LAYOUT_VAL3(ICON_SZ, 25, 16, 25) - ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect, uint8_t _channel, bool isInHeader) : Window(parent, rect), channel(_channel) @@ -226,31 +218,31 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect, isInHeader ? COLOR_THEME_PRIMARY2 : COLOR_THEME_SECONDARY1; outputChannelBar = new OutputChannelBar( - this, {LMARGIN, BAR_HEIGHT + TMARGIN, width() - LMARGIN, BAR_HEIGHT}, + this, {ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT + ChannelBar::TMARGIN, width() - ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT}, channel, isInHeader); new MixerChannelBar( this, - {LMARGIN, (2 * BAR_HEIGHT) + TMARGIN + 1, width() - LMARGIN, BAR_HEIGHT}, + {ChannelBar::LMARGIN, (2 * ChannelBar::BAR_HEIGHT) + ChannelBar::TMARGIN + 1, width() - ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT}, channel); // Channel number char chanString[] = TR_CH "32 "; strAppendSigned(&chanString[2], channel + 1, 2); - new StaticText(this, {LMARGIN, 0, LV_SIZE_CONTENT, 12}, chanString, + new StaticText(this, {ChannelBar::LMARGIN, 0, LV_SIZE_CONTENT, 12}, chanString, textColor | FONT(XS) | LEFT); // Channel name if (g_model.limitData[channel].name[0]) { char nm[LEN_CHANNEL_NAME + 1]; strAppend(nm, g_model.limitData[channel].name, LEN_CHANNEL_NAME); - new StaticText(this, {LMARGIN + VAL_W, 0, LV_SIZE_CONTENT, VAL_H}, nm, + new StaticText(this, {ChannelBar::LMARGIN + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm, textColor | FONT(XS) | LEFT); } // Channel value in µS new DynamicNumber( - this, {width() - VAL_W, 0, VAL_W, VAL_H}, + this, {width() - ChannelBar::VAL_W, 0, ChannelBar::VAL_W, ChannelBar::VAL_H}, [=] { return PPM_CH_CENTER(channel) + channelOutputs[channel] / 2; }, textColor | FONT(XS) | RIGHT, "", STR_US); diff --git a/radio/src/gui/colorlcd/channel_bar.h b/radio/src/gui/colorlcd/channel_bar.h index 28c6ced957f..b981f24569f 100644 --- a/radio/src/gui/colorlcd/channel_bar.h +++ b/radio/src/gui/colorlcd/channel_bar.h @@ -23,11 +23,6 @@ #include "opentx.h" -LAYOUT_VAL1(ROW_HEIGHT, 42) -LAYOUT_VAL3(BAR_HEIGHT, 13, 9, 13) -LAYOUT_VAL1(LMARGIN, 15) -constexpr coord_t TMARGIN = 2; - class ChannelBar : public Window { public: @@ -35,6 +30,16 @@ class ChannelBar : public Window std::function getValue, LcdFlags barColor, LcdFlags textColor = COLOR_THEME_SECONDARY1); + static LAYOUT_VAL(BAR_HEIGHT, 13, 13, 9) + static LAYOUT_VAL(LMARGIN, 15, 15, LS(15)) + static LAYOUT_VAL(TMARGIN, 2, 2, 2) + + static LAYOUT_VAL(VAL_W, 45, 45, LS(45)) + static LAYOUT_VAL(VAL_H, 12, 12, LS(12)) + static LAYOUT_VAL(VAL_XO, 5, 5, LS(5)) + static LAYOUT_VAL(VAL_YO, -2, -2, LS(-2)) + static LAYOUT_VAL(VAL_XT, -54, -54, LS(-54)) + protected: int16_t value = -10000; std::function getValue; @@ -78,6 +83,8 @@ class ComboChannelBar : public Window ComboChannelBar(Window* parent, const rect_t& rect, uint8_t channel, bool isInHeader = false); + static LAYOUT_VAL(ICON_SZ, 25, 25, 16) + protected: uint8_t channel; OutputChannelBar* outputChannelBar = nullptr; diff --git a/radio/src/gui/colorlcd/color_editor.cpp b/radio/src/gui/colorlcd/color_editor.cpp index 925bbf8d01c..0757abfe55a 100644 --- a/radio/src/gui/colorlcd/color_editor.cpp +++ b/radio/src/gui/colorlcd/color_editor.cpp @@ -23,13 +23,6 @@ #include "button.h" #include "themes/etx_lv_theme.h" -LAYOUT_VAL3(BAR_MARGIN, 5, 4, 5) -LAYOUT_VAL3(BAR_TOP_MARGIN, 5, 4, 5) -LAYOUT_VAL3(BAR_HEIGHT_OFFSET, 25, 16, 25) -LAYOUT_VAL3(LBL_YO, 9, 5, 9) -LAYOUT_VAL3(VAL_XO, 10, 6, 10) -LAYOUT_VAL1(VAL_YO, 3) - static const char* const RGBChars[MAX_BARS] = {"R", "G", "B"}; static const char* const HSVChars[MAX_BARS] = {"H", "S", "V"}; @@ -172,12 +165,12 @@ class ColorBar : public Window // draw cursor lv_area_t cursor_area; - cursor_area.x1 = area->x1 + (lv_area_get_width(area) / 2) - 5; - cursor_area.x2 = cursor_area.x1 + 10 - 1; + cursor_area.x1 = area->x1 + (lv_area_get_width(area) / 2) - ColorEditor::CRSR_SZ / 2; + cursor_area.x2 = cursor_area.x1 + ColorEditor::CRSR_SZ - 1; auto pos = bar->valueToScreen(bar->value); - cursor_area.y1 = area->y1 + pos - 3; - cursor_area.y2 = cursor_area.y1 + 10 - 1; + cursor_area.y1 = area->y1 + pos - ColorEditor::CRSR_YO; + cursor_area.y2 = cursor_area.y1 + ColorEditor::CRSR_SZ - 1; lv_draw_rect_dsc_t cursor_dsc; lv_draw_rect_dsc_init(&cursor_dsc); @@ -276,12 +269,12 @@ BarColorType::BarColorType(Window* parent) int leftPos = 0; rect_t r; - r.y = BAR_TOP_MARGIN; - r.w = spacePerBar - BAR_MARGIN - 5; - r.h = parent->height() - (BAR_TOP_MARGIN + BAR_HEIGHT_OFFSET); + r.y = ColorEditor::BAR_TOP_MARGIN; + r.w = spacePerBar - ColorEditor::BAR_MARGIN - 5; + r.h = parent->height() - (ColorEditor::BAR_TOP_MARGIN + ColorEditor::BAR_HEIGHT_OFFSET); for (int i = 0; i < MAX_BARS; i++) { - r.x = leftPos + BAR_MARGIN; + r.x = leftPos + ColorEditor::BAR_MARGIN; bars[i] = new ColorBar(parent, r); leftPos += spacePerBar; @@ -291,8 +284,8 @@ BarColorType::BarColorType(Window* parent) auto x = bar->left(); auto y = bar->bottom(); - barLabels[i] = create_bar_label(parent->getLvObj(), x, y + LBL_YO); - barValLabels[i] = create_bar_value_label(parent->getLvObj(), x + VAL_XO, y + VAL_YO); + barLabels[i] = create_bar_label(parent->getLvObj(), x, y + ColorEditor::LBL_YO); + barValLabels[i] = create_bar_value_label(parent->getLvObj(), x + ColorEditor::VAL_XO, y + ColorEditor::VAL_YO); } } diff --git a/radio/src/gui/colorlcd/color_editor.h b/radio/src/gui/colorlcd/color_editor.h index 2c3f0e7d866..b9ac5db1295 100644 --- a/radio/src/gui/colorlcd/color_editor.h +++ b/radio/src/gui/colorlcd/color_editor.h @@ -45,6 +45,15 @@ class ColorEditor : public Window void setColorEditorType(COLOR_EDITOR_TYPE colorType); + static LAYOUT_VAL(BAR_MARGIN, 5, 5, 4) + static LAYOUT_VAL(BAR_TOP_MARGIN, 5, 5, 4) + static LAYOUT_VAL(BAR_HEIGHT_OFFSET, 25, 25, 16) + static LAYOUT_VAL(LBL_YO, 9, 9, 5) + static LAYOUT_VAL(VAL_XO, 10, 10, 6) + static LAYOUT_VAL(VAL_YO, 3, 3, LS(3)) + static LAYOUT_VAL(CRSR_SZ, 10, 10, 8) + static LAYOUT_VAL(CRSR_YO, 3, 3, 2) + protected: ColorType* _colorType = nullptr; std::function _setValue; diff --git a/radio/src/gui/colorlcd/color_picker.cpp b/radio/src/gui/colorlcd/color_picker.cpp index 2f2b8654e17..81aafebff24 100644 --- a/radio/src/gui/colorlcd/color_picker.cpp +++ b/radio/src/gui/colorlcd/color_picker.cpp @@ -25,26 +25,18 @@ #include "color_list.h" #include "themes/etx_lv_theme.h" -// based on LVGL default switch size -constexpr lv_coord_t COLOR_PAD_WIDTH = (4 * LV_DPI_DEF) / 10; -constexpr lv_coord_t COLOR_PAD_HEIGHT = 32; - #if !PORTRAIT_LCD // Landscape static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; -#define COLOR_EDIT_WIDTH LCD_W * 0.8 - #else // Portrait static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; -#define COLOR_EDIT_WIDTH LCD_W * 0.7 - #endif class ColorEditorPopup : public BaseDialog @@ -74,7 +66,7 @@ class ColorEditorPopup : public BaseDialog FlexGridLayout grid(col_dsc, row_dsc); auto line = form->newLine(grid); - rect_t r{0, 0, 7 * LV_DPI_DEF / 5, 7 * LV_DPI_DEF / 5}; + rect_t r{0, 0, CE_SZ, CE_SZ}; auto cedit = new ColorEditor(line, r, color, [=](uint32_t c) { updateColor(c); }); lv_obj_set_style_grid_cell_x_align(cedit->getLvObj(), LV_GRID_ALIGN_CENTER, @@ -94,7 +86,7 @@ class ColorEditorPopup : public BaseDialog colorPad = new ColorSwatch(hbox, {0, 0, COLOR_PAD_WIDTH, COLOR_PAD_HEIGHT}, COLOR_THEME_PRIMARY1); - hexStr = new StaticText(hbox, {0, 0, 100, 0}, "", COLOR_THEME_PRIMARY1 | FONT(L)); + hexStr = new StaticText(hbox, {0, 0, CVAL_W, 0}, "", COLOR_THEME_PRIMARY1 | FONT(L)); updateColor(color); @@ -135,29 +127,38 @@ class ColorEditorPopup : public BaseDialog hsvBtn->check(true); hbox = new Window(vbox, rect_t{}); - hbox->padTop(60); - hbox->setFlexLayout(LV_FLEX_FLOW_ROW, 20); + hbox->padTop(BTN_PAD_TOP); + hbox->setFlexLayout(LV_FLEX_FLOW_ROW, BTN_PAD_ROW); lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_SPACE_BETWEEN); lv_obj_set_flex_grow(hbox->getLvObj(), 1); - new TextButton(hbox, rect_t{0, 0, 80, 0}, STR_CANCEL, [=]() -> int8_t { + new TextButton(hbox, rect_t{0, 0, BTN_W, 0}, STR_CANCEL, [=]() -> int8_t { this->deleteLater(); return 0; }); - new TextButton(hbox, rect_t{0, 0, 80, 0}, STR_SAVE, [=]() -> int8_t { + new TextButton(hbox, rect_t{0, 0, BTN_W, 0}, STR_SAVE, [=]() -> int8_t { if (_setValue) _setValue(m_color); this->deleteLater(); return 0; }); } + + static LAYOUT_VAL(CE_SZ, 182, 182, LS(182)) + static LAYOUT_VAL(COLOR_EDIT_WIDTH, LCD_W * 0.8, LCD_W * 0.7, LCD_W * 0.8) + static LAYOUT_VAL(COLOR_PAD_WIDTH, 52, 52, LS(52)) + static LAYOUT_VAL(COLOR_PAD_HEIGHT, 32, 32, LS(32)) + static LAYOUT_VAL(CVAL_W, 100, 100, LS(100)) + static LAYOUT_VAL(BTN_W, 80, 80, LS(80)) + static LAYOUT_VAL(BTN_PAD_TOP, 60, 60, LS(60)) + static LAYOUT_VAL(BTN_PAD_ROW, 20, 20, LS(20)) }; ColorPicker::ColorPicker(Window* parent, const rect_t& rect, std::function getValue, std::function setValue) : - Button(parent, {0, 0, COLOR_PAD_WIDTH, COLOR_PAD_HEIGHT}), + Button(parent, {0, 0, ColorEditorPopup::COLOR_PAD_WIDTH, ColorEditorPopup::COLOR_PAD_HEIGHT}), setValue(std::move(setValue)) { updateColor(getValue()); diff --git a/radio/src/gui/colorlcd/custom_failsafe.cpp b/radio/src/gui/colorlcd/custom_failsafe.cpp index 8d07349b2f2..cbf0db9b7ec 100644 --- a/radio/src/gui/colorlcd/custom_failsafe.cpp +++ b/radio/src/gui/colorlcd/custom_failsafe.cpp @@ -36,12 +36,12 @@ class ChannelFailsafeBargraph : public Window etx_obj_add_style(lvobj, styles->border_thin, LV_PART_MAIN); etx_obj_add_style(lvobj, styles->border_color_black, LV_PART_MAIN); - outputsBar = new OutputChannelBar(this, {0, 1, width() - 2, BAR_HEIGHT}, + outputsBar = new OutputChannelBar(this, {0, 1, width() - 2, ChannelBar::BAR_HEIGHT}, channel, false, false); outputsBar->hide(); failsafeBar = new ChannelBar( - this, {0, BAR_HEIGHT + 3, width() - 2, BAR_HEIGHT}, + this, {0, ChannelBar::BAR_HEIGHT + 3, width() - 2, ChannelBar::BAR_HEIGHT}, [=] { return calcRESXto100(g_model.failsafeChannels[channel]); }, COLOR_THEME_WARNING, COLOR_THEME_WARNING); failsafeBar->hide(); diff --git a/radio/src/gui/colorlcd/file_carosell.cpp b/radio/src/gui/colorlcd/file_carosell.cpp index 595060a7841..c493c2c5e62 100644 --- a/radio/src/gui/colorlcd/file_carosell.cpp +++ b/radio/src/gui/colorlcd/file_carosell.cpp @@ -35,7 +35,7 @@ FileCarosell::FileCarosell(Window *parent, const rect_t &rect, { setWindowFlag(NO_FOCUS); - message = new StaticText(this, {0, rect.h/2, rect.w, PAGE_LINE_HEIGHT}, "", CENTERED | FONT(L) | COLOR_THEME_PRIMARY1); + message = new StaticText(this, {0, rect.h/2, rect.w, EdgeTxStyles::PAGE_LINE_HEIGHT}, "", CENTERED | FONT(L) | COLOR_THEME_PRIMARY1); setFileNames(fileNames); } diff --git a/radio/src/gui/colorlcd/fm_matrix.cpp b/radio/src/gui/colorlcd/fm_matrix.cpp index b291d17f500..bcd712a50dc 100644 --- a/radio/src/gui/colorlcd/fm_matrix.cpp +++ b/radio/src/gui/colorlcd/fm_matrix.cpp @@ -32,8 +32,6 @@ #define FM_ROWS 2 #endif -LAYOUT_VAL1(FM_BTN_W, 48) - template FMMatrix::FMMatrix(Window* parent, const rect_t& r, T* input) : ButtonMatrix(parent, r), input(input) @@ -47,7 +45,7 @@ FMMatrix::FMMatrix(Window* parent, const rect_t& r, T* input) : update(); lv_obj_set_width(lvobj, FM_COLS * (FM_BTN_W + 3) + 3); - lv_obj_set_height(lvobj, FM_ROWS * (UI_ELEMENT_HEIGHT + 3) +3); + lv_obj_set_height(lvobj, FM_ROWS * (EdgeTxStyles::UI_ELEMENT_HEIGHT + 3) +3); padAll(PAD_SMALL); } diff --git a/radio/src/gui/colorlcd/fm_matrix.h b/radio/src/gui/colorlcd/fm_matrix.h index 382b532c91d..dbe4a0e7578 100644 --- a/radio/src/gui/colorlcd/fm_matrix.h +++ b/radio/src/gui/colorlcd/fm_matrix.h @@ -33,6 +33,8 @@ struct FMMatrix : public ButtonMatrix { void onPress(uint8_t btn_id); bool isActive(uint8_t btn_id); void setTextAndState(uint8_t btn_id); + + static LAYOUT_VAL(FM_BTN_W, 48, 48, LS(48)) }; extern template struct FMMatrix; diff --git a/radio/src/gui/colorlcd/gvar_numberedit.cpp b/radio/src/gui/colorlcd/gvar_numberedit.cpp index 0f2251a6573..6cb7c7b8499 100644 --- a/radio/src/gui/colorlcd/gvar_numberedit.cpp +++ b/radio/src/gui/colorlcd/gvar_numberedit.cpp @@ -22,8 +22,6 @@ #include "gvar_numberedit.h" #include "opentx.h" -LAYOUT_VAL1(NUM_EDIT_W, 70) - void GVarNumberEdit::value_changed(lv_event_t* e) { auto obj = lv_event_get_target(e); diff --git a/radio/src/gui/colorlcd/gvar_numberedit.h b/radio/src/gui/colorlcd/gvar_numberedit.h index 7253965d409..0c35484a62c 100644 --- a/radio/src/gui/colorlcd/gvar_numberedit.h +++ b/radio/src/gui/colorlcd/gvar_numberedit.h @@ -26,8 +26,6 @@ #include "numberedit.h" #include "gvars.h" -constexpr coord_t GVAR_BUTTON_WIDTH = 30; - class TextButton; class GVarNumberEdit : public Window @@ -43,7 +41,9 @@ class GVarNumberEdit : public Window void setFastStep(int value) { num_field->setFastStep(value); } void setAccelFactor(int value) { num_field->setAccelFactor(value); } - + + static LAYOUT_VAL(NUM_EDIT_W, 70, 70, LS(70)) + protected: Choice* gvar_field = nullptr; NumberEdit* num_field = nullptr; diff --git a/radio/src/gui/colorlcd/hw_inputs.cpp b/radio/src/gui/colorlcd/hw_inputs.cpp index 58b2fd61744..1decc23720d 100644 --- a/radio/src/gui/colorlcd/hw_inputs.cpp +++ b/radio/src/gui/colorlcd/hw_inputs.cpp @@ -29,15 +29,15 @@ #define SET_DIRTY() storageDirty(EE_GENERAL) -LAYOUT_VAL1(HW_INP_W, 64) - struct HWInputEdit : public RadioTextEdit { HWInputEdit(Window* parent, char* name, size_t len, coord_t x = 0, coord_t y = 0) : - RadioTextEdit(parent, rect_t{x, y, HW_INP_W, UI_ELEMENT_HEIGHT}, name, + RadioTextEdit(parent, rect_t{x, y, HW_INP_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, name, len) { } + + static LAYOUT_VAL(HW_INP_W, 64, 64, LS(64)) }; static const lv_coord_t col_two_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2), @@ -80,20 +80,6 @@ HWSticks::HWSticks(Window* parent) : Window(parent, rect_t{}) #endif } -// Absolute layout for Pots popup - due to performance issues with lv_textarea -// in a flex layout -LAYOUT_VAL1(P_LBL_X, 0) -LAYOUT_VAL3(P_LBL_W, (DIALOG_DEFAULT_WIDTH - 45) * 2 / 11, (DIALOG_DEFAULT_WIDTH - 30) * 2 / 11, (DIALOG_DEFAULT_WIDTH - 18) * 13 / 21) -constexpr coord_t P_NM_X = P_LBL_X + P_LBL_W + PAD_MEDIUM; -LAYOUT_VAL1(P_NM_W, 70) -LAYOUT_VAL3(P_TYP_X, P_NM_X + P_NM_W, P_NM_X + P_NM_W, 0) -LAYOUT_VAL2(P_TYP_W, 160, P_LBL_W) -constexpr coord_t P_INV_X = P_TYP_X + P_TYP_W + PAD_MEDIUM; -LAYOUT_VAL1(P_INV_W, 52) -LAYOUT_VAL3(P_ROW_H, 36, 26, 72) -#define P_Y(i) (i * P_ROW_H + 2) -LAYOUT_VAL3(P_OFST_Y, 0, 0, 36) - HWPots::HWPots(Window* parent) : Window(parent, rect_t{0, 0, DIALOG_DEFAULT_WIDTH - 12, LV_SIZE_CONTENT}) { @@ -116,14 +102,14 @@ HWPots::HWPots(Window* parent) : // if (!globalData.flyskygimbals && (i >= (NUM_POTS - 2))) continue; // #endif new StaticText(this, - rect_t{P_LBL_X, P_Y(i) + 6, P_LBL_W, UI_ELEMENT_HEIGHT}, + rect_t{P_LBL_X, P_Y(i) + 6, P_LBL_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, adcGetInputLabel(ADC_INPUT_FLEX, i)); new HWInputEdit(this, (char*)analogGetCustomLabel(ADC_INPUT_FLEX, i), LEN_ANA_NAME, P_NM_X, P_Y(i)); auto pot = new Choice( - this, rect_t{P_TYP_X, P_Y(i) + P_OFST_Y, P_TYP_W, UI_ELEMENT_HEIGHT}, + this, rect_t{P_TYP_X, P_Y(i) + P_OFST_Y, P_TYP_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, STR_POTTYPES, FLEX_NONE, FLEX_SWITCH, [=]() -> int { return getPotType(i); }, [=](int newValue) { @@ -135,7 +121,7 @@ HWPots::HWPots(Window* parent) : pot->setAvailableHandler([=](int val) { return isPotTypeAvailable(val); }); new ToggleSwitch( - this, rect_t{P_INV_X, P_Y(i) + P_OFST_Y, P_INV_W, UI_ELEMENT_HEIGHT}, + this, rect_t{P_INV_X, P_Y(i) + P_OFST_Y, P_INV_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, [=]() -> uint8_t { return (uint8_t)getPotInversion(i); }, [=](int8_t newValue) { setPotInversion(i, newValue); @@ -144,16 +130,11 @@ HWPots::HWPots(Window* parent) : } } -// Absolute layout for Switches popup - due to performance issues with -// lv_textarea in a flex layout -LAYOUT_VAL2(SW_CTRL_W, 86, 75) -LAYOUT_VAL3(SW_CTRL_H, 36, 26, 36) - class SwitchDynamicLabel : public StaticText { public: SwitchDynamicLabel(Window* parent, uint8_t index, coord_t x, coord_t y) : - StaticText(parent, rect_t{x, y, SW_CTRL_W, UI_ELEMENT_HEIGHT}, ""), + StaticText(parent, rect_t{x, y, HWSwitches::SW_CTRL_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, ""), index(index) { checkEvents(); @@ -219,7 +200,7 @@ HWSwitches::HWSwitches(Window* parent) : Choice* channel = nullptr; if (switchIsFlex(i)) { channel = new Choice( - this, rect_t{x, i * SW_CTRL_H + 2, SW_CTRL_W, UI_ELEMENT_HEIGHT}, -1, + this, rect_t{x, i * SW_CTRL_H + 2, SW_CTRL_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, -1, adcGetMaxInputs(ADC_INPUT_FLEX) - 1, [=]() -> int { return switchGetFlexConfig(i); }, [=](int newValue) { switchConfigFlex(i, newValue); }); @@ -234,7 +215,7 @@ HWSwitches::HWSwitches(Window* parent) : } auto sw_cfg = new Choice( - this, rect_t{x, i * SW_CTRL_H + 2, SW_CTRL_W, UI_ELEMENT_HEIGHT}, + this, rect_t{x, i * SW_CTRL_H + 2, SW_CTRL_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, STR_SWTYPES, SWITCH_NONE, switchGetMaxType(i), [=]() -> int { return SWITCH_CONFIG(i); }, [=](int newValue) { diff --git a/radio/src/gui/colorlcd/hw_inputs.h b/radio/src/gui/colorlcd/hw_inputs.h index 7695bff2857..1f3a1da2596 100644 --- a/radio/src/gui/colorlcd/hw_inputs.h +++ b/radio/src/gui/colorlcd/hw_inputs.h @@ -32,10 +32,29 @@ struct HWSticks : public Window { struct HWPots : public Window { HWPots(Window* parent); bool potsChanged; + + // Absolute layout for Pots popup - due to performance issues with lv_textarea + // in a flex layout + static LAYOUT_VAL(P_LBL_X, 0, 0, 0) + static LAYOUT_VAL(P_LBL_W, (DIALOG_DEFAULT_WIDTH - 45) * 2 / 11, (DIALOG_DEFAULT_WIDTH - 18) * 13 / 21, (DIALOG_DEFAULT_WIDTH - 30) * 2 / 11) + static constexpr coord_t P_NM_X = P_LBL_X + P_LBL_W + PAD_MEDIUM; + static LAYOUT_VAL(P_NM_W, 70, 70, LS(70)) + static LAYOUT_VAL(P_TYP_X, P_NM_X + P_NM_W, 0, P_NM_X + P_NM_W) + static LAYOUT_VAL(P_TYP_W, 160, P_LBL_W, LS(160)) + static constexpr coord_t P_INV_X = P_TYP_X + P_TYP_W + PAD_MEDIUM; + static LAYOUT_VAL(P_INV_W, 52, 52, LS(52)) + static LAYOUT_VAL(P_ROW_H, 36, 72, 26) + static LAYOUT_VAL(P_OFST_Y, 0, 36, 0) + #define P_Y(i) (i * P_ROW_H + 2) }; struct HWSwitches : public Window { HWSwitches(Window* parent); + + // Absolute layout for Switches popup - due to performance issues with + // lv_textarea in a flex layout + static LAYOUT_VAL(SW_CTRL_W, 86, 75, LS(86)) + static LAYOUT_VAL(SW_CTRL_H, 36, 36, 26) }; template diff --git a/radio/src/gui/colorlcd/hw_serial.cpp b/radio/src/gui/colorlcd/hw_serial.cpp index 1852a5bd48a..bcab1fe3214 100644 --- a/radio/src/gui/colorlcd/hw_serial.cpp +++ b/radio/src/gui/colorlcd/hw_serial.cpp @@ -24,9 +24,6 @@ #define SET_DIRTY() storageDirty(EE_GENERAL) -LAYOUT_VAL1(WARN_PADL, 20); -LAYOUT_VAL1(WARN_PADB, 6); - SerialConfigWindow::SerialConfigWindow(Window *parent, FlexGridLayout& grid) { for (uint8_t port_nr = 0; port_nr < MAX_SERIAL_PORTS; port_nr++) { diff --git a/radio/src/gui/colorlcd/hw_serial.h b/radio/src/gui/colorlcd/hw_serial.h index e29dd772cdf..9ce1af58b81 100644 --- a/radio/src/gui/colorlcd/hw_serial.h +++ b/radio/src/gui/colorlcd/hw_serial.h @@ -27,4 +27,7 @@ class SerialConfigWindow { public: SerialConfigWindow(Window *parent, FlexGridLayout& grid); + + static LAYOUT_VAL(WARN_PADL, 20, 20, LS(20)); + static LAYOUT_VAL(WARN_PADB, 6, 6, LS(6)); }; diff --git a/radio/src/gui/colorlcd/input_edit.cpp b/radio/src/gui/colorlcd/input_edit.cpp index 9d1fb88b149..44969b22e73 100644 --- a/radio/src/gui/colorlcd/input_edit.cpp +++ b/radio/src/gui/colorlcd/input_edit.cpp @@ -32,9 +32,6 @@ #define SET_DIRTY() storageDirty(EE_MODEL) -LAYOUT_VAL3(INPUT_EDIT_CURVE_WIDTH, 140, 110, 176) -LAYOUT_VAL3(INPUT_EDIT_CURVE_HEIGHT, INPUT_EDIT_CURVE_WIDTH, INPUT_EDIT_CURVE_WIDTH, 132) - InputEditWindow::InputEditWindow(int8_t input, uint8_t index) : Page(ICON_MODEL_INPUTS), input(input), index(index) { diff --git a/radio/src/gui/colorlcd/input_edit.h b/radio/src/gui/colorlcd/input_edit.h index b6d4654dd38..b468fa83b96 100644 --- a/radio/src/gui/colorlcd/input_edit.h +++ b/radio/src/gui/colorlcd/input_edit.h @@ -32,6 +32,9 @@ class InputEditWindow : public Page public: InputEditWindow(int8_t input, uint8_t index); + static LAYOUT_VAL(INPUT_EDIT_CURVE_WIDTH, 140, 176, 110) + static LAYOUT_VAL(INPUT_EDIT_CURVE_HEIGHT, INPUT_EDIT_CURVE_WIDTH, 132, INPUT_EDIT_CURVE_WIDTH) + protected: uint8_t input; uint8_t index; diff --git a/radio/src/gui/colorlcd/layout.h b/radio/src/gui/colorlcd/layout.h index 451c0907a3f..7debd97ed72 100644 --- a/radio/src/gui/colorlcd/layout.h +++ b/radio/src/gui/colorlcd/layout.h @@ -29,10 +29,6 @@ #define MAX_LAYOUT_ZONES 10 #define MAX_LAYOUT_OPTIONS 10 -LAYOUT_VAL1(TRIM_LINE_WIDTH, 8) -LAYOUT_VAL3(TRIM_SQUARE_SIZE, 17, 13, 17) -LAYOUT_VAL3(MAIN_ZONE_BORDER, 10, 6, 10) - constexpr uint32_t LAYOUT_REFRESH = 1000 / 2; // 2 Hz #if !defined(YAML_GENERATOR) @@ -83,6 +79,12 @@ class LayoutFactory WidgetsContainer* createCustomScreen(unsigned customScreenIndex) const; + static LAYOUT_VAL(TRIM_LINE_WIDTH, 8, 8, LS(8)) + static LAYOUT_VAL(TRIM_SQUARE_SIZE, 17, 17, 13) + + static LAYOUT_VAL(BM_W, 51, 22, LS(51)) + static LAYOUT_VAL(BM_H, 25, 34, LS(25)) + protected: const char* id; const char* name; diff --git a/radio/src/gui/colorlcd/layouts/layout_factory_impl.h b/radio/src/gui/colorlcd/layouts/layout_factory_impl.h index 2c0c1de56e1..9162f4d8923 100644 --- a/radio/src/gui/colorlcd/layouts/layout_factory_impl.h +++ b/radio/src/gui/colorlcd/layouts/layout_factory_impl.h @@ -109,6 +109,8 @@ class Layout: public LayoutBase bool isLayout() override { return true; } + static LAYOUT_VAL(MAIN_ZONE_BORDER, 10, 10, 6) + protected: const LayoutFactory * factory = nullptr; std::unique_ptr decoration; @@ -138,9 +140,6 @@ class Layout: public LayoutBase rect_t getZone(unsigned int index) const override; }; -LAYOUT_VAL2(BM_W, 51, 22) -LAYOUT_VAL2(BM_H, 25, 34) - template class BaseLayoutFactory: public LayoutFactory { diff --git a/radio/src/gui/colorlcd/layouts/sliders.cpp b/radio/src/gui/colorlcd/layouts/sliders.cpp index 3ae732e2901..d0534910449 100644 --- a/radio/src/gui/colorlcd/layouts/sliders.cpp +++ b/radio/src/gui/colorlcd/layouts/sliders.cpp @@ -26,9 +26,6 @@ #include "opentx.h" #include "switches.h" -LAYOUT_VAL3(SL_SZ, 15, 11, 15) -LAYOUT_VAL1(SL_TK, 2) - static const lv_style_const_prop_t shadow1_props[] = { // LV_STYLE_CONST_SHADOW_COLOR does not compile in GitHub ??? {.prop = LV_STYLE_SHADOW_COLOR, .value = {.color = {.full = 0}}}, @@ -52,19 +49,19 @@ static const lv_style_const_prop_t shadow2_props[] = { static LV_STYLE_CONST_MULTI_INIT(shadow2_style, shadow2_props); SliderIcon::SliderIcon(Window* parent) : - Window(parent, rect_t{0, 0, SL_SZ + 2, SL_SZ + 2}) + Window(parent, rect_t{0, 0, MainViewSlider::SL_SZ + 2, MainViewSlider::SL_SZ + 2}) { setWindowFlag(NO_FOCUS); auto shad = lv_obj_create(lvobj); etx_obj_add_style(shad, shadow1_style, LV_PART_MAIN); lv_obj_set_pos(shad, 1, 1); - lv_obj_set_size(shad, SL_SZ, SL_SZ); + lv_obj_set_size(shad, MainViewSlider::SL_SZ, MainViewSlider::SL_SZ); fill = lv_obj_create(lvobj); etx_obj_add_style(fill, shadow2_style, LV_PART_MAIN); lv_obj_set_pos(fill, 0, 0); - lv_obj_set_size(fill, SL_SZ, SL_SZ); + lv_obj_set_size(fill, MainViewSlider::SL_SZ, MainViewSlider::SL_SZ); etx_solid_bg(fill, COLOR_THEME_FOCUS_INDEX); } @@ -73,10 +70,10 @@ MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx, Window(parent, rect), idx(idx), isVertical(isVertical) { if (isVertical) { - int sliderTicksCount = (height() - TRIM_SQUARE_SIZE) / SLIDER_TICK_SPACING; + int sliderTicksCount = (height() - LayoutFactory::TRIM_SQUARE_SIZE) / SLIDER_TICK_SPACING; tickPoints = new lv_point_t[(sliderTicksCount + 1) * 2]; - lv_coord_t y = TRIM_SQUARE_SIZE / 2; + lv_coord_t y = LayoutFactory::TRIM_SQUARE_SIZE / 2; for (uint8_t i = 0; i <= sliderTicksCount; i++) { if (i == 0 || i == sliderTicksCount / 2 || i == sliderTicksCount) { tickPoints[i * 2] = {SL_TK, y}; @@ -91,10 +88,10 @@ MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx, y += SLIDER_TICK_SPACING; } } else { - int sliderTicksCount = (width() - TRIM_SQUARE_SIZE) / SLIDER_TICK_SPACING; + int sliderTicksCount = (width() - LayoutFactory::TRIM_SQUARE_SIZE) / SLIDER_TICK_SPACING; tickPoints = new lv_point_t[(sliderTicksCount + 1) * 2]; - lv_coord_t x = TRIM_SQUARE_SIZE / 2; + lv_coord_t x = LayoutFactory::TRIM_SQUARE_SIZE / 2; for (uint8_t i = 0; i <= sliderTicksCount; i++) { if (i == 0 || i == sliderTicksCount / 2 || i == SLIDER_TICKS_COUNT) { tickPoints[i * 2] = {x, SL_TK}; @@ -113,9 +110,9 @@ MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx, sliderIcon = new SliderIcon(this); coord_t x = 0, y = 0; if (isVertical) - y = (height() - TRIM_SQUARE_SIZE) / 2; + y = (height() - LayoutFactory::TRIM_SQUARE_SIZE) / 2; else - y = (width() - TRIM_SQUARE_SIZE) / 2; + y = (width() - LayoutFactory::TRIM_SQUARE_SIZE) / 2; lv_obj_set_pos(sliderIcon->getLvObj(), x, y); checkEvents(); @@ -140,10 +137,10 @@ void MainViewSlider::checkEvents() coord_t x = 0, y = 0; if (isVertical) { - y = divRoundClosest((height() - TRIM_SQUARE_SIZE) * (-value + RESX), + y = divRoundClosest((height() - LayoutFactory::TRIM_SQUARE_SIZE) * (-value + RESX), 2 * RESX); } else { - x = divRoundClosest((width() - TRIM_SQUARE_SIZE) * (value + RESX), + x = divRoundClosest((width() - LayoutFactory::TRIM_SQUARE_SIZE) * (value + RESX), 2 * RESX); } lv_obj_set_pos(sliderIcon->getLvObj(), x, y); @@ -153,7 +150,7 @@ void MainViewSlider::checkEvents() MainViewHorizontalSlider::MainViewHorizontalSlider(Window* parent, uint8_t idx) : MainViewSlider(parent, - rect_t{0, 0, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE}, + rect_t{0, 0, HORIZONTAL_SLIDERS_WIDTH, LayoutFactory::TRIM_SQUARE_SIZE}, idx, false) { } @@ -165,18 +162,11 @@ MainViewVerticalSlider::MainViewVerticalSlider(Window* parent, { } -LAYOUT_VAL3(MULTIPOS_H, 18, 13, 18) -LAYOUT_VAL1(MULTIPOS_W_SPACING, 12) -LAYOUT_VAL1(MULTIPOS_SZ, 12) -LAYOUT_VAL1(MULTIPOS_XO, 3) - -constexpr coord_t MULTIPOS_W = (6 + 1) * MULTIPOS_W_SPACING; - MainView6POS::MainView6POS(Window* parent, uint8_t idx) : Window(parent, rect_t{0, 0, MULTIPOS_W, MULTIPOS_H}), idx(idx) { char num[] = " "; - coord_t x = MULTIPOS_W_SPACING / 4 + TRIM_SQUARE_SIZE / 4; + coord_t x = MULTIPOS_W_SPACING / 4 + LayoutFactory::TRIM_SQUARE_SIZE / 4; for (uint8_t value = 0; value < XPOTS_MULTIPOS_COUNT; value++) { num[0] = value + '1'; auto p = lv_label_create(lvobj); diff --git a/radio/src/gui/colorlcd/layouts/sliders.h b/radio/src/gui/colorlcd/layouts/sliders.h index 4d605c20638..ef78ea1e1a8 100644 --- a/radio/src/gui/colorlcd/layouts/sliders.h +++ b/radio/src/gui/colorlcd/layouts/sliders.h @@ -23,13 +23,6 @@ #include "libopenui.h" -LAYOUT_VAL3(SLIDER_TICKS_COUNT, 40, 36, 30) -LAYOUT_VAL1(SLIDER_TICK_SPACING, 4) -constexpr coord_t HORIZONTAL_SLIDERS_WIDTH = - SLIDER_TICKS_COUNT * SLIDER_TICK_SPACING + TRIM_SQUARE_SIZE; -constexpr coord_t VERTICAL_SLIDERS_HEIGHT = - SLIDER_TICKS_COUNT * SLIDER_TICK_SPACING + TRIM_SQUARE_SIZE; - class SliderIcon : public Window { public: @@ -46,6 +39,16 @@ class MainViewSlider : public Window bool isVertical); void checkEvents() override; + static LAYOUT_VAL(SLIDER_TICKS_COUNT, 40, 30, 36) + static LAYOUT_VAL(SLIDER_TICK_SPACING, 4, 4, LS(4)) + static constexpr coord_t HORIZONTAL_SLIDERS_WIDTH = + SLIDER_TICKS_COUNT * SLIDER_TICK_SPACING + LayoutFactory::TRIM_SQUARE_SIZE; + static constexpr coord_t VERTICAL_SLIDERS_HEIGHT = + SLIDER_TICKS_COUNT * SLIDER_TICK_SPACING + LayoutFactory::TRIM_SQUARE_SIZE; + + static LAYOUT_VAL(SL_SZ, 15, 15, 11) + static LAYOUT_VAL(SL_TK, 2, 2, LS(2)) + protected: uint8_t idx; int16_t value = -10000; @@ -75,6 +78,12 @@ class MainView6POS : public Window void checkEvents() override; + static LAYOUT_VAL(MULTIPOS_H, 18, 18, 13) + static LAYOUT_VAL(MULTIPOS_W_SPACING, 12, 12, LS(12)) + static LAYOUT_VAL(MULTIPOS_SZ, 12, 12, LS(12)) + static LAYOUT_VAL(MULTIPOS_XO, 3, 3, LS(3)) + static constexpr coord_t MULTIPOS_W = (6 + 1) * MULTIPOS_W_SPACING; + protected: uint8_t idx; int16_t value = -10000; diff --git a/radio/src/gui/colorlcd/layouts/topbar_impl.cpp b/radio/src/gui/colorlcd/layouts/topbar_impl.cpp index 278c767da34..4c4044a2998 100644 --- a/radio/src/gui/colorlcd/layouts/topbar_impl.cpp +++ b/radio/src/gui/colorlcd/layouts/topbar_impl.cpp @@ -26,7 +26,7 @@ constexpr uint32_t TOPBAR_REFRESH = 1000 / 10; // 10 Hz TopBar::TopBar(Window * parent) : - TopBarBase(parent, {0, 0, LCD_W, MENU_HEADER_HEIGHT}, &g_model.topbarData) + TopBarBase(parent, {0, 0, LCD_W, EdgeTxStyles::MENU_HEADER_HEIGHT}, &g_model.topbarData) { etx_solid_bg(lvobj, COLOR_THEME_SECONDARY1_INDEX); @@ -40,7 +40,7 @@ unsigned int TopBar::getZonesCount() const rect_t TopBar::getZone(unsigned int index) const { -#if LCD_H > LCD_W +#if PORTRAIT_LCD if (index == MAX_TOPBAR_ZONES - 1) { coord_t size = LCD_W - HDR_DATE_XO - (MAX_TOPBAR_ZONES - 1) * (TOPBAR_ZONE_WIDTH + TOPBAR_ZONE_HMARGIN); return {LCD_W - size, TOPBAR_ZONE_VMARGIN, size, TOPBAR_ZONE_HEIGHT}; @@ -58,13 +58,13 @@ rect_t TopBar::getZone(unsigned int index) const void TopBar::setVisible(float visible) // 0.0 -> 1.0 { if (visible == 0.0) { - setTop(-(int)MENU_HEADER_HEIGHT); + setTop(-(int)EdgeTxStyles::MENU_HEADER_HEIGHT); } else if (visible == 1.0) { setTop(0); } else if (visible > 0.0 && visible < 1.0){ - float top = - (float)MENU_HEADER_HEIGHT * (1.0 - visible); + float top = - (float)EdgeTxStyles::MENU_HEADER_HEIGHT * (1.0 - visible); setTop((coord_t)top); } } @@ -75,10 +75,10 @@ coord_t TopBar::getVisibleHeight(float visible) const // 0.0 -> 1.0 return 0; } else if (visible == 1.0) { - return MENU_HEADER_HEIGHT; + return EdgeTxStyles::MENU_HEADER_HEIGHT; } - float h = (float)MENU_HEADER_HEIGHT * visible; + float h = (float)EdgeTxStyles::MENU_HEADER_HEIGHT * visible; return (coord_t)h; } diff --git a/radio/src/gui/colorlcd/layouts/topbar_impl.h b/radio/src/gui/colorlcd/layouts/topbar_impl.h index ac24189be5d..b152f68ca84 100644 --- a/radio/src/gui/colorlcd/layouts/topbar_impl.h +++ b/radio/src/gui/colorlcd/layouts/topbar_impl.h @@ -58,6 +58,14 @@ class TopBar: public TopBarBase void removeWidget(unsigned int index) override; + static LAYOUT_VAL(TOPBAR_ZONE_WIDTH, 70, 70, 47) + static LAYOUT_VAL(TOPBAR_ZONE_VMARGIN, 3, 3, LS(3)) + static LAYOUT_VAL(TOPBAR_ZONE_HMARGIN, 2, 2, LS(2)) + static constexpr coord_t TOPBAR_ZONE_HEIGHT = EdgeTxStyles::MENU_HEADER_HEIGHT - 2 * TOPBAR_ZONE_VMARGIN; + + static LAYOUT_VAL(HDR_DATE_XO, 48, 48, LS(48)) + static LAYOUT_VAL(MENU_HEADER_BUTTONS_LEFT, 47, 47, LS(47)) + protected: uint32_t lastRefresh = 0; HeaderIcon* headerIcon = nullptr; diff --git a/radio/src/gui/colorlcd/layouts/trims.cpp b/radio/src/gui/colorlcd/layouts/trims.cpp index 8ce0c78020f..195f9114d7d 100644 --- a/radio/src/gui/colorlcd/layouts/trims.cpp +++ b/radio/src/gui/colorlcd/layouts/trims.cpp @@ -101,27 +101,27 @@ MainViewTrim::MainViewTrim(Window* parent, const rect_t& rect, uint8_t idx, etx_solid_bg(trimBar, COLOR_THEME_SECONDARY1_INDEX); etx_obj_add_style(trimBar, styles->rounded, LV_PART_MAIN); if (isVertical) { - lv_obj_set_pos(trimBar, (TRIM_SQUARE_SIZE - TRIM_LINE_WIDTH) / 2, - TRIM_SQUARE_SIZE / 2); - lv_obj_set_size(trimBar, TRIM_LINE_WIDTH, - VERTICAL_SLIDERS_HEIGHT - TRIM_SQUARE_SIZE + 1); + lv_obj_set_pos(trimBar, (LayoutFactory::TRIM_SQUARE_SIZE - LayoutFactory::TRIM_LINE_WIDTH) / 2, + LayoutFactory::TRIM_SQUARE_SIZE / 2); + lv_obj_set_size(trimBar, LayoutFactory::TRIM_LINE_WIDTH, + MainViewSlider::VERTICAL_SLIDERS_HEIGHT - LayoutFactory::TRIM_SQUARE_SIZE + 1); } else { - lv_obj_set_pos(trimBar, TRIM_SQUARE_SIZE / 2, - (TRIM_SQUARE_SIZE - TRIM_LINE_WIDTH - 1) / 2); - lv_obj_set_size(trimBar, HORIZONTAL_SLIDERS_WIDTH - TRIM_SQUARE_SIZE + 1, - TRIM_LINE_WIDTH); + lv_obj_set_pos(trimBar, LayoutFactory::TRIM_SQUARE_SIZE / 2, + (LayoutFactory::TRIM_SQUARE_SIZE - LayoutFactory::TRIM_LINE_WIDTH - 1) / 2); + lv_obj_set_size(trimBar, MainViewSlider::HORIZONTAL_SLIDERS_WIDTH - LayoutFactory::TRIM_SQUARE_SIZE + 1, + LayoutFactory::TRIM_LINE_WIDTH); } trimIcon = new TrimIcon(this, isVertical); coord_t x = 0, y = 0; if (isVertical) - y = (height() - TRIM_SQUARE_SIZE) / 2; + y = (height() - LayoutFactory::TRIM_SQUARE_SIZE) / 2; else - y = (width() - TRIM_SQUARE_SIZE) / 2; + y = (width() - LayoutFactory::TRIM_SQUARE_SIZE) / 2; lv_obj_set_pos(trimIcon->getLvObj(), x, y); trimValue = new DynamicNumber( - this, {0, 0, TRIM_SQUARE_SIZE, 12}, + this, {0, 0, LayoutFactory::TRIM_SQUARE_SIZE, 12}, [=]() { return divRoundClosest(abs(value) * 100, trimMax); }, COLOR_THEME_PRIMARY2 | FONT(XXS) | CENTERED); etx_solid_bg(trimValue->getLvObj(), COLOR_THEME_SECONDARY1_INDEX); @@ -155,13 +155,13 @@ void MainViewTrim::setPos() if (value) { if (isVertical) { x = 0; - y = (value > 0) ? VERTICAL_SLIDERS_HEIGHT * 4 / 5 - : VERTICAL_SLIDERS_HEIGHT / 5 - 11; + y = (value > 0) ? MainViewSlider::VERTICAL_SLIDERS_HEIGHT * 4 / 5 + : MainViewSlider::VERTICAL_SLIDERS_HEIGHT / 5 - 11; } else { - x = ((value < 0) ? HORIZONTAL_SLIDERS_WIDTH * 4 / 5 - : HORIZONTAL_SLIDERS_WIDTH / 5) - - TRIM_SQUARE_SIZE / 2; - y = (TRIM_SQUARE_SIZE - 12) / 2; + x = ((value < 0) ? MainViewSlider::HORIZONTAL_SLIDERS_WIDTH * 4 / 5 + : MainViewSlider::HORIZONTAL_SLIDERS_WIDTH / 5) - + LayoutFactory::TRIM_SQUARE_SIZE / 2; + y = (LayoutFactory::TRIM_SQUARE_SIZE - 12) / 2; } lv_obj_set_pos(trimValue->getLvObj(), x, y); trimValue->show(); @@ -222,7 +222,7 @@ coord_t MainViewTrim::sx() if (isVertical) return 0; return divRoundClosest( - (HORIZONTAL_SLIDERS_WIDTH - TRIM_SQUARE_SIZE) * (value - trimMin), + (MainViewSlider::HORIZONTAL_SLIDERS_WIDTH - LayoutFactory::TRIM_SQUARE_SIZE) * (value - trimMin), trimMax - trimMin); } @@ -231,20 +231,20 @@ coord_t MainViewTrim::sy() if (!isVertical) return 0; return divRoundClosest( - (VERTICAL_SLIDERS_HEIGHT - TRIM_SQUARE_SIZE) * (trimMax - value), + (MainViewSlider::VERTICAL_SLIDERS_HEIGHT - LayoutFactory::TRIM_SQUARE_SIZE) * (trimMax - value), trimMax - trimMin); } MainViewHorizontalTrim::MainViewHorizontalTrim(Window* parent, uint8_t idx) : MainViewTrim(parent, - rect_t{0, 0, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE}, idx, + rect_t{0, 0, MainViewSlider::HORIZONTAL_SLIDERS_WIDTH, LayoutFactory::TRIM_SQUARE_SIZE}, idx, false) { } MainViewVerticalTrim::MainViewVerticalTrim(Window* parent, uint8_t idx) : MainViewTrim(parent, - rect_t{0, 0, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT}, idx, + rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, MainViewSlider::VERTICAL_SLIDERS_HEIGHT}, idx, true) { } diff --git a/radio/src/gui/colorlcd/list_line_button.cpp b/radio/src/gui/colorlcd/list_line_button.cpp index b9c2060a4fe..708480cd163 100644 --- a/radio/src/gui/colorlcd/list_line_button.cpp +++ b/radio/src/gui/colorlcd/list_line_button.cpp @@ -61,40 +61,11 @@ void ListLineButton::checkEvents() ButtonBase::checkEvents(); } -// total: 92 x 17 -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 + PAD_TINY) -#endif -LAYOUT_VAL3(FM_W, 8, 5, 8) - -#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 + 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(IM_BTN_H); + setHeight(ListLineButton::BTN_H); padAll(PAD_ZERO); weight = lv_label_create(lvobj); @@ -141,7 +112,7 @@ void InputMixButtonBase::setFlightModes(uint16_t modes) fm_canvas = nullptr; fm_buffer = nullptr; #if PORTRAIT_LCD - setHeight(IM_BTN_H); + setHeight(ListLineButton::BTN_H); #endif return; } @@ -153,7 +124,7 @@ void InputMixButtonBase::setFlightModes(uint16_t modes) FM_CANVAS_HEIGHT, LV_IMG_CF_ALPHA_8BIT); lv_obj_set_pos(fm_canvas, FM_X, FM_Y); #if PORTRAIT_LCD - setHeight(IM_BTN_H + FM_CANVAS_HEIGHT + 2); + setHeight(ListLineButton::BTN_H + FM_CANVAS_HEIGHT + 2); #endif lv_obj_set_style_img_recolor(fm_canvas, makeLvColor(COLOR_THEME_SECONDARY1), @@ -206,7 +177,7 @@ static const lv_obj_class_t group_class = { .destructor_cb = nullptr, .user_data = nullptr, .event_cb = nullptr, - .width_def = IM_GRP_W, + .width_def = ListLineButton::GRP_W, .height_def = LV_SIZE_CONTENT, .editable = LV_OBJ_CLASS_EDITABLE_FALSE, .group_def = LV_OBJ_CLASS_GROUP_DEF_FALSE, @@ -232,12 +203,12 @@ InputMixGroupBase::InputMixGroupBase(Window* parent, mixsrc_t idx) : void InputMixGroupBase::adjustHeight() { - if (getLineCount() == 0) setHeight(IM_BTN_H + 8); + if (getLineCount() == 0) setHeight(ListLineButton::BTN_H + 8); coord_t y = 2; for (auto it = lines.cbegin(); it != lines.cend(); ++it) { auto line = *it; - line->updatePos(LN_X, y); + line->updatePos(InputMixButtonBase::LN_X, y); y += line->height() + 2; } setHeight(y + 4); diff --git a/radio/src/gui/colorlcd/list_line_button.h b/radio/src/gui/colorlcd/list_line_button.h index 7858734dba6..368954a460f 100644 --- a/radio/src/gui/colorlcd/list_line_button.h +++ b/radio/src/gui/colorlcd/list_line_button.h @@ -25,9 +25,6 @@ #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: @@ -40,6 +37,9 @@ class ListLineButton : public ButtonBase virtual void refresh() = 0; + static LAYOUT_VAL(BTN_H, 29, 29, LS(29)) + static constexpr coord_t GRP_W = LCD_W - PAD_MEDIUM * 2; + protected: uint8_t index; @@ -59,6 +59,28 @@ class InputMixButtonBase : public ListLineButton virtual void updatePos(coord_t x, coord_t y) = 0; virtual void swapLvglGroup(InputMixButtonBase* line2) = 0; + // total: 90 x 17 + static LAYOUT_VAL(FM_CANVAS_HEIGHT, 17, 17, LS(17)) + static LAYOUT_VAL(FM_CANVAS_WIDTH, 90, 90, 57) + + static LAYOUT_VAL(BTN_W, 389, 229, 258) + static constexpr coord_t WGT_X = PAD_TINY; + static constexpr coord_t WGT_Y = PAD_TINY; + static LAYOUT_VAL(WGT_W, 42, 42, LS(42)) + static LAYOUT_VAL(WGT_H, 21, 21, LS(21)) + static constexpr coord_t SRC_X = WGT_X + WGT_W + PAD_TINY; + static constexpr coord_t SRC_Y = WGT_Y; + static LAYOUT_VAL(SRC_W, 70, 69, LS(70)) + static constexpr coord_t SRC_H = WGT_H; + static constexpr coord_t OPT_X = SRC_X + SRC_W + PAD_TINY; + static constexpr coord_t OPT_Y = WGT_Y; + static LAYOUT_VAL(OPT_W, 171, 106, 116) + static constexpr coord_t OPT_H = WGT_H; + static LAYOUT_VAL(LN_X, 73, 73, 48) + static LAYOUT_VAL(FM_X, (OPT_X + OPT_W + PAD_TINY), 12, (OPT_X + OPT_W + PAD_TINY)) + static LAYOUT_VAL(FM_Y, (WGT_Y + PAD_TINY), (WGT_Y + WGT_H + PAD_TINY), (WGT_Y + PAD_TINY)) + static LAYOUT_VAL(FM_W, 8, 8, 5) + protected: lv_obj_t* fm_canvas = nullptr; diff --git a/radio/src/gui/colorlcd/listbox.h b/radio/src/gui/colorlcd/listbox.h index bb3bd31db54..1d289cdb20a 100644 --- a/radio/src/gui/colorlcd/listbox.h +++ b/radio/src/gui/colorlcd/listbox.h @@ -84,6 +84,8 @@ class ListBox : public TableField std::string getName() const override { return "ListBox"; } #endif + static LAYOUT_VAL(MENUS_LINE_HEIGHT, 35, 35, LS(35)) + protected: static void event_cb(lv_event_t* e); int activeItem = -1; diff --git a/radio/src/gui/colorlcd/menu_model.cpp b/radio/src/gui/colorlcd/menu_model.cpp index 6005829c0c8..67f32fa22e6 100644 --- a/radio/src/gui/colorlcd/menu_model.cpp +++ b/radio/src/gui/colorlcd/menu_model.cpp @@ -70,19 +70,6 @@ void ModelMenu::build() #endif } -#if defined(PCBNV14) || defined(PCBPL18) -void ModelMenu::addGoToMonitorsButton() -{ - new TextButton( - getHeaderWindow(), - {LCD_W / 2 + 6, MENU_TITLE_TOP + 1, LCD_W / 2 - 8, MENU_TITLE_HEIGHT - 2}, - STR_OPEN_CHANNEL_MONITORS, [=]() { - pushEvent(EVT_KEY_FIRST(KEY_MODEL)); - return 0; - }); -} -#endif - #if defined(HARDWARE_KEYS) void ModelMenu::onPressSYS() { diff --git a/radio/src/gui/colorlcd/menu_model.h b/radio/src/gui/colorlcd/menu_model.h index 297c74f556d..827ebf3bc01 100644 --- a/radio/src/gui/colorlcd/menu_model.h +++ b/radio/src/gui/colorlcd/menu_model.h @@ -33,10 +33,6 @@ class ModelMenu : public TabsGroup #endif protected: -#if defined(PCBNV14) || defined(PCBPL18) - void addGoToMonitorsButton(void); -#endif - void build(); #if defined(HARDWARE_KEYS) diff --git a/radio/src/gui/colorlcd/mixer_edit.cpp b/radio/src/gui/colorlcd/mixer_edit.cpp index 4cb8b9ce354..4607743d32b 100644 --- a/radio/src/gui/colorlcd/mixer_edit.cpp +++ b/radio/src/gui/colorlcd/mixer_edit.cpp @@ -34,10 +34,6 @@ #define SET_DIRTY() storageDirty(EE_MODEL) -LAYOUT_VAL2(MIX_STATUS_BAR_WIDTH, 250, 180) -LAYOUT_VAL2(MIX_STATUS_BAR_MARGIN, 3, 0) -LAYOUT_VAL2(MIX_RIGHT_MARGIN, 0, 3) - class MixerEditStatusBar : public Window { public: @@ -51,6 +47,8 @@ class MixerEditStatusBar : public Window channel, true); } + static LAYOUT_VAL(MIX_STATUS_BAR_MARGIN, 3, 0, LS(3)) + protected: ComboChannelBar *channelBar; int8_t _channel; @@ -72,7 +70,7 @@ void MixEditWindow::buildHeader(Window *window) new MixerEditStatusBar( window, {window->getRect().w - MIX_STATUS_BAR_WIDTH - MIX_RIGHT_MARGIN, 0, - MIX_STATUS_BAR_WIDTH, MENU_HEADER_HEIGHT}, + MIX_STATUS_BAR_WIDTH, EdgeTxStyles::MENU_HEADER_HEIGHT}, channel); } diff --git a/radio/src/gui/colorlcd/mixer_edit.h b/radio/src/gui/colorlcd/mixer_edit.h index 660baa304c0..e8a759acd6a 100644 --- a/radio/src/gui/colorlcd/mixer_edit.h +++ b/radio/src/gui/colorlcd/mixer_edit.h @@ -30,6 +30,9 @@ class MixEditWindow : public Page public: MixEditWindow(int8_t channel, uint8_t index); + static LAYOUT_VAL(MIX_STATUS_BAR_WIDTH, 250, 180, LS(250)) + static LAYOUT_VAL(MIX_RIGHT_MARGIN, 0, 3, 0) + protected: uint8_t channel; uint8_t index; diff --git a/radio/src/gui/colorlcd/mixer_edit_adv.cpp b/radio/src/gui/colorlcd/mixer_edit_adv.cpp index 03e2bbc693a..2edf92434a6 100644 --- a/radio/src/gui/colorlcd/mixer_edit_adv.cpp +++ b/radio/src/gui/colorlcd/mixer_edit_adv.cpp @@ -29,8 +29,6 @@ #define SET_DIRTY() storageDirty(EE_MODEL) -LAYOUT_VAL1(NUM_EDIT_W, 100) - MixEditAdvanced::MixEditAdvanced(int8_t channel, uint8_t index) : Page(ICON_MODEL_MIXER, PAD_MEDIUM), channel(channel), index(index) { @@ -102,7 +100,7 @@ void MixEditAdvanced::buildBody(Window* form) edit->setSuffix("s"); // Slow up/down precision -#if LCD_W > LCD_H +#if !PORTRAIT_LCD grid.setColSpan(2); #endif line = form->newLine(grid); @@ -117,7 +115,7 @@ void MixEditAdvanced::buildBody(Window* form) slowDn->update(); SET_DIRTY(); }); -#if LCD_W > LCD_H +#if !PORTRAIT_LCD grid.setColSpan(1); #endif diff --git a/radio/src/gui/colorlcd/mixer_edit_adv.h b/radio/src/gui/colorlcd/mixer_edit_adv.h index b1cafe8a9d1..04af2fa36f9 100644 --- a/radio/src/gui/colorlcd/mixer_edit_adv.h +++ b/radio/src/gui/colorlcd/mixer_edit_adv.h @@ -33,6 +33,8 @@ class MixEditAdvanced : public Page public: MixEditAdvanced(int8_t channel, uint8_t index); + static LAYOUT_VAL(NUM_EDIT_W, 100, 100, LS(100)) + protected: uint8_t channel; uint8_t index; diff --git a/radio/src/gui/colorlcd/model_curves.cpp b/radio/src/gui/colorlcd/model_curves.cpp index 9c063eafed6..efc10b3acfd 100644 --- a/radio/src/gui/colorlcd/model_curves.cpp +++ b/radio/src/gui/colorlcd/model_curves.cpp @@ -27,11 +27,6 @@ #define SET_DIRTY() storageDirty(EE_MODEL) -LAYOUT_VAL1(TITLE_H, 20) -LAYOUT_VAL3(INFO_H, 27, 19, 27) -LAYOUT_VAL1(CURVE_BTN_W, 142) -constexpr coord_t CURVE_BTH_H = CURVE_BTN_W + TITLE_H + INFO_H - PAD_MEDIUM; - #if PORTRAIT_LCD #define PER_ROW 2 #else @@ -84,6 +79,11 @@ class CurveButton : public Button void update() { preview->update(); } + static LAYOUT_VAL(TITLE_H, 20, 20, LS(20)) + static LAYOUT_VAL(INFO_H, 27, 27, 19) + static LAYOUT_VAL(CURVE_BTN_W, 142, 142, LS(142)) + static constexpr coord_t CURVE_BTH_H = CURVE_BTN_W + TITLE_H + INFO_H - PAD_MEDIUM; + protected: uint8_t index; StaticText *title; @@ -238,7 +238,7 @@ void ModelCurvesPage::build(Window *window) // Curve drawing auto button = - new CurveButton(line, rect_t{0, 0, CURVE_BTN_W, CURVE_BTH_H}, index); + new CurveButton(line, rect_t{0, 0, CurveButton::CURVE_BTN_W, CurveButton::CURVE_BTH_H}, index); button->setPressHandler([=]() -> uint8_t { Menu *menu = new Menu(window); menu->setTitle(STR_CURVE); @@ -295,7 +295,7 @@ void ModelCurvesPage::build(Window *window) LV_GRID_ALIGN_SPACE_BETWEEN); } - addButton = new TextButton(line, rect_t{0, 0, CURVE_BTN_W, CURVE_BTH_H}, + addButton = new TextButton(line, rect_t{0, 0, CurveButton::CURVE_BTN_W, CurveButton::CURVE_BTH_H}, LV_SYMBOL_PLUS, [=]() { plusPopup(window); return 0; diff --git a/radio/src/gui/colorlcd/model_flightmodes.cpp b/radio/src/gui/colorlcd/model_flightmodes.cpp index a653b37e5da..487218c05fb 100644 --- a/radio/src/gui/colorlcd/model_flightmodes.cpp +++ b/radio/src/gui/colorlcd/model_flightmodes.cpp @@ -30,9 +30,6 @@ #define SET_DIRTY() storageDirty(EE_MODEL) -LAYOUT_VAL3(TR_BTN_W, 65, 44, 65) -LAYOUT_VAL1(TR_MODE_W, 70) - static std::string getFMTrimStr(uint8_t mode, bool spacer) { mode &= 0x1F; @@ -111,6 +108,9 @@ class TrimEdit : public Window showControls(); } + static LAYOUT_VAL(TR_BTN_W, 65, 65, 44) + static LAYOUT_VAL(TR_MODE_W, 70, 70, LS(70)) + protected: int trimId; int fmId; @@ -200,143 +200,6 @@ class FlightModeEdit : public Page uint8_t index; }; -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 -LAYOUT_VAL3(TRIM_Y, 0, -1, 20) -LAYOUT_VAL2(TRIM_W, 30, 40) -#define TRIMC_W (MAX_FMTRIMS * TRIM_W) -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) -{ - etx_obj_add_style(obj, styles->text_align_left, LV_PART_MAIN); -} - -static const lv_obj_class_t fm_id_class = { - .base_class = &lv_label_class, - .constructor_cb = fm_id_constructor, - .destructor_cb = nullptr, - .user_data = nullptr, - .event_cb = nullptr, - .width_def = FMID_W, - .height_def = PAGE_LINE_HEIGHT, - .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, - .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, - .instance_size = sizeof(lv_label_t), -}; - -static void fm_name_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) -{ - etx_obj_add_style(obj, styles->text_align_left, LV_PART_MAIN); - etx_font(obj, FONT_XS_INDEX); -} - -static const lv_obj_class_t fm_name_class = { - .base_class = &lv_label_class, - .constructor_cb = fm_name_constructor, - .destructor_cb = nullptr, - .user_data = nullptr, - .event_cb = nullptr, - .width_def = NAME_W, - .height_def = PAGE_LINE_HEIGHT, - .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, - .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, - .instance_size = sizeof(lv_label_t), -}; - -static void fm_switch_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) -{ - etx_obj_add_style(obj, styles->text_align_left, LV_PART_MAIN); -} - -static const lv_obj_class_t fm_switch_class = { - .base_class = &lv_label_class, - .constructor_cb = fm_switch_constructor, - .destructor_cb = nullptr, - .user_data = nullptr, - .event_cb = nullptr, - .width_def = SWTCH_W, - .height_def = PAGE_LINE_HEIGHT, - .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, - .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, - .instance_size = sizeof(lv_label_t), -}; - -static void fm_fade_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) -{ - etx_obj_add_style(obj, styles->text_align_right, LV_PART_MAIN); -} - -static const lv_obj_class_t fm_fade_class = { - .base_class = &lv_label_class, - .constructor_cb = fm_fade_constructor, - .destructor_cb = nullptr, - .user_data = nullptr, - .event_cb = nullptr, - .width_def = FADE_W, - .height_def = PAGE_LINE_HEIGHT, - .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, - .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, - .instance_size = sizeof(lv_label_t), -}; - -static void fm_trim_mode_constructor(const lv_obj_class_t* class_p, - lv_obj_t* obj) -{ - etx_obj_add_style(obj, styles->text_align_center, LV_PART_MAIN); -} - -static const lv_obj_class_t fm_trim_mode_class = { - .base_class = &lv_label_class, - .constructor_cb = fm_trim_mode_constructor, - .destructor_cb = nullptr, - .user_data = nullptr, - .event_cb = nullptr, - .width_def = TRIM_W, - .height_def = TRIM_H, - .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, - .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, - .instance_size = sizeof(lv_label_t), -}; - -static void fm_trim_value_constructor(const lv_obj_class_t* class_p, - lv_obj_t* obj) -{ - etx_obj_add_style(obj, styles->text_align_center, LV_PART_MAIN); - etx_font(obj, FONT_XS_INDEX); -} - -static const lv_obj_class_t fm_trim_value_class = { - .base_class = &lv_label_class, - .constructor_cb = fm_trim_value_constructor, - .destructor_cb = nullptr, - .user_data = nullptr, - .event_cb = nullptr, - .width_def = TRIM_W, - .height_def = TRIM_H, - .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, - .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, - .instance_size = sizeof(lv_label_t), -}; - class FlightModeBtn : public ListLineButton { public: @@ -459,6 +322,26 @@ class FlightModeBtn : public ListLineButton formatNumberAsString(fm.fadeOut, PREC1, 0, nullptr, "s").c_str()); } + static LAYOUT_VAL(BTN_H, 36, 56, LS(36)) + static LAYOUT_VAL(MAX_FMTRIMS, 6, 4, 6) + static constexpr coord_t FMID_X = PAD_TINY; + static LAYOUT_VAL(FMID_Y, 6, 16, 3) + static LAYOUT_VAL(FMID_W, 36, 46, LS(36)) + static constexpr coord_t NAME_X = FMID_X + FMID_W + PAD_TINY; + static LAYOUT_VAL(NAME_Y, 8, 0, 4) + static LAYOUT_VAL(NAME_W, 95, 160, LS(95)) + static constexpr coord_t SWTCH_X = NAME_X + NAME_W + PAD_TINY; + static LAYOUT_VAL(SWTCH_Y, 6, 0, 3) + static LAYOUT_VAL(SWTCH_W, 50, 50, LS(50)) + static LAYOUT_VAL(TRIM_X, SWTCH_X + SWTCH_W + PAD_TINY, FMID_X + FMID_W + PAD_TINY, SWTCH_X + SWTCH_W + PAD_TINY) + static LAYOUT_VAL(TRIM_Y, 0, 20, -1) + static LAYOUT_VAL(TRIM_W, 30, 40, LS(30)) + static LAYOUT_VAL(TRIM_H, 16, 16, 11) + static constexpr coord_t TRIMC_W = MAX_FMTRIMS * TRIM_W; + static constexpr coord_t FADE_X = TRIM_X + TRIMC_W + PAD_TINY; + static LAYOUT_VAL(FADE_Y, 6, 24, 3) + static LAYOUT_VAL(FADE_W, 45, 45, LS(45)) + protected: bool init = false; bool refreshing = false; @@ -471,6 +354,125 @@ class FlightModeBtn : public ListLineButton lv_obj_t* fmFadeIn = nullptr; lv_obj_t* fmFadeOut = nullptr; int lastTrim[MAX_FMTRIMS]; + + static const lv_obj_class_t fm_id_class; + static const lv_obj_class_t fm_name_class; + static const lv_obj_class_t fm_switch_class; + static const lv_obj_class_t fm_fade_class; + static const lv_obj_class_t fm_trim_mode_class; + static const lv_obj_class_t fm_trim_value_class; +}; + +static void fm_id_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) +{ + etx_obj_add_style(obj, styles->text_align_left, LV_PART_MAIN); +} + +const lv_obj_class_t FlightModeBtn::fm_id_class = { + .base_class = &lv_label_class, + .constructor_cb = fm_id_constructor, + .destructor_cb = nullptr, + .user_data = nullptr, + .event_cb = nullptr, + .width_def = FlightModeBtn::FMID_W, + .height_def = EdgeTxStyles::PAGE_LINE_HEIGHT, + .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, + .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, + .instance_size = sizeof(lv_label_t), +}; + +static void fm_name_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) +{ + etx_obj_add_style(obj, styles->text_align_left, LV_PART_MAIN); + etx_font(obj, FONT_XS_INDEX); +} + +const lv_obj_class_t FlightModeBtn::fm_name_class = { + .base_class = &lv_label_class, + .constructor_cb = fm_name_constructor, + .destructor_cb = nullptr, + .user_data = nullptr, + .event_cb = nullptr, + .width_def = FlightModeBtn::NAME_W, + .height_def = EdgeTxStyles::PAGE_LINE_HEIGHT, + .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, + .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, + .instance_size = sizeof(lv_label_t), +}; + +static void fm_switch_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) +{ + etx_obj_add_style(obj, styles->text_align_left, LV_PART_MAIN); +} + +const lv_obj_class_t FlightModeBtn::fm_switch_class = { + .base_class = &lv_label_class, + .constructor_cb = fm_switch_constructor, + .destructor_cb = nullptr, + .user_data = nullptr, + .event_cb = nullptr, + .width_def = FlightModeBtn::SWTCH_W, + .height_def = EdgeTxStyles::PAGE_LINE_HEIGHT, + .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, + .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, + .instance_size = sizeof(lv_label_t), +}; + +static void fm_fade_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) +{ + etx_obj_add_style(obj, styles->text_align_right, LV_PART_MAIN); +} + +const lv_obj_class_t FlightModeBtn::fm_fade_class = { + .base_class = &lv_label_class, + .constructor_cb = fm_fade_constructor, + .destructor_cb = nullptr, + .user_data = nullptr, + .event_cb = nullptr, + .width_def = FlightModeBtn::FADE_W, + .height_def = EdgeTxStyles::PAGE_LINE_HEIGHT, + .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, + .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, + .instance_size = sizeof(lv_label_t), +}; + +static void fm_trim_mode_constructor(const lv_obj_class_t* class_p, + lv_obj_t* obj) +{ + etx_obj_add_style(obj, styles->text_align_center, LV_PART_MAIN); +} + +const lv_obj_class_t FlightModeBtn::fm_trim_mode_class = { + .base_class = &lv_label_class, + .constructor_cb = fm_trim_mode_constructor, + .destructor_cb = nullptr, + .user_data = nullptr, + .event_cb = nullptr, + .width_def = FlightModeBtn::TRIM_W, + .height_def = FlightModeBtn::TRIM_H, + .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, + .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, + .instance_size = sizeof(lv_label_t), +}; + +static void fm_trim_value_constructor(const lv_obj_class_t* class_p, + lv_obj_t* obj) +{ + etx_obj_add_style(obj, styles->text_align_center, LV_PART_MAIN); + etx_font(obj, FONT_XS_INDEX); +} + +const lv_obj_class_t FlightModeBtn::fm_trim_value_class = { + .base_class = &lv_label_class, + .constructor_cb = fm_trim_value_constructor, + .destructor_cb = nullptr, + .user_data = nullptr, + .event_cb = nullptr, + .width_def = FlightModeBtn::TRIM_W, + .height_def = FlightModeBtn::TRIM_H, + .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, + .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, + .instance_size = sizeof(lv_label_t), }; ModelFlightModesPage::ModelFlightModesPage() : @@ -490,8 +492,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(), PAD_MEDIUM, i * (BTN_H + 3) + 4); - btn->setWidth(IM_GRP_W); + lv_obj_set_pos(btn->getLvObj(), PAD_MEDIUM, i * (FlightModeBtn::BTN_H + 3) + 4); + btn->setWidth(ListLineButton::GRP_W); btn->setPressHandler([=]() { new FlightModeEdit(i); @@ -500,7 +502,7 @@ void ModelFlightModesPage::build(Window* form) } trimCheck = new TextButton( - form, rect_t{6, MAX_FLIGHT_MODES * (BTN_H + 3) + PAD_LARGE, IM_GRP_W, TRIM_CHK_H}, STR_CHECKTRIMS, [&]() -> uint8_t { + form, rect_t{6, MAX_FLIGHT_MODES * (FlightModeBtn::BTN_H + 3) + PAD_LARGE, ListLineButton::GRP_W, TRIM_CHK_H}, STR_CHECKTRIMS, [&]() -> uint8_t { if (trimsCheckTimer) trimsCheckTimer = 0; else diff --git a/radio/src/gui/colorlcd/model_flightmodes.h b/radio/src/gui/colorlcd/model_flightmodes.h index cea2f7db1f3..8bbcd3e37d2 100644 --- a/radio/src/gui/colorlcd/model_flightmodes.h +++ b/radio/src/gui/colorlcd/model_flightmodes.h @@ -33,6 +33,8 @@ class ModelFlightModesPage : public PageTab void build(Window* window) override; + static LAYOUT_VAL(TRIM_CHK_H, 40, 40, LS(40)) + protected: TextButton* trimCheck = nullptr; diff --git a/radio/src/gui/colorlcd/model_gvars.cpp b/radio/src/gui/colorlcd/model_gvars.cpp index bebbb87e11c..5bc9dedb59e 100644 --- a/radio/src/gui/colorlcd/model_gvars.cpp +++ b/radio/src/gui/colorlcd/model_gvars.cpp @@ -30,24 +30,6 @@ #define SET_DIRTY() storageDirty(EE_MODEL) -#if PORTRAIT_LCD -#define BTN_H (modelFMEnabled() ? 72 : 38) -#define GVAR_NM_Y (modelFMEnabled() ? 24 : 7) -#else -LAYOUT_VAL3(BTN_H, 38, 26, 0) -LAYOUT_VAL3(GVAR_NM_Y, 7, 4, 0) -#endif -LAYOUT_VAL2(GVAR_VAL_W, 45, 50) -LAYOUT_VAL1(GVAR_NAME_SIZE, 44) - -#define GVAR_VAL_H (PAGE_LINE_HEIGHT * 2 - PAD_MEDIUM) - -#if !PORTRAIT_LCD -#define GVAR_COLS MAX_FLIGHT_MODES -#else -#define GVAR_COLS 5 -#endif - #define ETX_STATE_VALUE_SMALL_FONT LV_STATE_USER_1 void getFMExtName(char* dest, int8_t idx) @@ -63,46 +45,6 @@ void getFMExtName(char* dest, int8_t idx) } } -static void gv_label_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) -{ - etx_obj_add_style(obj, styles->text_align_center, LV_PART_MAIN); - etx_font(obj, FONT_XS_INDEX); - etx_solid_bg(obj, COLOR_THEME_ACTIVE_INDEX, LV_STATE_CHECKED); -} - -static const lv_obj_class_t gv_label_class = { - .base_class = &lv_label_class, - .constructor_cb = gv_label_constructor, - .destructor_cb = nullptr, - .user_data = nullptr, - .event_cb = nullptr, - .width_def = GVAR_VAL_W, - .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), -}; - -static void gv_value_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) -{ - etx_obj_add_style(obj, styles->text_align_center, LV_PART_MAIN); - etx_font(obj, FONT_XS_INDEX, LV_PART_MAIN | ETX_STATE_VALUE_SMALL_FONT); - etx_solid_bg(obj, COLOR_THEME_ACTIVE_INDEX, LV_STATE_CHECKED); -} - -static const lv_obj_class_t gv_value_class = { - .base_class = &lv_label_class, - .constructor_cb = gv_value_constructor, - .destructor_cb = nullptr, - .user_data = nullptr, - .event_cb = nullptr, - .width_def = GVAR_VAL_W, - .height_def = PAGE_LINE_HEIGHT, - .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, - .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, - .instance_size = sizeof(lv_label_t), -}; - class GVarButton : public ListLineButton { public: @@ -124,6 +66,13 @@ class GVarButton : public ListLineButton if (line) line->build(); } + static LAYOUT_VAL(GVAR_NAME_SIZE, 44, 44, LS(44)) + static constexpr coord_t GVAR_VAL_H = EdgeTxStyles::PAGE_LINE_HEIGHT * 2 - PAD_MEDIUM; + static LAYOUT_VAL(GVAR_VAL_W, 45, 50, LS(45)) + static LAYOUT_VAL(GVAR_COLS, MAX_FLIGHT_MODES, 5, MAX_FLIGHT_MODES) + static LAYOUT_VAL(BTN_H, 38, 72, 26) + static LAYOUT_VAL(GVAR_NM_Y, 7, 24, 4) + protected: bool init = false; uint8_t currentFlightMode = 0; // used for checking updates @@ -169,7 +118,7 @@ class GVarButton : public ListLineButton auto nm = lv_label_create(lvobj); lv_label_set_text(nm, getGVarString(index)); lv_obj_set_pos(nm, PAD_TINY, GVAR_NM_Y); - lv_obj_set_size(nm, GVAR_NAME_SIZE, PAGE_LINE_HEIGHT); + lv_obj_set_size(nm, GVAR_NAME_SIZE, EdgeTxStyles::PAGE_LINE_HEIGHT); if (modelFMEnabled()) { char label[16] = {}; @@ -184,7 +133,7 @@ class GVarButton : public ListLineButton valueTexts[flightMode] = etx_create(&gv_value_class, lvobj); 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); + (flightMode / GVAR_COLS) * GVAR_VAL_H + EdgeTxStyles::PAGE_LINE_HEIGHT - PAD_MEDIUM); if (flightMode == currentFlightMode) { lv_obj_add_state(valueTexts[flightMode], LV_STATE_CHECKED); @@ -195,7 +144,7 @@ class GVarButton : public ListLineButton } } else { valueTexts[0] = lv_label_create(lvobj); - lv_obj_set_pos(valueTexts[0], GVAR_NAME_SIZE + PAD_MEDIUM, (BTN_H - PAGE_LINE_HEIGHT - PAD_SMALL) / 2); + lv_obj_set_pos(valueTexts[0], GVAR_NAME_SIZE + PAD_MEDIUM, (BTN_H - EdgeTxStyles::PAGE_LINE_HEIGHT - PAD_SMALL) / 2); updateValueText(0); } @@ -237,6 +186,49 @@ class GVarButton : public ListLineButton bool isActive() const override { return false; } void refresh() override {} + + static const lv_obj_class_t gv_label_class; + static const lv_obj_class_t gv_value_class; +}; + +static void gv_label_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) +{ + etx_obj_add_style(obj, styles->text_align_center, LV_PART_MAIN); + etx_font(obj, FONT_XS_INDEX); + etx_solid_bg(obj, COLOR_THEME_ACTIVE_INDEX, LV_STATE_CHECKED); +} + +const lv_obj_class_t GVarButton::gv_label_class = { + .base_class = &lv_label_class, + .constructor_cb = gv_label_constructor, + .destructor_cb = nullptr, + .user_data = nullptr, + .event_cb = nullptr, + .width_def = GVarButton::GVAR_VAL_W, + .height_def = EdgeTxStyles::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), +}; + +static void gv_value_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) +{ + etx_obj_add_style(obj, styles->text_align_center, LV_PART_MAIN); + etx_font(obj, FONT_XS_INDEX, LV_PART_MAIN | ETX_STATE_VALUE_SMALL_FONT); + etx_solid_bg(obj, COLOR_THEME_ACTIVE_INDEX, LV_STATE_CHECKED); +} + +const lv_obj_class_t GVarButton::gv_value_class = { + .base_class = &lv_label_class, + .constructor_cb = gv_value_constructor, + .destructor_cb = nullptr, + .user_data = nullptr, + .event_cb = nullptr, + .width_def = GVarButton::GVAR_VAL_W, + .height_def = EdgeTxStyles::PAGE_LINE_HEIGHT, + .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, + .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, + .instance_size = sizeof(lv_label_t), }; class GVarEditWindow : public Page diff --git a/radio/src/gui/colorlcd/model_logical_switches.cpp b/radio/src/gui/colorlcd/model_logical_switches.cpp index 8cd409ecc35..e0b2d493944 100644 --- a/radio/src/gui/colorlcd/model_logical_switches.cpp +++ b/radio/src/gui/colorlcd/model_logical_switches.cpp @@ -294,42 +294,6 @@ void getsEdgeDelayParam(char* s, LogicalSwitchData* ls) .c_str()); } -LAYOUT_VAL2(LS_BUTTON_H, 32, 44) -LAYOUT_VAL3(NM_Y, 4, 1, 10) -LAYOUT_VAL2(NM_W, 30, 36) -LAYOUT_VAL2(FN_W, 50, 58) -LAYOUT_VAL3(V1_Y, NM_Y, NM_Y, 0) -LAYOUT_VAL3(AND_Y, NM_Y, NM_Y, 20) -LAYOUT_VAL2(DUR_W, 40, 54) - -#if !PORTRAIT_LCD -#define AND_X (V2_X + V2_W + PAD_TINY) -#else -#define AND_X (FN_X + FN_W + PAD_TINY) -#endif - -#define NM_X PAD_TINY -LAYOUT_VAL1(NM_H, 20) -#define FN_X (NM_X + NM_W + PAD_TINY) -#define FN_Y NM_Y -#define FN_H NM_H -#define V1_X (FN_X + FN_W + PAD_TINY) -LAYOUT_VAL1(V1_W, 88) -#define V1_H NM_H -#define V2_X (V1_X + V1_W + PAD_TINY) -#define V2_Y V1_Y -LAYOUT_VAL1(V2_W, 110) -#define V2_H NM_H -#define AND_W V1_W -#define AND_H NM_H -#define DUR_X (AND_X + AND_W + PAD_TINY) -#define DUR_Y AND_Y -#define DUR_H NM_H -#define DEL_X (DUR_X + DUR_W + PAD_TINY) -#define DEL_Y AND_Y -#define DEL_H NM_H -#define DEL_W DUR_W - class LogicalSwitchButton : public ListLineButton { public: @@ -490,6 +454,37 @@ class LogicalSwitchButton : public ListLineButton } } + static LAYOUT_VAL(LS_BUTTON_H, 32, 44, LS(32)) + + static constexpr coord_t NM_X = PAD_TINY; + static LAYOUT_VAL(NM_Y, 4, 10, 1) + static LAYOUT_VAL(NM_W, 30, 36, LS(30)) + static LAYOUT_VAL(NM_H, 20, 20, LS(20)) + static constexpr coord_t FN_X = NM_X + NM_W + PAD_TINY; + static constexpr coord_t FN_Y = NM_Y; + static LAYOUT_VAL(FN_W, 50, 58, LS(50)) + static constexpr coord_t FN_H = NM_H; + static constexpr coord_t V1_X = FN_X + FN_W + PAD_TINY; + static LAYOUT_VAL(V1_Y, NM_Y, 0, NM_Y) + static LAYOUT_VAL(V1_W, 88, 88, LS(88)) + static constexpr coord_t V1_H = NM_H; + static constexpr coord_t V2_X = V1_X + V1_W + PAD_TINY; + static constexpr coord_t V2_Y = V1_Y; + static LAYOUT_VAL(V2_W, 110, 110, LS(110)) + static constexpr coord_t V2_H = NM_H; + static LAYOUT_VAL(AND_X, V2_X + V2_W + PAD_TINY, FN_X + FN_W + PAD_TINY, V2_X + V2_W + PAD_TINY) + static LAYOUT_VAL(AND_Y, NM_Y, 20, NM_Y) + static constexpr coord_t AND_W = V1_W; + static constexpr coord_t AND_H = NM_H; + static constexpr coord_t DUR_X = AND_X + AND_W + PAD_TINY; + static constexpr coord_t DUR_Y = AND_Y; + static LAYOUT_VAL(DUR_W, 40, 54, LS(40)) + static constexpr coord_t DUR_H = NM_H; + static constexpr coord_t DEL_X = DUR_X + DUR_W + PAD_TINY; + static constexpr coord_t DEL_Y = AND_Y; + static constexpr coord_t DEL_H = NM_H; + static constexpr coord_t DEL_W = DUR_W; + protected: bool init = false; @@ -584,7 +579,7 @@ void ModelLogicalSwitchesPage::build(Window* window) line = window->newLine(grid); auto button = new LogicalSwitchButton( - line, rect_t{0, 0, window->width() - 12, LS_BUTTON_H}, i); + line, rect_t{0, 0, window->width() - 12, LogicalSwitchButton::LS_BUTTON_H}, i); button->setPressHandler([=]() { Menu* menu = new Menu(window); @@ -647,7 +642,7 @@ void ModelLogicalSwitchesPage::build(Window* window) if (hasEmptySwitch) { line = window->newLine(grid); addButton = - new TextButton(line, rect_t{0, 0, window->width() - 12, LS_BUTTON_H}, + new TextButton(line, rect_t{0, 0, window->width() - 12, LogicalSwitchButton::LS_BUTTON_H}, LV_SYMBOL_PLUS, [=]() { plusPopup(window); return 0; diff --git a/radio/src/gui/colorlcd/model_mixes.cpp b/radio/src/gui/colorlcd/model_mixes.cpp index 98fc835a866..bb5260adfd8 100644 --- a/radio/src/gui/colorlcd/model_mixes.cpp +++ b/radio/src/gui/colorlcd/model_mixes.cpp @@ -29,9 +29,6 @@ #define SET_DIRTY() storageDirty(EE_MODEL) -LAYOUT_VAL1(MPLEX_ICON_W, 25) -LAYOUT_VAL3(MPLEX_ICON_H, 29, 22, 29) - class MPlexIcon : public Window { public: @@ -70,6 +67,9 @@ class MPlexIcon : public Window index = i; } + static LAYOUT_VAL(MPLEX_ICON_W, 25, 25, LS(25)) + static LAYOUT_VAL(MPLEX_ICON_H, 29, 29, 22) + protected: uint8_t index; StaticIcon* icon = nullptr; @@ -139,8 +139,8 @@ class MixLineButton : public InputMixButtonBase void updatePos(coord_t x, coord_t y) override { setPos(x, y); - mplex->setPos(x - 28, y); - mplex->show(y > IM_BTN_H); + mplex->setPos(x - MPLEX_XO, y); + mplex->show(y > ListLineButton::BTN_H); } lv_obj_t* mplexLvObj() const { return mplex->getLvObj(); } @@ -163,6 +163,8 @@ class MixLineButton : public InputMixButtonBase } } + static LAYOUT_VAL(MPLEX_XO, 28, 28, LS(28)) + protected: MPlexIcon* mplex = nullptr; @@ -177,7 +179,7 @@ class MixGroup : public InputMixGroupBase { adjustHeight(); - lv_obj_set_pos(label, 2, -1); + lv_obj_set_pos(label, PAD_TINY, -1); lv_obj_t* chText = nullptr; if (idx >= MIXSRC_FIRST_CH && idx <= MIXSRC_LAST_CH && @@ -186,7 +188,7 @@ class MixGroup : public InputMixGroupBase etx_font(chText, FONT_XS_INDEX); lv_label_set_text_fmt(chText, TR_CH "%" PRIu32, UINT32_C(idx - MIXSRC_FIRST_CH + 1)); - lv_obj_set_pos(chText, 2, 17); + lv_obj_set_pos(chText, PAD_TINY, CHNUM_Y); } refresh(); @@ -195,7 +197,7 @@ class MixGroup : public InputMixGroupBase void enableMixerMonitor() { if (!monitor) - monitor = new MixerChannelBar(this, {LCD_W - 118, 1, 100, 14}, idx - MIXSRC_FIRST_CH); + monitor = new MixerChannelBar(this, {LCD_W - CHBAR_XO, 1, CHBAR_W, CHBAR_H}, idx - MIXSRC_FIRST_CH); monitorVisible = true; monitor->show(); adjustHeight(); @@ -208,6 +210,11 @@ class MixGroup : public InputMixGroupBase adjustHeight(); } + static LAYOUT_VAL(CHNUM_Y, 17, 17, LS(17)) + static LAYOUT_VAL(CHBAR_XO, 118, 118, LS(118)) + static LAYOUT_VAL(CHBAR_W, 100, 100, LS(100)) + static LAYOUT_VAL(CHBAR_H, 14, 14, LS(14)) + protected: MixerChannelBar* monitor = nullptr; bool monitorVisible = false; diff --git a/radio/src/gui/colorlcd/model_outputs.cpp b/radio/src/gui/colorlcd/model_outputs.cpp index 8f8eec14972..55e361603c2 100644 --- a/radio/src/gui/colorlcd/model_outputs.cpp +++ b/radio/src/gui/colorlcd/model_outputs.cpp @@ -32,44 +32,6 @@ #define ETX_STATE_MINMAX_BOLD LV_STATE_USER_1 #define ETX_STATE_NAME_FONT_SMALL LV_STATE_USER_1 -LAYOUT_VAL1(CH_BAR_WIDTH, 100) -LAYOUT_VAL1(CH_BAR_HEIGHT, 16) -LAYOUT_VAL2(CH_LINE_H, 32, 50) -LAYOUT_VAL3(MIN_Y, 4, 2, 2) -LAYOUT_VAL2(MAX_W, 52, 60) -LAYOUT_VAL3(OFF_Y, MIN_Y, MIN_Y, 24) -LAYOUT_VAL2(OFF_W, 44, 52) -#define BAR_Y PAD_MEDIUM - -#if !PORTRAIT_LCD -#define OFF_X (MAX_X + MAX_W + PAD_TINY) -#else -#define OFF_X (SRC_X + SRC_W + PAD_TINY) -#endif - -#define SRC_X PAD_TINY -#define SRC_Y 1 -LAYOUT_VAL1(SRC_W, 80) -#define SRC_H (CH_LINE_H - PAD_MEDIUM) -#define MIN_X (SRC_X + SRC_W + PAD_TINY) -LAYOUT_VAL1(MIN_W, 52) -LAYOUT_VAL1(MIN_H, 20) -#define MAX_X (MIN_X + MIN_W + PAD_TINY) -#define MAX_Y MIN_Y -#define MAX_H MIN_H -#define OFF_H MIN_H -#define CTR_X (OFF_X + OFF_W + PAD_TINY) -#define CTR_Y OFF_Y -LAYOUT_VAL1(CTR_W, 60) -#define CTR_H MIN_H -#define REV_X (CTR_X + CTR_W + PAD_TINY) -#define REV_Y CTR_Y -LAYOUT_VAL1(REV_W, 16) -#define CRV_X (REV_X + REV_W + PAD_TINY) -#define CRV_Y (REV_Y + 1) -LAYOUT_VAL1(BAR_XO, 17) -#define BAR_X (LCD_W - CH_BAR_WIDTH - BAR_XO) - class OutputLineButton : public ListLineButton { bool init = false; @@ -125,7 +87,7 @@ class OutputLineButton : public ListLineButton curve = new StaticIcon(this, CRV_X, CRV_Y, ICON_TEXTLINE_CURVE, COLOR_THEME_SECONDARY1); - bar = new OutputChannelBar(this, rect_t{BAR_X, BAR_Y, CH_BAR_WIDTH, CH_BAR_HEIGHT}, + bar = new OutputChannelBar(this, rect_t{BAR_X, PAD_MEDIUM, CH_BAR_WIDTH, CH_BAR_HEIGHT}, index, false, false); refresh(); @@ -145,7 +107,7 @@ class OutputLineButton : public ListLineButton lv_obj_set_pos(source, SRC_X, SRC_Y); lv_obj_set_size(source, SRC_W, SRC_H); -#if LCD_W > LCD_H +#if !PORTRAIT_LCD etx_font(source, FONT_XS_INDEX, ETX_STATE_NAME_FONT_SMALL); lv_obj_set_style_pad_top(source, -2, ETX_STATE_NAME_FONT_SMALL); lv_obj_set_style_text_line_space(source, -3, ETX_STATE_NAME_FONT_SMALL); @@ -194,6 +156,38 @@ class OutputLineButton : public ListLineButton curve->show(output->curve); } + static LAYOUT_VAL(CH_LINE_H, 32, 50, LS(32)) + static LAYOUT_VAL(CH_BAR_WIDTH, 100, 100, LS(100)) + static LAYOUT_VAL(CH_BAR_HEIGHT, 16, 16, LS(16)) + static LAYOUT_VAL(BAR_XO, 17, 17, LS(17)) + static constexpr coord_t BAR_X = LCD_W - CH_BAR_WIDTH - BAR_XO; + + static constexpr coord_t SRC_X = PAD_TINY; + static constexpr coord_t SRC_Y = 1; + static LAYOUT_VAL(SRC_W, 80, 80, LS(80)) + static constexpr coord_t SRC_H = CH_LINE_H - PAD_MEDIUM; + static constexpr coord_t MIN_X = SRC_X + SRC_W + PAD_TINY; + static LAYOUT_VAL(MIN_Y, 4, 2, 2) + static LAYOUT_VAL(MIN_W, 52, 52, LS(52)) + static LAYOUT_VAL(MIN_H, 20, 20, LS(20)) + static constexpr coord_t MAX_X = MIN_X + MIN_W + PAD_TINY; + static constexpr coord_t MAX_Y = MIN_Y; + static LAYOUT_VAL(MAX_W, 52, 60, LS(52)) + static constexpr coord_t MAX_H = MIN_H; + static LAYOUT_VAL(OFF_X, MAX_X + MAX_W + PAD_TINY, SRC_X + SRC_W + PAD_TINY, MAX_X + MAX_W + PAD_TINY) + static LAYOUT_VAL(OFF_Y, MIN_Y, 24, MIN_Y) + static LAYOUT_VAL(OFF_W, 44, 52, LS(44)) + static constexpr coord_t OFF_H = MIN_H; + static constexpr coord_t CTR_X = OFF_X + OFF_W + PAD_TINY; + static constexpr coord_t CTR_Y = OFF_Y; + static LAYOUT_VAL(CTR_W, 60, 60, LS(60)) + static constexpr coord_t CTR_H = MIN_H; + static constexpr coord_t REV_X = CTR_X + CTR_W + PAD_TINY; + static constexpr coord_t REV_Y = CTR_Y; + static LAYOUT_VAL(REV_W, 16, 16, LS(16)) + static constexpr coord_t CRV_X = REV_X + REV_W + PAD_TINY; + static constexpr coord_t CRV_Y = REV_Y + 1; + protected: int value = -10000; @@ -231,30 +225,6 @@ ModelOutputsPage::ModelOutputsPage() : { } -#define ADD_TRIMS_X PAD_MEDIUM -#define ADD_TRIMS_Y PAD_SMALL -#define ADD_TRIMS_H UI_ELEMENT_HEIGHT - -LAYOUT_VAL3(ADD_TRIMS_W, (LCD_W / 2) - 10, (LCD_W / 2) - 7, LCD_W - 12) -LAYOUT_VAL2(EXLIM_Y, 10, ADD_TRIMS_X + ADD_TRIMS_H + 8) -LAYOUT_VAL2(EXLIMCB_Y, 4, ADD_TRIMS_X + ADD_TRIMS_H + 2) - -#if !PORTRAIT_LCD -#define EXLIM_X (ADD_TRIMS_X + ADD_TRIMS_W + PAD_SMALL) -#else -#define EXLIM_X 6 -#endif - -#define EXLIM_W (EXLIMCB_X - EXLIM_X - PAD_SMALL) -LAYOUT_VAL1(EXLIM_H, 20) -LAYOUT_VAL1(EXLIM_XO, 58) -#define EXLIMCB_X (LCD_W - EXLIM_XO) -LAYOUT_VAL1(EXLIMCB_W, 52) -#define EXLIMCB_H UI_ELEMENT_HEIGHT -#define TRIMB_X PAD_MEDIUM -#define TRIMB_Y (EXLIMCB_Y + EXLIMCB_H + PAD_MEDIUM / 2) -#define TRIMB_W (LCD_W - PAD_MEDIUM * 2) - void ModelOutputsPage::build(Window* window) { window->padAll(PAD_ZERO); @@ -271,7 +241,7 @@ void ModelOutputsPage::build(Window* window) for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) { // Channel settings auto btn = new OutputLineButton(window, ch); - lv_obj_set_pos(btn->getLvObj(), TRIMB_X, TRIMB_Y + (ch * (CH_LINE_H + 2))); + lv_obj_set_pos(btn->getLvObj(), TRIMB_X, TRIMB_Y + (ch * (OutputLineButton::CH_LINE_H + 2))); btn->setWidth(TRIMB_W); LimitData* output = limitAddress(ch); diff --git a/radio/src/gui/colorlcd/model_outputs.h b/radio/src/gui/colorlcd/model_outputs.h index 6c8738b19c1..64e2d9d7aa5 100644 --- a/radio/src/gui/colorlcd/model_outputs.h +++ b/radio/src/gui/colorlcd/model_outputs.h @@ -31,6 +31,23 @@ class ModelOutputsPage : public PageTab ModelOutputsPage(); void build(Window* window) override; + static constexpr coord_t ADD_TRIMS_X = PAD_MEDIUM; + static constexpr coord_t ADD_TRIMS_Y = PAD_SMALL; + static LAYOUT_VAL(ADD_TRIMS_W, (LCD_W / 2) - 10, LCD_W - 12, (LCD_W / 2) - 7) + static constexpr coord_t ADD_TRIMS_H = EdgeTxStyles::UI_ELEMENT_HEIGHT; + static LAYOUT_VAL(EXLIM_XO, 58, 58, LS(58)) + static constexpr coord_t EXLIMCB_X = LCD_W - EXLIM_XO; + static LAYOUT_VAL(EXLIMCB_Y, 4, ADD_TRIMS_X + ADD_TRIMS_H + 2, LS(4)) + static LAYOUT_VAL(EXLIMCB_W, 52, 52, LS(52)) + static constexpr coord_t EXLIMCB_H = EdgeTxStyles::UI_ELEMENT_HEIGHT; + static LAYOUT_VAL(EXLIM_X, ADD_TRIMS_X + ADD_TRIMS_W + PAD_SMALL, 6, ADD_TRIMS_X + ADD_TRIMS_W + PAD_SMALL) + static LAYOUT_VAL(EXLIM_Y, 10, ADD_TRIMS_X + ADD_TRIMS_H + 8, LS(10)) + static constexpr coord_t EXLIM_W = EXLIMCB_X - EXLIM_X - PAD_SMALL; + static LAYOUT_VAL(EXLIM_H, 20, 20, LS(20)) + static constexpr coord_t TRIMB_X = PAD_MEDIUM; + static constexpr coord_t TRIMB_Y = EXLIMCB_Y + EXLIMCB_H + PAD_MEDIUM / 2; + static constexpr coord_t TRIMB_W = LCD_W - PAD_MEDIUM * 2; + protected: void editOutput(uint8_t channel, OutputLineButton* btn); }; diff --git a/radio/src/gui/colorlcd/model_select.cpp b/radio/src/gui/colorlcd/model_select.cpp index 1b88a7b09d3..b69562ab5d6 100644 --- a/radio/src/gui/colorlcd/model_select.cpp +++ b/radio/src/gui/colorlcd/model_select.cpp @@ -41,34 +41,20 @@ struct ModelButtonLayout { uint16_t font; }; -LAYOUT_VAL2(L0_W, 165, 147) -LAYOUT_VAL1(L0_H, 92) -LAYOUT_VAL2(L1_W, 108, 96) -LAYOUT_VAL1(L1_H, 61) -LAYOUT_VAL2(L3_W, 336, 300) -LAYOUT_VAL3(MODEL_CELL_PADDING, 4, 3, 4) +static LAYOUT_VAL(L0_W, 165, 147, LS(165)) +static LAYOUT_VAL(L0_H, 92, 92, LS(92)) +static LAYOUT_VAL(L1_W, 108, 96, LS(108)) +static LAYOUT_VAL(L1_H, 61, 61, LS(61)) +static LAYOUT_VAL(L3_W, 336, 300, LS(336)) +static LAYOUT_VAL(MODEL_CELL_PADDING, 4, 4, 3) ModelButtonLayout modelLayouts[] = { {L0_W, L0_H, MODEL_CELL_PADDING, true, FONT(STD)}, {L1_W, L1_H, MODEL_CELL_PADDING, true, FONT(XS)}, - {L0_W, UI_ELEMENT_HEIGHT, MODEL_CELL_PADDING, false, FONT(STD)}, - {L3_W, UI_ELEMENT_HEIGHT, MODEL_CELL_PADDING, false, FONT(STD)}, + {L0_W, EdgeTxStyles::UI_ELEMENT_HEIGHT, MODEL_CELL_PADDING, false, FONT(STD)}, + {L3_W, EdgeTxStyles::UI_ELEMENT_HEIGHT, MODEL_CELL_PADDING, false, FONT(STD)}, }; -LAYOUT_VAL3(BUTTONS_HEIGHT, 36, 26, 36) -LAYOUT_VAL2(LABELS_WIDTH, 132, 0) -LAYOUT_VAL2(LABELS_HEIGHT, 0, 152) -LAYOUT_VAL3(LABELS_ROW, 0, 0, 1) -LAYOUT_VAL3(MODELS_COL, 1, 1, 0) -constexpr int MODELS_ROW = 0; -LAYOUT_VAL3(MODELS_ROW_CNT, 2, 2, 1) -LAYOUT_VAL3(BUTTONS_ROW, 1, 1, 2) -LAYOUT_VAL3(NAME_H, 17, 12, 17) -LAYOUT_VAL3(NAME_PAD_TOP, -3, -1, -3) -LAYOUT_VAL1(NEW_BTN_W, 60) -LAYOUT_VAL3(LAYOUT_BTN_XO, 105, 75, 105) -LAYOUT_VAL3(LAYOUT_BTN_YO, 6, 3, 6) - class ModelButton : public Button { public: @@ -688,7 +674,7 @@ void ModelLabelsWindow::buildHead(Window *hdr) setTitle(); // new model button - auto btn = new TextButton(hdr, rect_t{0, 0, NEW_BTN_W, UI_ELEMENT_HEIGHT}, STR_NEW, [=]() { + auto btn = new TextButton(hdr, rect_t{0, 0, NEW_BTN_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, STR_NEW, [=]() { auto menu = new Menu(this); menu->setTitle(STR_CREATE_NEW); menu->addLine(STR_NEW_MODEL, [=]() { newModel(); }); @@ -715,14 +701,14 @@ void ModelLabelsWindow::buildHead(Window *hdr) } #if !PORTRAIT_LCD -static const lv_coord_t col_dsc[] = {LABELS_WIDTH, LV_GRID_FR(1), +static const lv_coord_t col_dsc[] = {ModelLabelsWindow::LABELS_WIDTH, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; -static const lv_coord_t row_dsc[] = {LV_GRID_FR(1), BUTTONS_HEIGHT, +static const lv_coord_t row_dsc[] = {LV_GRID_FR(1), ModelLabelsWindow::BUTTONS_HEIGHT, LV_GRID_TEMPLATE_LAST}; #else static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; -static const lv_coord_t row_dsc[] = {LV_GRID_FR(1), LABELS_HEIGHT, - BUTTONS_HEIGHT, LV_GRID_TEMPLATE_LAST}; +static const lv_coord_t row_dsc[] = {LV_GRID_FR(1), ModelLabelsWindow::LABELS_HEIGHT, + ModelLabelsWindow::BUTTONS_HEIGHT, LV_GRID_TEMPLATE_LAST}; #endif void ModelLabelsWindow::buildBody(Window *window) @@ -737,7 +723,7 @@ void ModelLabelsWindow::buildBody(Window *window) mdlselector->setLblRefreshFunc([=]() { labelRefreshRequest(); }); auto mdl_obj = mdlselector->getLvObj(); lv_obj_set_grid_cell(mdl_obj, LV_GRID_ALIGN_STRETCH, MODELS_COL, 1, - LV_GRID_ALIGN_STRETCH, MODELS_ROW, MODELS_ROW_CNT); + LV_GRID_ALIGN_STRETCH, 0, MODELS_ROW_CNT); if (mdlselector->getSortOrder() == NO_SORT) mdlselector->setSortOrder(NAME_ASC); diff --git a/radio/src/gui/colorlcd/model_select.h b/radio/src/gui/colorlcd/model_select.h index 5a3982a4d4b..91cb497656e 100644 --- a/radio/src/gui/colorlcd/model_select.h +++ b/radio/src/gui/colorlcd/model_select.h @@ -33,6 +33,17 @@ class ModelLabelsWindow : public Page public: ModelLabelsWindow(); + static LAYOUT_VAL(BUTTONS_HEIGHT, 36, 36, 26) + static LAYOUT_VAL(LABELS_WIDTH, 132, 0, LS(132)) + static LAYOUT_VAL(LABELS_HEIGHT, 0, 152, LS(0)) + static LAYOUT_VAL(LABELS_ROW, 0, 1, 0) + static LAYOUT_VAL(MODELS_COL, 1, 0, 1) + static LAYOUT_VAL(MODELS_ROW_CNT, 2, 1, 2) + static LAYOUT_VAL(BUTTONS_ROW, 1, 2, 1) + static LAYOUT_VAL(NEW_BTN_W, 60, 60, LS(60)) + static LAYOUT_VAL(LAYOUT_BTN_XO, 105, 105, 75) + static LAYOUT_VAL(LAYOUT_BTN_YO, 6, 6, 3) + protected: ModelsSortBy sort = DEFAULT_MODEL_SORT; char tmpLabel[LABEL_LENGTH + 1] = "\0"; diff --git a/radio/src/gui/colorlcd/model_setup.cpp b/radio/src/gui/colorlcd/model_setup.cpp index 3a0ee6e28be..95c995dcd6f 100644 --- a/radio/src/gui/colorlcd/model_setup.cpp +++ b/radio/src/gui/colorlcd/model_setup.cpp @@ -122,6 +122,8 @@ class SubScreenButton : public TextButton check(isActive()); } + static LAYOUT_VAL(SUBSCR_BTN_H, 62, 62, LS(62)) + protected: std::function m_isActive = nullptr; @@ -272,10 +274,6 @@ class ModelViewOptions : public Page } }; -LAYOUT_VAL3(SW_BTNS, 8, 8, 4) -LAYOUT_VAL3(SW_BTN_W, 56, 38, 72) -LAYOUT_VAL1(SW_BTN_H, 36) - struct CenterBeepsMatrix : public ButtonMatrix { CenterBeepsMatrix(Window* parent, const rect_t& rect) : ButtonMatrix(parent, rect) @@ -347,6 +345,10 @@ struct CenterBeepsMatrix : public ButtonMatrix { setChecked(btn_id); } + static LAYOUT_VAL(SW_BTNS, 8, 4, 8) + static LAYOUT_VAL(SW_BTN_W, 56, 72, 38) + static LAYOUT_VAL(SW_BTN_H, 36, 36, LS(36)) + private: uint8_t max_analogs; uint8_t ana_idx[MAX_ANALOG_INPUTS]; diff --git a/radio/src/gui/colorlcd/model_telemetry.cpp b/radio/src/gui/colorlcd/model_telemetry.cpp index 926fe136531..240a46f35ba 100644 --- a/radio/src/gui/colorlcd/model_telemetry.cpp +++ b/radio/src/gui/colorlcd/model_telemetry.cpp @@ -64,14 +64,6 @@ static const lv_coord_t e_col_dsc2[] = {LV_GRID_FR(4), LV_GRID_FR(3), static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; -#define BTN_H UI_ELEMENT_HEIGHT -LAYOUT_VAL1(NUM_W, 36) -LAYOUT_VAL1(NUM_H, 20) -LAYOUT_VAL1(NAME_W, 56) -LAYOUT_VAL1(ID_Y, 17) -LAYOUT_VAL1(ID_H, 11) -LAYOUT_VAL1(FRSH_Y, 10) - class TSStyle { public: @@ -98,6 +90,13 @@ class TSStyle lv_style_t tsFreshStyle; + static LAYOUT_VAL(NUM_W, 36, 36, LS(36)) + static LAYOUT_VAL(NUM_H, 20, 20, LS(20)) + static LAYOUT_VAL(NAME_W, 56, 56, LS(56)) + static LAYOUT_VAL(ID_Y, 17, 17, LS(17)) + static LAYOUT_VAL(ID_H, 11, 11, LS(11)) + static LAYOUT_VAL(FRSH_Y, 10, 10, LS(10)) + private: bool styleInitDone; }; @@ -116,8 +115,8 @@ static const lv_obj_class_t ts_num_class = { .destructor_cb = nullptr, .user_data = nullptr, .event_cb = nullptr, - .width_def = NUM_W, - .height_def = NUM_H, + .width_def = TSStyle::NUM_W, + .height_def = TSStyle::NUM_H, .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, .instance_size = sizeof(lv_label_t), @@ -143,8 +142,8 @@ static const lv_obj_class_t ts_id_class = { .destructor_cb = nullptr, .user_data = nullptr, .event_cb = nullptr, - .width_def = NUM_W, - .height_def = ID_H, + .width_def = TSStyle::NUM_W, + .height_def = TSStyle::ID_H, .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, .instance_size = sizeof(lv_label_t), @@ -169,8 +168,8 @@ static const lv_obj_class_t ts_name_class = { .destructor_cb = nullptr, .user_data = nullptr, .event_cb = nullptr, - .width_def = NAME_W, - .height_def = NUM_H, + .width_def = TSStyle::NAME_W, + .height_def = TSStyle::NUM_H, .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, .instance_size = sizeof(lv_label_t), @@ -197,7 +196,7 @@ static const lv_obj_class_t ts_value_class = { .user_data = nullptr, .event_cb = nullptr, .width_def = LV_SIZE_CONTENT, - .height_def = NUM_H, + .height_def = TSStyle::NUM_H, .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, .instance_size = sizeof(lv_label_t), @@ -261,7 +260,7 @@ class SensorButton : public ListLineButton ListLineButton(parent, index) { padAll(PAD_ZERO); - setHeight(BTN_H); + setHeight(EdgeTxStyles::UI_ELEMENT_HEIGHT); check(isActive()); @@ -325,20 +324,20 @@ class SensorButton : public ListLineButton sprintf(s, "ID: %d", sensor->instance); idLabel = tsStyle.newId(lvobj, s); - lv_obj_set_pos(idLabel, PAD_TINY, ID_Y); + lv_obj_set_pos(idLabel, PAD_TINY, TSStyle::ID_Y); } setNumIdState(); strAppend(s, g_model.telemetrySensors[index].label, TELEM_LABEL_LEN); lv_obj_t* nm = tsStyle.newName(lvobj, s); - lv_obj_set_pos(nm, NUM_W + PAD_SMALL, PAD_MEDIUM/2); + lv_obj_set_pos(nm, TSStyle::NUM_W + PAD_SMALL, PAD_MEDIUM/2); fresh = etx_create(&ts_fresh_icon_class, lvobj); - lv_obj_set_pos(fresh, NUM_W + NAME_W + PAD_MEDIUM, FRSH_Y); + lv_obj_set_pos(fresh, TSStyle::NUM_W + TSStyle::NAME_W + PAD_MEDIUM, TSStyle::FRSH_Y); valLabel = tsStyle.newValue(lvobj); - lv_obj_set_pos(valLabel, NUM_W + NAME_W + PAD_LARGE * 2, PAD_MEDIUM/2); + lv_obj_set_pos(valLabel, TSStyle::NUM_W + TSStyle::NAME_W + PAD_LARGE * 2, PAD_MEDIUM/2); lv_obj_update_layout(lvobj); } @@ -898,8 +897,6 @@ void ModelTelemetryPage::buildSensorList(int8_t focusSensorIndex) deleteAll->show(sensorsCount > 0); } -LAYOUT_VAL2(NUM_EDIT_W, 100, 65) - void ModelTelemetryPage::build(Window* window) { window->padAll(PAD_TINY); diff --git a/radio/src/gui/colorlcd/model_telemetry.h b/radio/src/gui/colorlcd/model_telemetry.h index eb9f4fa7410..05f4ba0bf4c 100644 --- a/radio/src/gui/colorlcd/model_telemetry.h +++ b/radio/src/gui/colorlcd/model_telemetry.h @@ -33,6 +33,8 @@ class ModelTelemetryPage : public PageTab void build(Window* window) override; + static LAYOUT_VAL(NUM_EDIT_W, 100, 65, LS(100)) + protected: int lastKnownIndex = 0; Window* window = nullptr; diff --git a/radio/src/gui/colorlcd/model_templates.cpp b/radio/src/gui/colorlcd/model_templates.cpp index b3948e6a4fd..cc6f3b5d31d 100644 --- a/radio/src/gui/colorlcd/model_templates.cpp +++ b/radio/src/gui/colorlcd/model_templates.cpp @@ -136,7 +136,7 @@ class SelectTemplate : public TemplatePage for (auto name : files) { auto tb = new TextButton( - listWindow, rect_t{0, 0, lv_pct(100), PAGE_LINE_HEIGHT * 2}, name, + listWindow, rect_t{0, 0, lv_pct(100), EdgeTxStyles::PAGE_LINE_HEIGHT * 2}, name, [=]() -> uint8_t { deleteLater(); templateFolderPage->doUpdate(folder, name); @@ -177,7 +177,7 @@ SelectTemplateFolder::SelectTemplateFolder( header->setTitle2(STR_NEW_MODEL); auto tfb = new TextButton(listWindow, - rect_t{0, 0, lv_pct(100), PAGE_LINE_HEIGHT * 2}, + rect_t{0, 0, lv_pct(100), EdgeTxStyles::PAGE_LINE_HEIGHT * 2}, STR_BLANK_MODEL, [=]() -> uint8_t { doUpdate("", ""); return 0; @@ -216,7 +216,7 @@ SelectTemplateFolder::SelectTemplateFolder( if (!strcasecmp(name.c_str(), "WIZARD") == 0) { #endif auto tfb = new TextButton( - listWindow, rect_t{0, 0, lv_pct(100), PAGE_LINE_HEIGHT * 2}, name, + listWindow, rect_t{0, 0, lv_pct(100), EdgeTxStyles::PAGE_LINE_HEIGHT * 2}, name, [=]() -> uint8_t { new SelectTemplate(this, name); return 0; diff --git a/radio/src/gui/colorlcd/model_usbjoystick.cpp b/radio/src/gui/colorlcd/model_usbjoystick.cpp index e492afded4b..1f000e09a77 100644 --- a/radio/src/gui/colorlcd/model_usbjoystick.cpp +++ b/radio/src/gui/colorlcd/model_usbjoystick.cpp @@ -289,7 +289,7 @@ class USBChannelEditWindow : public Page window, {window->getRect().w - USBCH_EDIT_STATUS_BAR_WIDTH - USBCH_EDIT_RIGHT_MARGIN, - 0, USBCH_EDIT_STATUS_BAR_WIDTH, MENU_HEADER_HEIGHT}, + 0, USBCH_EDIT_STATUS_BAR_WIDTH, EdgeTxStyles::MENU_HEADER_HEIGHT}, channel); } diff --git a/radio/src/gui/colorlcd/output_edit.cpp b/radio/src/gui/colorlcd/output_edit.cpp index d84db76032f..8e16dbe2d87 100644 --- a/radio/src/gui/colorlcd/output_edit.cpp +++ b/radio/src/gui/colorlcd/output_edit.cpp @@ -30,10 +30,6 @@ #define ETX_STATE_MINMAX_HIGHLIGHT LV_STATE_USER_1 -LAYOUT_VAL2(OUTPUT_EDIT_STATUS_BAR_WIDTH, 250, 180) -LAYOUT_VAL2(OUTPUT_EDIT_STATUS_BAR_MARGIN, 3, 0) -LAYOUT_VAL2(OUTPUT_EDIT_RIGHT_MARGIN, 0, 3) - // deadband in % for switching direction of Min/Max text and value field highlighting // 0 = no deadband // 1..100 = [-DEADBAND; DEADBAND] @@ -57,6 +53,8 @@ class OutputEditStatusBar : public Window channel, true); } + static LAYOUT_VAL(OUTPUT_EDIT_STATUS_BAR_MARGIN, 3, 0, LS(3)) + protected: ComboChannelBar *channelBar; int8_t _channel; @@ -107,7 +105,7 @@ void OutputEditWindow::buildHeader(Window *window) window, {window->getRect().w - OUTPUT_EDIT_STATUS_BAR_WIDTH - OUTPUT_EDIT_RIGHT_MARGIN, - 0, OUTPUT_EDIT_STATUS_BAR_WIDTH, MENU_HEADER_HEIGHT}, + 0, OUTPUT_EDIT_STATUS_BAR_WIDTH, EdgeTxStyles::MENU_HEADER_HEIGHT}, channel); } diff --git a/radio/src/gui/colorlcd/output_edit.h b/radio/src/gui/colorlcd/output_edit.h index eeb0aa0e5da..a8e6e7d0609 100644 --- a/radio/src/gui/colorlcd/output_edit.h +++ b/radio/src/gui/colorlcd/output_edit.h @@ -31,6 +31,9 @@ class OutputEditWindow : public Page public: explicit OutputEditWindow(uint8_t channel); + static LAYOUT_VAL(OUTPUT_EDIT_STATUS_BAR_WIDTH, 250, 180, LS(250)) + static LAYOUT_VAL(OUTPUT_EDIT_RIGHT_MARGIN, 0, 3, 0) + protected: uint8_t channel; int value = 0; diff --git a/radio/src/gui/colorlcd/page.cpp b/radio/src/gui/colorlcd/page.cpp index cb450628907..5e960c595b9 100644 --- a/radio/src/gui/colorlcd/page.cpp +++ b/radio/src/gui/colorlcd/page.cpp @@ -26,7 +26,7 @@ #include "view_main.h" PageHeader::PageHeader(Page* parent, EdgeTxIcon icon) : - Window(parent, {0, 0, LCD_W, MENU_HEADER_HEIGHT}), + Window(parent, {0, 0, LCD_W, EdgeTxStyles::MENU_HEADER_HEIGHT}), icon(icon) { setWindowFlag(NO_FOCUS | OPAQUE); @@ -37,7 +37,7 @@ PageHeader::PageHeader(Page* parent, EdgeTxIcon icon) : title = new StaticText(this, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP, - LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, + LCD_W - PAGE_TITLE_LEFT, EdgeTxStyles::PAGE_LINE_HEIGHT}, "", COLOR_THEME_PRIMARY2); } @@ -45,8 +45,8 @@ StaticText* PageHeader::setTitle2(std::string txt) { if (title2 == nullptr) { title2 = new StaticText(this, - {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT, - LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, + {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + EdgeTxStyles::PAGE_LINE_HEIGHT, + LCD_W - PAGE_TITLE_LEFT, EdgeTxStyles::PAGE_LINE_HEIGHT}, "", COLOR_THEME_PRIMARY2); } title2->setText(std::move(txt)); @@ -58,11 +58,11 @@ Page::Page(EdgeTxIcon icon, PaddingSize padding) : { header = new PageHeader(this, icon); body = new Window(this, - {0, MENU_HEADER_HEIGHT, LCD_W, LCD_H - MENU_HEADER_HEIGHT}); + {0, EdgeTxStyles::MENU_HEADER_HEIGHT, LCD_W, LCD_H - EdgeTxStyles::MENU_HEADER_HEIGHT}); body->setWindowFlag(NO_FOCUS); etx_solid_bg(lvobj); - lv_obj_set_style_max_height(body->getLvObj(), LCD_H - MENU_HEADER_HEIGHT, + lv_obj_set_style_max_height(body->getLvObj(), LCD_H - EdgeTxStyles::MENU_HEADER_HEIGHT, LV_PART_MAIN); etx_scrollbar(body->getLvObj()); diff --git a/radio/src/gui/colorlcd/page.h b/radio/src/gui/colorlcd/page.h index cc23a16486a..07e8d60d956 100644 --- a/radio/src/gui/colorlcd/page.h +++ b/radio/src/gui/colorlcd/page.h @@ -35,6 +35,9 @@ class PageHeader : public Window void setTitle(std::string txt) { title->setText(std::move(txt)); } StaticText* setTitle2(std::string txt); + static LAYOUT_VAL(PAGE_TITLE_LEFT, 50, 50, LS(50)) + static constexpr coord_t PAGE_TITLE_TOP = 2; + protected: EdgeTxIcon icon; StaticText* title; diff --git a/radio/src/gui/colorlcd/preflight_checks.cpp b/radio/src/gui/colorlcd/preflight_checks.cpp index c358199f9a1..d23862dab22 100644 --- a/radio/src/gui/colorlcd/preflight_checks.cpp +++ b/radio/src/gui/colorlcd/preflight_checks.cpp @@ -89,6 +89,10 @@ struct SwitchWarnMatrix : public ButtonMatrix { bool isActive(uint8_t btn_id); void setTextAndState(uint8_t btn_id); + static LAYOUT_VAL(SW_BTNS, 8, 4, 8) + static LAYOUT_VAL(SW_BTN_W, 56, 72, 38) + static LAYOUT_VAL(SW_BTN_H, 36, 36, LS(36)) + private: uint8_t sw_idx[MAX_SWITCHES]; }; @@ -195,10 +199,6 @@ static std::string switchWarninglabel(swsrc_t index) std::string(getSwitchWarnSymbol(warn_pos)); } -LAYOUT_VAL3(SW_BTNS, 8, 8, 4) -LAYOUT_VAL3(SW_BTN_W, 56, 38, 72) -LAYOUT_VAL1(SW_BTN_H, 36) - SwitchWarnMatrix::SwitchWarnMatrix(Window* parent, const rect_t& r) : ButtonMatrix(parent, r) { @@ -273,7 +273,7 @@ PotWarnMatrix::PotWarnMatrix(Window* parent, const rect_t& r) : } } - initBtnMap(min((int)btn_cnt, SW_BTNS), btn_cnt); + initBtnMap(min((int)btn_cnt, SwitchWarnMatrix::SW_BTNS), btn_cnt); uint8_t btn_id = 0; for (uint16_t i = 0; i < MAX_POTS; i++) { @@ -285,10 +285,10 @@ PotWarnMatrix::PotWarnMatrix(Window* parent, const rect_t& r) : update(); - lv_obj_set_width(lvobj, min((int)btn_cnt, SW_BTNS) * SW_BTN_W + PAD_SMALL); + lv_obj_set_width(lvobj, min((int)btn_cnt, SwitchWarnMatrix::SW_BTNS) * SwitchWarnMatrix::SW_BTN_W + PAD_SMALL); - uint8_t rows = ((btn_cnt - 1) / SW_BTNS) + 1; - lv_obj_set_height(lvobj, (rows * SW_BTN_H) + PAD_SMALL); + uint8_t rows = ((btn_cnt - 1) / SwitchWarnMatrix::SW_BTNS) + 1; + lv_obj_set_height(lvobj, (rows * SwitchWarnMatrix::SW_BTN_H) + PAD_SMALL); padAll(PAD_SMALL); } diff --git a/radio/src/gui/colorlcd/preview_window.cpp b/radio/src/gui/colorlcd/preview_window.cpp index 4ac9f914ab9..b9648566cec 100644 --- a/radio/src/gui/colorlcd/preview_window.cpp +++ b/radio/src/gui/colorlcd/preview_window.cpp @@ -27,6 +27,7 @@ #include "theme.h" #include "themes/etx_lv_theme.h" #include "trims.h" +#include "topbar_impl.h" extern inline tmr10ms_t getTicks() { return g_tmr10ms; } @@ -151,34 +152,34 @@ PreviewWindow::PreviewWindow(Window *window, rect_t rect, etx_solid_bg(lvobj, COLOR_THEME_SECONDARY3_INDEX); - auto topbar = new Window(this, {0, 0, LV_PCT(100), TOPBAR_ZONE_HEIGHT}); + auto topbar = new Window(this, {0, 0, LV_PCT(100), TopBar::TOPBAR_ZONE_HEIGHT}); etx_solid_bg(topbar->getLvObj(), COLOR_THEME_SECONDARY1_INDEX); - new StaticIcon(topbar, 5, 5, ICON_RADIO, + new StaticIcon(topbar, ICON_X1, ICON_Y, ICON_RADIO, COLOR_THEME_PRIMARY2); - new StaticIcon(topbar, 38, 5, ICON_RADIO_TOOLS, + new StaticIcon(topbar, ICON_X2, ICON_Y, ICON_RADIO_TOOLS, COLOR_THEME_PRIMARY2); - new StaticIcon(topbar, 71, 5, ICON_RADIO_SETUP, + new StaticIcon(topbar, ICON_X3, ICON_Y, ICON_RADIO_SETUP, COLOR_THEME_PRIMARY2); - new StaticText(this, {5, 44, 100, PAGE_LINE_HEIGHT}, STR_THEME_CHECKBOX); - new ThemedCheckBox(this, {100, 40, 40, 28}, true); - new ThemedCheckBox(this, {150, 40, 40, 28}, false); - (new ThemedButton(this, {210, 40, 100, 32}, STR_THEME_ACTIVE, true)) + new StaticText(this, {ICON_X1, CBT_Y, CBT_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_THEME_CHECKBOX); + new ThemedCheckBox(this, {CB1_X, CB_Y, CB_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, true); + new ThemedCheckBox(this, {CB2_X, CB_Y, CB_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, false); + (new ThemedButton(this, {BTN_X, BTN1_Y, BTN_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, STR_THEME_ACTIVE, true)) ->check(true); - new ThemedButton(this, {210, 75, 100, 32}, STR_THEME_REGULAR, false); - new MainViewTrim(this, {5, 75, HORIZONTAL_SLIDERS_WIDTH, 20}, 0, false); - new MainViewSlider(this, {5, 97, HORIZONTAL_SLIDERS_WIDTH, 20}, 0, false); - new StaticText(this, {5, 122, 100, PAGE_LINE_HEIGHT}, STR_THEME_WARNING, + new ThemedButton(this, {BTN_X, BTN2_Y, BTN_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, STR_THEME_REGULAR, false); + new MainViewTrim(this, {ICON_X1, TRIM_Y, MainViewSlider::HORIZONTAL_SLIDERS_WIDTH, TRIM_H}, 0, false); + new MainViewSlider(this, {ICON_X1, SLIDER_Y, MainViewSlider::HORIZONTAL_SLIDERS_WIDTH, TRIM_H}, 0, false); + new StaticText(this, {ICON_X1, TXT1_Y, TXT_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_THEME_WARNING, COLOR_THEME_WARNING); - new StaticText(this, {5, 144, 100, PAGE_LINE_HEIGHT}, STR_THEME_DISABLED, + new StaticText(this, {ICON_X1, TXT2_Y, TXT_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_THEME_DISABLED, COLOR_THEME_DISABLED); - new ThemedTextEdit(this, {5, 170, 100, 0}, STR_THEME_EDIT, true); - new ThemedTextEdit(this, {110, 170, 100, 0}, STR_THEME_FOCUS, false); + new ThemedTextEdit(this, {ICON_X1, EDT_Y, TXT_W, 0}, STR_THEME_EDIT, true); + new ThemedTextEdit(this, {EDT2_X, EDT_Y, TXT_W, 0}, STR_THEME_FOCUS, false); ticks = 0; - dateTime = new HeaderDateTime(this->getLvObj(), width() - 42, 4); + dateTime = new HeaderDateTime(this->getLvObj(), width() - DATE_XO, PAD_SMALL); lv_group_set_default(def_group); diff --git a/radio/src/gui/colorlcd/preview_window.h b/radio/src/gui/colorlcd/preview_window.h index bdd462c5c14..4e27538c4bd 100644 --- a/radio/src/gui/colorlcd/preview_window.h +++ b/radio/src/gui/colorlcd/preview_window.h @@ -34,6 +34,30 @@ class PreviewWindow : public Window void setColorList(std::vector colorList); + static LAYOUT_VAL(ICON_X1, 5, 5, LS(5)) + static LAYOUT_VAL(ICON_X2, 38, 38, LS(38)) + static LAYOUT_VAL(ICON_X3, 71, 71, LS(71)) + static LAYOUT_VAL(ICON_Y, 5, 5, LS(5)) + static LAYOUT_VAL(DATE_XO, 44, 44, LS(44)) + static LAYOUT_VAL(CBT_Y, 44, 44, LS(44)) + static LAYOUT_VAL(CBT_W, 100, 100, LS(100)) + static LAYOUT_VAL(CB1_X, 100, 100, LS(100)) + static LAYOUT_VAL(CB2_X, 154, 154, LS(154)) + static LAYOUT_VAL(CB_Y, 40, 40, LS(40)) + static LAYOUT_VAL(CB_W, 50, 50, LS(50)) + static LAYOUT_VAL(BTN_X, 210, 210, LS(210)) + static LAYOUT_VAL(BTN1_Y, 40, 40, LS(40)) + static LAYOUT_VAL(BTN2_Y, 79, 79, LS(79)) + static LAYOUT_VAL(BTN_W, 100, 100, LS(100)) + static LAYOUT_VAL(TRIM_Y, 79, 79, LS(79)) + static LAYOUT_VAL(TRIM_H, 20, 20, LS(20)) + static LAYOUT_VAL(SLIDER_Y, 101, 101, LS(101)) + static LAYOUT_VAL(TXT1_Y, 122, 122, LS(122)) + static LAYOUT_VAL(TXT2_Y, 144, 144, LS(144)) + static LAYOUT_VAL(TXT_W, 100, 100, LS(100)) + static LAYOUT_VAL(EDT2_X, 114, 114, LS(114)) + static LAYOUT_VAL(EDT_Y, 170, 170, LS(170)) + protected: tmr10ms_t ticks; HeaderDateTime *dateTime; diff --git a/radio/src/gui/colorlcd/radio_calibration.cpp b/radio/src/gui/colorlcd/radio_calibration.cpp index fc4a1caa1ec..9a2d8137e1d 100644 --- a/radio/src/gui/colorlcd/radio_calibration.cpp +++ b/radio/src/gui/colorlcd/radio_calibration.cpp @@ -30,9 +30,6 @@ uint8_t menuCalibrationState; -LAYOUT_VAL1(CAL_CTR, 9) -LAYOUT_VAL1(CAL_SIZ, 68) - static const uint8_t stick_pointer[] = { #include "alpha_stick_pointer.lbm" }; @@ -60,6 +57,9 @@ class StickCalibrationWindow : public Window lv_obj_set_pos(calibStick->getLvObj(), dx, dy); } + static LAYOUT_VAL(CAL_CTR, 9, 9, LS(9)) + static LAYOUT_VAL(CAL_SIZ, 68, 68, LS(68)) + protected: uint8_t stickX, stickY; StaticLZ4Image *calibStick = nullptr; diff --git a/radio/src/gui/colorlcd/radio_diagkeys.cpp b/radio/src/gui/colorlcd/radio_diagkeys.cpp index 514ebd7c3cb..f00a1c49cf2 100644 --- a/radio/src/gui/colorlcd/radio_diagkeys.cpp +++ b/radio/src/gui/colorlcd/radio_diagkeys.cpp @@ -98,22 +98,22 @@ class RadioKeyDiagsWindow : public Window auto lbl = lv_label_create(obj); lv_label_set_text(lbl, keysGetLabel(k)); - lv_obj_set_pos(lbl, 0, i * FH); + lv_obj_set_pos(lbl, 0, i * EdgeTxStyles::PAGE_LINE_HEIGHT); lbl = lv_label_create(obj); lv_label_set_text(lbl, ""); - lv_obj_set_pos(lbl, 70, i * FH); + lv_obj_set_pos(lbl, 70, i * EdgeTxStyles::PAGE_LINE_HEIGHT); keyValues[i] = lbl; } #if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_HATS_AS_KEYS) auto lbl = lv_label_create(obj); lv_label_set_text(lbl, STR_ROTARY_ENCODER); - lv_obj_set_pos(lbl, 0, (i + 1) * FH); + lv_obj_set_pos(lbl, 0, (i + 1) * EdgeTxStyles::PAGE_LINE_HEIGHT); reValue = lv_label_create(obj); lv_label_set_text(reValue, ""); - lv_obj_set_pos(reValue, 70, (i + 1) * FH); + lv_obj_set_pos(reValue, 70, (i + 1) * EdgeTxStyles::PAGE_LINE_HEIGHT); #endif } @@ -129,7 +129,7 @@ class RadioKeyDiagsWindow : public Window if (SWITCH_EXISTS(i)) { auto lbl = lv_label_create(obj); lv_label_set_text(lbl, ""); - lv_obj_set_pos(lbl, 0, row * FH); + lv_obj_set_pos(lbl, 0, row * EdgeTxStyles::PAGE_LINE_HEIGHT); switchValues[i] = lbl; row += 1; } @@ -157,16 +157,16 @@ class RadioKeyDiagsWindow : public Window lbl = lv_label_create(obj); formatNumberAsString(s, 10, i + 1, 0, 10, "T"); lv_label_set_text(lbl, s); - lv_obj_set_pos(lbl, 4, i * FH + FH); + lv_obj_set_pos(lbl, 4, i * EdgeTxStyles::PAGE_LINE_HEIGHT + EdgeTxStyles::PAGE_LINE_HEIGHT); lbl = lv_label_create(obj); lv_label_set_text(lbl, ""); - lv_obj_set_pos(lbl, 60, i * FH + FH); + lv_obj_set_pos(lbl, 60, i * EdgeTxStyles::PAGE_LINE_HEIGHT + EdgeTxStyles::PAGE_LINE_HEIGHT); trimValues[i * 2] = lbl; lbl = lv_label_create(obj); lv_label_set_text(lbl, ""); - lv_obj_set_pos(lbl, 75, i * FH + FH); + lv_obj_set_pos(lbl, 75, i * EdgeTxStyles::PAGE_LINE_HEIGHT + EdgeTxStyles::PAGE_LINE_HEIGHT); trimValues[i * 2 + 1] = lbl; } } diff --git a/radio/src/gui/colorlcd/radio_ghost_module_config.cpp b/radio/src/gui/colorlcd/radio_ghost_module_config.cpp index 1d0cf02c4c3..4ceb3c1ea65 100644 --- a/radio/src/gui/colorlcd/radio_ghost_module_config.cpp +++ b/radio/src/gui/colorlcd/radio_ghost_module_config.cpp @@ -162,7 +162,7 @@ void RadioGhostModuleConfig::buildBody(Window* window) { window->padAll(PAD_ZERO); new GhostModuleConfigWindow(window, - {0, 0, LCD_W, LCD_H - MENU_HEADER_HEIGHT - 5}); + {0, 0, LCD_W, LCD_H - EdgeTxStyles::MENU_HEADER_HEIGHT - 5}); } #if defined(HARDWARE_KEYS) && !defined(PCBPL18) diff --git a/radio/src/gui/colorlcd/radio_hardware.cpp b/radio/src/gui/colorlcd/radio_hardware.cpp index ffcebc8869b..2e696e247aa 100644 --- a/radio/src/gui/colorlcd/radio_hardware.cpp +++ b/radio/src/gui/colorlcd/radio_hardware.cpp @@ -36,8 +36,6 @@ #include "hw_bluetooth.h" #endif -LAYOUT_VAL1(NUM_EDIT_W, 80) - #define SET_DIRTY() storageDirty(EE_GENERAL) static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2), diff --git a/radio/src/gui/colorlcd/radio_hardware.h b/radio/src/gui/colorlcd/radio_hardware.h index 1f023de6c3c..e9bbd283c23 100644 --- a/radio/src/gui/colorlcd/radio_hardware.h +++ b/radio/src/gui/colorlcd/radio_hardware.h @@ -27,6 +27,8 @@ class RadioHardwarePage : public PageTab { void checkEvents() override; + static LAYOUT_VAL(NUM_EDIT_W, 80, 80, LS(80)) + public: RadioHardwarePage(); diff --git a/radio/src/gui/colorlcd/radio_setup.cpp b/radio/src/gui/colorlcd/radio_setup.cpp index 66e4b2594c1..69e2c6fbdb1 100644 --- a/radio/src/gui/colorlcd/radio_setup.cpp +++ b/radio/src/gui/colorlcd/radio_setup.cpp @@ -38,12 +38,6 @@ static const lv_coord_t col_two_dsc[] = {LV_GRID_FR(19), LV_GRID_FR(21), LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; -// Absolute layout for date/time setion due to slow performance -// of lv_textarea in a flex layout. -LAYOUT_VAL2(DT_EDT_W, 80, 52) -LAYOUT_VAL3(DT_EDT_X, 220, 144, 144) -LAYOUT_VAL2(DT_LBL_W, 200, 140) - class DateTimeWindow : public Window { public: @@ -88,6 +82,12 @@ class DateTimeWindow : public Window } } + // Absolute layout for date/time setion due to slow performance + // of lv_textarea in a flex layout. + static LAYOUT_VAL(DT_EDT_W, 80, 52, LS(80)) + static LAYOUT_VAL(DT_EDT_X, 220, 144, 144) + static LAYOUT_VAL(DT_LBL_W, 200, 140, LS(200)) + protected: struct gtm m_tm; struct gtm m_last_tm; @@ -867,7 +867,7 @@ void RadioSetupPage::build(Window* window) #if defined(FAI_CHOICE) /* case ITEM_SETUP_FAI: - lcdDrawText(MENUS_MARGIN_LEFT, y, "FAI Mode"); + lcdDrawText(PAD_MEDIUM, y, "FAI Mode"); if (g_eeGeneral.fai) { lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, "Locked in FAI Mode"); } diff --git a/radio/src/gui/colorlcd/radio_theme.cpp b/radio/src/gui/colorlcd/radio_theme.cpp index eba84339786..52294922d23 100644 --- a/radio/src/gui/colorlcd/radio_theme.cpp +++ b/radio/src/gui/colorlcd/radio_theme.cpp @@ -30,24 +30,6 @@ #include "preview_window.h" #include "themes/etx_lv_theme.h" -constexpr int COLOR_PREVIEW_SIZE = 18; - -#if PORTRAIT_LCD -constexpr int LIST_HEIGHT = (LCD_H / 2 - 38); -constexpr int COLOR_LIST_HEIGHT = (LCD_H / 2 - 24); -#else -constexpr int LIST_WIDTH = ((LCD_W - 12) / 2 - COLOR_PREVIEW_SIZE); -constexpr int COLOR_LIST_WIDTH = ((LCD_W * 3) / 10); -#endif - -LAYOUT_VAL2(BUTTON_WIDTH, 75, 65) -LAYOUT_VAL2(COLOR_BOX_WIDTH, 45, 55) -LAYOUT_VAL1(BUTTON_HEIGHT, 30) -LAYOUT_VAL1(COLOR_BOX_HEIGHT, 30) -constexpr int BOX_MARGIN = 2; -LAYOUT_VAL1(MAX_BOX_WIDTH, 15) -LAYOUT_VAL1(HEX_STR_W, 95) - class ThemeColorPreview : public Window { public: @@ -87,6 +69,9 @@ class ThemeColorPreview : public Window build(); } + static LAYOUT_VAL(MAX_BOX_WIDTH, 15, 15, LS(15)) + static constexpr int BOX_MARGIN = 2; + protected: std::vector colorList; int boxWidth = MAX_BOX_WIDTH; @@ -158,7 +143,7 @@ class ThemeDetailsDialog : public BaseDialog line->padTop(10); auto button = - new TextButton(line, rect_t{0, 0, lv_pct(30), 32}, STR_CANCEL, [=]() { + new TextButton(line, rect_t{0, 0, lv_pct(30), 0}, STR_CANCEL, [=]() { deleteLater(); return 0; }); @@ -166,7 +151,7 @@ class ThemeDetailsDialog : public BaseDialog LV_GRID_ALIGN_CENTER, 0, 1); button = - new TextButton(line, rect_t{0, 0, lv_pct(30), 32}, STR_SAVE, [=]() { + new TextButton(line, rect_t{0, 0, lv_pct(30), 0}, STR_SAVE, [=]() { if (saveHandler != nullptr) if (!saveHandler(this->theme)) return 0; @@ -207,6 +192,17 @@ class ColorEditPage : public Page } } + static LAYOUT_VAL(COLOR_BOX_WIDTH, 45, 55, LS(45)) + static LAYOUT_VAL(COLOR_BOX_HEIGHT, 30, 30, LS(30)) + static LAYOUT_VAL(HEX_STR_W, 95, 95, LS(95)) + static LAYOUT_VAL(BUTTON_WIDTH, 75, 65, LS(75)) + +#if PORTRAIT_LCD + static constexpr int COLOR_LIST_HEIGHT = (LCD_H / 2 - 24); +#else + static constexpr int COLOR_LIST_WIDTH = ((LCD_W * 3) / 10); +#endif + protected: std::function _updateHandler; LcdColorIndex _indexOfColor; @@ -241,10 +237,10 @@ class ColorEditPage : public Page form->padAll(PAD_SMALL); #if !PORTRAIT_LCD form->setFlexLayout(LV_FLEX_FLOW_ROW, PAD_SMALL); - rect_t r = {0, 0, COLOR_LIST_WIDTH, form->height() - 8}; + rect_t r = {0, 0, COLOR_LIST_WIDTH, form->height() - PAD_LARGE}; #else form->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_SMALL); - rect_t r = {0, 0, form->width() - 9, COLOR_LIST_HEIGHT}; + rect_t r = {0, 0, form->width() - PAD_LARGE, COLOR_LIST_HEIGHT}; #endif Window *colForm = new Window(form, r); @@ -252,9 +248,9 @@ class ColorEditPage : public Page colForm->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_SMALL, r.w); #if !PORTRAIT_LCD - r.w = form->width() - COLOR_LIST_WIDTH - 12; + r.w = form->width() - COLOR_LIST_WIDTH - PAD_MEDIUM * 2; #else - r.h = form->height() - COLOR_LIST_HEIGHT - 12; + r.h = form->height() - COLOR_LIST_HEIGHT - PAD_MEDIUM * 2; #endif _previewWindow = new PreviewWindow(form, r, _theme->getColorList()); @@ -306,7 +302,7 @@ class ColorEditPage : public Page #endif // page tabs - rect_t r = {LCD_W - 2 * (BUTTON_WIDTH + 5), 6, BUTTON_WIDTH, BUTTON_HEIGHT}; + rect_t r = {LCD_W - 2 * (BUTTON_WIDTH + 5), PAD_MEDIUM, BUTTON_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT}; _tabs.emplace_back(new TextButton(window, r, "RGB", [=]() { setActiveColorBar(0); return 1; @@ -381,7 +377,7 @@ class ThemeEditPage : public Page #endif // save and cancel - rect_t r = {LCD_W - (BUTTON_WIDTH + 5), 6, BUTTON_WIDTH, BUTTON_HEIGHT}; + rect_t r = {LCD_W - (ColorEditPage::BUTTON_WIDTH + 5), PAD_MEDIUM, ColorEditPage::BUTTON_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT}; new TextButton(window, r, STR_DETAILS, [=]() { new ThemeDetailsDialog(page, _theme, [=](ThemeFile t) { _theme.setAuthor(t.getAuthor()); @@ -402,10 +398,10 @@ class ThemeEditPage : public Page form->padAll(PAD_SMALL); #if !PORTRAIT_LCD form->setFlexLayout(LV_FLEX_FLOW_ROW, PAD_SMALL); - rect_t r = {0, 0, COLOR_LIST_WIDTH, form->height() - 8}; + rect_t r = {0, 0, ColorEditPage::COLOR_LIST_WIDTH, form->height() - PAD_LARGE}; #else form->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_SMALL); - rect_t r = {0, 0, form->width() - 8, COLOR_LIST_HEIGHT}; + rect_t r = {0, 0, form->width() - 8, ColorEditPage::COLOR_LIST_HEIGHT}; #endif _cList = new ColorList(form, r, _theme.getColorList()); @@ -413,9 +409,9 @@ class ThemeEditPage : public Page _cList->setPressHandler([=]() { editColorPage(); }); #if !PORTRAIT_LCD - r.w = form->width() - COLOR_LIST_WIDTH - 12; + r.w = form->width() - ColorEditPage::COLOR_LIST_WIDTH - PAD_MEDIUM * 2; #else - r.h = form->height() - COLOR_LIST_HEIGHT - 12; + r.h = form->height() - ColorEditPage::COLOR_LIST_HEIGHT - PAD_MEDIUM * 2; #endif _previewWindow = new PreviewWindow(form, r, _theme.getColorList()); } diff --git a/radio/src/gui/colorlcd/radio_theme.h b/radio/src/gui/colorlcd/radio_theme.h index c593861dca5..b8618c3fc25 100644 --- a/radio/src/gui/colorlcd/radio_theme.h +++ b/radio/src/gui/colorlcd/radio_theme.h @@ -41,6 +41,13 @@ class ThemeSetupPage : public PageTab bool isVisible() const override { return radioThemesEnabled(); } + static LAYOUT_VAL(COLOR_PREVIEW_SIZE, 18, 18, LS(18)) +#if PORTRAIT_LCD + static constexpr int LIST_HEIGHT = (LCD_H / 2 - 38); +#else + static constexpr int LIST_WIDTH = ((LCD_W - PAD_MEDIUM * 2) / 2 - COLOR_PREVIEW_SIZE); +#endif + protected: TabsGroup *tabsGroup = nullptr; Window *pageWindow = nullptr; diff --git a/radio/src/gui/colorlcd/radio_tools.cpp b/radio/src/gui/colorlcd/radio_tools.cpp index 6f82009f713..e81bae02d56 100644 --- a/radio/src/gui/colorlcd/radio_tools.cpp +++ b/radio/src/gui/colorlcd/radio_tools.cpp @@ -191,6 +191,8 @@ struct ToolButton : public TextButton { etx_obj_add_style(label, styles->text_align_center, LV_PART_MAIN); lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP); } + + static LAYOUT_VAL(TOOLS_BTN_H, 48, 48, LS(48)) }; void RadioToolsPage::rebuild(Window* window) diff --git a/radio/src/gui/colorlcd/radio_trainer.cpp b/radio/src/gui/colorlcd/radio_trainer.cpp index 541fb4f00a9..d52a15a04c3 100644 --- a/radio/src/gui/colorlcd/radio_trainer.cpp +++ b/radio/src/gui/colorlcd/radio_trainer.cpp @@ -34,8 +34,6 @@ RadioTrainerPage::RadioTrainerPage(): { } -LAYOUT_VAL2(NUM_EDIT_W, 80, 65) - #if !PORTRAIT_LCD static const lv_coord_t col_dsc[] = {LV_GRID_FR(7), LV_GRID_FR(13), LV_GRID_FR(10), LV_GRID_FR(10), LV_GRID_FR(10), LV_GRID_TEMPLATE_LAST}; diff --git a/radio/src/gui/colorlcd/radio_trainer.h b/radio/src/gui/colorlcd/radio_trainer.h index 969a083a9c0..12a5089838a 100644 --- a/radio/src/gui/colorlcd/radio_trainer.h +++ b/radio/src/gui/colorlcd/radio_trainer.h @@ -32,4 +32,6 @@ class RadioTrainerPage : public PageTab bool isVisible() const override { return radioTrainerEnabled(); } void build(Window* window) override; + + static LAYOUT_VAL(NUM_EDIT_W, 80, 65, LS(80)) }; diff --git a/radio/src/gui/colorlcd/screen_setup.cpp b/radio/src/gui/colorlcd/screen_setup.cpp index 648976c8201..9261ef93c04 100644 --- a/radio/src/gui/colorlcd/screen_setup.cpp +++ b/radio/src/gui/colorlcd/screen_setup.cpp @@ -44,7 +44,7 @@ class LayoutChoice : public Button LayoutChoice(Window* parent, LayoutFactoryGetter getValue, LayoutFactorySetter setValue) : - Button(parent, {0, 0, BM_W + 12, BM_H + 12}), + Button(parent, {0, 0, LayoutFactory::BM_W + 12, LayoutFactory::BM_H + 12}), getValue(std::move(getValue)), _setValue(std::move(setValue)) { diff --git a/radio/src/gui/colorlcd/select_fab_carousel.cpp b/radio/src/gui/colorlcd/select_fab_carousel.cpp index 7f0382b1cba..e0d469a33f7 100644 --- a/radio/src/gui/colorlcd/select_fab_carousel.cpp +++ b/radio/src/gui/colorlcd/select_fab_carousel.cpp @@ -25,11 +25,6 @@ #include "button.h" #include "static.h" -LAYOUT_VAL3(FAB_ICON_SIZE, 52, 36, 52) -LAYOUT_VAL1(FAB_TXT_YO, 48) -LAYOUT_VAL3(FAB_PAD, 4, 2, 4) -constexpr coord_t FAB_BUTTON_INNER_WIDTH = FAB_BUTTON_WIDTH - PAD_MEDIUM; - static void etx_quick_button_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) { @@ -49,8 +44,8 @@ static const lv_obj_class_t etx_quick_button_class = { .destructor_cb = nullptr, .user_data = nullptr, .event_cb = nullptr, - .width_def = FAB_BUTTON_WIDTH, - .height_def = FAB_BUTTON_HEIGHT, + .width_def = SelectFabCarousel::FAB_BUTTON_WIDTH, + .height_def = SelectFabCarousel::FAB_BUTTON_HEIGHT, .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, .instance_size = sizeof(lv_btn_t), @@ -79,8 +74,8 @@ static const lv_obj_class_t etx_quick_icon_class = { .destructor_cb = nullptr, .user_data = nullptr, .event_cb = nullptr, - .width_def = FAB_ICON_SIZE, - .height_def = FAB_ICON_SIZE, + .width_def = SelectFabCarousel::FAB_ICON_SIZE, + .height_def = SelectFabCarousel::FAB_ICON_SIZE, .editable = LV_OBJ_CLASS_EDITABLE_FALSE, .group_def = LV_OBJ_CLASS_GROUP_DEF_FALSE, .instance_size = sizeof(lv_obj_t), @@ -102,16 +97,16 @@ class SelectFabButton : public ButtonBase auto iconLayout = new Window(this, - {(FAB_BUTTON_INNER_WIDTH - FAB_ICON_SIZE) / 2, - (FAB_BUTTON_INNER_WIDTH - FAB_ICON_SIZE) / 2 - 2, - FAB_ICON_SIZE, FAB_ICON_SIZE}, + {(SelectFabCarousel::FAB_BUTTON_INNER_WIDTH - SelectFabCarousel::FAB_ICON_SIZE) / 2, + (SelectFabCarousel::FAB_BUTTON_INNER_WIDTH - SelectFabCarousel::FAB_ICON_SIZE) / 2 - 2, + SelectFabCarousel::FAB_ICON_SIZE, SelectFabCarousel::FAB_ICON_SIZE}, etx_quick_icon_create); iconLayout->setWindowFlag(NO_FOCUS); (new StaticIcon(iconLayout, 0, 0, icon, COLOR_WHITE)) - ->center(FAB_ICON_SIZE - 4, FAB_ICON_SIZE - 4); + ->center(SelectFabCarousel::FAB_ICON_SIZE - 4, SelectFabCarousel::FAB_ICON_SIZE - 4); - new StaticText(this, {0, FAB_BUTTON_HEIGHT - FAB_TXT_YO, FAB_BUTTON_INNER_WIDTH, 0}, + new StaticText(this, {0, SelectFabCarousel::FAB_BUTTON_HEIGHT - SelectFabCarousel::FAB_TXT_YO, SelectFabCarousel::FAB_BUTTON_INNER_WIDTH, 0}, title, COLOR_WHITE | CENTERED); } diff --git a/radio/src/gui/colorlcd/select_fab_carousel.h b/radio/src/gui/colorlcd/select_fab_carousel.h index 52400e6d1c5..239f0f3ed1f 100644 --- a/radio/src/gui/colorlcd/select_fab_carousel.h +++ b/radio/src/gui/colorlcd/select_fab_carousel.h @@ -24,9 +24,6 @@ #include "form.h" #include "bitmaps.h" -LAYOUT_VAL3(FAB_BUTTON_WIDTH, 80, 54, 80) -LAYOUT_VAL3(FAB_BUTTON_HEIGHT, 114, 78, 114) - class SelectFabCarousel : public Window { public: @@ -39,4 +36,12 @@ class SelectFabCarousel : public Window // Add a new button to the carousel void addButton(EdgeTxIcon icon, const char* title, std::function pressHandler); + + static LAYOUT_VAL(FAB_BUTTON_WIDTH, 80, 80, 54) + static LAYOUT_VAL(FAB_BUTTON_HEIGHT, 114, 114, 78) + + static LAYOUT_VAL(FAB_ICON_SIZE, 52, 52, 36) + static LAYOUT_VAL(FAB_TXT_YO, 48, 48, LS(48)) + static LAYOUT_VAL(FAB_PAD, 4, 4, 2) + static constexpr coord_t FAB_BUTTON_INNER_WIDTH = FAB_BUTTON_WIDTH - PAD_MEDIUM; }; diff --git a/radio/src/gui/colorlcd/special_functions.cpp b/radio/src/gui/colorlcd/special_functions.cpp index b05dcaaf256..164ca2d6008 100644 --- a/radio/src/gui/colorlcd/special_functions.cpp +++ b/radio/src/gui/colorlcd/special_functions.cpp @@ -32,33 +32,6 @@ #define SET_DIRTY() setDirty() -LAYOUT_VAL2(SF_BUTTON_H, 32, 44) -#define NM_X PAD_TINY -LAYOUT_VAL3(NM_Y, 4, 1, 10) -LAYOUT_VAL2(NM_W, 43, 40) -LAYOUT_VAL3(SW_Y, NM_Y, NM_Y, 0) -LAYOUT_VAL2(SW_W, 70, 198) -LAYOUT_VAL3(FN_Y, NM_Y, NM_Y, 20) -LAYOUT_VAL3(FN_W, 278, 183, SW_W) -LAYOUT_VAL2(RP_W, 40, 34) - -#if !PORTRAIT_LCD -#define FN_X (SW_X + SW_W + PAD_TINY) -#else -#define FN_X (NM_X + NM_W + PAD_TINY) -#endif - -LAYOUT_VAL1(NM_H, 20) -#define SW_X (NM_X + NM_W + PAD_TINY) -#define SW_H NM_H -#define FN_H NM_H -#define RP_X (FN_X + FN_W + PAD_TINY) -#define RP_Y NM_Y -#define RP_H NM_H -#define EN_X (RP_X + RP_W + PAD_TINY) -#define EN_Y (NM_Y + PAD_TINY_GAP) -LAYOUT_VAL1(EN_SZ, 16) - //----------------------------------------------------------------------------- static const char *_failsafe_module[] = { @@ -91,8 +64,8 @@ static const lv_obj_class_t sf_enable_state = { .destructor_cb = nullptr, .user_data = nullptr, .event_cb = nullptr, - .width_def = EN_SZ, - .height_def = EN_SZ, + .width_def = FunctionLineButton::EN_SZ, + .height_def = FunctionLineButton::EN_SZ, .editable = LV_OBJ_CLASS_EDITABLE_FALSE, .group_def = LV_OBJ_CLASS_GROUP_DEF_FALSE, .instance_size = sizeof(lv_obj_t), @@ -108,7 +81,7 @@ FunctionLineButton::FunctionLineButton(Window *parent, const rect_t &rect, uint8_t index, const char *prefix) : ListLineButton(parent, index), cfn(cfn), prefix(prefix) { - setHeight(SF_BUTTON_H); + setHeight(FunctionsPage::SF_BUTTON_H); padAll(PAD_ZERO); lv_obj_add_event_cb(lvobj, FunctionLineButton::on_draw, diff --git a/radio/src/gui/colorlcd/special_functions.h b/radio/src/gui/colorlcd/special_functions.h index 81033e21f25..acf05442f46 100644 --- a/radio/src/gui/colorlcd/special_functions.h +++ b/radio/src/gui/colorlcd/special_functions.h @@ -50,6 +50,26 @@ class FunctionLineButton : public ListLineButton void refresh() override; + static constexpr coord_t NM_X = PAD_TINY; + static LAYOUT_VAL(NM_Y, 4, 10, 1) + static LAYOUT_VAL(NM_W, 43, 40, LS(43)) + static LAYOUT_VAL(NM_H, 20, 20, LS(20)) + static constexpr coord_t SW_X = NM_X + NM_W + PAD_TINY; + static LAYOUT_VAL(SW_Y, NM_Y, 0, NM_Y) + static LAYOUT_VAL(SW_W, 70, 198, LS(70)) + static constexpr coord_t SW_H = NM_H; + static LAYOUT_VAL(FN_X, SW_X + SW_W + PAD_TINY, NM_X + NM_W + PAD_TINY, SW_X + SW_W + PAD_TINY) + static LAYOUT_VAL(FN_Y, NM_Y, 20, NM_Y) + static LAYOUT_VAL(FN_W, 278, SW_W, 183) + static LAYOUT_VAL(RP_W, 40, 34, LS(40)) + static constexpr coord_t FN_H = NM_H; + static constexpr coord_t RP_X = FN_X + FN_W + PAD_TINY; + static constexpr coord_t RP_Y = NM_Y; + static constexpr coord_t RP_H = NM_H; + static constexpr coord_t EN_X = RP_X + RP_W + PAD_TINY; + static constexpr coord_t EN_Y = NM_Y + PAD_TINY_GAP; + static LAYOUT_VAL(EN_SZ, 16, 16, LS(16)) + protected: bool init = false; const CustomFunctionData *cfn; @@ -114,6 +134,8 @@ class FunctionsPage : public PageTab void build(Window* window) override; + static LAYOUT_VAL(SF_BUTTON_H, 32, 44, LS(32)) + protected: int8_t focusIndex = -1; int8_t prevFocusIndex = -1; diff --git a/radio/src/gui/colorlcd/standalone_lua.cpp b/radio/src/gui/colorlcd/standalone_lua.cpp index c186789bdf5..5a594a3909c 100644 --- a/radio/src/gui/colorlcd/standalone_lua.cpp +++ b/radio/src/gui/colorlcd/standalone_lua.cpp @@ -45,7 +45,7 @@ void LuaPopup::paint(BitmapBuffer* dc, uint8_t type, const char* text, dc->drawSolidFilledRect(0, POPUP_HEADER_HEIGHT, rect.w, rect.h - POPUP_HEADER_HEIGHT, COLOR_THEME_SECONDARY3); - dc->drawText(FIELD_PADDING_LEFT, POPUP_HEADER_HEIGHT + PAGE_LINE_HEIGHT, info, + dc->drawText(FIELD_PADDING_LEFT, POPUP_HEADER_HEIGHT + EdgeTxStyles::PAGE_LINE_HEIGHT, info, COLOR_THEME_SECONDARY1); } diff --git a/radio/src/gui/colorlcd/startup_shutdown.cpp b/radio/src/gui/colorlcd/startup_shutdown.cpp index 33d587d8215..c1c3f5d73e5 100644 --- a/radio/src/gui/colorlcd/startup_shutdown.cpp +++ b/radio/src/gui/colorlcd/startup_shutdown.cpp @@ -47,7 +47,7 @@ const std::string git_str = "(" GIT_STR ")"; #endif #endif -LAYOUT_VAL1(TXT_H, 24) +static LAYOUT_VAL(TXT_H, 24, 24, LS(24)) #if !PORTRAIT_LCD #define TXT_X (LCD_W * 4 / 5) diff --git a/radio/src/gui/colorlcd/tabsgroup.cpp b/radio/src/gui/colorlcd/tabsgroup.cpp index 8beffbba232..5de871da017 100644 --- a/radio/src/gui/colorlcd/tabsgroup.cpp +++ b/radio/src/gui/colorlcd/tabsgroup.cpp @@ -24,17 +24,12 @@ #include "theme.h" #include "themes/etx_lv_theme.h" #include "view_main.h" +#include "topbar_impl.h" #if defined(HARDWARE_TOUCH) #include "keyboard_base.h" #endif -LAYOUT_VAL3(SEL_DOT_X, 10, 6, 10) -LAYOUT_VAL1(SEL_DOT_Y, 39) -LAYOUT_VAL1(ICON_Y, 7) -LAYOUT_VAL1(DATE_XO, 48) -LAYOUT_VAL1(DATE_Y, 6) - class SelectedTabIcon : public StaticIcon { public: @@ -48,6 +43,9 @@ class SelectedTabIcon : public StaticIcon #if defined(DEBUG_WINDOWS) std::string getName() const override { return "SelectedTabIcon"; } #endif + + static LAYOUT_VAL(SEL_DOT_X, 10, 10, 6) + static LAYOUT_VAL(SEL_DOT_Y, 39, 39, LS(39)) }; class TabCarouselButton : public ButtonBase @@ -60,7 +58,7 @@ class TabCarouselButton : public ButtonBase selected->hide(); lastIcon = getIcon(); - icon = new StaticIcon(this, 2, ICON_Y,lastIcon, COLOR_THEME_PRIMARY2); + icon = new StaticIcon(this, 2, ICON_Y, lastIcon, COLOR_THEME_PRIMARY2); show(isVisible()); } @@ -77,6 +75,8 @@ class TabCarouselButton : public ButtonBase EdgeTxIcon getIcon() const { return pageTab->getIcon(); } PageTab* page() const { return pageTab; } + static LAYOUT_VAL(ICON_Y, 7, 7, LS(7)) + protected: PageTab* pageTab; EdgeTxIcon lastIcon; @@ -101,13 +101,13 @@ class TabsCarousel : public Window public: TabsCarousel(Window* parent, TabsGroup* menu) : Window(parent, - {MENU_HEADER_BUTTONS_LEFT, 0, - LCD_W - HDR_DATE_FULL_WIDTH - MENU_HEADER_BUTTONS_LEFT, MENU_HEADER_HEIGHT + 10}), + {TopBar::MENU_HEADER_BUTTONS_LEFT, 0, + LCD_W - HDR_DATE_FULL_WIDTH - TopBar::MENU_HEADER_BUTTONS_LEFT, EdgeTxStyles::MENU_HEADER_HEIGHT + 10}), menu(menu) { setWindowFlag(NO_FOCUS); - lv_obj_set_style_max_width(lvobj, LCD_W - HDR_DATE_FULL_WIDTH - MENU_HEADER_BUTTONS_LEFT, + lv_obj_set_style_max_width(lvobj, LCD_W - HDR_DATE_FULL_WIDTH - TopBar::MENU_HEADER_BUTTONS_LEFT, LV_PART_MAIN); padAll(PAD_ZERO); @@ -154,7 +154,7 @@ class TabsCarousel : public Window void addTab(PageTab* page) { TabCarouselButton* btn = new TabCarouselButton( - this, {0, 0, MENU_HEADER_BUTTON_WIDTH + 3, MENU_TITLE_TOP + 5}, page); + this, {0, 0, MENU_HEADER_BUTTON_WIDTH + 3, TabsGroup::MENU_TITLE_TOP + 5}, page); btn->setPressHandler([=]() { menu->setCurrentTab(getIndex(btn->getIcon())); return true; @@ -188,6 +188,9 @@ class TabsCarousel : public Window } return -1; } + + static LAYOUT_VAL(MENU_HEADER_BUTTON_WIDTH, 33, 33, LS(33)) + static LAYOUT_VAL(HDR_DATE_FULL_WIDTH, 51, 51, LS(51)) }; #if defined(DEBUG) @@ -215,7 +218,7 @@ class TabsGroupHeader : public Window public: TabsGroupHeader(TabsGroup* menu, EdgeTxIcon icon) : - Window(menu, {0, 0, LCD_W, MENU_BODY_TOP}), + Window(menu, {0, 0, LCD_W, TabsGroup::MENU_BODY_TOP}), icon(icon) { setWindowFlag(NO_FOCUS | OPAQUE); @@ -226,15 +229,15 @@ class TabsGroupHeader : public Window auto sep = lv_obj_create(lvobj); etx_solid_bg(sep); - lv_obj_set_pos(sep, 0, MENU_HEADER_HEIGHT); - lv_obj_set_size(sep, LCD_W, MENU_TITLE_TOP - MENU_HEADER_HEIGHT); + lv_obj_set_pos(sep, 0, EdgeTxStyles::MENU_HEADER_HEIGHT); + lv_obj_set_size(sep, LCD_W, TabsGroup::MENU_TITLE_TOP - EdgeTxStyles::MENU_HEADER_HEIGHT); titleLabel = lv_label_create(lvobj); etx_txt_color(titleLabel, COLOR_THEME_PRIMARY2_INDEX); lv_obj_set_style_pad_left(titleLabel, PAD_MEDIUM, LV_PART_MAIN); lv_obj_set_style_pad_top(titleLabel, 1, LV_PART_MAIN); - lv_obj_set_pos(titleLabel, 0, MENU_TITLE_TOP); - lv_obj_set_size(titleLabel, LCD_W, MENU_TITLE_HEIGHT); + lv_obj_set_pos(titleLabel, 0, TabsGroup::MENU_TITLE_TOP); + lv_obj_set_size(titleLabel, LCD_W, TabsGroup::MENU_TITLE_HEIGHT); setTitle(""); carousel = new TabsCarousel(this, menu); @@ -248,6 +251,9 @@ class TabsGroupHeader : public Window std::string getName() const override { return "TabsGroupHeader"; } #endif + static LAYOUT_VAL(DATE_XO, 48, 48, LS(48)) + static LAYOUT_VAL(DATE_Y, 6, 6, LS(6)) + protected: EdgeTxIcon icon; TabsCarousel* carousel = nullptr; @@ -370,4 +376,15 @@ void TabsGroup::onClicked() { Keyboard::hide(false); } void TabsGroup::onCancel() { deleteLater(); } -Window* TabsGroup::getHeaderWindow() { return header; } +#if defined(PCBNV14) || defined(PCBPL18) +void TabsGroup::addGoToMonitorsButton() +{ + new TextButton( + header, + {LCD_W / 2 + 6, MENU_TITLE_TOP + 1, LCD_W / 2 - 8, MENU_TITLE_HEIGHT - 2}, + STR_OPEN_CHANNEL_MONITORS, [=]() { + pushEvent(EVT_KEY_FIRST(KEY_MODEL)); + return 0; + }); +} +#endif diff --git a/radio/src/gui/colorlcd/tabsgroup.h b/radio/src/gui/colorlcd/tabsgroup.h index 30b71bf4c40..7a241e54846 100644 --- a/radio/src/gui/colorlcd/tabsgroup.h +++ b/radio/src/gui/colorlcd/tabsgroup.h @@ -87,7 +87,10 @@ class TabsGroup : public NavWindow void onClicked() override; void onCancel() override; - Window* getHeaderWindow(); + static LAYOUT_VAL(MENU_TITLE_TOP, 48, 48, LS(48)) + static LAYOUT_VAL(MENU_TITLE_HEIGHT, 21, 21, LS(21)) + static constexpr coord_t MENU_BODY_TOP = MENU_TITLE_TOP + MENU_TITLE_HEIGHT; + static constexpr coord_t MENU_BODY_HEIGHT = LCD_H - MENU_BODY_TOP; protected: TabsGroupHeader* header = nullptr; @@ -100,4 +103,8 @@ class TabsGroup : public NavWindow void onPressPGUP() override; void onPressPGDN() override; #endif + +#if defined(PCBNV14) || defined(PCBPL18) + void addGoToMonitorsButton(void); +#endif }; diff --git a/radio/src/gui/colorlcd/theme.cpp b/radio/src/gui/colorlcd/theme.cpp index ca0b48f1b32..71279f97a16 100644 --- a/radio/src/gui/colorlcd/theme.cpp +++ b/radio/src/gui/colorlcd/theme.cpp @@ -23,6 +23,7 @@ #include "libopenui.h" #include "theme_manager.h" +#include "topbar_impl.h" EdgeTxTheme* EdgeTxTheme::_instance = nullptr; @@ -119,7 +120,7 @@ UsbSDConnected::UsbSDConnected() : setWindowFlag(OPAQUE); etx_solid_bg(lvobj, COLOR_THEME_PRIMARY1_INDEX); - dateTime = new HeaderDateTime(lvobj, LCD_W - HDR_DATE_XO, HDR_DATE_Y); + dateTime = new HeaderDateTime(lvobj, LCD_W - TopBar::HDR_DATE_XO, HDR_DATE_Y); auto icon = new StaticIcon(this, 0, 0, ICON_USB_PLUGGED, COLOR_THEME_PRIMARY2); lv_obj_center(icon->getLvObj()); diff --git a/radio/src/gui/colorlcd/theme.h b/radio/src/gui/colorlcd/theme.h index 132108d7bda..93b1a07a916 100644 --- a/radio/src/gui/colorlcd/theme.h +++ b/radio/src/gui/colorlcd/theme.h @@ -53,6 +53,10 @@ class HeaderDateTime void update(); void setColor(uint32_t color); + static LAYOUT_VAL(HDR_DATE_WIDTH, 45, 45, LS(45)) + static LAYOUT_VAL(HDR_DATE_HEIGHT, 12, 12, LS(12)) + static LAYOUT_VAL(HDR_DATE_LINE2, 15, 15, LS(15)) + protected: lv_obj_t *date = nullptr; lv_obj_t *time = nullptr; @@ -72,6 +76,8 @@ class UsbSDConnected : public Window void checkEvents() override; + static LAYOUT_VAL(HDR_DATE_Y, 6, 6, LS(6)) + protected: HeaderDateTime* dateTime = nullptr; }; diff --git a/radio/src/gui/colorlcd/themes/etx_lv_theme.h b/radio/src/gui/colorlcd/themes/etx_lv_theme.h index 646ae4eaaf0..4a78c05996e 100644 --- a/radio/src/gui/colorlcd/themes/etx_lv_theme.h +++ b/radio/src/gui/colorlcd/themes/etx_lv_theme.h @@ -54,73 +54,21 @@ enum PaddingSize { #endif // Macros for setting up layout values -// LAYOUT_VAL1 - single value where portait and landscape use the same value -// and landscape small screen = value * 2 / 3 -// LAYOUT_VAL2 - 2 value, first is landscape, second is portrait -// and landscape small screen = landscape * 2 / 3 -// LAYOUT_VAL3 - 3 values - landscape, landscape small, portrait +// LS - scaling factor to convert 480 wide landscape to 320 wide landscape +// LAYOUT_VAL - 3 values - landscape, portrait, landscape small +#define LS(val) ((val * 4 + 3) / 6) #if LANDSCAPE_LCD -#define LAYOUT_VAL1(name, landscape) \ - constexpr coord_t name = landscape; -#define LAYOUT_VAL2(name, landscape, portrait) \ - constexpr coord_t name = landscape; -#define LAYOUT_VAL3(name, landscape, landscape_small, portrait) \ +#define LAYOUT_VAL(name, landscape, portrait, landscape_small) \ constexpr coord_t name = landscape; #elif LANDSCAPE_LCD_SMALL -#define LAYOUT_VAL1(name, landscape) \ - constexpr coord_t name = (landscape * 4 + 3) / 6; -#define LAYOUT_VAL2(name, landscape, portrait) \ - constexpr coord_t name = (landscape * 4 + 3) / 6; -#define LAYOUT_VAL3(name, landscape, landscape_small, portrait) \ +#define LAYOUT_VAL(name, landscape, portrait, landscape_small) \ constexpr coord_t name = landscape_small; #else -#define LAYOUT_VAL1(name, landscape) \ - constexpr coord_t name = landscape; -#define LAYOUT_VAL2(name, landscape, portrait) \ - constexpr coord_t name = portrait; -#define LAYOUT_VAL3(name, landscape, landscape_small, portrait) \ +#define LAYOUT_VAL(name, landscape, portrait, landscape_small) \ constexpr coord_t name = portrait; #endif -LAYOUT_VAL1(MENU_HEADER_BUTTON_WIDTH, 33) -LAYOUT_VAL1(MENU_HEADER_BUTTONS_LEFT, 47) -LAYOUT_VAL1(MENU_HEADER_HEIGHT, 45) -LAYOUT_VAL1(MENU_TITLE_TOP, 48) -LAYOUT_VAL1(MENU_TITLE_HEIGHT, 21) - -constexpr coord_t MENU_BODY_TOP = MENU_TITLE_TOP + MENU_TITLE_HEIGHT; -constexpr coord_t MENU_BODY_HEIGHT = LCD_H - MENU_BODY_TOP; - -LAYOUT_VAL1(MENUS_MARGIN_LEFT, 6) -LAYOUT_VAL1(PAGE_LINE_HEIGHT, 20) - -constexpr coord_t FH = PAGE_LINE_HEIGHT; -constexpr coord_t NUM_BODY_LINES = MENU_BODY_HEIGHT / PAGE_LINE_HEIGHT; - -constexpr coord_t PAGE_TITLE_TOP = 2; - -LAYOUT_VAL1(PAGE_TITLE_LEFT, 50) - -LAYOUT_VAL1(HDR_DATE_WIDTH, 45) -LAYOUT_VAL1(HDR_DATE_HEIGHT, 12) -LAYOUT_VAL1(HDR_DATE_LINE2, 15) -LAYOUT_VAL1(HDR_DATE_XO, 48) -LAYOUT_VAL1(HDR_DATE_Y, 6) -LAYOUT_VAL1(HDR_DATE_FULL_WIDTH, 51) - -LAYOUT_VAL3(UI_ELEMENT_HEIGHT, 32, 24, 32) - -LAYOUT_VAL1(TOOLS_BTN_H, 48) -LAYOUT_VAL1(SUBSCR_BTN_H, 62) -LAYOUT_VAL1(MENUS_LINE_HEIGHT, 35) - -#if PORTRAIT_LCD -constexpr coord_t MENUS_MAX_HEIGHT = (MENUS_LINE_HEIGHT * 10); -#else -constexpr coord_t MENUS_MAX_HEIGHT = (MENUS_LINE_HEIGHT * 7) + 8; -#endif - /********************** * GLOBAL PROTOTYPES **********************/ @@ -260,6 +208,10 @@ class EdgeTxStyles void init(); void applyColors(); + static LAYOUT_VAL(PAGE_LINE_HEIGHT, 20, 20, LS(20)) + static LAYOUT_VAL(UI_ELEMENT_HEIGHT, 32, 32, 24) + static LAYOUT_VAL(MENU_HEADER_HEIGHT, 45, 45, LS(45)) + protected: bool initDone = false; }; diff --git a/radio/src/gui/colorlcd/topbar.h b/radio/src/gui/colorlcd/topbar.h index b54e6b48564..20ae95694ce 100644 --- a/radio/src/gui/colorlcd/topbar.h +++ b/radio/src/gui/colorlcd/topbar.h @@ -23,11 +23,6 @@ #include "layout.h" -LAYOUT_VAL3(TOPBAR_ZONE_WIDTH, 70, 47, 70) -LAYOUT_VAL1(TOPBAR_ZONE_VMARGIN, 3) -LAYOUT_VAL1(TOPBAR_ZONE_HMARGIN, 2) -constexpr coord_t TOPBAR_ZONE_HEIGHT = MENU_HEADER_HEIGHT - 2 * TOPBAR_ZONE_VMARGIN; - class ScreenMenu; class TopBar; diff --git a/radio/src/gui/colorlcd/view_channels.cpp b/radio/src/gui/colorlcd/view_channels.cpp index 954229c37f8..6f8692b745c 100644 --- a/radio/src/gui/colorlcd/view_channels.cpp +++ b/radio/src/gui/colorlcd/view_channels.cpp @@ -100,7 +100,7 @@ class ChannelsViewPage : public PageTab coord_t yPos = (chan % 4) * ((window->height() - 23) / 4); #endif - new ComboChannelBar(window, {xPos, yPos, width, 3 * BAR_HEIGHT + 3}, + new ComboChannelBar(window, {xPos, yPos, width, 3 * ChannelBar::BAR_HEIGHT + 3}, chan); } diff --git a/radio/src/gui/colorlcd/view_logical_switches.cpp b/radio/src/gui/colorlcd/view_logical_switches.cpp index 48238748c52..12e3faf4212 100644 --- a/radio/src/gui/colorlcd/view_logical_switches.cpp +++ b/radio/src/gui/colorlcd/view_logical_switches.cpp @@ -25,14 +25,6 @@ #include "switches.h" #include "themes/etx_lv_theme.h" -LAYOUT_VAL2(FOOTER_HEIGHT, 20, 40) -LAYOUT_VAL3(BTN_HEIGHT, 20, 18, 21) -LAYOUT_VAL3(BTN_PAD, 1, 2, 2) -LAYOUT_VAL3(BTN_MATRIX_COL, 8, 8, 4) -LAYOUT_VAL3(V2_COL_CNT, 1, 1, 2) -LAYOUT_VAL3(ANDSW_ROW, 0, 0, 1) -LAYOUT_VAL3(ANDSW_COL, 3, 3, 1) - #if PORTRAIT_LCD static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), @@ -210,6 +202,10 @@ class LogicalSwitchDisplayFooter : public Window refresh(); } + static LAYOUT_VAL(V2_COL_CNT, 1, 2, 1) + static LAYOUT_VAL(ANDSW_ROW, 0, 1, 0) + static LAYOUT_VAL(ANDSW_COL, 3, 1, 3) + protected: unsigned lsIndex = 0; lv_obj_t* lsFunc = nullptr; diff --git a/radio/src/gui/colorlcd/view_logical_switches.h b/radio/src/gui/colorlcd/view_logical_switches.h index 776aeca251f..684c07d8aef 100644 --- a/radio/src/gui/colorlcd/view_logical_switches.h +++ b/radio/src/gui/colorlcd/view_logical_switches.h @@ -30,6 +30,11 @@ class LogicalSwitchesViewPage : public PageTab public: LogicalSwitchesViewPage(); + static LAYOUT_VAL(FOOTER_HEIGHT, 20, 40, LS(20)) + static LAYOUT_VAL(BTN_HEIGHT, 20, 21, 18) + static LAYOUT_VAL(BTN_PAD, 1, 2, 2) + static LAYOUT_VAL(BTN_MATRIX_COL, 8, 4, 8) + protected: void build(Window* window) override; LogicalSwitchDisplayFooter* footer = nullptr; diff --git a/radio/src/gui/colorlcd/view_main_decoration.cpp b/radio/src/gui/colorlcd/view_main_decoration.cpp index 6868f4af492..12f73bcf014 100644 --- a/radio/src/gui/colorlcd/view_main_decoration.cpp +++ b/radio/src/gui/colorlcd/view_main_decoration.cpp @@ -148,34 +148,34 @@ void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Windo // create containers for the sliders, so that they are at the borders of the display // on top of each other, when there are two sliders to display per side auto leftPots = create_layout_box(ml, LV_ALIGN_LEFT_MID, LV_FLEX_FLOW_COLUMN); - leftPots->setHeight(VERTICAL_SLIDERS_HEIGHT); + leftPots->setHeight(MainViewSlider::HORIZONTAL_SLIDERS_WIDTH); auto rightPots = create_layout_box(mr, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_COLUMN); - rightPots->setHeight(VERTICAL_SLIDERS_HEIGHT); + rightPots->setHeight(MainViewSlider::VERTICAL_SLIDERS_HEIGHT); - coord_t lsh = (IS_POT_AVAILABLE(pot + 2)) ? VERTICAL_SLIDERS_HEIGHT / 2 : VERTICAL_SLIDERS_HEIGHT; - coord_t rsh = (IS_POT_AVAILABLE(pot + 3)) ? VERTICAL_SLIDERS_HEIGHT / 2 : VERTICAL_SLIDERS_HEIGHT; + coord_t lsh = (IS_POT_AVAILABLE(pot + 2)) ? MainViewSlider::HORIZONTAL_SLIDERS_WIDTH / 2 : MainViewSlider::HORIZONTAL_SLIDERS_WIDTH; + coord_t rsh = (IS_POT_AVAILABLE(pot + 3)) ? MainViewSlider::HORIZONTAL_SLIDERS_WIDTH / 2 : MainViewSlider::HORIZONTAL_SLIDERS_WIDTH; if (IS_POT_AVAILABLE(pot)) { - sliders[sl] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, TRIM_SQUARE_SIZE, lsh}, pot); + sliders[sl] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, lsh}, pot); sl += 1; } pot += 1; if (IS_POT_AVAILABLE(pot)) { - sliders[sl] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, TRIM_SQUARE_SIZE, rsh}, pot); + sliders[sl] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, rsh}, pot); sl += 1; } pot += 1; if (IS_POT_AVAILABLE(pot)) { - sliders[sl] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, TRIM_SQUARE_SIZE, lsh}, pot); + sliders[sl] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, lsh}, pot); sl += 1; } pot += 1; if (IS_POT_AVAILABLE(pot)) { - sliders[sl] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, TRIM_SQUARE_SIZE, rsh}, pot); + sliders[sl] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, rsh}, pot); } } } diff --git a/radio/src/gui/colorlcd/view_main_menu.cpp b/radio/src/gui/colorlcd/view_main_menu.cpp index 75bc9fa1dae..a17490c43ef 100644 --- a/radio/src/gui/colorlcd/view_main_menu.cpp +++ b/radio/src/gui/colorlcd/view_main_menu.cpp @@ -59,11 +59,11 @@ static lv_obj_t* etx_modal_dialog_create(lv_obj_t* parent) } #if !PORTRAIT_LCD -#define VM_W (FAB_BUTTON_WIDTH * 4 + 16) -#define VM_H (FAB_BUTTON_HEIGHT * 2 + 16) +#define VM_W (SelectFabCarousel::FAB_BUTTON_WIDTH * 4 + PAD_LARGE * 2) +#define VM_H (SelectFabCarousel::FAB_BUTTON_HEIGHT * 2 + PAD_LARGE * 2) #else -#define VM_W (FAB_BUTTON_WIDTH * 3 + 16) -#define VM_H (FAB_BUTTON_HEIGHT * 3 + 16) +#define VM_W (SelectFabCarousel::FAB_BUTTON_WIDTH * 3 + PAD_LARGE * 2) +#define VM_H (SelectFabCarousel::FAB_BUTTON_HEIGHT * 3 + PAD_LARGE * 2) #endif ViewMainMenu::ViewMainMenu(Window* parent, std::function closeHandler) : @@ -78,7 +78,7 @@ ViewMainMenu::ViewMainMenu(Window* parent, std::function closeHandler) : #if !PORTRAIT_LCD if (hasNotes) - width += FAB_BUTTON_WIDTH; + width += SelectFabCarousel::FAB_BUTTON_WIDTH; #endif auto box = diff --git a/radio/src/gui/colorlcd/widgets/radio_info.cpp b/radio/src/gui/colorlcd/widgets/radio_info.cpp index eb54856dc89..385a1def6f0 100644 --- a/radio/src/gui/colorlcd/widgets/radio_info.cpp +++ b/radio/src/gui/colorlcd/widgets/radio_info.cpp @@ -25,22 +25,6 @@ #include "widget.h" #include "widgets_container_impl.h" -constexpr coord_t W_AUDIO_X = 0; -LAYOUT_VAL1(W_AUDIO_SCALE_X, 15) -LAYOUT_VAL1(W_USB_X, 32) -LAYOUT_VAL3(W_USB_Y, 5, 4, 5) -LAYOUT_VAL1(W_LOG_X, 32) -LAYOUT_VAL1(W_LOG_Y, 3) -LAYOUT_VAL1(W_RSSI_X, 40) -LAYOUT_VAL1(W_RSSI_BAR_W, 4) -LAYOUT_VAL1(W_RSSI_BAR_H, 35) -LAYOUT_VAL1(W_RSSI_BAR_SZ, 6) -LAYOUT_VAL3(W_BATT_Y, 25, 16, 25) -LAYOUT_VAL1(W_BATT_FILL_W, 20) -LAYOUT_VAL1(W_BATT_FILL_H, 9) -LAYOUT_VAL3(W_BATT_CHG_X, 25, 16, 25) -LAYOUT_VAL3(W_BATT_CHG_Y, 23, 15, 23) - class TopBarWidget : public Widget { public: @@ -196,6 +180,22 @@ class RadioInfoWidget : public TopBarWidget } } + static constexpr coord_t W_AUDIO_X = 0; + static LAYOUT_VAL(W_AUDIO_SCALE_X, 15, 15, LS(15)) + static LAYOUT_VAL(W_USB_X, 32, 32, LS(32)) + static LAYOUT_VAL(W_USB_Y, 5, 5, 4) + static LAYOUT_VAL(W_LOG_X, 32, 32, LS(32)) + static LAYOUT_VAL(W_LOG_Y, 3, 3, LS(3)) + static LAYOUT_VAL(W_RSSI_X, 40, 40, LS(40)) + static LAYOUT_VAL(W_RSSI_BAR_W, 4, 4, LS(4)) + static LAYOUT_VAL(W_RSSI_BAR_H, 35, 35, LS(35)) + static LAYOUT_VAL(W_RSSI_BAR_SZ, 6, 6, LS(6)) + static LAYOUT_VAL(W_BATT_Y, 25, 25, 16) + static LAYOUT_VAL(W_BATT_FILL_W, 20, 20, LS(20)) + static LAYOUT_VAL(W_BATT_FILL_H, 9, 9, LS(9)) + static LAYOUT_VAL(W_BATT_CHG_X, 25, 25, 16) + static LAYOUT_VAL(W_BATT_CHG_Y, 23, 23, 15) + protected: uint8_t lastVol = 0; uint8_t lastBatt = 0; @@ -218,10 +218,6 @@ class RadioInfoWidget : public TopBarWidget BaseWidgetFactory RadioInfoWidget("Radio Info", nullptr, "Radio Info"); -// Adjustment to make main view date/time align with model/radio settings views -LAYOUT_VAL2(DT_X, 24, 8) -LAYOUT_VAL1(DT_Y, 3) - class DateTimeWidget : public TopBarWidget { public: @@ -253,6 +249,10 @@ class DateTimeWidget : public TopBarWidget int8_t lastMinute = -1; static const ZoneOption options[]; + + // Adjustment to make main view date/time align with model/radio settings views + static LAYOUT_VAL(DT_X, 24, 8, LS(24)) + static LAYOUT_VAL(DT_Y, 3, 3, LS(3)) }; const ZoneOption DateTimeWidget::options[] = { diff --git a/radio/src/gui/colorlcd/widgets/timer.cpp b/radio/src/gui/colorlcd/widgets/timer.cpp index c4d49c8dcad..fff5df7a083 100644 --- a/radio/src/gui/colorlcd/widgets/timer.cpp +++ b/radio/src/gui/colorlcd/widgets/timer.cpp @@ -23,21 +23,6 @@ #include "opentx.h" #include "widget.h" -LAYOUT_VAL1(TMR_LRG_W, 180) -LAYOUT_VAL1(TMR_ARC_SZ, 64) -LAYOUT_VAL1(TMR_ARC_W, 10) -LAYOUT_VAL1(NM_LRG_X, 78) -LAYOUT_VAL1(NM_LRG_Y, 19) -LAYOUT_VAL1(NM_LRG_W, 93) -LAYOUT_VAL1(U0_X, 111) -LAYOUT_VAL3(U0_Y, 33, 25, 33) -LAYOUT_VAL1(U1_X, 161) -LAYOUT_VAL3(U1_Y, 33, 25, 33) -LAYOUT_VAL1(D0_X, 76) -LAYOUT_VAL3(D0_Y, 31, 24, 31) -LAYOUT_VAL1(D1_X, 126) -LAYOUT_VAL3(D1_Y, 31, 24, 31) - #define ETX_STATE_BG_WARNING LV_STATE_USER_1 #define EXT_NAME_ALIGN_RIGHT LV_STATE_USER_1 #define ETX_NAME_TXT_WARNING LV_STATE_USER_2 @@ -207,6 +192,21 @@ class TimerWidget : public Widget static const ZoneOption options[]; + static LAYOUT_VAL(TMR_LRG_W, 180, 180, LS(180)) + static LAYOUT_VAL(TMR_ARC_SZ, 64, 64, LS(64)) + static LAYOUT_VAL(TMR_ARC_W, 10, 10, LS(10)) + static LAYOUT_VAL(NM_LRG_X, 78, 78, LS(78)) + static LAYOUT_VAL(NM_LRG_Y, 19, 19, LS(19)) + static LAYOUT_VAL(NM_LRG_W, 93, 93, LS(93)) + static LAYOUT_VAL(U0_X, 111, 111, LS(111)) + static LAYOUT_VAL(U0_Y, 33, 33, 25) + static LAYOUT_VAL(U1_X, 161, 161, LS(161)) + static LAYOUT_VAL(U1_Y, 33, 33, 25) + static LAYOUT_VAL(D0_X, 76, 76, LS(76)) + static LAYOUT_VAL(D0_Y, 31, 31, 24) + static LAYOUT_VAL(D1_X, 126, 126, LS(126)) + static LAYOUT_VAL(D1_Y, 31, 31, 24) + protected: tmrval_t lastValue = 0; uint32_t lastStartValue = 0; diff --git a/radio/src/gui/colorlcd/widgets/value.cpp b/radio/src/gui/colorlcd/widgets/value.cpp index 4da782a23c4..e98ae0e10e0 100644 --- a/radio/src/gui/colorlcd/widgets/value.cpp +++ b/radio/src/gui/colorlcd/widgets/value.cpp @@ -159,8 +159,8 @@ class ValueWidget : public Widget lv_obj_t* valueShadow; LcdFlags valueFlags = 0; - static LAYOUT_VAL3(VAL_Y1, 14, 10, 14) - static LAYOUT_VAL1(VAL_Y2, 18) + static LAYOUT_VAL(VAL_Y1, 14, 14, 10) + static LAYOUT_VAL(VAL_Y2, 18, 18, LS(18)) void update() override { diff --git a/radio/src/gui/colorlcd/widgets_container.h b/radio/src/gui/colorlcd/widgets_container.h index fb9b16c7c08..367424f8cec 100644 --- a/radio/src/gui/colorlcd/widgets_container.h +++ b/radio/src/gui/colorlcd/widgets_container.h @@ -27,7 +27,7 @@ #define WIDGET_NAME_LEN 12 #define MAX_WIDGET_OPTIONS 5 // Name? -LAYOUT_VAL3(MAX_TOPBAR_ZONES, 6, 6, 4) +static LAYOUT_VAL(MAX_TOPBAR_ZONES, 6, 4, 6) #define MAX_TOPBAR_OPTIONS 1 // just because of VC++ which doesn't like 0-size arrays :( diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index e6d89d27fe5..0cb5f5b0da5 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -3082,7 +3082,7 @@ LROT_BEGIN(etxcst, NULL, 0) LROT_NUMENTRY( TEXT_SIZE, ZoneOption::TextSize ) LROT_NUMENTRY( ALIGNMENT, ZoneOption::Align ) LROT_NUMENTRY( SWITCH, ZoneOption::Switch ) - LROT_NUMENTRY( MENU_HEADER_HEIGHT, COLOR2FLAGS(MENU_HEADER_HEIGHT) ) + LROT_NUMENTRY( MENU_HEADER_HEIGHT, COLOR2FLAGS(EdgeTxStyles::MENU_HEADER_HEIGHT) ) // Colors gui/colorlcd/colors.h LROT_NUMENTRY( COLOR_THEME_PRIMARY1, COLOR2FLAGS(COLOR_THEME_PRIMARY1_INDEX) ) diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 4adc6854655..6f36f4866a2 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -678,7 +678,9 @@ union ReusableBuffer #if defined(SDCARD) struct { +#if defined(NUM_BODY_LINES) char lines[NUM_BODY_LINES][SD_SCREEN_FILE_LENGTH+1+1]; // the last char is used to store the flags (directory) of the line +#endif uint32_t available; uint16_t offset; uint16_t count; diff --git a/radio/src/thirdparty/libopenui/src/bitmapbuffer_draw_extra.cpp b/radio/src/thirdparty/libopenui/src/bitmapbuffer_draw_extra.cpp index cc3765cdfa1..7aa5b7f31dc 100644 --- a/radio/src/thirdparty/libopenui/src/bitmapbuffer_draw_extra.cpp +++ b/radio/src/thirdparty/libopenui/src/bitmapbuffer_draw_extra.cpp @@ -154,7 +154,7 @@ void BitmapBuffer::drawGPSPosition(coord_t x, coord_t y, int32_t longitude, { if (flags & PREC1) { drawGPSCoord(x, y, latitude, "NS", flags, true); - drawGPSCoord(x, y + FH, longitude, "EW", flags, true); + drawGPSCoord(x, y + EdgeTxStyles::PAGE_LINE_HEIGHT, longitude, "EW", flags, true); } else { if (flags & RIGHT) { x = drawGPSCoord(x, y, longitude, "EW", flags, true); @@ -181,7 +181,7 @@ void BitmapBuffer::drawDate(coord_t x, coord_t y, TelemetryItem &telemetryItem, x = drawText(x, y, s.c_str(), att); if (doTwoLines) { - y += FH; + y += EdgeTxStyles::PAGE_LINE_HEIGHT; x = ox; } else { x += 11; diff --git a/radio/src/thirdparty/libopenui/src/button.cpp b/radio/src/thirdparty/libopenui/src/button.cpp index 7c032f1d60b..10ba2126375 100644 --- a/radio/src/thirdparty/libopenui/src/button.cpp +++ b/radio/src/thirdparty/libopenui/src/button.cpp @@ -34,7 +34,7 @@ const lv_obj_class_t button_class = { .user_data = nullptr, .event_cb = nullptr, .width_def = LV_SIZE_CONTENT, - .height_def = UI_ELEMENT_HEIGHT, + .height_def = EdgeTxStyles::UI_ELEMENT_HEIGHT, .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, .instance_size = sizeof(lv_btn_t), @@ -117,11 +117,11 @@ TextButton::TextButton(Window* parent, const rect_t& rect, std::string text, IconButton::IconButton(Window* parent, EdgeTxIcon icon, std::function pressHandler) : - ButtonBase(parent, {0, 0, UI_ELEMENT_HEIGHT, UI_ELEMENT_HEIGHT}, pressHandler, button_create) + ButtonBase(parent, {0, 0, EdgeTxStyles::UI_ELEMENT_HEIGHT, EdgeTxStyles::UI_ELEMENT_HEIGHT}, pressHandler, button_create) { padAll(PAD_ZERO); iconImage = new StaticIcon(this, 0, 0, icon, COLOR_THEME_SECONDARY1); - iconImage->center(UI_ELEMENT_HEIGHT - 4, UI_ELEMENT_HEIGHT - 4); + iconImage->center(EdgeTxStyles::UI_ELEMENT_HEIGHT - 4, EdgeTxStyles::UI_ELEMENT_HEIGHT - 4); } void IconButton::setIcon(EdgeTxIcon icon) { iconImage->setIcon(icon); } diff --git a/radio/src/thirdparty/libopenui/src/choice.cpp b/radio/src/thirdparty/libopenui/src/choice.cpp index 5bf3d4bfee4..cf9452500e6 100644 --- a/radio/src/thirdparty/libopenui/src/choice.cpp +++ b/radio/src/thirdparty/libopenui/src/choice.cpp @@ -36,7 +36,7 @@ static const lv_obj_class_t choice_class = { .user_data = nullptr, .event_cb = nullptr, .width_def = LV_SIZE_CONTENT, - .height_def = UI_ELEMENT_HEIGHT, + .height_def = EdgeTxStyles::UI_ELEMENT_HEIGHT, .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, .instance_size = sizeof(lv_obj_t), diff --git a/radio/src/thirdparty/libopenui/src/dialog.h b/radio/src/thirdparty/libopenui/src/dialog.h index c1c852000a2..604b267b2fd 100644 --- a/radio/src/thirdparty/libopenui/src/dialog.h +++ b/radio/src/thirdparty/libopenui/src/dialog.h @@ -97,7 +97,7 @@ class DynamicMessageDialog : public BaseDialog DynamicMessageDialog(Window* parent, const char* title, std::function textHandler, const char* message = "", - const int lineHeight = PAGE_LINE_HEIGHT, + const int lineHeight = EdgeTxStyles::PAGE_LINE_HEIGHT, const LcdFlags textFlags = CENTERED); // Attn.: FONT(XXL) is not supported by DynamicMessageDialog diff --git a/radio/src/thirdparty/libopenui/src/menutoolbar.cpp b/radio/src/thirdparty/libopenui/src/menutoolbar.cpp index 61f9dd54fd7..2c65a79223e 100644 --- a/radio/src/thirdparty/libopenui/src/menutoolbar.cpp +++ b/radio/src/thirdparty/libopenui/src/menutoolbar.cpp @@ -22,8 +22,6 @@ #include "themes/etx_lv_theme.h" #include "translations.h" -LAYOUT_VAL3(MENUS_TOOLBAR_BUTTON_WIDTH, 32, 24, 32) - static const lv_obj_class_t menu_button_class = { .base_class = &button_class, .constructor_cb = nullptr, diff --git a/radio/src/thirdparty/libopenui/src/menutoolbar.h b/radio/src/thirdparty/libopenui/src/menutoolbar.h index 70166cd7b3a..3fc1dbab4ad 100644 --- a/radio/src/thirdparty/libopenui/src/menutoolbar.h +++ b/radio/src/thirdparty/libopenui/src/menutoolbar.h @@ -20,6 +20,7 @@ #include "button.h" #include "choice.h" +#include "listbox.h" class Menu; @@ -44,6 +45,14 @@ class MenuToolbar : public Window virtual void longPress() {} + static LAYOUT_VAL(MENUS_TOOLBAR_BUTTON_WIDTH, 32, 32, 24) + +#if PORTRAIT_LCD + static constexpr coord_t MENUS_MAX_HEIGHT = (ListBox::MENUS_LINE_HEIGHT * 10); +#else + static constexpr coord_t MENUS_MAX_HEIGHT = (ListBox::MENUS_LINE_HEIGHT * 7) + 8; +#endif + protected: Choice* choice; Choice::FilterFct filter; diff --git a/radio/src/thirdparty/libopenui/src/numberedit.cpp b/radio/src/thirdparty/libopenui/src/numberedit.cpp index ba6fbe2bc34..0e6b3b17cbc 100644 --- a/radio/src/thirdparty/libopenui/src/numberedit.cpp +++ b/radio/src/thirdparty/libopenui/src/numberedit.cpp @@ -23,8 +23,6 @@ #include "strhelpers.h" #include "themes/etx_lv_theme.h" -LAYOUT_VAL3(DEF_W, 100, 70, 100) - static void numberedit_cb(lv_event_t* e) { NumberEdit* numEdit = (NumberEdit*)lv_event_get_user_data(e); @@ -61,7 +59,7 @@ NumberEdit::NumberEdit(Window* parent, const rect_t& rect, int vmin, int vmax, update(); etx_textarea_style(lvobj); - setHeight(UI_ELEMENT_HEIGHT); + setHeight(EdgeTxStyles::UI_ELEMENT_HEIGHT); etx_obj_add_style(lvobj, styles->text_align_right, LV_PART_MAIN); diff --git a/radio/src/thirdparty/libopenui/src/numberedit.h b/radio/src/thirdparty/libopenui/src/numberedit.h index a17e05e34f2..06846e2bf5e 100644 --- a/radio/src/thirdparty/libopenui/src/numberedit.h +++ b/radio/src/thirdparty/libopenui/src/numberedit.h @@ -146,6 +146,8 @@ class NumberEdit: public FormField virtual void update(); + static LAYOUT_VAL(DEF_W, 100, 100, 70) + protected: int vdefault = 0; int vmin; diff --git a/radio/src/thirdparty/libopenui/src/progress.cpp b/radio/src/thirdparty/libopenui/src/progress.cpp index 91b81125a61..3488dcc9506 100644 --- a/radio/src/thirdparty/libopenui/src/progress.cpp +++ b/radio/src/thirdparty/libopenui/src/progress.cpp @@ -36,7 +36,7 @@ static const lv_obj_class_t bar_class = { .user_data = nullptr, .event_cb = nullptr, .width_def = LV_PCT(100), - .height_def = UI_ELEMENT_HEIGHT, + .height_def = EdgeTxStyles::UI_ELEMENT_HEIGHT, .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, .instance_size = sizeof(lv_bar_t), diff --git a/radio/src/thirdparty/libopenui/src/textedit.cpp b/radio/src/thirdparty/libopenui/src/textedit.cpp index ed30ec63cde..e71cb784080 100644 --- a/radio/src/thirdparty/libopenui/src/textedit.cpp +++ b/radio/src/thirdparty/libopenui/src/textedit.cpp @@ -23,8 +23,6 @@ #include "storage/storage.h" #include "themes/etx_lv_theme.h" -LAYOUT_VAL3(DEF_W, 100, 70, 100) - #if defined(HARDWARE_KEYS) #include "menu.h" #endif @@ -44,7 +42,7 @@ TextEdit::TextEdit(Window* parent, const rect_t& rect, char* value, update(); etx_textarea_style(lvobj); - setHeight(UI_ELEMENT_HEIGHT); + setHeight(EdgeTxStyles::UI_ELEMENT_HEIGHT); lv_textarea_set_max_length(lvobj, length); lv_textarea_set_placeholder_text(lvobj, "---"); diff --git a/radio/src/thirdparty/libopenui/src/textedit.h b/radio/src/thirdparty/libopenui/src/textedit.h index f0ac4a2778e..57a26a8e894 100644 --- a/radio/src/thirdparty/libopenui/src/textedit.h +++ b/radio/src/thirdparty/libopenui/src/textedit.h @@ -34,6 +34,8 @@ class TextEdit : public FormField void update(); + static LAYOUT_VAL(DEF_W, 100, 100, 70) + protected: static void event_cb(lv_event_t* e); diff --git a/radio/src/thirdparty/libopenui/src/toggleswitch.cpp b/radio/src/thirdparty/libopenui/src/toggleswitch.cpp index eb29e4b9963..3a046e942b6 100644 --- a/radio/src/thirdparty/libopenui/src/toggleswitch.cpp +++ b/radio/src/thirdparty/libopenui/src/toggleswitch.cpp @@ -21,8 +21,6 @@ #include "theme.h" #include "themes/etx_lv_theme.h" -LAYOUT_VAL3(TOGGLE_W, 52, 40, 52) - // Animation LV_STYLE_CONST_SINGLE_INIT(anim_fast, LV_STYLE_ANIM_TIME, 120); @@ -57,8 +55,8 @@ static const lv_obj_class_t switch_class = { .destructor_cb = nullptr, .user_data = nullptr, .event_cb = nullptr, - .width_def = TOGGLE_W, - .height_def = UI_ELEMENT_HEIGHT, + .width_def = ToggleSwitch::TOGGLE_W, + .height_def = EdgeTxStyles::UI_ELEMENT_HEIGHT, .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT, .instance_size = sizeof(lv_switch_t), diff --git a/radio/src/thirdparty/libopenui/src/toggleswitch.h b/radio/src/thirdparty/libopenui/src/toggleswitch.h index 70bde0391f7..1dd6f6f970f 100644 --- a/radio/src/thirdparty/libopenui/src/toggleswitch.h +++ b/radio/src/thirdparty/libopenui/src/toggleswitch.h @@ -47,7 +47,9 @@ class ToggleSwitch : public FormField } void update() const; - + + static LAYOUT_VAL(TOGGLE_W, 52, 52, 40) + protected: std::function _getValue; std::function _setValue; diff --git a/radio/src/thirdparty/libopenui/src/window.cpp b/radio/src/thirdparty/libopenui/src/window.cpp index b3ae5c53f23..354692e6e4e 100644 --- a/radio/src/thirdparty/libopenui/src/window.cpp +++ b/radio/src/thirdparty/libopenui/src/window.cpp @@ -382,7 +382,7 @@ void Window::enable(bool enabled) void Window::addBackButton() { new ButtonBase( - this, {0, 0, MENU_HEADER_HEIGHT, MENU_HEADER_HEIGHT}, + this, {0, 0, EdgeTxStyles::MENU_HEADER_HEIGHT, EdgeTxStyles::MENU_HEADER_HEIGHT}, [=]() -> uint8_t { onCancel(); return 0;