From 23df4f63bbc12eea395f72919abe048fc91c0b9b Mon Sep 17 00:00:00 2001 From: philmoz Date: Thu, 1 Aug 2024 10:05:52 +1000 Subject: [PATCH] chore(color): color UI code cleanup - round 3 (#5351) --- radio/src/gui/colorlcd/access_settings.cpp | 2 +- radio/src/gui/colorlcd/channel_bar.cpp | 21 +- radio/src/gui/colorlcd/channel_bar.h | 2 - radio/src/gui/colorlcd/color_list.cpp | 2 +- radio/src/gui/colorlcd/color_list.h | 3 +- radio/src/gui/colorlcd/color_picker.cpp | 2 +- radio/src/gui/colorlcd/crossfire_settings.cpp | 2 +- radio/src/gui/colorlcd/curve.cpp | 2 +- radio/src/gui/colorlcd/curveedit.cpp | 12 +- radio/src/gui/colorlcd/custom_failsafe.cpp | 4 +- radio/src/gui/colorlcd/file_carosell.cpp | 2 +- radio/src/gui/colorlcd/fullscreen_dialog.cpp | 6 +- radio/src/gui/colorlcd/function_switches.cpp | 23 +-- radio/src/gui/colorlcd/gvar_numberedit.cpp | 3 +- radio/src/gui/colorlcd/hw_bluetooth.cpp | 6 +- radio/src/gui/colorlcd/hw_inputs.cpp | 6 +- radio/src/gui/colorlcd/hw_serial.cpp | 4 +- radio/src/gui/colorlcd/hw_serial.h | 1 - radio/src/gui/colorlcd/layout.h | 2 - radio/src/gui/colorlcd/layouts/sliders.cpp | 47 +++-- radio/src/gui/colorlcd/layouts/sliders.h | 10 +- .../src/gui/colorlcd/layouts/topbar_impl.cpp | 4 +- radio/src/gui/colorlcd/layouts/topbar_impl.h | 1 - radio/src/gui/colorlcd/layouts/trims.cpp | 36 ++-- radio/src/gui/colorlcd/layouts/trims.h | 1 + radio/src/gui/colorlcd/lcd.cpp | 26 +-- radio/src/gui/colorlcd/lcd.h | 5 +- radio/src/gui/colorlcd/list_line_button.cpp | 2 +- radio/src/gui/colorlcd/list_line_button.h | 4 +- radio/src/gui/colorlcd/model_curves.cpp | 12 +- radio/src/gui/colorlcd/model_flightmodes.cpp | 4 +- radio/src/gui/colorlcd/model_gvars.cpp | 2 +- radio/src/gui/colorlcd/model_heli.cpp | 6 +- .../gui/colorlcd/model_logical_switches.cpp | 19 +- .../src/gui/colorlcd/model_mixer_scripts.cpp | 28 +-- radio/src/gui/colorlcd/model_mixes.cpp | 6 +- radio/src/gui/colorlcd/model_outputs.cpp | 6 +- radio/src/gui/colorlcd/model_outputs.h | 6 +- radio/src/gui/colorlcd/model_select.cpp | 12 +- radio/src/gui/colorlcd/model_setup.cpp | 2 +- radio/src/gui/colorlcd/model_usbjoystick.cpp | 6 +- radio/src/gui/colorlcd/module_setup.cpp | 2 +- radio/src/gui/colorlcd/mpm_settings.cpp | 5 +- radio/src/gui/colorlcd/page.cpp | 6 +- radio/src/gui/colorlcd/preview_window.cpp | 10 +- radio/src/gui/colorlcd/radio_calibration.cpp | 6 +- radio/src/gui/colorlcd/radio_diaganas.cpp | 17 +- .../colorlcd/radio_ghost_module_config.cpp | 4 +- radio/src/gui/colorlcd/radio_hardware.cpp | 5 +- radio/src/gui/colorlcd/radio_setup.cpp | 2 +- .../gui/colorlcd/radio_spectrum_analyser.cpp | 36 ++-- radio/src/gui/colorlcd/radio_theme.cpp | 11 +- radio/src/gui/colorlcd/radio_tools.cpp | 31 ++- radio/src/gui/colorlcd/radio_trainer.cpp | 6 +- .../gui/colorlcd/screen_user_interface.cpp | 84 ++++---- .../src/gui/colorlcd/select_fab_carousel.cpp | 4 +- radio/src/gui/colorlcd/select_fab_carousel.h | 1 - radio/src/gui/colorlcd/special_functions.cpp | 15 +- radio/src/gui/colorlcd/startup_shutdown.cpp | 14 +- radio/src/gui/colorlcd/tabsgroup.cpp | 11 +- radio/src/gui/colorlcd/tabsgroup.h | 4 +- radio/src/gui/colorlcd/theme_manager.cpp | 25 +-- radio/src/gui/colorlcd/theme_manager.h | 4 +- radio/src/gui/colorlcd/view_about.cpp | 2 +- radio/src/gui/colorlcd/view_channels.cpp | 4 +- .../src/gui/colorlcd/view_main_decoration.cpp | 79 +++---- radio/src/gui/colorlcd/view_main_decoration.h | 12 +- radio/src/gui/colorlcd/view_statistics.cpp | 32 ++- radio/src/gui/colorlcd/widgets/gauge.cpp | 4 +- radio/src/gui/colorlcd/widgets/modelbmp.cpp | 1 - radio/src/gui/colorlcd/widgets/radio_info.cpp | 18 +- radio/src/gui/colorlcd/widgets/timer.cpp | 4 +- radio/src/lua/api_model.cpp | 4 +- radio/src/lua/lua_widget.cpp | 13 +- radio/src/storage/modelslist.h | 5 +- radio/src/storage/sdcard_yaml.h | 7 +- radio/src/storage/yaml/yaml_bits.h | 5 +- radio/src/storage/yaml/yaml_datastructs.h | 5 +- radio/src/storage/yaml/yaml_defs.h | 5 +- radio/src/storage/yaml/yaml_labelslist.h | 5 +- radio/src/storage/yaml/yaml_modelslist.h | 5 +- radio/src/storage/yaml/yaml_node.h | 5 +- radio/src/storage/yaml/yaml_parser.h | 5 +- radio/src/storage/yaml/yaml_tree_walker.h | 6 +- .../thirdparty/libopenui/src/bitmapbuffer.cpp | 55 +++-- .../thirdparty/libopenui/src/bitmapbuffer.h | 148 ++++--------- .../libopenui/src/bitmapbuffer_draw_extra.cpp | 18 +- radio/src/thirdparty/libopenui/src/button.cpp | 5 +- .../libopenui/src/button_matrix.cpp | 2 +- radio/src/thirdparty/libopenui/src/choice.cpp | 2 +- radio/src/thirdparty/libopenui/src/dialog.cpp | 16 +- radio/src/thirdparty/libopenui/src/dialog.h | 2 +- radio/src/thirdparty/libopenui/src/form.cpp | 3 +- radio/src/thirdparty/libopenui/src/form.h | 3 +- radio/src/thirdparty/libopenui/src/menu.cpp | 2 +- .../thirdparty/libopenui/src/numberedit.cpp | 194 ++++-------------- .../src/thirdparty/libopenui/src/numberedit.h | 6 + radio/src/thirdparty/libopenui/src/slider.cpp | 2 +- radio/src/thirdparty/libopenui/src/static.cpp | 12 +- radio/src/thirdparty/libopenui/src/static.h | 16 +- .../src/thirdparty/libopenui/src/textedit.cpp | 8 +- .../thirdparty/libopenui/src/toggleswitch.cpp | 2 +- radio/src/thirdparty/libopenui/src/window.cpp | 2 +- radio/src/thirdparty/libopenui/src/window.h | 1 + 104 files changed, 554 insertions(+), 824 deletions(-) diff --git a/radio/src/gui/colorlcd/access_settings.cpp b/radio/src/gui/colorlcd/access_settings.cpp index 03fa10d4bc2..c330ac56c0c 100644 --- a/radio/src/gui/colorlcd/access_settings.cpp +++ b/radio/src/gui/colorlcd/access_settings.cpp @@ -541,7 +541,7 @@ void ModuleOptions::update() if (!optionsAvailable) { // no options available line = form->newLine(grid); - new StaticText(line, rect_t{}, STR_NO_TX_OPTIONS, 0); + new StaticText(line, rect_t{}, STR_NO_TX_OPTIONS); } else { // some options available if (optionsAvailable & (1 << MODULE_OPTION_EXTERNAL_ANTENNA)) { diff --git a/radio/src/gui/colorlcd/channel_bar.cpp b/radio/src/gui/colorlcd/channel_bar.cpp index 5270440d883..b1aa26346bd 100644 --- a/radio/src/gui/colorlcd/channel_bar.cpp +++ b/radio/src/gui/colorlcd/channel_bar.cpp @@ -219,30 +219,29 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect, uint8_t _channel, bool isInHeader) : Window(parent, rect), channel(_channel) { - LcdFlags textColor = - isInHeader ? COLOR_THEME_PRIMARY2 : COLOR_THEME_SECONDARY1; + LcdColorIndex txtColIdx = isInHeader ? COLOR_THEME_PRIMARY2_INDEX : COLOR_THEME_SECONDARY1_INDEX; outputChannelBar = new OutputChannelBar( - this, {ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT + ChannelBar::TMARGIN, width() - ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT}, + this, {PAD_TINY, ChannelBar::BAR_HEIGHT + PAD_TINY, width() - PAD_TINY, ChannelBar::BAR_HEIGHT}, channel, isInHeader); new MixerChannelBar( this, - {ChannelBar::LMARGIN, (2 * ChannelBar::BAR_HEIGHT) + ChannelBar::TMARGIN + 1, width() - ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT}, + {PAD_TINY, (2 * ChannelBar::BAR_HEIGHT) + PAD_TINY + 1, width() - PAD_TINY, ChannelBar::BAR_HEIGHT}, channel); // Channel number char chanString[] = TR_CH "32 "; strAppendSigned(&chanString[2], channel + 1, 2); - new StaticText(this, {ChannelBar::LMARGIN, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, chanString, - textColor | FONT(XS) | LEFT); + new StaticText(this, {PAD_TINY, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, chanString, + txtColIdx, 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, {ChannelBar::LMARGIN + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm, - textColor | FONT(XS) | LEFT); + new StaticText(this, {PAD_TINY + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm, + txtColIdx, FONT(XS) | LEFT); } // Channel value in µS @@ -254,12 +253,12 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect, return calcRESXto100(channelOutputs[channel]); return PPM_CH_CENTER(channel) + channelOutputs[channel] / 2; }, - textColor | FONT(XS) | RIGHT, "", suffix); + txtColIdx, FONT(XS) | RIGHT, "", suffix); // Override icon #if defined(OVERRIDE_CHANNEL_FUNCTION) overrideIcon = new StaticIcon( - this, 0, 5, ICON_CHAN_MONITOR_LOCKED, textColor); + this, 0, 5, ICON_CHAN_MONITOR_LOCKED, txtColIdx); overrideIcon->show(safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED); #endif @@ -267,7 +266,7 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect, LimitData* ld = limitAddress(channel); if (ld && ld->revert) { new StaticIcon(this, 0, ICON_SZ, ICON_CHAN_MONITOR_INVERTED, - textColor); + txtColIdx); } } diff --git a/radio/src/gui/colorlcd/channel_bar.h b/radio/src/gui/colorlcd/channel_bar.h index 36681deab3f..c5a67dd065d 100644 --- a/radio/src/gui/colorlcd/channel_bar.h +++ b/radio/src/gui/colorlcd/channel_bar.h @@ -31,8 +31,6 @@ class ChannelBar : public Window LcdColorIndex textColorIndex = COLOR_THEME_SECONDARY1_INDEX); static LAYOUT_VAL(BAR_HEIGHT, 13, 13) - static LAYOUT_VAL(LMARGIN, 2, 2) - static LAYOUT_VAL(TMARGIN, 2, 2) static LAYOUT_VAL(VAL_W, 45, 45) static LAYOUT_VAL(VAL_H, 14, 14) diff --git a/radio/src/gui/colorlcd/color_list.cpp b/radio/src/gui/colorlcd/color_list.cpp index 53290dff128..431560f020c 100644 --- a/radio/src/gui/colorlcd/color_list.cpp +++ b/radio/src/gui/colorlcd/color_list.cpp @@ -25,7 +25,7 @@ #include "themes/etx_lv_theme.h" ColorList::ColorList(Window *parent, const rect_t &rect, - std::vector colors, LcdFlags lcdFlags) : + std::vector colors) : ListBox(parent, rect, getColorListNames(colors)), _colorList(colors) { setSelected(0); diff --git a/radio/src/gui/colorlcd/color_list.h b/radio/src/gui/colorlcd/color_list.h index f4e61cea925..30cbad28bf1 100644 --- a/radio/src/gui/colorlcd/color_list.h +++ b/radio/src/gui/colorlcd/color_list.h @@ -30,8 +30,7 @@ class ColorList : public ListBox { public: - ColorList(Window* parent, const rect_t& rect, std::vector colors, - LcdFlags lcdFlags = 0); + ColorList(Window* parent, const rect_t& rect, std::vector colors); inline ColorEntry getSelectedColor() { diff --git a/radio/src/gui/colorlcd/color_picker.cpp b/radio/src/gui/colorlcd/color_picker.cpp index 1847b3a4793..b7236768f97 100644 --- a/radio/src/gui/colorlcd/color_picker.cpp +++ b/radio/src/gui/colorlcd/color_picker.cpp @@ -89,7 +89,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, CVAL_W, 0}, "", COLOR_THEME_PRIMARY1 | FONT(L)); + hexStr = new StaticText(hbox, {0, 0, CVAL_W, 0}, "", COLOR_THEME_PRIMARY1_INDEX, FONT(L)); updateColor(color); diff --git a/radio/src/gui/colorlcd/crossfire_settings.cpp b/radio/src/gui/colorlcd/crossfire_settings.cpp index dcc26ced3fb..3cf0dac2539 100644 --- a/radio/src/gui/colorlcd/crossfire_settings.cpp +++ b/radio/src/gui/colorlcd/crossfire_settings.cpp @@ -54,7 +54,7 @@ CrossfireSettings::CrossfireSettings(Window* parent, const FlexGridLayout& g, // getStringAtIndex(buf, STR_CRSF_BAUDRATE, // CROSSFIRE_STORE_TO_INDEX( // g_eeGeneral.internalModuleBaudrate)), - // 0, COLOR_THEME_PRIMARY1); + // COLOR_THEME_PRIMARY1); } auto line = newLine(grid); diff --git a/radio/src/gui/colorlcd/curve.cpp b/radio/src/gui/colorlcd/curve.cpp index 0ea93ae2351..7a294c1674b 100644 --- a/radio/src/gui/colorlcd/curve.cpp +++ b/radio/src/gui/colorlcd/curve.cpp @@ -165,7 +165,7 @@ Curve::Curve(Window* parent, const rect_t& rect, posHLine = lv_line_create(lvobj); etx_obj_add_style(posHLine, styles->graph_position_line, LV_PART_MAIN); - positionValue = new StaticText(this, {10, 10, LV_SIZE_CONTENT, 17}, "", COLOR_THEME_PRIMARY1 | FONT(XS)); + positionValue = new StaticText(this, {10, 10, LV_SIZE_CONTENT, 17}, "", COLOR_THEME_PRIMARY1_INDEX, FONT(XS)); positionValue->padLeft(PAD_TINY); positionValue->padRight(PAD_TINY); etx_solid_bg(positionValue->getLvObj(), COLOR_THEME_ACTIVE_INDEX); diff --git a/radio/src/gui/colorlcd/curveedit.cpp b/radio/src/gui/colorlcd/curveedit.cpp index 614abeeca8f..504d580d6bc 100644 --- a/radio/src/gui/colorlcd/curveedit.cpp +++ b/radio/src/gui/colorlcd/curveedit.cpp @@ -90,14 +90,14 @@ class CurveDataEdit : public Window {PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y, NUM_BTN_WIDTH, PTNUM_H}, std::to_string(i + start + 1), - COLOR_THEME_PRIMARY1 | FONT(XS) | CENTERED); + COLOR_THEME_PRIMARY1_INDEX, FONT(XS) | CENTERED); } y += NUM_HDR_HEIGHT; new StaticText( parent, {1, y + PAD_MEDIUM, PTNUM_X, EdgeTxStyles::UI_ELEMENT_HEIGHT}, - "X", COLOR_THEME_PRIMARY1 | CENTERED); + "X", COLOR_THEME_PRIMARY1_INDEX, CENTERED); int8_t* points = curveAddress(index); @@ -110,7 +110,7 @@ class CurveDataEdit : public Window parent, {PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y + PAD_MEDIUM, NUM_BTN_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT}, - "-100", COLOR_THEME_SECONDARY1 | CENTERED); + "-100", COLOR_THEME_SECONDARY1_INDEX, CENTERED); i += 1; } if ((start + count) == curvePointsCount) { @@ -145,7 +145,7 @@ class CurveDataEdit : public Window parent, {PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y + PAD_MEDIUM, NUM_BTN_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT}, - "100", COLOR_THEME_SECONDARY1 | CENTERED); + "100", COLOR_THEME_SECONDARY1_INDEX, CENTERED); } } else { for (uint8_t i = 0; i < count; i++) { @@ -154,7 +154,7 @@ class CurveDataEdit : public Window rect_t{PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y + PAD_MEDIUM, NUM_BTN_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT}, std::to_string(-100 + (200 * (i + start)) / (curvePointsCount - 1)), - COLOR_THEME_SECONDARY1 | CENTERED); + COLOR_THEME_SECONDARY1_INDEX, CENTERED); } } @@ -162,7 +162,7 @@ class CurveDataEdit : public Window new StaticText( parent, {1, y + PAD_MEDIUM, PTNUM_X, EdgeTxStyles::UI_ELEMENT_HEIGHT}, - "Y", COLOR_THEME_PRIMARY1 | CENTERED); + "Y", COLOR_THEME_PRIMARY1_INDEX, CENTERED); // y value for (uint8_t i = 0; i < count; i++) { diff --git a/radio/src/gui/colorlcd/custom_failsafe.cpp b/radio/src/gui/colorlcd/custom_failsafe.cpp index 3ed909280b2..fe30d7adf76 100644 --- a/radio/src/gui/colorlcd/custom_failsafe.cpp +++ b/radio/src/gui/colorlcd/custom_failsafe.cpp @@ -168,12 +168,12 @@ class ChannelFSCombo : public Window lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0); edit = new ChannelFailsafeEdit(this, ch, vmin, vmax); - auto btn = new TextButton(this, rect_t{}, LV_SYMBOL_SETTINGS, [=]() { + new TextButton(this, rect_t{}, LV_SYMBOL_SETTINGS, [=]() { edit->toggle(); return 0; }); - btn = new TextButton(this, rect_t{}, LV_SYMBOL_COPY, [=]() { + new TextButton(this, rect_t{}, LV_SYMBOL_COPY, [=]() { edit->copyChannel(); return 0; }); diff --git a/radio/src/gui/colorlcd/file_carosell.cpp b/radio/src/gui/colorlcd/file_carosell.cpp index 28509649379..6bd0ec2fb17 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, EdgeTxStyles::PAGE_LINE_HEIGHT * 2}, "", CENTERED | FONT(L) | COLOR_THEME_PRIMARY1); + message = new StaticText(this, {0, rect.h/2, rect.w, EdgeTxStyles::PAGE_LINE_HEIGHT * 2}, "", COLOR_THEME_PRIMARY1_INDEX, CENTERED | FONT(L)); setFileNames(fileNames); } diff --git a/radio/src/gui/colorlcd/fullscreen_dialog.cpp b/radio/src/gui/colorlcd/fullscreen_dialog.cpp index 608f36c34cd..2e071de65b3 100644 --- a/radio/src/gui/colorlcd/fullscreen_dialog.cpp +++ b/radio/src/gui/colorlcd/fullscreen_dialog.cpp @@ -78,7 +78,7 @@ void FullScreenDialog::build() new StaticIcon( this, ALERT_BITMAP_LEFT, ALERT_BITMAP_TOP, (type == WARNING_TYPE_INFO) ? ICON_BUSY : ICON_ERROR, - COLOR_THEME_WARNING); + COLOR_THEME_WARNING_INDEX); std::string t; if (type == WARNING_TYPE_ALERT) { @@ -95,14 +95,14 @@ void FullScreenDialog::build() rect_t{ALERT_TITLE_LEFT, ALERT_TITLE_TOP, LCD_W - ALERT_TITLE_LEFT - PAD_MEDIUM, LCD_H - ALERT_TITLE_TOP - PAD_MEDIUM}, - t.c_str(), COLOR_THEME_WARNING | FONT(XL)); + t.c_str(), COLOR_THEME_WARNING_INDEX, FONT(XL)); messageLabel = new StaticText(this, rect_t{ALERT_MESSAGE_LEFT, ALERT_MESSAGE_TOP, LCD_W - ALERT_MESSAGE_LEFT - PAD_MEDIUM, LCD_H - ALERT_MESSAGE_TOP - PAD_MEDIUM}, - message.c_str(), COLOR_THEME_PRIMARY1 | FONT(BOLD)); + message.c_str(), COLOR_THEME_PRIMARY1_INDEX, FONT(BOLD)); if (!action.empty()) { auto btn = new TextButton( diff --git a/radio/src/gui/colorlcd/function_switches.cpp b/radio/src/gui/colorlcd/function_switches.cpp index 15d3185ce97..695facdd71a 100644 --- a/radio/src/gui/colorlcd/function_switches.cpp +++ b/radio/src/gui/colorlcd/function_switches.cpp @@ -56,8 +56,7 @@ class FunctionSwitch : public Window std::string s(STR_CHAR_SWITCH); s += switchGetName(switchIndex + switchGetMaxSwitches()); - new StaticText(this, {PAD_LARGE, PAD_MEDIUM, SW_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, s, - COLOR_THEME_PRIMARY1); + new StaticText(this, {PAD_LARGE, PAD_MEDIUM, SW_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, s); new ModelTextEdit(this, {NM_X, 0, NM_W, 0}, g_model.switchNames[switchIndex], LEN_SWITCH_NAME); @@ -146,7 +145,7 @@ class FunctionSwitch : public Window void checkEvents() override { setState(); - if (lastType != FSWITCH_CONFIG(switchIndex)) { + if (lastType != (int)FSWITCH_CONFIG(switchIndex)) { lastType = FSWITCH_CONFIG(switchIndex); typeChoice->setValue(lastType); } @@ -163,8 +162,7 @@ class SwitchGroup : public Window padAll(PAD_TINY_GAP); new StaticText(this, {0, PAD_MEDIUM, NM_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, - STR_FUNCTION_SWITCH_GROUPS[groupIndex], - COLOR_THEME_PRIMARY1); + STR_FUNCTION_SWITCH_GROUPS[groupIndex]); auto btn = new TextButton( this, {AO_X, 0, AO_W, 0}, STR_GROUP_ALWAYS_ON, [=]() -> int8_t { @@ -178,8 +176,7 @@ class SwitchGroup : public Window }); btn->check(IS_FSWITCH_GROUP_ON(groupIndex)); - new StaticText(this, {SL_X, PAD_MEDIUM, SL_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_SWITCH_STARTUP, - COLOR_THEME_PRIMARY1); + new StaticText(this, {SL_X, PAD_MEDIUM, SL_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_SWITCH_STARTUP); startChoice = new Choice( this, {ST_X, 0, ST_W, 0}, STR_FSSWITCHES, 0, @@ -234,13 +231,13 @@ ModelFunctionSwitches::ModelFunctionSwitches() : Page(ICON_MODEL_SETUP) FlexGridLayout grid2(line_col_dsc2, line_row_dsc, PAD_TINY); auto line = body->newLine(grid2); - new StaticText(line, rect_t{}, STR_SWITCHES, COLOR_THEME_PRIMARY1); - new StaticText(line, rect_t{}, STR_NAME, COLOR_THEME_PRIMARY1 | FONT(XS)); + new StaticText(line, rect_t{}, STR_SWITCHES); + new StaticText(line, rect_t{}, STR_NAME, COLOR_THEME_PRIMARY1_INDEX, FONT(XS)); new StaticText(line, rect_t{}, STR_SWITCH_TYPE, - COLOR_THEME_PRIMARY1 | FONT(XS)); - new StaticText(line, rect_t{}, STR_GROUP, COLOR_THEME_PRIMARY1 | FONT(XS)); + COLOR_THEME_PRIMARY1_INDEX, FONT(XS)); + new StaticText(line, rect_t{}, STR_GROUP, COLOR_THEME_PRIMARY1_INDEX, FONT(XS)); startupHeader = new StaticText(line, rect_t{}, STR_SWITCH_STARTUP, - COLOR_THEME_PRIMARY1 | FONT(XS)); + COLOR_THEME_PRIMARY1_INDEX, FONT(XS)); for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i += 1) { new FunctionSwitch(body, i); @@ -254,7 +251,7 @@ ModelFunctionSwitches::ModelFunctionSwitches() : Page(ICON_MODEL_SETUP) line = body->newLine(grid1); - new StaticText(line, rect_t{}, STR_MORE_INFO, COLOR_THEME_PRIMARY1); + new StaticText(line, rect_t{}, STR_MORE_INFO); line = body->newLine(grid1); line->padBottom(PAD_LARGE); diff --git a/radio/src/gui/colorlcd/gvar_numberedit.cpp b/radio/src/gui/colorlcd/gvar_numberedit.cpp index 5b06e95de62..9e6598b657c 100644 --- a/radio/src/gui/colorlcd/gvar_numberedit.cpp +++ b/radio/src/gui/colorlcd/gvar_numberedit.cpp @@ -64,8 +64,7 @@ GVarNumberEdit::GVarNumberEdit(Window* parent, int32_t vmin, num_field = new NumberEdit( this, {0, 0, NUM_EDIT_W, 0}, vmin, vmax, [=]() { return getValue() + voffset; }, - nullptr); - num_field->setTextFlag(textFlags); + nullptr, textFlags); num_field->setDefault(vdefault); #if defined(GVARS) diff --git a/radio/src/gui/colorlcd/hw_bluetooth.cpp b/radio/src/gui/colorlcd/hw_bluetooth.cpp index 721b9e0d3d4..1adaf2e0a8a 100644 --- a/radio/src/gui/colorlcd/hw_bluetooth.cpp +++ b/radio/src/gui/colorlcd/hw_bluetooth.cpp @@ -51,8 +51,7 @@ class BTDetailsDialog : public BaseDialog [=]() { return std::string(bluetooth.localAddr[0] ? bluetooth.localAddr : "---"); - }, - COLOR_THEME_PRIMARY1); + }); // Remote MAC line = form->newLine(grid); @@ -62,8 +61,7 @@ class BTDetailsDialog : public BaseDialog [=]() { return std::string(bluetooth.distantAddr[0] ? bluetooth.distantAddr : "---"); - }, - COLOR_THEME_PRIMARY1); + }); } }; diff --git a/radio/src/gui/colorlcd/hw_inputs.cpp b/radio/src/gui/colorlcd/hw_inputs.cpp index ca2cf37d6a6..27a7b5c763a 100644 --- a/radio/src/gui/colorlcd/hw_inputs.cpp +++ b/radio/src/gui/colorlcd/hw_inputs.cpp @@ -92,9 +92,9 @@ HWPots::HWPots(Window* parent) : } }); - new StaticText(this, {P_NM_X, -2, 0, 0}, STR_NAME, FONT(XS)); - new StaticText(this, {P_TYP_X, -2, 0, 0}, STR_TYPE, FONT(XS)); - new StaticText(this, {P_INV_X, -2, 0, 0}, STR_MENU_INVERT, FONT(XS)); + new StaticText(this, {P_NM_X, -2, 0, 0}, STR_NAME, COLOR_THEME_PRIMARY1_INDEX, FONT(XS)); + new StaticText(this, {P_TYP_X, -2, 0, 0}, STR_TYPE, COLOR_THEME_PRIMARY1_INDEX, FONT(XS)); + new StaticText(this, {P_INV_X, -2, 0, 0}, STR_MENU_INVERT, COLOR_THEME_PRIMARY1_INDEX, FONT(XS)); coord_t yo = EdgeTxStyles::PAGE_LINE_HEIGHT - 2; diff --git a/radio/src/gui/colorlcd/hw_serial.cpp b/radio/src/gui/colorlcd/hw_serial.cpp index bcab1fe3214..3e827f75de6 100644 --- a/radio/src/gui/colorlcd/hw_serial.cpp +++ b/radio/src/gui/colorlcd/hw_serial.cpp @@ -64,8 +64,8 @@ SerialConfigWindow::SerialConfigWindow(Window *parent, FlexGridLayout& grid) grid.setColSpan(2); auto line = parent->newLine(grid); line->padLeft(WARN_PADL); - line->padBottom(WARN_PADB); - new StaticText(line, rect_t{}, STR_TTL_WARNING, COLOR_THEME_WARNING); + line->padBottom(PAD_MEDIUM); + new StaticText(line, rect_t{}, STR_TTL_WARNING, COLOR_THEME_WARNING_INDEX); grid.setColSpan(1); } } diff --git a/radio/src/gui/colorlcd/hw_serial.h b/radio/src/gui/colorlcd/hw_serial.h index 26d5d64d6a1..24f72c80f47 100644 --- a/radio/src/gui/colorlcd/hw_serial.h +++ b/radio/src/gui/colorlcd/hw_serial.h @@ -29,5 +29,4 @@ class SerialConfigWindow SerialConfigWindow(Window *parent, FlexGridLayout& grid); static LAYOUT_VAL(WARN_PADL, 20, 20); - static LAYOUT_VAL(WARN_PADB, 6, 6); }; diff --git a/radio/src/gui/colorlcd/layout.h b/radio/src/gui/colorlcd/layout.h index 51e72a1086e..15110152cc2 100644 --- a/radio/src/gui/colorlcd/layout.h +++ b/radio/src/gui/colorlcd/layout.h @@ -29,8 +29,6 @@ #define MAX_LAYOUT_ZONES 10 #define MAX_LAYOUT_OPTIONS 10 -constexpr uint32_t LAYOUT_REFRESH = 1000 / 2; // 2 Hz - #if !defined(YAML_GENERATOR) typedef WidgetsContainerPersistentData LayoutPersistentData; diff --git a/radio/src/gui/colorlcd/layouts/sliders.cpp b/radio/src/gui/colorlcd/layouts/sliders.cpp index d0534910449..a53f29fc4da 100644 --- a/radio/src/gui/colorlcd/layouts/sliders.cpp +++ b/radio/src/gui/colorlcd/layouts/sliders.cpp @@ -67,8 +67,10 @@ SliderIcon::SliderIcon(Window* parent) : MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx, bool isVertical) : - Window(parent, rect), idx(idx), isVertical(isVertical) + Window(parent, rect), isVertical(isVertical) { + potIdx = adcGetInputOffset(ADC_INPUT_FLEX) + idx; + if (isVertical) { int sliderTicksCount = (height() - LayoutFactory::TRIM_SQUARE_SIZE) / SLIDER_TICK_SPACING; tickPoints = new lv_point_t[(sliderTicksCount + 1) * 2]; @@ -76,10 +78,10 @@ MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx, 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}; + tickPoints[i * 2] = {PAD_TINY, y}; tickPoints[i * 2 + 1] = {SL_SZ, y}; } else { - tickPoints[i * 2] = {SL_TK + 2, y}; + tickPoints[i * 2] = {PAD_TINY + 2, y}; tickPoints[i * 2 + 1] = {SL_SZ - 2, y}; } auto line = lv_line_create(lvobj); @@ -94,10 +96,10 @@ MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx, 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}; + tickPoints[i * 2] = {x, PAD_TINY}; tickPoints[i * 2 + 1] = {x, SL_SZ}; } else { - tickPoints[i * 2] = {x, SL_TK + 2}; + tickPoints[i * 2] = {x, PAD_TINY + 2}; tickPoints[i * 2 + 1] = {x, SL_SZ - 2}; } auto line = lv_line_create(lvobj); @@ -108,14 +110,8 @@ 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() - LayoutFactory::TRIM_SQUARE_SIZE) / 2; - else - y = (width() - LayoutFactory::TRIM_SQUARE_SIZE) / 2; - lv_obj_set_pos(sliderIcon->getLvObj(), x, y); - checkEvents(); + setPos(); } void MainViewSlider::deleteLater(bool detach, bool trash) @@ -126,24 +122,27 @@ void MainViewSlider::deleteLater(bool detach, bool trash) } } +void MainViewSlider::setPos() +{ + coord_t x = 0, y = 0; + if (isVertical) { + y = divRoundClosest((height() - LayoutFactory::TRIM_SQUARE_SIZE) * (-value + RESX), + 2 * RESX); + } else { + x = divRoundClosest((width() - LayoutFactory::TRIM_SQUARE_SIZE) * (value + RESX), + 2 * RESX); + } + lv_obj_set_pos(sliderIcon->getLvObj(), x, y); +} + void MainViewSlider::checkEvents() { Window::checkEvents(); - auto pot_idx = adcGetInputOffset(ADC_INPUT_FLEX) + idx; - int16_t newValue = calibratedAnalogs[pot_idx]; + int16_t newValue = calibratedAnalogs[potIdx]; if (value != newValue) { value = newValue; - - coord_t x = 0, y = 0; - if (isVertical) { - y = divRoundClosest((height() - LayoutFactory::TRIM_SQUARE_SIZE) * (-value + RESX), - 2 * RESX); - } else { - x = divRoundClosest((width() - LayoutFactory::TRIM_SQUARE_SIZE) * (value + RESX), - 2 * RESX); - } - lv_obj_set_pos(sliderIcon->getLvObj(), x, y); + setPos(); } } diff --git a/radio/src/gui/colorlcd/layouts/sliders.h b/radio/src/gui/colorlcd/layouts/sliders.h index 2a063832813..1e91d53374a 100644 --- a/radio/src/gui/colorlcd/layouts/sliders.h +++ b/radio/src/gui/colorlcd/layouts/sliders.h @@ -37,7 +37,6 @@ class MainViewSlider : public Window public: MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx, bool isVertical); - void checkEvents() override; static LAYOUT_VAL(SLIDER_TICKS_COUNT, 40, 30) static LAYOUT_VAL(SLIDER_TICK_SPACING, 4, 4) @@ -47,15 +46,18 @@ class MainViewSlider : public Window SLIDER_TICKS_COUNT * SLIDER_TICK_SPACING + LayoutFactory::TRIM_SQUARE_SIZE; static LAYOUT_VAL(SL_SZ, 15, 15) - static LAYOUT_VAL(SL_TK, 2, 2) protected: - uint8_t idx; - int16_t value = -10000; + uint8_t potIdx; + int16_t value = 0; bool isVertical; SliderIcon* sliderIcon = nullptr; lv_point_t* tickPoints = nullptr; + void setPos(); + + void checkEvents() override; + void deleteLater(bool detach = true, bool trash = true) override; }; diff --git a/radio/src/gui/colorlcd/layouts/topbar_impl.cpp b/radio/src/gui/colorlcd/layouts/topbar_impl.cpp index f05efc91965..a3748012d05 100644 --- a/radio/src/gui/colorlcd/layouts/topbar_impl.cpp +++ b/radio/src/gui/colorlcd/layouts/topbar_impl.cpp @@ -62,9 +62,9 @@ rect_t TopBar::getZone(unsigned int index) const coord_t x = MENU_HEADER_BUTTONS_LEFT + 1; for (int i = 0; i < index; i += 1) - x += (g_model.topbarWidgetWidth[i] * (TOPBAR_ZONE_WIDTH + TOPBAR_ZONE_HMARGIN)); + x += (g_model.topbarWidgetWidth[i] * (TOPBAR_ZONE_WIDTH + PAD_TINY)); - coord_t size = ((g_model.topbarWidgetWidth[index] - 1) * (TOPBAR_ZONE_WIDTH + TOPBAR_ZONE_HMARGIN) + TOPBAR_ZONE_WIDTH); + coord_t size = ((g_model.topbarWidgetWidth[index] - 1) * (TOPBAR_ZONE_WIDTH + PAD_TINY) + TOPBAR_ZONE_WIDTH); if ((x + size) > LCD_W) size = LCD_W - x; diff --git a/radio/src/gui/colorlcd/layouts/topbar_impl.h b/radio/src/gui/colorlcd/layouts/topbar_impl.h index 004f70b8fb6..242946a5351 100644 --- a/radio/src/gui/colorlcd/layouts/topbar_impl.h +++ b/radio/src/gui/colorlcd/layouts/topbar_impl.h @@ -62,7 +62,6 @@ class TopBar: public TopBarBase static LAYOUT_VAL(TOPBAR_ZONE_WIDTH, 70, 70) static LAYOUT_VAL(TOPBAR_ZONE_VMARGIN, 3, 3) - static LAYOUT_VAL(TOPBAR_ZONE_HMARGIN, 2, 2) static constexpr coord_t TOPBAR_ZONE_HEIGHT = EdgeTxStyles::MENU_HEADER_HEIGHT - 2 * TOPBAR_ZONE_VMARGIN; static LAYOUT_VAL(HDR_DATE_XO, 48, 48) diff --git a/radio/src/gui/colorlcd/layouts/trims.cpp b/radio/src/gui/colorlcd/layouts/trims.cpp index 9a65158d7d6..6da33de1a12 100644 --- a/radio/src/gui/colorlcd/layouts/trims.cpp +++ b/radio/src/gui/colorlcd/layouts/trims.cpp @@ -45,9 +45,11 @@ class TrimIcon : public SliderIcon bar1 = lv_line_create(lvobj); etx_obj_add_style(bar1, styles->div_line_white, LV_PART_MAIN); + etx_obj_add_style(bar1, styles->div_line_black, LV_STATE_USER_1); lv_line_set_points(bar1, &barPoints[0], 2); bar2 = lv_line_create(lvobj); etx_obj_add_style(bar2, styles->div_line_white, LV_PART_MAIN); + etx_obj_add_style(bar2, styles->div_line_black, LV_STATE_USER_1); lv_line_set_points(bar2, &barPoints[2], 2); etx_bg_color(fill, COLOR_THEME_ACTIVE_INDEX, LV_STATE_USER_1); @@ -55,10 +57,15 @@ class TrimIcon : public SliderIcon void setState(int value) { - if (value < TRIM_MIN || value > TRIM_MAX) + if (value < TRIM_MIN || value > TRIM_MAX) { lv_obj_add_state(fill, LV_STATE_USER_1); - else + lv_obj_add_state(bar1, LV_STATE_USER_1); + lv_obj_add_state(bar2, LV_STATE_USER_1); + } else { lv_obj_clear_state(fill, LV_STATE_USER_1); + lv_obj_clear_state(bar1, LV_STATE_USER_1); + lv_obj_clear_state(bar2, LV_STATE_USER_1); + } if (value >= 0) lv_obj_clear_flag(bar1, LV_OBJ_FLAG_HIDDEN); @@ -81,8 +88,6 @@ MainViewTrim::MainViewTrim(Window* parent, const rect_t& rect, uint8_t idx, bool isVertical) : Window(parent, rect), idx(idx), isVertical(isVertical) { - setRange(); - trimBar = lv_obj_create(lvobj); etx_solid_bg(trimBar, COLOR_THEME_SECONDARY1_INDEX); etx_obj_add_style(trimBar, styles->rounded, LV_PART_MAIN); @@ -99,26 +104,22 @@ MainViewTrim::MainViewTrim(Window* parent, const rect_t& rect, uint8_t idx, } trimIcon = new TrimIcon(this, isVertical); - coord_t x = 0, y = 0; - if (isVertical) - y = (height() - LayoutFactory::TRIM_SQUARE_SIZE) / 2; - else - y = (width() - LayoutFactory::TRIM_SQUARE_SIZE) / 2; - lv_obj_set_pos(trimIcon->getLvObj(), x, y); trimValue = new DynamicNumber( this, {0, 0, LayoutFactory::TRIM_SQUARE_SIZE, 12}, [=]() { return divRoundClosest(abs(value) * 100, trimMax); }, - COLOR_THEME_PRIMARY2 | FONT(XXS) | CENTERED); + COLOR_THEME_PRIMARY2_INDEX, FONT(XXS) | CENTERED); etx_solid_bg(trimValue->getLvObj(), COLOR_THEME_SECONDARY1_INDEX); trimValue->hide(); + setRange(); setPos(); } void MainViewTrim::setRange() { - if (g_model.extendedTrims) { + extendedTrims = g_model.extendedTrims; + if (extendedTrims) { trimMin = TRIM_EXTENDED_MIN; trimMax = TRIM_EXTENDED_MAX; } else { @@ -193,10 +194,15 @@ void MainViewTrim::checkEvents() int newValue = getTrimValue(mixerCurrentFlightMode, inputMappingConvertMode(idx)); - setRange(); - newValue = min(max(newValue, trimMin), trimMax); + bool update = false; + + if (extendedTrims != g_model.extendedTrims) { + update = true; + setRange(); + newValue = limit(trimMin, newValue, trimMax); + } - if (value != newValue || (g_model.displayTrims == DISPLAY_TRIMS_CHANGE && + if (update || value != newValue || (g_model.displayTrims == DISPLAY_TRIMS_CHANGE && showChange && trimsDisplayTimer == 0)) { value = newValue; setPos(); diff --git a/radio/src/gui/colorlcd/layouts/trims.h b/radio/src/gui/colorlcd/layouts/trims.h index 47d444cf3e2..769ddb1bbaf 100644 --- a/radio/src/gui/colorlcd/layouts/trims.h +++ b/radio/src/gui/colorlcd/layouts/trims.h @@ -39,6 +39,7 @@ class MainViewTrim : public Window bool isVertical; bool showChange = false; int trimMin = 0, trimMax = 0; + bool extendedTrims = false; bool hidden = false; TrimIcon* trimIcon = nullptr; DynamicNumber* trimValue = nullptr; diff --git a/radio/src/gui/colorlcd/lcd.cpp b/radio/src/gui/colorlcd/lcd.cpp index 039863223a3..ff6b80a5808 100644 --- a/radio/src/gui/colorlcd/lcd.cpp +++ b/radio/src/gui/colorlcd/lcd.cpp @@ -50,8 +50,6 @@ static lv_disp_drv_t disp_drv; static lv_disp_t disp; #endif -static lv_area_t screen_area = {0, 0, LCD_W - 1, LCD_H - 1}; - // Call backs static void (*lcd_wait_cb)(lv_disp_drv_t*) = nullptr; static void (*lcd_flush_cb)(lv_disp_drv_t*, uint16_t* buffer, @@ -222,8 +220,22 @@ void lcdInitDisplayDriver() lcdFront->setDrawCtx(draw_ctx); } +void lcdClear() { lcd->clear(); } + +void lcdFlushed() +{ + // its possible to get here before flushLcd is ever called. + // so check for nullptr first. (Race condition if you put breakpoints in + // startup code) + if (refr_disp != nullptr) lv_disp_flush_ready(refr_disp); +} + +// Direct drawing - used by boot loader and battery charging state + void lcdInitDirectDrawing() { + static lv_area_t screen_area = {0, 0, LCD_W - 1, LCD_H - 1}; + lv_draw_ctx_t* draw_ctx = disp_drv.draw_ctx; draw_ctx->buf = disp_drv.draw_buf->buf_act; draw_ctx->buf_area = &screen_area; @@ -285,13 +297,3 @@ void lcdRefresh() lv_disp_t* d = _lv_refr_get_disp_refreshing(); _draw_buf_flush(d); } - -void lcdClear() { lcd->clear(); } - -void lcdFlushed() -{ - // its possible to get here before flushLcd is ever called. - // so check for nullptr first. (Race condition if you put breakpoints in - // startup code) - if (refr_disp != nullptr) lv_disp_flush_ready(refr_disp); -} diff --git a/radio/src/gui/colorlcd/lcd.h b/radio/src/gui/colorlcd/lcd.h index 7d2d6aaec4d..1fe9525c938 100644 --- a/radio/src/gui/colorlcd/lcd.h +++ b/radio/src/gui/colorlcd/lcd.h @@ -45,10 +45,11 @@ void lcdSetFlushCb(void (*cb)(lv_disp_drv_t *, uint16_t*, const rect_t&)); // Init LVGL and its display driver void lcdInitDisplayDriver(); +void lcdClear(); + // Patch the draw context to allow for direct drawing void lcdInitDirectDrawing(); -void lcdClear(); - void lcdRefresh(); + void lcdFlushed(); diff --git a/radio/src/gui/colorlcd/list_line_button.cpp b/radio/src/gui/colorlcd/list_line_button.cpp index 143644e6d47..630f0d1b3e7 100644 --- a/radio/src/gui/colorlcd/list_line_button.cpp +++ b/radio/src/gui/colorlcd/list_line_button.cpp @@ -39,7 +39,7 @@ static const lv_obj_class_t input_mix_line_class = { .user_data = nullptr, .event_cb = nullptr, .width_def = LV_PCT(100), - .height_def = LV_SIZE_CONTENT, + .height_def = ListLineButton::BTN_H, .editable = LV_OBJ_CLASS_EDITABLE_INHERIT, .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, .instance_size = sizeof(lv_btn_t), diff --git a/radio/src/gui/colorlcd/list_line_button.h b/radio/src/gui/colorlcd/list_line_button.h index a7886e1bce5..b23f2b07b4f 100644 --- a/radio/src/gui/colorlcd/list_line_button.h +++ b/radio/src/gui/colorlcd/list_line_button.h @@ -38,7 +38,7 @@ class ListLineButton : public ButtonBase virtual void refresh() = 0; static LAYOUT_VAL(BTN_H, 29, 29) - static constexpr coord_t GRP_W = LCD_W - PAD_MEDIUM * 2; + static constexpr coord_t GRP_W = LCD_W - PAD_SMALL * 2; protected: uint8_t index; @@ -64,7 +64,7 @@ class InputMixButtonBase : public ListLineButton static LAYOUT_VAL(FM_CANVAS_HEIGHT, 17, 17) static LAYOUT_VAL(FM_CANVAS_WIDTH, 90, 90) - static LAYOUT_VAL(BTN_W, 389, 229) + static LAYOUT_VAL(BTN_W, 395, 235) static constexpr coord_t WGT_X = PAD_TINY; static constexpr coord_t WGT_Y = PAD_TINY; static LAYOUT_VAL(WGT_W, 50, 50) diff --git a/radio/src/gui/colorlcd/model_curves.cpp b/radio/src/gui/colorlcd/model_curves.cpp index 1391b6c8b7d..66c078b6a54 100644 --- a/radio/src/gui/colorlcd/model_curves.cpp +++ b/radio/src/gui/colorlcd/model_curves.cpp @@ -43,7 +43,7 @@ class CurveButton : public Button strAppend(s, g_model.curves[index].name, LEN_CURVE_NAME); } title = new StaticText(this, {4, -1, width() - 12, TITLE_H + 1}, buf, - COLOR_THEME_SECONDARY1 | CENTERED | FONT(BOLD)); + COLOR_THEME_SECONDARY1_INDEX, CENTERED | FONT(BOLD)); etx_txt_color(title->getLvObj(), COLOR_THEME_PRIMARY2_INDEX, LV_PART_MAIN | LV_STATE_USER_1); etx_solid_bg(title->getLvObj(), COLOR_THEME_SECONDARY2_INDEX); @@ -51,10 +51,10 @@ class CurveButton : public Button LV_PART_MAIN | LV_STATE_USER_1); hdrLeft = new StaticIcon(this, 0, 0, ICON_ROUND_TITLE_LEFT, - COLOR_THEME_SECONDARY2); + COLOR_THEME_SECONDARY2_INDEX); hdrRight = new StaticIcon(this, width() - 8, 0, ICON_ROUND_TITLE_RIGHT, - COLOR_THEME_SECONDARY2); + COLOR_THEME_SECONDARY2_INDEX); // Preview preview = new CurveRenderer( @@ -68,7 +68,7 @@ class CurveButton : public Button snprintf(buf, 32, "%s %d %s", STR_CURVE_TYPES[curve.type], 5 + curve.points, STR_PTS); new StaticText(this, {0, height() - INFO_H + 1, LV_PCT(100), 16}, buf, - COLOR_THEME_SECONDARY1 | CENTERED | FONT(BOLD)); + COLOR_THEME_SECONDARY1_INDEX, CENTERED | FONT(BOLD)); } void update() { preview->update(); } @@ -211,9 +211,9 @@ void ModelCurvesPage::build(Window *window) #endif static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; - window->setFlexLayout(); + window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO); - FlexGridLayout grid(col_dsc, row_dsc); + FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY); FormLine *line = nullptr; diff --git a/radio/src/gui/colorlcd/model_flightmodes.cpp b/radio/src/gui/colorlcd/model_flightmodes.cpp index 707e65887a3..841e12ec71a 100644 --- a/radio/src/gui/colorlcd/model_flightmodes.cpp +++ b/radio/src/gui/colorlcd/model_flightmodes.cpp @@ -478,7 +478,7 @@ const lv_obj_class_t FlightModeBtn::fm_trim_value_class = { }; ModelFlightModesPage::ModelFlightModesPage() : - PageTab(STR_MENUFLIGHTMODES, ICON_MODEL_FLIGHT_MODES, PAD_MEDIUM) + PageTab(STR_MENUFLIGHTMODES, ICON_MODEL_FLIGHT_MODES) { } @@ -494,7 +494,7 @@ 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 * (FlightModeBtn::BTN_H + 3) + 4); + lv_obj_set_pos(btn->getLvObj(), PAD_SMALL, i * (FlightModeBtn::BTN_H + 3) + 4); btn->setWidth(ListLineButton::GRP_W); btn->setPressHandler([=]() { diff --git a/radio/src/gui/colorlcd/model_gvars.cpp b/radio/src/gui/colorlcd/model_gvars.cpp index f456be3e492..79adaa9bdde 100644 --- a/radio/src/gui/colorlcd/model_gvars.cpp +++ b/radio/src/gui/colorlcd/model_gvars.cpp @@ -554,7 +554,7 @@ void ModelGVarsPage::build(Window* window) if (modelFMEnabled()) { hdr = new GVarHeader(window->getParent()); lv_obj_set_pos(hdr->getLvObj(), 0, TabsGroup::MENU_TITLE_TOP + TabsGroup::MENU_TITLE_HEIGHT); - yo = GVarButton::HDR_H - 4; + yo = GVarButton::HDR_H - 2; } for (uint8_t index = 0; index < MAX_GVARS; index++) { diff --git a/radio/src/gui/colorlcd/model_heli.cpp b/radio/src/gui/colorlcd/model_heli.cpp index 024cdf13919..999868b62f6 100644 --- a/radio/src/gui/colorlcd/model_heli.cpp +++ b/radio/src/gui/colorlcd/model_heli.cpp @@ -66,7 +66,7 @@ void ModelHeliPage::build(Window* form) GET_SET_DEFAULT(g_model.swashR.elevatorSource)); // Elevator weight - auto w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1 | RIGHT); + auto w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1_INDEX, RIGHT); w->padRight(PAD_LARGE); new NumberEdit(line, rect_t{}, -100, 100, GET_SET_DEFAULT(g_model.swashR.elevatorWeight)); @@ -78,7 +78,7 @@ void ModelHeliPage::build(Window* form) GET_SET_DEFAULT(g_model.swashR.aileronSource)); // Aileron weight - w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1 | RIGHT); + w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1_INDEX, RIGHT); w->padRight(PAD_LARGE); new NumberEdit(line, rect_t{}, -100, 100, GET_SET_DEFAULT(g_model.swashR.aileronWeight)); @@ -90,7 +90,7 @@ void ModelHeliPage::build(Window* form) GET_SET_DEFAULT(g_model.swashR.collectiveSource)); // Collective weight - w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1 | RIGHT); + w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1_INDEX, RIGHT); w->padRight(PAD_LARGE); new NumberEdit(line, rect_t{}, -100, 100, GET_SET_DEFAULT(g_model.swashR.collectiveWeight)); diff --git a/radio/src/gui/colorlcd/model_logical_switches.cpp b/radio/src/gui/colorlcd/model_logical_switches.cpp index a5c590bc9f1..d2c28ec6426 100644 --- a/radio/src/gui/colorlcd/model_logical_switches.cpp +++ b/radio/src/gui/colorlcd/model_logical_switches.cpp @@ -304,7 +304,7 @@ void getsEdgeDelayParam(char* s, LogicalSwitchData* ls) class LogicalSwitchButton : public ListLineButton { public: - LogicalSwitchButton(Window* parent, const rect_t& rect, int lsIndex) : + LogicalSwitchButton(Window* parent, int lsIndex) : ListLineButton(parent, lsIndex) { setHeight(LS_BUTTON_H); @@ -510,7 +510,7 @@ class LogicalSwitchButton : public ListLineButton }; ModelLogicalSwitchesPage::ModelLogicalSwitchesPage() : - PageTab(STR_MENULOGICALSWITCHES, ICON_MODEL_LOGICAL_SWITCHES, PAD_SMALL) + PageTab(STR_MENULOGICALSWITCHES, ICON_MODEL_LOGICAL_SWITCHES) { } @@ -570,13 +570,8 @@ void ModelLogicalSwitchesPage::plusPopup(Window* window) void ModelLogicalSwitchesPage::build(Window* window) { - static const lv_coord_t l_col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY); - window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO); - - FlexGridLayout grid(l_col_dsc, row_dsc, PAD_TINY); - - FormLine* line; bool hasEmptySwitch = false; // Reset focusIndex after switching tabs @@ -588,10 +583,7 @@ void ModelLogicalSwitchesPage::build(Window* window) bool isActive = (ls->func != LS_FUNC_NONE); if (isActive) { - line = window->newLine(grid); - - auto button = new LogicalSwitchButton( - line, rect_t{0, 0, window->width() - 12, LogicalSwitchButton::LS_BUTTON_H}, i); + auto button = new LogicalSwitchButton(window, i); button->setPressHandler([=]() { Menu* menu = new Menu(window); @@ -652,9 +644,8 @@ void ModelLogicalSwitchesPage::build(Window* window) } if (hasEmptySwitch) { - line = window->newLine(grid); addButton = - new TextButton(line, rect_t{0, 0, window->width() - 12, LogicalSwitchButton::LS_BUTTON_H}, + new TextButton(window, 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_mixer_scripts.cpp b/radio/src/gui/colorlcd/model_mixer_scripts.cpp index e67ce4cf820..efc1ef9a629 100644 --- a/radio/src/gui/colorlcd/model_mixer_scripts.cpp +++ b/radio/src/gui/colorlcd/model_mixer_scripts.cpp @@ -35,9 +35,6 @@ #define SET_DIRTY() storageDirty(EE_MODEL) -// Overview grid -static const lv_coord_t col_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; - // Edit grid #if !PORTRAIT_LCD static const lv_coord_t e_col_dsc[] = {LV_GRID_FR(2), LV_GRID_FR(3), @@ -153,11 +150,11 @@ class ScriptEditWindow : public Page getSourceString( s, MIXSRC_FIRST_LUA + (idx * MAX_SCRIPT_OUTPUTS) + i); return std::string(s, sizeof(s) - 1); - }, - COLOR_THEME_PRIMARY1); + }); lbl->padLeft(PAD_LARGE); new DynamicNumber( - line, rect_t{}, [=]() { return calcRESXto1000(so->value); }, PREC1); + line, rect_t{}, [=]() { return calcRESXto1000(so->value); }, + COLOR_THEME_PRIMARY1_INDEX, PREC1); } } } @@ -174,16 +171,15 @@ class ScriptEditWindow : public Page class ScriptLineButton : public ListLineButton { public: - ScriptLineButton(Window* parent, const rect_t& rect, + ScriptLineButton(Window* parent, const ScriptData& scriptData, const ScriptInternalData* runtimeData, uint8_t index) : ListLineButton(parent, index), scriptData(scriptData), runtimeData(runtimeData) { -#if PORTRAIT_LCD + setHeight(EdgeTxStyles::UI_ELEMENT_HEIGHT); padTop(PAD_SMALL); -#endif padLeft(PAD_TINY); padRight(PAD_TINY); lv_obj_set_layout(lvobj, LV_LAYOUT_GRID); @@ -274,8 +270,6 @@ class ScriptLineButton : public ListLineButton const ScriptInternalData* runtimeData; }; -#define CM_BUTTON_H 34 - ModelMixerScriptsPage::ModelMixerScriptsPage() : PageTab(STR_MENUCUSTOMSCRIPTS, ICON_MODEL_LUA_SCRIPTS) { @@ -291,15 +285,11 @@ void ModelMixerScriptsPage::rebuild(Window* window, int8_t focusIdx) void ModelMixerScriptsPage::build(Window* window, int8_t focusIdx) { - window->padAll(PAD_SMALL); - window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO); - - FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY); + window->padBottom(PAD_LARGE); + window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY); int8_t scriptIdx = 0; for (int8_t idx = 0; idx < MAX_SCRIPTS; idx++) { - auto line = window->newLine(grid); - ScriptInternalData* runtimeData = nullptr; ScriptData* const sd = &(g_model.scriptsData[idx]); ScriptInputsOutputs* const sio = &(scriptInputsOutputs[idx]); @@ -308,9 +298,7 @@ void ModelMixerScriptsPage::build(Window* window, int8_t focusIdx) runtimeData = &(scriptInternalData[scriptIdx++]); } - auto button = new ScriptLineButton( - line, rect_t{0, 0, window->width() - 12, CM_BUTTON_H}, *sd, runtimeData, - idx); + auto button = new ScriptLineButton(window, *sd, runtimeData, idx); button->setPressHandler([=]() -> uint8_t { Menu* const menu = new Menu(window); diff --git a/radio/src/gui/colorlcd/model_mixes.cpp b/radio/src/gui/colorlcd/model_mixes.cpp index d4665132adc..148f40edff6 100644 --- a/radio/src/gui/colorlcd/model_mixes.cpp +++ b/radio/src/gui/colorlcd/model_mixes.cpp @@ -43,7 +43,7 @@ class MPlexIcon : public Window } else if (mix->mltpx == MLTPX_REPL) { n = ICON_MPLEX_REPLACE; } - icon = new StaticIcon(this, 0, 0, n, COLOR_THEME_SECONDARY1); + icon = new StaticIcon(this, 0, 0, n, COLOR_THEME_SECONDARY1_INDEX); icon->center(width(), height()); } @@ -429,10 +429,10 @@ void ModelMixesPage::pasteMixAfter(uint8_t dst_idx) void ModelMixesPage::build(Window * window) { - window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3); + window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY); form = new Window(window, rect_t{}); - form->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3); + form->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY); auto box = new Window(window, rect_t{}); box->padAll(PAD_TINY); diff --git a/radio/src/gui/colorlcd/model_outputs.cpp b/radio/src/gui/colorlcd/model_outputs.cpp index 7bb7acc36fa..e90ff8ce73d 100644 --- a/radio/src/gui/colorlcd/model_outputs.cpp +++ b/radio/src/gui/colorlcd/model_outputs.cpp @@ -98,7 +98,7 @@ class OutputLineButton : public ListLineButton lv_obj_set_pos(revert, REV_X, REV_Y); curve = - new StaticIcon(this, CRV_X, CRV_Y, ICON_TEXTLINE_CURVE, COLOR_THEME_SECONDARY1); + new StaticIcon(this, CRV_X, CRV_Y, ICON_TEXTLINE_CURVE, COLOR_THEME_SECONDARY1_INDEX); new OutputChannelBar(this, rect_t{BAR_X, PAD_MEDIUM, CH_BAR_WIDTH, CH_BAR_HEIGHT}, index, false, false); @@ -230,7 +230,7 @@ class OutputLineButton : public ListLineButton }; ModelOutputsPage::ModelOutputsPage() : - PageTab(STR_MENULIMITS, ICON_MODEL_OUTPUTS, PAD_TINY) + PageTab(STR_MENULIMITS, ICON_MODEL_OUTPUTS) { } @@ -244,7 +244,7 @@ void ModelOutputsPage::build(Window* window) return 0; }); - new StaticText(window, {EXLIM_X, EXLIM_Y, EXLIM_W, EXLIM_H}, STR_ELIMITS, RIGHT); + new StaticText(window, {EXLIM_X, EXLIM_Y, EXLIM_W, EXLIM_H}, STR_ELIMITS, COLOR_THEME_PRIMARY1_INDEX, RIGHT); new ToggleSwitch(window, {EXLIMCB_X, EXLIMCB_Y, EXLIMCB_W, EXLIMCB_H}, GET_SET_DEFAULT(g_model.extendedLimits)); for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) { diff --git a/radio/src/gui/colorlcd/model_outputs.h b/radio/src/gui/colorlcd/model_outputs.h index 0d571a08240..fcfb1eb197d 100644 --- a/radio/src/gui/colorlcd/model_outputs.h +++ b/radio/src/gui/colorlcd/model_outputs.h @@ -31,7 +31,7 @@ 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_X = PAD_SMALL; static constexpr coord_t ADD_TRIMS_Y = PAD_SMALL; static LAYOUT_VAL(ADD_TRIMS_W, (LCD_W / 2) - 10, LCD_W - 12) static constexpr coord_t ADD_TRIMS_H = EdgeTxStyles::UI_ELEMENT_HEIGHT; @@ -44,9 +44,9 @@ class ModelOutputsPage : public PageTab static LAYOUT_VAL(EXLIM_Y, 10, ADD_TRIMS_X + ADD_TRIMS_H + 8) static constexpr coord_t EXLIM_W = EXLIMCB_X - EXLIM_X - PAD_SMALL; static LAYOUT_VAL(EXLIM_H, 20, 20) - static constexpr coord_t TRIMB_X = PAD_MEDIUM; + static constexpr coord_t TRIMB_X = PAD_SMALL; static constexpr coord_t TRIMB_Y = EXLIMCB_Y + EXLIMCB_H + PAD_MEDIUM / 2; - static constexpr coord_t TRIMB_W = LCD_W - PAD_MEDIUM * 2; + static constexpr coord_t TRIMB_W = LCD_W - PAD_SMALL * 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 5acf369ff5b..8ebf7a55f3f 100644 --- a/radio/src/gui/colorlcd/model_select.cpp +++ b/radio/src/gui/colorlcd/model_select.cpp @@ -88,13 +88,13 @@ class ModelButton : public Button coord_t fo = (font == FONT(STD)) ? -3 : (font == FONT(XS)) ? -3 : -1; modelName = new StaticText(this, {PAD_TINY, PAD_TINY, w, fh}, modelCell->modelName, - CENTERED | COLOR_THEME_SECONDARY1 | font); + COLOR_THEME_SECONDARY1_INDEX, CENTERED | font); etx_bg_color(modelName->getLvObj(), COLOR_THEME_ACTIVE_INDEX, LV_STATE_USER_1); etx_obj_add_style(modelName->getLvObj(), styles->bg_opacity_75, LV_STATE_USER_1); modelName->padTop(fo); } else { modelName = new StaticText(this, {PAD_TINY, PAD_SMALL, w, EdgeTxStyles::PAGE_LINE_HEIGHT}, modelCell->modelName, - COLOR_THEME_SECONDARY1 | font); + COLOR_THEME_SECONDARY1_INDEX, font); } lv_label_set_long_mode(modelName->getLvObj(), LV_LABEL_LONG_DOT); @@ -173,7 +173,7 @@ class ModelButton : public Button errorMsg += ")"; LcdFlags font = (modelLayouts[layout].font == FONT(STD)) ? FONT(XS) : FONT(XXS); new StaticText(this, {PAD_TINY, h / 2, w, getFontHeight(font)}, errorMsg, - CENTERED | COLOR_THEME_SECONDARY1 | font); + COLOR_THEME_SECONDARY1_INDEX, CENTERED | font); } void checkEvents() override @@ -689,7 +689,7 @@ void ModelLabelsWindow::buildHead(Window *hdr) setTitle(); // new model button - new TextButton(hdr, {LCD_W - NEW_BTN_W - PAD_LARGE, LAYOUT_BTN_YO, NEW_BTN_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, STR_NEW, [=]() { + new TextButton(hdr, {LCD_W - NEW_BTN_W - PAD_LARGE, PAD_MEDIUM, 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(); }); @@ -697,7 +697,7 @@ void ModelLabelsWindow::buildHead(Window *hdr) return 0; }); - mdlLayout = new ModelLayoutButton(this, LCD_W - LAYOUT_BTN_XO, LAYOUT_BTN_YO, g_eeGeneral.modelSelectLayout, [=]() { + mdlLayout = new ModelLayoutButton(this, LCD_W - LAYOUT_BTN_XO, PAD_MEDIUM, g_eeGeneral.modelSelectLayout, [=]() { uint8_t l = mdlLayout->getLayout(); l = (l + 1) & 3; mdlLayout->setLayout(l); @@ -711,7 +711,7 @@ void ModelLabelsWindow::buildHead(Window *hdr) void ModelLabelsWindow::buildBody(Window *window) { // Models List - mdlselector = new ModelsPageBody(window, {MDLS_X, MDLS_Y, MDLS_W, MDLS_H}); + mdlselector = new ModelsPageBody(window, {MDLS_X, PAD_SMALL, MDLS_W, MDLS_H}); mdlselector->setLblRefreshFunc([=]() { labelRefreshRequest(); }); auto mdl_obj = mdlselector->getLvObj(); lv_obj_set_style_max_width(mdl_obj, MDLS_W, LV_PART_MAIN); diff --git a/radio/src/gui/colorlcd/model_setup.cpp b/radio/src/gui/colorlcd/model_setup.cpp index 8c3da3cce69..cc46c7f2b8c 100644 --- a/radio/src/gui/colorlcd/model_setup.cpp +++ b/radio/src/gui/colorlcd/model_setup.cpp @@ -78,7 +78,7 @@ static void viewOption(Window* parent, coord_t x, coord_t y, std::function setValue, bool globalState) { auto lbl = new StaticText(parent, {x + ModelSetupPage::OPTS_W + PAD_MEDIUM, y + PAD_SMALL + 1, 0, 0}, - STR_ADCFILTERVALUES[globalState ? 1 : 2], COLOR_THEME_SECONDARY1); + STR_ADCFILTERVALUES[globalState ? 1 : 2], COLOR_THEME_SECONDARY1_INDEX); new Choice(parent, {x, y, ModelSetupPage::OPTS_W, 0}, STR_ADCFILTERVALUES, 0, 2, getValue, [=](int newValue) { setValue(newValue); diff --git a/radio/src/gui/colorlcd/model_usbjoystick.cpp b/radio/src/gui/colorlcd/model_usbjoystick.cpp index 03607b153bf..c521368dffc 100644 --- a/radio/src/gui/colorlcd/model_usbjoystick.cpp +++ b/radio/src/gui/colorlcd/model_usbjoystick.cpp @@ -350,7 +350,7 @@ class USBChannelEditWindow : public Page line->padBottom(PAD_ZERO); collisionText = new StaticText(line, rect_t{}, "", - FONT(BOLD) | COLOR_THEME_PRIMARY2 | CENTERED); + COLOR_THEME_PRIMARY2_INDEX, FONT(BOLD) | CENTERED); etx_bg_color(collisionText->getLvObj(), COLOR_THEME_WARNING_INDEX); lv_obj_set_grid_cell(collisionText->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, USBCH_COLS, LV_GRID_ALIGN_CENTER, 0, 1); @@ -400,7 +400,7 @@ class USBChannelLineButton : public ListLineButton m_inverse = new StaticIcon(this, 0, 0, ICON_CHAN_MONITOR_INVERTED, - COLOR_THEME_SECONDARY1); + COLOR_THEME_SECONDARY1_INDEX); lv_obj_set_grid_cell(m_inverse->getLvObj(), LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 0, 1); @@ -531,7 +531,7 @@ ModelUSBJoystickPage::ModelUSBJoystickPage() : Page(ICON_MODEL_USB) line = body->newLine(grid); _CircCoutoutLabel = new StaticText( - line, rect_t{}, STR_USBJOYSTICK_CIRC_COUTOUT, COLOR_THEME_PRIMARY1); + line, rect_t{}, STR_USBJOYSTICK_CIRC_COUTOUT); _CircCoutout = new Choice(line, rect_t{}, STR_VUSBJOYSTICK_CIRC_COUTOUT, 0, USBJOYS_LAST, GET_DEFAULT(g_model.usbJoystickCircularCut), diff --git a/radio/src/gui/colorlcd/module_setup.cpp b/radio/src/gui/colorlcd/module_setup.cpp index 52423809ceb..b24e67c4ee2 100644 --- a/radio/src/gui/colorlcd/module_setup.cpp +++ b/radio/src/gui/colorlcd/module_setup.cpp @@ -554,7 +554,7 @@ void ModuleWindow::startRSSIDialog(std::function closeHandler) return std::to_string((int)TELEMETRY_RSSI()) + getRxStatLabels()->unit; }, getRxStatLabels()->label, 50, - COLOR_THEME_SECONDARY1 | CENTERED | FONT(XL)); + COLOR_THEME_SECONDARY1_INDEX, CENTERED | FONT(XL)); rssiDialog->setCloseHandler([this, closeHandler]() { rangeButton->check(false); diff --git a/radio/src/gui/colorlcd/mpm_settings.cpp b/radio/src/gui/colorlcd/mpm_settings.cpp index 59b9b321fb2..c27f62ff3b3 100644 --- a/radio/src/gui/colorlcd/mpm_settings.cpp +++ b/radio/src/gui/colorlcd/mpm_settings.cpp @@ -52,7 +52,7 @@ class MPMProtoOption : public FormLine { edit = new NumberEdit(box, rect_t{}, 0, 0, nullptr); cb = new ToggleSwitch(box, rect_t{}, nullptr, nullptr); rssi = new DynamicNumber( - box, rect_t{}, [] { return (uint16_t)TELEMETRY_RSSI(); }, 0, + box, rect_t{}, [] { return (uint16_t)TELEMETRY_RSSI(); }, COLOR_THEME_PRIMARY1_INDEX, 0, getRxStatLabels()->label, getRxStatLabels()->unit); rssi->padTop(PAD_SMALL); } @@ -345,8 +345,7 @@ MultimoduleSettings::MultimoduleSettings(Window* parent, char msg[64] = ""; getModuleStatusString(moduleIdx, msg); return std::string(msg); - }, - COLOR_THEME_PRIMARY1); + }); st_line = new MPMSubtype(this, grid, moduleIdx); diff --git a/radio/src/gui/colorlcd/page.cpp b/radio/src/gui/colorlcd/page.cpp index 63cf1796cce..263ece07678 100644 --- a/radio/src/gui/colorlcd/page.cpp +++ b/radio/src/gui/colorlcd/page.cpp @@ -37,7 +37,7 @@ PageHeader::PageHeader(Window* parent, EdgeTxIcon icon) : title = new StaticText(this, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT, EdgeTxStyles::PAGE_LINE_HEIGHT}, - "", COLOR_THEME_PRIMARY2); + "", COLOR_THEME_PRIMARY2_INDEX); } PageHeader::PageHeader(Window* parent, const char* iconFile) : @@ -52,7 +52,7 @@ PageHeader::PageHeader(Window* parent, const char* iconFile) : title = new StaticText(this, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT, EdgeTxStyles::PAGE_LINE_HEIGHT}, - "", COLOR_THEME_PRIMARY2); + "", COLOR_THEME_PRIMARY2_INDEX); } StaticText* PageHeader::setTitle2(std::string txt) @@ -61,7 +61,7 @@ StaticText* PageHeader::setTitle2(std::string txt) title2 = new StaticText(this, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + EdgeTxStyles::PAGE_LINE_HEIGHT, LCD_W - PAGE_TITLE_LEFT, EdgeTxStyles::PAGE_LINE_HEIGHT}, - "", COLOR_THEME_PRIMARY2); + "", COLOR_THEME_PRIMARY2_INDEX); } title2->setText(std::move(txt)); return title2; diff --git a/radio/src/gui/colorlcd/preview_window.cpp b/radio/src/gui/colorlcd/preview_window.cpp index 1c1ffc09d3b..30104bec8ac 100644 --- a/radio/src/gui/colorlcd/preview_window.cpp +++ b/radio/src/gui/colorlcd/preview_window.cpp @@ -151,11 +151,11 @@ PreviewWindow::PreviewWindow(Window *window, rect_t rect, etx_solid_bg(topbar->getLvObj(), COLOR_THEME_SECONDARY1_INDEX); new StaticIcon(topbar, ICON_X1, ICON_Y, ICON_RADIO, - COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX); new StaticIcon(topbar, ICON_X2, ICON_Y, ICON_RADIO_TOOLS, - COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX); new StaticIcon(topbar, ICON_X3, ICON_Y, ICON_RADIO_SETUP, - COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX); 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, 0}, true); @@ -166,9 +166,9 @@ PreviewWindow::PreviewWindow(Window *window, rect_t rect, 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); + COLOR_THEME_WARNING_INDEX); new StaticText(this, {ICON_X1, TXT2_Y, TXT_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_THEME_DISABLED, - COLOR_THEME_DISABLED); + COLOR_THEME_DISABLED_INDEX); 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); diff --git a/radio/src/gui/colorlcd/radio_calibration.cpp b/radio/src/gui/colorlcd/radio_calibration.cpp index 26ba379e60b..778fab0010d 100644 --- a/radio/src/gui/colorlcd/radio_calibration.cpp +++ b/radio/src/gui/colorlcd/radio_calibration.cpp @@ -46,6 +46,7 @@ class StickCalibrationWindow : public Window { new StaticLZ4Image(this, 0, 0, (LZ4Bitmap *)stick_background); calibStick = new StaticLZ4Image(this, 0, 0, (LZ4Bitmap *)stick_pointer); + checkEvents(); } void checkEvents() override @@ -103,10 +104,7 @@ void RadioCalibrationPage::buildBody(Window *window) 3, 2); } - std::unique_ptr deco(new ViewMainDecoration(window)); - deco->setTrimsVisible(false); - deco->setSlidersVisible(true); - deco->setFlightModeVisible(false); + std::unique_ptr deco(new ViewMainDecoration(window, false, true, false)); #if defined(PCBNV14) || defined(PCBPL18) new TextButton(window, {LCD_W - 120, LCD_H - 140, 90, 40}, "Next", diff --git a/radio/src/gui/colorlcd/radio_diaganas.cpp b/radio/src/gui/colorlcd/radio_diaganas.cpp index 117a547927e..a73f6257f89 100644 --- a/radio/src/gui/colorlcd/radio_diaganas.cpp +++ b/radio/src/gui/colorlcd/radio_diaganas.cpp @@ -92,13 +92,11 @@ class AnaViewWindow : public Window line, rect_t{}, [=]() { return std::to_string((int16_t)calibratedAnalogs[i] * 25 / 256); - }, - COLOR_THEME_PRIMARY1); + }); etx_obj_add_style(lbl->getLvObj(), styles->text_align_right, LV_PART_MAIN); lbl = new DynamicText( - line, rect_t{}, [=]() { return std::to_string((int16_t)column3(i)); }, - COLOR_THEME_PRIMARY1); + line, rect_t{}, [=]() { return std::to_string((int16_t)column3(i)); }); etx_obj_add_style(lbl->getLvObj(), styles->text_align_right, LV_PART_MAIN); if (column4size() > 0) { @@ -107,8 +105,7 @@ class AnaViewWindow : public Window [=]() { return std::string(column4prefix()) + std::to_string((int16_t)column4(i)); - }, - COLOR_THEME_PRIMARY1); + }); etx_obj_add_style(lbl->getLvObj(), (column4size() == 2) ? styles->text_align_left : styles->text_align_right, LV_PART_MAIN); #if !PORTRAIT_LCD lv_obj_set_grid_cell(lbl->getLvObj(), LV_GRID_ALIGN_STRETCH, @@ -125,8 +122,7 @@ class AnaViewWindow : public Window if (column5size() > 0) { lbl = new DynamicText( line, rect_t{}, - [=]() { return std::to_string((int16_t)column5(i)); }, - COLOR_THEME_PRIMARY1); + [=]() { return std::to_string((int16_t)column5(i)); }); etx_obj_add_style(lbl->getLvObj(), styles->text_align_left, LV_PART_MAIN); } else { grid.nextCell(); @@ -182,8 +178,7 @@ class AnaCalibratedViewWindow : public AnaViewWindow std::to_string(rawTouchState.x) + " : " + std::to_string(rawTouchState.y); return std::string(""); - }, - COLOR_THEME_PRIMARY1); + }); lv_obj_set_grid_cell(lbl->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, 5, LV_GRID_ALIGN_CENTER, 0, 1); @@ -192,7 +187,7 @@ class AnaCalibratedViewWindow : public AnaViewWindow auto lbl2 = new StaticText( line, rect_t{}, std::string("Touch GT911 FW ver: ") + std::to_string(touchGT911fwver), - COLOR_THEME_PRIMARY1); + COLOR_THEME_PRIMARY1_INDEX); lv_obj_set_grid_cell(lbl2->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, 5, LV_GRID_ALIGN_CENTER, 0, 1); diff --git a/radio/src/gui/colorlcd/radio_ghost_module_config.cpp b/radio/src/gui/colorlcd/radio_ghost_module_config.cpp index 8058938497d..61f6cd9fd70 100644 --- a/radio/src/gui/colorlcd/radio_ghost_module_config.cpp +++ b/radio/src/gui/colorlcd/radio_ghost_module_config.cpp @@ -39,7 +39,7 @@ class GhostModuleConfigWindow : public Window for (int i = 0; i < GHST_MENU_LINES; i += 1) { menuLines[i][0] = new StaticText( this, {xOffset, yOffset + i * lineSpacing, LV_SIZE_CONTENT, h}, "", - FONT(L)); + COLOR_THEME_PRIMARY1_INDEX, FONT(L)); etx_txt_color(menuLines[i][0]->getLvObj(), COLOR_THEME_SECONDARY1_INDEX, LV_PART_MAIN); etx_solid_bg(menuLines[i][0]->getLvObj(), COLOR_THEME_FOCUS_INDEX, @@ -49,7 +49,7 @@ class GhostModuleConfigWindow : public Window menuLines[i][1] = new StaticText( this, {xOffset2, yOffset + i * lineSpacing, LV_SIZE_CONTENT, h}, "", - FONT(L)); + COLOR_THEME_PRIMARY1_INDEX, FONT(L)); etx_txt_color(menuLines[i][1]->getLvObj(), COLOR_THEME_SECONDARY1_INDEX, LV_PART_MAIN); etx_solid_bg(menuLines[i][1]->getLvObj(), COLOR_THEME_FOCUS_INDEX, diff --git a/radio/src/gui/colorlcd/radio_hardware.cpp b/radio/src/gui/colorlcd/radio_hardware.cpp index f5e2c16dea7..8538c8228f7 100644 --- a/radio/src/gui/colorlcd/radio_hardware.cpp +++ b/radio/src/gui/colorlcd/radio_hardware.cpp @@ -138,8 +138,8 @@ static SetupLineDef setupLines[] = { // RTC Batt display new DynamicNumber( parent, - {x + ToggleSwitch::TOGGLE_W + PAD_LARGE, y + PAD_SMALL + 1, 0, 0}, - [] { return getRTCBatteryVoltage(); }, COLOR_THEME_PRIMARY1 | PREC2, + {x + ToggleSwitch::TOGGLE_W + PAD_SMALL, y + PAD_SMALL + 1, 0, 0}, + [] { return getRTCBatteryVoltage(); }, COLOR_THEME_PRIMARY1_INDEX, PREC2, "", "V"); } }, @@ -165,7 +165,6 @@ void RadioHardwarePage::build(Window* window) { window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY); - // TODO: sub-title? SetupLine::showLines(window, 0, SubPage::EDT_X, padding, setupLines, DIM(setupLines)); FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY); diff --git a/radio/src/gui/colorlcd/radio_setup.cpp b/radio/src/gui/colorlcd/radio_setup.cpp index bfc3e1f8b4f..403693e10d5 100644 --- a/radio/src/gui/colorlcd/radio_setup.cpp +++ b/radio/src/gui/colorlcd/radio_setup.cpp @@ -574,7 +574,7 @@ static void viewOption(Window* parent, coord_t x, coord_t y, std::string s(STR_MODEL); s += " - "; s += STR_ADCFILTERVALUES[modelOption]; - new StaticText(parent, {x + ToggleSwitch::TOGGLE_W + PAD_MEDIUM, y + PAD_SMALL + 1, 0, 0}, s.c_str(), COLOR_THEME_SECONDARY1); + new StaticText(parent, {x + ToggleSwitch::TOGGLE_W + PAD_MEDIUM, y + PAD_SMALL + 1, 0, 0}, s.c_str(), COLOR_THEME_SECONDARY1_INDEX); } } diff --git a/radio/src/gui/colorlcd/radio_spectrum_analyser.cpp b/radio/src/gui/colorlcd/radio_spectrum_analyser.cpp index 1d271689d78..15438e0c780 100644 --- a/radio/src/gui/colorlcd/radio_spectrum_analyser.cpp +++ b/radio/src/gui/colorlcd/radio_spectrum_analyser.cpp @@ -26,13 +26,9 @@ #define SET_DIRTY() storageDirty(EE_GENERAL) -constexpr coord_t SPECTRUM_HEIGHT = 180; constexpr coord_t SCALE_HEIGHT = 15; constexpr coord_t FOOTER_HEIGHT = 32; - -static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), 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}; +constexpr coord_t SPECTRUM_HEIGHT = LCD_H - EdgeTxStyles::MENU_HEADER_HEIGHT - SCALE_HEIGHT - FOOTER_HEIGHT; coord_t getAverage(uint8_t number, const uint8_t* value) { @@ -49,15 +45,7 @@ class SpectrumFooterWindow : public Window SpectrumFooterWindow(Window* parent, const rect_t& rect, int moduleIdx) : Window(parent, rect) { - setFlexLayout(); padAll(PAD_ZERO); - padLeft(PAD_SMALL); - padRight(PAD_SMALL); - - FlexGridLayout grid(col_dsc, row_dsc); - - auto line = newLine(grid); - line->padAll(PAD_ZERO); if (isModuleMultimodule(moduleIdx)) { char label[16]; @@ -65,18 +53,18 @@ class SpectrumFooterWindow : public Window // Frequency sprintf(label, "T: %dMHz", int(reusableBuffer.spectrumAnalyser.freq / 1000000)); - (new StaticText(line, rect_t{0, 0, lv_pct(30), FOOTER_HEIGHT}, label)) + (new StaticText(this, rect_t{PAD_TINY, 0, FLD_W, FOOTER_HEIGHT}, label)) ->padTop(PAD_MEDIUM); // Span sprintf(label, "S: %dMHz", int(reusableBuffer.spectrumAnalyser.span / 1000000)); - (new StaticText(line, rect_t{0, 0, lv_pct(30), FOOTER_HEIGHT}, label)) + (new StaticText(this, rect_t{PAD_TINY + FLD_W, 0, FLD_W, FOOTER_HEIGHT}, label)) ->padTop(PAD_MEDIUM); } else { // Frequency auto freq = new NumberEdit( - line, rect_t{0, 0, lv_pct(30), FOOTER_HEIGHT}, + this, rect_t{PAD_TINY, 0, FLD_W, 0}, reusableBuffer.spectrumAnalyser.freqMin, reusableBuffer.spectrumAnalyser.freqMax, GET_DEFAULT(reusableBuffer.spectrumAnalyser.freq / 1000000), @@ -86,7 +74,7 @@ class SpectrumFooterWindow : public Window // Span auto span = new NumberEdit( - line, rect_t{0, 0, lv_pct(30), FOOTER_HEIGHT}, 1, + this, rect_t{PAD_TINY + FLD_W, 0, FLD_W, 0}, 1, reusableBuffer.spectrumAnalyser.spanMax, GET_DEFAULT(reusableBuffer.spectrumAnalyser.span / 1000000), SET_VALUE(reusableBuffer.spectrumAnalyser.span, newValue * 1000000)); @@ -96,7 +84,7 @@ class SpectrumFooterWindow : public Window // Tracker auto tracker = new NumberEdit( - line, rect_t{0, 0, lv_pct(30), LV_SIZE_CONTENT}, + this, rect_t{(PAD_TINY + FLD_W) * 2, 0, FLD_W, FOOTER_HEIGHT}, (reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2) / 1000000, @@ -109,6 +97,8 @@ class SpectrumFooterWindow : public Window tracker->setPrefix("T: "); tracker->setDefault(reusableBuffer.spectrumAnalyser.freqDefault); } + + static constexpr coord_t FLD_W = (LCD_W - PAD_TINY * 4) / 3; }; class SpectrumScaleWindow : public Window @@ -132,8 +122,8 @@ class SpectrumScaleWindow : public Window int x = (frequency - startFreq) / reusableBuffer.spectrumAnalyser.step; if (x >= LCD_W - 1) break; formatNumberAsString(s, 16, frequency / 1000000, 16); - new StaticText(this, {x - 16, 0, 32, 15}, s, - FONT(XS) | CENTERED | COLOR_THEME_PRIMARY1); + new StaticText(this, {x - 16, 0, 32, SCALE_HEIGHT}, s, + COLOR_THEME_PRIMARY1_INDEX, FONT(XS) | CENTERED); } } @@ -193,7 +183,7 @@ class SpectrumWindow : public Window warning = new StaticText( this, {0, height() / 2 - 20, lv_pct(100), LV_SIZE_CONTENT}, - STR_TURN_OFF_RECEIVER, COLOR_THEME_PRIMARY1 | CENTERED | FONT(XL)); + STR_TURN_OFF_RECEIVER, COLOR_THEME_PRIMARY1_INDEX, CENTERED | FONT(XL)); warning->show(TELEMETRY_STREAMING()); } @@ -331,8 +321,8 @@ void RadioSpectrumAnalyser::checkEvents() limit(0, offset / reusableBuffer.spectrumAnalyser.step, width() - 1); if (x != trackX) { trackX = x; - trackPts[0] = {(lv_coord_t)x, 45}; - trackPts[1] = {(lv_coord_t)x, (lv_coord_t)(height() - 32)}; + trackPts[0] = {(lv_coord_t)x, EdgeTxStyles::MENU_HEADER_HEIGHT}; + trackPts[1] = {(lv_coord_t)x, (lv_coord_t)(height() - FOOTER_HEIGHT)}; lv_line_set_points(trackLine, trackPts, 2); } Page::checkEvents(); diff --git a/radio/src/gui/colorlcd/radio_theme.cpp b/radio/src/gui/colorlcd/radio_theme.cpp index e91d53624a3..abad386d311 100644 --- a/radio/src/gui/colorlcd/radio_theme.cpp +++ b/radio/src/gui/colorlcd/radio_theme.cpp @@ -272,9 +272,12 @@ class ColorEditPage : public Page r.h = colForm->height() - COLOR_BOX_HEIGHT - 4; + uint32_t color = _theme->getColorEntryByIndex(_indexOfColor)->colorValue; + _colorEditor = new ColorEditor( - colForm, r, _theme->getColorEntryByIndex(_indexOfColor)->colorValue, + colForm, r, COLOR2FLAGS(color) | RGB_FLAG, [=](uint32_t rgb) { + rgb = COLOR_VAL(rgb); _theme->setColor(_indexOfColor, rgb); if (_colorSquare != nullptr) { _colorSquare->setColor(rgb); @@ -290,12 +293,12 @@ class ColorEditPage : public Page r.w = COLOR_BOX_WIDTH; r.h = COLOR_BOX_HEIGHT; _colorSquare = new ColorSwatch( - colBoxForm, r, _theme->getColorEntryByIndex(_indexOfColor)->colorValue); + colBoxForm, r, color); // hexBox r.w = HEX_STR_W; - _hexBox = new StaticText(colBoxForm, r, "", COLOR_THEME_PRIMARY1 | FONT(L) | RIGHT); - setHexStr(_theme->getColorEntryByIndex(_indexOfColor)->colorValue); + _hexBox = new StaticText(colBoxForm, r, "", COLOR_THEME_PRIMARY1_INDEX, FONT(L) | RIGHT); + setHexStr(color); } void buildHead(PageHeader *window) diff --git a/radio/src/gui/colorlcd/radio_tools.cpp b/radio/src/gui/colorlcd/radio_tools.cpp index 8d0ded996b3..d3a437df8d0 100644 --- a/radio/src/gui/colorlcd/radio_tools.cpp +++ b/radio/src/gui/colorlcd/radio_tools.cpp @@ -149,10 +149,12 @@ static void run_spektrum_int(Window* parent, const std::string&) } #endif +#if defined(HARDWARE_EXTERNAL_MODULE) static void run_spektrum_ext(Window* parent, const std::string&) { new RadioSpectrumAnalyser(EXTERNAL_MODULE); } +#endif #endif // defined(PXX2) || defined(MULTIMODULE) #if defined(INTERNAL_MODULE_PXX2) @@ -196,6 +198,13 @@ void RadioToolsPage::rebuild(Window* window) std::list tools; +#if defined(HARDWARE_INTERNAL_MODULE) + bool intSpecAnalyser = false; +#endif +#if defined(HARDWARE_EXTERNAL_MODULE) + bool extSpecAnalyser = false; +#endif + #if defined(PXX2) auto hwSettings = &reusableBuffer.hardwareAndSettings; @@ -204,8 +213,7 @@ void RadioToolsPage::rebuild(Window* window) // PXX2 modules tools if (isPXX2ModuleOptionAvailable(intHwSettings->information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER)) { - tools.emplace_back( - ToolEntry{STR_SPECTRUM_ANALYSER_INT, {}, run_spektrum_int}); + intSpecAnalyser = true; } if (isPXX2ModuleOptionAvailable(intHwSettings->information.modelID, MODULE_OPTION_POWER_METER)) { @@ -216,25 +224,32 @@ void RadioToolsPage::rebuild(Window* window) auto extHwSettings = &hwSettings->modules[EXTERNAL_MODULE]; if (isPXX2ModuleOptionAvailable(extHwSettings->information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER)) { - tools.emplace_back( - ToolEntry{STR_SPECTRUM_ANALYSER_EXT, {}, run_spektrum_ext}); + extSpecAnalyser = true; } #endif // defined(PXX2) #if defined(HARDWARE_INTERNAL_MODULE) && defined(MULTIMODULE) if (g_eeGeneral.internalModule == MODULE_TYPE_MULTIMODULE) { - tools.emplace_back( - ToolEntry{STR_SPECTRUM_ANALYSER_INT, {}, run_spektrum_int}); + intSpecAnalyser = true; } #endif #if defined(PXX2) || defined(MULTIMODULE) if (isModuleMultimodule(EXTERNAL_MODULE)) { - tools.emplace_back( - ToolEntry{STR_SPECTRUM_ANALYSER_EXT, {}, run_spektrum_ext}); + extSpecAnalyser = true; } #endif +#if defined(HARDWARE_INTERNAL_MODULE) + if (intSpecAnalyser) + tools.emplace_back(ToolEntry{STR_SPECTRUM_ANALYSER_INT, {}, run_spektrum_int}); +#endif + +#if defined(HARDWARE_EXTERNAL_MODULE) + if (extSpecAnalyser) + tools.emplace_back(ToolEntry{STR_SPECTRUM_ANALYSER_EXT, {}, run_spektrum_ext}); +#endif + #if defined(GHOST) if (isModuleGhost(EXTERNAL_MODULE)) { tools.emplace_back(ToolEntry{"Ghost module config", {}, run_ghost_config}); diff --git a/radio/src/gui/colorlcd/radio_trainer.cpp b/radio/src/gui/colorlcd/radio_trainer.cpp index bdecfe2dffe..52d1a395df3 100644 --- a/radio/src/gui/colorlcd/radio_trainer.cpp +++ b/radio/src/gui/colorlcd/radio_trainer.cpp @@ -52,7 +52,7 @@ void RadioTrainerPage::build(Window* form) if (SLAVE_MODE()) { form->setHeight(TabsGroup::MENU_BODY_HEIGHT); - auto txt = new StaticText(form, rect_t{}, STR_SLAVE, FONT(L)); + auto txt = new StaticText(form, rect_t{}, STR_SLAVE, COLOR_THEME_PRIMARY1_INDEX, FONT(L)); lv_obj_align(txt->getLvObj(), LV_ALIGN_CENTER, 0, 0); } else { FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY); @@ -78,7 +78,7 @@ void RadioTrainerPage::build(Window* form) line->padBottom(PAD_LARGE); #endif - LcdFlags flags = LEFT | COLOR_THEME_PRIMARY1; + LcdFlags flags = LEFT; if (g_eeGeneral.ppmunit == PPM_PERCENT_PREC1) flags |= PREC1; new DynamicNumber( @@ -86,7 +86,7 @@ void RadioTrainerPage::build(Window* form) [=]() { return (trainerInput[i] - g_eeGeneral.trainer.calib[i]) * 2; }, - flags); + COLOR_THEME_PRIMARY1_INDEX, flags); } auto line = form->newLine(grid); diff --git a/radio/src/gui/colorlcd/screen_user_interface.cpp b/radio/src/gui/colorlcd/screen_user_interface.cpp index 9db3c588145..d7627ffe848 100644 --- a/radio/src/gui/colorlcd/screen_user_interface.cpp +++ b/radio/src/gui/colorlcd/screen_user_interface.cpp @@ -69,62 +69,62 @@ class ThemeView : public Window auto theme = tp->getCurrentTheme(); if (theme) { - if (!details) { - FlexGridLayout theme_grid(theme_col_dsc, theme_row_dsc); - auto line = newLine(theme_grid); + FlexGridLayout theme_grid(theme_col_dsc, theme_row_dsc, PAD_TINY); + auto line = newLine(theme_grid); - details = new Window(line, rect_t{}); - // vertical flow layout - lv_obj_set_flex_flow(details->getLvObj(), LV_FLEX_FLOW_COLUMN); - lv_obj_set_style_pad_row(details->getLvObj(), 2, LV_PART_MAIN); + details = new Window(line, rect_t{0, 0, 0, LV_SIZE_CONTENT}); + // vertical flow layout + lv_obj_set_flex_flow(details->getLvObj(), LV_FLEX_FLOW_COLUMN); + lv_obj_set_style_pad_row(details->getLvObj(), PAD_TINY, LV_PART_MAIN); - // make the object fill the grid cell - lv_obj_set_style_grid_cell_x_align(details->getLvObj(), - LV_GRID_ALIGN_STRETCH, 0); + // make the object fill the grid cell + lv_obj_set_style_grid_cell_x_align(details->getLvObj(), + LV_GRID_ALIGN_STRETCH, 0); + lv_obj_set_style_grid_cell_y_align(details->getLvObj(), + LV_GRID_ALIGN_START, 0); - new StaticText(details, rect_t{}, STR_AUTHOR, COLOR_THEME_PRIMARY1 | FONT(BOLD)); - author = new StaticText(details, rect_t{}, ""); + new StaticText(details, rect_t{}, STR_AUTHOR, COLOR_THEME_PRIMARY1_INDEX, FONT(BOLD)); + author = new StaticText(details, rect_t{}, ""); - // labels default to LV_SIZE_CONTENT, - // which could overflow the width avail - lv_obj_set_width(author->getLvObj(), lv_pct(100)); + // labels default to LV_SIZE_CONTENT, + // which could overflow the width avail + lv_obj_set_width(author->getLvObj(), lv_pct(100)); - new StaticText(details, rect_t{}, STR_DESCRIPTION, COLOR_THEME_PRIMARY1 | FONT(BOLD)); - description = - new StaticText(details, rect_t{}, ""); + new StaticText(details, rect_t{}, STR_DESCRIPTION, COLOR_THEME_PRIMARY1_INDEX, FONT(BOLD)); + description = + new StaticText(details, rect_t{}, ""); - lv_obj_set_width(description->getLvObj(), lv_pct(100)); + lv_obj_set_width(description->getLvObj(), lv_pct(100)); -#if !PORTRAIT_LCD - preview = new FilePreview(line, rect_t{0, 0, LCD_W / 2, LCD_H / 2}); -#else - preview = new FilePreview(line, rect_t{0, 0, LCD_W - 12, LCD_H / 2}); -#endif - - // center within cell - lv_obj_set_style_grid_cell_x_align(preview->getLvObj(), - LV_GRID_ALIGN_CENTER, 0); - } + preview = new FilePreview(line, {0, 0, PREVIEW_W, LV_SIZE_CONTENT}); - author->setText(theme->getAuthor()); - description->setText(theme->getInfo()); + // align within cell + lv_obj_set_style_grid_cell_x_align(preview->getLvObj(), + LV_GRID_ALIGN_START, 0); - setImage(); + update(); } } - void setImage() + void update() { auto tp = ThemePersistance::instance(); auto theme = tp->getCurrentTheme(); - auto themeImage = theme->getThemeImageFileNames(); - if (themeImage.size() > 0) { - preview->setFile(themeImage[0].c_str()); - } else { - preview->setFile(""); + if (theme) { + author->setText(theme->getAuthor()); + description->setText(theme->getInfo()); + + auto themeImage = theme->getThemeImageFileNames(); + if (themeImage.size() > 0) { + preview->setFile(themeImage[0].c_str()); + } else { + preview->setFile(""); + } } } + static LAYOUT_VAL(PREVIEW_W, (LCD_W - PAD_MEDIUM * 3) / 2, LCD_W - 12) + protected: Window* details = nullptr; FilePreview* preview = nullptr; @@ -133,16 +133,16 @@ class ThemeView : public Window }; ScreenUserInterfacePage::ScreenUserInterfacePage(ScreenMenu* menu) : - PageTab(STR_USER_INTERFACE, ICON_THEME_SETUP), menu(menu) + PageTab(STR_USER_INTERFACE, ICON_THEME_SETUP, PAD_TINY), menu(menu) { } void ScreenUserInterfacePage::build(Window* window) { - window->padAll(PAD_SMALL); + window->padAll(PAD_TINY); window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO); - FlexGridLayout grid(line_col_dsc, line_row_dsc); + FlexGridLayout grid(line_col_dsc, line_row_dsc, PAD_TINY); // Top Bar auto line = window->newLine(grid); @@ -222,7 +222,7 @@ void ScreenUserInterfacePage::build(Window* window) tp->setThemeIndex(value); tp->applyTheme(value); tp->setDefaultTheme(value); - themeView->setImage(); + themeView->update(); }); grid.setColSpan(2); diff --git a/radio/src/gui/colorlcd/select_fab_carousel.cpp b/radio/src/gui/colorlcd/select_fab_carousel.cpp index e3e2c53fc75..72ca8b4d4df 100644 --- a/radio/src/gui/colorlcd/select_fab_carousel.cpp +++ b/radio/src/gui/colorlcd/select_fab_carousel.cpp @@ -103,11 +103,11 @@ class SelectFabButton : public ButtonBase etx_quick_icon_create); iconLayout->setWindowFlag(NO_FOCUS); - (new StaticIcon(iconLayout, 0, 0, icon, COLOR_WHITE)) + (new StaticIcon(iconLayout, 0, 0, icon, COLOR_WHITE_INDEX)) ->center(SelectFabCarousel::FAB_ICON_SIZE - 4, SelectFabCarousel::FAB_ICON_SIZE - 4); new StaticText(this, {0, SelectFabCarousel::FAB_BUTTON_HEIGHT - SelectFabCarousel::FAB_TXT_YO, SelectFabCarousel::FAB_BUTTON_INNER_WIDTH, 0}, - title, COLOR_WHITE | CENTERED); + title, COLOR_WHITE_INDEX, CENTERED); } #if defined(DEBUG_WINDOWS) diff --git a/radio/src/gui/colorlcd/select_fab_carousel.h b/radio/src/gui/colorlcd/select_fab_carousel.h index 35cb5891000..aef2eed636e 100644 --- a/radio/src/gui/colorlcd/select_fab_carousel.h +++ b/radio/src/gui/colorlcd/select_fab_carousel.h @@ -42,6 +42,5 @@ class SelectFabCarousel : public Window static LAYOUT_VAL(FAB_ICON_SIZE, 52, 52) static LAYOUT_VAL(FAB_TXT_YO, 48, 48) - static LAYOUT_VAL(FAB_PAD, 4, 4) 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 7edd0eb9ff7..f75d5af6e19 100644 --- a/radio/src/gui/colorlcd/special_functions.cpp +++ b/radio/src/gui/colorlcd/special_functions.cpp @@ -741,14 +741,8 @@ void FunctionsPage::plusPopup(Window *window) void FunctionsPage::build(Window *window) { - static const lv_coord_t l_col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY); - window->padAll(PAD_SMALL); - window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO); - - FlexGridLayout grid(l_col_dsc, row_dsc, PAD_TINY); - - FormLine *line; bool hasEmptyFunction = false; // Reset focusIndex after switching tabs @@ -760,10 +754,8 @@ void FunctionsPage::build(Window *window) bool isActive = (cfn->swtch != 0); if (isActive) { - line = window->newLine(grid); - auto button = functionButton( - line, rect_t{0, 0, window->width() - 12, SF_BUTTON_H}, i); + window, rect_t{0, 0, window->width() - 12, SF_BUTTON_H}, i); lv_obj_set_grid_cell(button->getLvObj(), LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1); @@ -862,9 +854,8 @@ void FunctionsPage::build(Window *window) } if (hasEmptyFunction) { - line = window->newLine(grid); addButton = - new TextButton(line, rect_t{0, 0, window->width() - 12, SF_BUTTON_H}, + new TextButton(window, rect_t{0, 0, window->width() - 12, SF_BUTTON_H}, LV_SYMBOL_PLUS, [=]() { plusPopup(window); return 0; diff --git a/radio/src/gui/colorlcd/startup_shutdown.cpp b/radio/src/gui/colorlcd/startup_shutdown.cpp index efeb377dae5..93a0d595c50 100644 --- a/radio/src/gui/colorlcd/startup_shutdown.cpp +++ b/radio/src/gui/colorlcd/startup_shutdown.cpp @@ -103,12 +103,12 @@ void drawSplash() new StaticLZ4Image(splashScreen, IMG_X - logo->width / 2, IMG_Y - logo->height / 2, logo); - new StaticText(splashScreen, {TXT_X - 100, TXT_Y, 200, 24}, ver_str.c_str(), COLOR_GREY | CENTERED); + new StaticText(splashScreen, {TXT_X - 100, TXT_Y, 200, 24}, ver_str.c_str(), COLOR_GREY_INDEX, CENTERED); new StaticText(splashScreen, {TXT_X - 100, TXT_Y + TXT_H, 200, TXT_H}, - nam_str.c_str(), COLOR_GREY | CENTERED); + nam_str.c_str(), COLOR_GREY_INDEX, CENTERED); #if !defined(VERSION_TAG) new StaticText(splashScreen, {TXT_X - 100, TXT_Y + TXT_H * 2, 200, TXT_H}, - git_str.c_str(), COLOR_GREY | CENTERED); + git_str.c_str(), COLOR_GREY_INDEX, CENTERED); #endif } @@ -197,7 +197,7 @@ void drawSleepBitmap() etx_solid_bg(shutdownWindow->getLvObj(), COLOR_THEME_PRIMARY1_INDEX); } - (new StaticIcon(shutdownWindow, 0, 0, ICON_SHUTDOWN, COLOR_THEME_PRIMARY2)) + (new StaticIcon(shutdownWindow, 0, 0, ICON_SHUTDOWN, COLOR_THEME_PRIMARY2_INDEX)) ->center(LCD_W, LCD_H); LvglWrapper::instance()->run(); @@ -235,14 +235,14 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, shutdownSplashImg->width(), shutdownSplashImg->height(), LV_IMG_CF_TRUE_COLOR); } - (new StaticIcon(shutdownWindow, 0, 0, ICON_SHUTDOWN, COLOR_THEME_PRIMARY2)) + (new StaticIcon(shutdownWindow, 0, 0, ICON_SHUTDOWN, COLOR_THEME_PRIMARY2_INDEX)) ->center(LCD_W, LCD_H); for (int i = 0; i < 4; i += 1) { shutdownAnim[i] = new StaticIcon( shutdownWindow, LCD_W / 2 + bmp_shutdown_xo[i], LCD_H / 2 + bmp_shutdown_yo[i], - (EdgeTxIcon)(ICON_SHUTDOWN_CIRCLE0 + i), COLOR_THEME_PRIMARY2); + (EdgeTxIcon)(ICON_SHUTDOWN_CIRCLE0 + i), COLOR_THEME_PRIMARY2_INDEX); } } @@ -264,7 +264,7 @@ void drawFatalErrorScreen(const char* message) etx_solid_bg(fatalErrorWindow->getLvObj(), COLOR_BLACK_INDEX); new StaticText(fatalErrorWindow, rect_t{0, LCD_H / 2 - 20, LCD_W, 40}, - message, FONT(XL) | CENTERED | COLOR_WHITE); + message, COLOR_WHITE_INDEX, FONT(XL) | CENTERED); } backlightEnable(100); diff --git a/radio/src/gui/colorlcd/tabsgroup.cpp b/radio/src/gui/colorlcd/tabsgroup.cpp index 8a47062abab..7f962d65b25 100644 --- a/radio/src/gui/colorlcd/tabsgroup.cpp +++ b/radio/src/gui/colorlcd/tabsgroup.cpp @@ -53,10 +53,10 @@ class SelectedTabIcon : public StaticIcon { public: SelectedTabIcon(Window* parent) : - StaticIcon(parent, 0, 0, ICON_CURRENTMENU_SHADOW, COLOR_THEME_PRIMARY1) + StaticIcon(parent, 0, 0, ICON_CURRENTMENU_SHADOW, COLOR_THEME_PRIMARY1_INDEX) { - new StaticIcon(this, 0, 0, ICON_CURRENTMENU_BG, COLOR_THEME_FOCUS); - new StaticIcon(this, SEL_DOT_X, SEL_DOT_Y, ICON_CURRENTMENU_DOT, COLOR_THEME_PRIMARY2); + new StaticIcon(this, 0, 0, ICON_CURRENTMENU_BG, COLOR_THEME_FOCUS_INDEX); + new StaticIcon(this, SEL_DOT_X, SEL_DOT_Y, ICON_CURRENTMENU_DOT, COLOR_THEME_PRIMARY2_INDEX); } #if defined(DEBUG_WINDOWS) @@ -74,7 +74,7 @@ class TabsGroupButton : public ButtonBase ButtonBase(parent, rect, nullptr, window_create), pageTab(page), index(idx) { lastIcon = pageTab->getIcon(); - icon = new StaticIcon(this, 2, ICON_Y, lastIcon, COLOR_THEME_PRIMARY2); + icon = new StaticIcon(this, 2, ICON_Y, lastIcon, COLOR_THEME_PRIMARY2_INDEX); show(isVisible()); } @@ -154,7 +154,7 @@ class TabsGroupHeader : public Window selectedIcon = new SelectedTabIcon(carousel); - new HeaderDateTime(this, LCD_W - DATE_XO, DATE_Y); + new HeaderDateTime(this, LCD_W - DATE_XO, PAD_MEDIUM); } void setTitle(const char* title) { lv_label_set_text(titleLabel, title); } @@ -221,7 +221,6 @@ class TabsGroupHeader : public Window uint8_t tabCount() const { return buttons.size(); } static LAYOUT_VAL(DATE_XO, 48, 48) - static LAYOUT_VAL(DATE_Y, 6, 6) static LAYOUT_VAL(MENU_HEADER_BUTTON_WIDTH, 33, 33) static LAYOUT_VAL(HDR_DATE_FULL_WIDTH, 51, 51) diff --git a/radio/src/gui/colorlcd/tabsgroup.h b/radio/src/gui/colorlcd/tabsgroup.h index bc5d8b55009..4918aae09ac 100644 --- a/radio/src/gui/colorlcd/tabsgroup.h +++ b/radio/src/gui/colorlcd/tabsgroup.h @@ -30,10 +30,10 @@ class TabsGroupHeader; class PageTab { public: - PageTab(PaddingSize padding = PAD_MEDIUM) : padding(padding) {} + PageTab(PaddingSize padding = PAD_SMALL) : padding(padding) {} PageTab(std::string title, EdgeTxIcon icon, - PaddingSize padding = PAD_MEDIUM) : + PaddingSize padding = PAD_SMALL) : title(std::move(title)), icon(icon), padding(padding) { } diff --git a/radio/src/gui/colorlcd/theme_manager.cpp b/radio/src/gui/colorlcd/theme_manager.cpp index 934a7ae9d8d..b3de31e071e 100644 --- a/radio/src/gui/colorlcd/theme_manager.cpp +++ b/radio/src/gui/colorlcd/theme_manager.cpp @@ -27,6 +27,7 @@ #include "themes/etx_lv_theme.h" #include "topbar_impl.h" #include "view_main.h" +#include "storage/sdcard_yaml.h" #define SET_DIRTY() storageDirty(EE_GENERAL) @@ -36,13 +37,6 @@ constexpr const char* RGBSTRING = "RGB("; ThemePersistance ThemePersistance::themePersistance; -// prototype for SD card function to read a YAML file -// TODO: should this be in sdcard header file? -enum class ChecksumResult; -extern const char* readYamlFile(const char* fullpath, - const YamlParserCalls* calls, void* parser_ctx, - ChecksumResult* checksum_result); - static uint32_t r_color(const YamlNode* node, const char* val, uint8_t val_len) { if ((strncmp(val, RGBSTRING, strlen(RGBSTRING)) == 0) && @@ -521,7 +515,8 @@ void HeaderDateTime::checkEvents() struct gtm t; gettime(&t); - if (t.tm_min != lastMinute) { + if (t.tm_min != lastTime.tm_min || t.tm_hour != lastTime.tm_hour || + t.tm_mday != lastTime.tm_mday || t.tm_mon != lastTime.tm_mon) { char str[10]; #if defined(TRANSLATIONS_CN) || defined(TRANSLATIONS_TW) sprintf(str, "%02d-%02d", t.tm_mon + 1, t.tm_mday); @@ -533,7 +528,7 @@ void HeaderDateTime::checkEvents() getTimerString(str, getValue(MIXSRC_TX_TIME), timerOptions); lv_label_set_text(time, str); - lastMinute = t.tm_min; + lastTime = t; } } @@ -544,15 +539,15 @@ void HeaderDateTime::setColor(LcdFlags color) } HeaderIcon::HeaderIcon(Window* parent, EdgeTxIcon icon) : - StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS) + StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS_INDEX) { - (new StaticIcon(this, 0, 0, icon, COLOR_THEME_PRIMARY2))->center(width(), height()); + (new StaticIcon(this, 0, 0, icon, COLOR_THEME_PRIMARY2_INDEX))->center(width(), height()); } HeaderIcon::HeaderIcon(Window* parent, const char* iconFile) : - StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS) + StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS_INDEX) { - (new StaticIcon(this, 0, 0, iconFile, COLOR_THEME_PRIMARY2))->center(width(), height()); + (new StaticIcon(this, 0, 0, iconFile, COLOR_THEME_PRIMARY2_INDEX))->center(width(), height()); } UsbSDConnected::UsbSDConnected() : @@ -561,8 +556,8 @@ UsbSDConnected::UsbSDConnected() : setWindowFlag(OPAQUE); etx_solid_bg(lvobj, COLOR_THEME_PRIMARY1_INDEX); - new HeaderDateTime(this, LCD_W - TopBar::HDR_DATE_XO, HDR_DATE_Y); + new HeaderDateTime(this, LCD_W - TopBar::HDR_DATE_XO, PAD_MEDIUM); - auto icon = new StaticIcon(this, 0, 0, ICON_USB_PLUGGED, COLOR_THEME_PRIMARY2); + auto icon = new StaticIcon(this, 0, 0, ICON_USB_PLUGGED, COLOR_THEME_PRIMARY2_INDEX); lv_obj_center(icon->getLvObj()); } diff --git a/radio/src/gui/colorlcd/theme_manager.h b/radio/src/gui/colorlcd/theme_manager.h index 9f79c9177d1..a6be838ecb0 100644 --- a/radio/src/gui/colorlcd/theme_manager.h +++ b/radio/src/gui/colorlcd/theme_manager.h @@ -172,7 +172,7 @@ class HeaderDateTime : public Window protected: lv_obj_t *date = nullptr; lv_obj_t *time = nullptr; - int8_t lastMinute = -1; + struct gtm lastTime = { 0 }; void checkEvents() override; }; @@ -188,6 +188,4 @@ class UsbSDConnected : public Window { public: UsbSDConnected(); - - static LAYOUT_VAL(HDR_DATE_Y, 6, 6) }; diff --git a/radio/src/gui/colorlcd/view_about.cpp b/radio/src/gui/colorlcd/view_about.cpp index aa7ae130514..a294334236d 100644 --- a/radio/src/gui/colorlcd/view_about.cpp +++ b/radio/src/gui/colorlcd/view_about.cpp @@ -43,7 +43,7 @@ AboutUs::AboutUs() : { new StaticText(form, {0, 0, LV_PCT(100), LV_SIZE_CONTENT}, about_str + "\n" + copyright_str, - COLOR_THEME_SECONDARY1 | CENTERED); + COLOR_THEME_SECONDARY1_INDEX, CENTERED); auto qrBox = new Window(form, {0, 0, LV_PCT(100), QR_SZ}); auto qr = new QRCode(qrBox, 0, 0, QR_SZ, edgetx_url); diff --git a/radio/src/gui/colorlcd/view_channels.cpp b/radio/src/gui/colorlcd/view_channels.cpp index d8c59741bdc..f4f00ccffdb 100644 --- a/radio/src/gui/colorlcd/view_channels.cpp +++ b/radio/src/gui/colorlcd/view_channels.cpp @@ -49,7 +49,7 @@ class ChannelsViewFooter : public Window w->setWindowFlag(NO_FOCUS); etx_solid_bg(w->getLvObj(), COLOR_THEME_ACTIVE_INDEX); - new StaticText(this, {LEG_COLORBOX + PAD_MEDIUM + PAD_SMALL, PAD_TINY, LV_SIZE_CONTENT, TXT_H}, STR_MONITOR_OUTPUT_DESC, COLOR_THEME_PRIMARY2 | LEFT); + new StaticText(this, {LEG_COLORBOX + PAD_MEDIUM + PAD_SMALL, PAD_TINY, LV_SIZE_CONTENT, TXT_H}, STR_MONITOR_OUTPUT_DESC, COLOR_THEME_PRIMARY2_INDEX); int x = getTextWidth(STR_MONITOR_OUTPUT_DESC) + LEG_COLORBOX + PAD_MEDIUM * 2; @@ -61,7 +61,7 @@ class ChannelsViewFooter : public Window etx_solid_bg(w->getLvObj(), COLOR_THEME_FOCUS_INDEX); new StaticText(this, {x + LEG_COLORBOX + PAD_MEDIUM + PAD_SMALL, PAD_TINY, LV_SIZE_CONTENT, TXT_H}, - STR_MONITOR_MIXER_DESC, COLOR_THEME_PRIMARY2); + STR_MONITOR_MIXER_DESC, COLOR_THEME_PRIMARY2_INDEX); } static LAYOUT_VAL(LEG_COLORBOX, 14, 14) diff --git a/radio/src/gui/colorlcd/view_main_decoration.cpp b/radio/src/gui/colorlcd/view_main_decoration.cpp index 12f73bcf014..50eb2786131 100644 --- a/radio/src/gui/colorlcd/view_main_decoration.cpp +++ b/radio/src/gui/colorlcd/view_main_decoration.cpp @@ -20,7 +20,6 @@ */ #include "view_main_decoration.h" -#include "layout.h" // because of IS_POT_MULTIPOS() and pal #include "opentx.h" @@ -29,12 +28,29 @@ #include "layouts/sliders.h" #include "layouts/trims.h" -#include "board.h" #include "hal/adc_driver.h" -#include "themes/etx_lv_theme.h" -static Window* create_layout_box(Window* parent, lv_align_t align, - lv_flex_flow_t flow) +ViewMainDecoration::ViewMainDecoration(Window* parent, bool showTrims, bool showSliders, bool showFM) : + parent(parent) +{ + w_ml = layoutBox(parent, LV_ALIGN_LEFT_MID, LV_FLEX_FLOW_ROW_REVERSE); + w_mr = layoutBox(parent, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_ROW); + w_bl = layoutBox(parent, LV_ALIGN_BOTTOM_LEFT, LV_FLEX_FLOW_COLUMN); + w_br = layoutBox(parent, LV_ALIGN_BOTTOM_RIGHT, LV_FLEX_FLOW_COLUMN); + + w_bc = layoutBox(parent, LV_ALIGN_BOTTOM_MID, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(w_bc->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND); + + if (showTrims) + createTrims(w_ml, w_mr, w_bl, w_br); + if (showFM) + createFlightMode(w_bc); + if (showSliders) + createSliders(w_ml, w_mr, w_bl, w_bc, w_br); +} + +Window* ViewMainDecoration::layoutBox(Window* parent, lv_align_t align, + lv_flex_flow_t flow) { auto w = new Window(parent, rect_t{0, 0, LV_SIZE_CONTENT, LV_SIZE_CONTENT}); @@ -50,26 +66,6 @@ static Window* create_layout_box(Window* parent, lv_align_t align, return w; } -ViewMainDecoration::ViewMainDecoration(Window* parent) : - parent(parent) -{ - memset(sliders, 0, sizeof(sliders)); - memset(trims, 0, sizeof(trims)); - flightMode = nullptr; - - w_ml = create_layout_box(parent, LV_ALIGN_LEFT_MID, LV_FLEX_FLOW_ROW_REVERSE); - w_mr = create_layout_box(parent, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_ROW); - w_bl = create_layout_box(parent, LV_ALIGN_BOTTOM_LEFT, LV_FLEX_FLOW_COLUMN); - w_br = create_layout_box(parent, LV_ALIGN_BOTTOM_RIGHT, LV_FLEX_FLOW_COLUMN); - - w_bc = create_layout_box(parent, LV_ALIGN_BOTTOM_MID, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(w_bc->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND); - - createTrims(w_ml, w_mr, w_bl, w_br); - createFlightMode(w_bc); - createSliders(w_ml, w_mr, w_bl, w_bc, w_br); -} - void ViewMainDecoration::setSlidersVisible(bool visible) { for (int i=0; i < SLIDERS_MAX; i++) { @@ -106,8 +102,7 @@ rect_t ViewMainDecoration::getMainZone() const Window* boxes[] = { w_bl, w_bc, w_br }; for ( auto box : boxes ) { - auto obj = box->getLvObj(); - auto y = lv_obj_get_y(obj); + auto y = lv_obj_get_y(box->getLvObj()); if (y < bottom) bottom = y; } @@ -116,12 +111,11 @@ rect_t ViewMainDecoration::getMainZone() const void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Window* bc, Window* br) { - int pot = 0, sl = 0; + int pot = 0; // Bottom left horizontal slider if (IS_POT_AVAILABLE(pot)) { - sliders[sl] = new MainViewHorizontalSlider(bl, pot); - sl += 1; + sliders[pot] = new MainViewHorizontalSlider(bl, pot); } pot += 1; @@ -129,8 +123,8 @@ void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Windo if (IS_POT_AVAILABLE(pot)) { if (IS_POT_MULTIPOS(pot)) { // Has 6POS - place bottom center - sliders[sl] = new MainView6POS(bc, pot); - pot += 1; sl += 1; + sliders[pot] = new MainView6POS(bc, pot); + pot += 1; } } else { pot += 1; @@ -138,8 +132,7 @@ void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Windo // Bottom right horizontal slider if (IS_POT_AVAILABLE(pot)) { - sliders[sl] = new MainViewHorizontalSlider(br, pot); - sl += 1; + sliders[pot] = new MainViewHorizontalSlider(br, pot); } pot += 1; @@ -147,35 +140,32 @@ void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Windo if (max_pots > pot) { // 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); + auto leftPots = layoutBox(ml, LV_ALIGN_LEFT_MID, LV_FLEX_FLOW_COLUMN); leftPots->setHeight(MainViewSlider::HORIZONTAL_SLIDERS_WIDTH); - auto rightPots = create_layout_box(mr, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_COLUMN); + auto rightPots = layoutBox(mr, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_COLUMN); rightPots->setHeight(MainViewSlider::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, LayoutFactory::TRIM_SQUARE_SIZE, lsh}, pot); - sl += 1; + sliders[pot] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, lsh}, pot); } pot += 1; if (IS_POT_AVAILABLE(pot)) { - sliders[sl] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, rsh}, pot); - sl += 1; + sliders[pot] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, rsh}, pot); } pot += 1; if (IS_POT_AVAILABLE(pot)) { - sliders[sl] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, lsh}, pot); - sl += 1; + sliders[pot] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, lsh}, pot); } pot += 1; if (IS_POT_AVAILABLE(pot)) { - sliders[sl] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, rsh}, pot); + sliders[pot] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, rsh}, pot); } } } @@ -195,6 +185,5 @@ void ViewMainDecoration::createFlightMode(Window* bc) return stringFromNtString(g_model.flightModeData[mixerCurrentFlightMode].name); }; - flightMode = new DynamicText(bc, rect_t{}, getFM, COLOR_THEME_SECONDARY1); + flightMode = new DynamicText(bc, rect_t{}, getFM, COLOR_THEME_SECONDARY1_INDEX); } - diff --git a/radio/src/gui/colorlcd/view_main_decoration.h b/radio/src/gui/colorlcd/view_main_decoration.h index 387e77b0c43..4a074086902 100644 --- a/radio/src/gui/colorlcd/view_main_decoration.h +++ b/radio/src/gui/colorlcd/view_main_decoration.h @@ -23,14 +23,12 @@ #include "window.h" -constexpr coord_t FM_LABEL_HEIGHT = 20; - class MainViewTrim; class ViewMainDecoration { public: - ViewMainDecoration(Window* parent); + ViewMainDecoration(Window* parent, bool showTrims = true, bool showSliders = true, bool showFM = true); // Set decoration visibility void setTrimsVisible(bool visible); @@ -69,9 +67,11 @@ class ViewMainDecoration Window* w_bc; Window* w_br; - Window* sliders[SLIDERS_MAX]; - MainViewTrim* trims[TRIMS_MAX]; - Window* flightMode; + Window* sliders[SLIDERS_MAX] = { 0 }; + MainViewTrim* trims[TRIMS_MAX] = { 0 }; + Window* flightMode = nullptr; + + Window* layoutBox(Window* parent, lv_align_t align, lv_flex_flow_t flow); void createSliders(Window* ml, Window* mr, Window* bl, Window* bc, Window* br); void createTrims(Window* ml, Window* mr, Window* bl, Window* br); diff --git a/radio/src/gui/colorlcd/view_statistics.cpp b/radio/src/gui/colorlcd/view_statistics.cpp index ee0b8db4c57..4f0f2e67a9c 100644 --- a/radio/src/gui/colorlcd/view_statistics.cpp +++ b/radio/src/gui/colorlcd/view_statistics.cpp @@ -96,7 +96,7 @@ class DebugInfoNumber : public Window coord_t prefixSize = 0; if (prefix != nullptr) { prefixSize = getTextWidth(prefix, 0, FONT(XS)); - new StaticText(this, {0, 1, prefixSize, rect.h}, prefix,FONT(XS)); + new StaticText(this, {0, 1, prefixSize, rect.h}, prefix, COLOR_THEME_PRIMARY1_INDEX, FONT(XS)); } new DynamicNumber(this, {prefixSize, 0, rect.w - prefixSize, rect.h}, @@ -179,15 +179,13 @@ void StatisticsViewPage::build(Window* window) // Session data new StaticText(line, rect_t{}, STR_SESSION); new DynamicText( - line, rect_t{}, [] { return getTimerString(sessionTimer); }, - COLOR_THEME_PRIMARY1); + line, rect_t{}, [] { return getTimerString(sessionTimer); }); // Battery data new StaticText(line, rect_t{}, STR_BATT_LABEL); new DynamicText( line, rect_t{}, - [] { return getTimerString(g_eeGeneral.globalTimer + sessionTimer); }, - COLOR_THEME_PRIMARY1); + [] { return getTimerString(g_eeGeneral.globalTimer + sessionTimer); }); line = window->newLine(grid); line->padAll(PAD_ZERO); @@ -195,14 +193,12 @@ void StatisticsViewPage::build(Window* window) // Throttle new StaticText(line, rect_t{}, STR_THROTTLE_LABEL); new DynamicText( - line, rect_t{}, [] { return getTimerString(s_timeCumThr); }, - COLOR_THEME_PRIMARY1); + line, rect_t{}, [] { return getTimerString(s_timeCumThr); }); // Throttle % data new StaticText(line, rect_t{}, STR_THROTTLE_PERCENT_LABEL); new DynamicText( - line, rect_t{}, [] { return getTimerString(s_timeCum16ThrP / 16); }, - COLOR_THEME_PRIMARY1); + line, rect_t{}, [] { return getTimerString(s_timeCum16ThrP / 16); }); line = window->newLine(grid); line->padAll(PAD_ZERO); @@ -210,14 +206,11 @@ void StatisticsViewPage::build(Window* window) // Timers new StaticText(line, rect_t{}, STR_TIMER_LABEL); new DynamicText( - line, rect_t{}, [] { return getTimerString(timersStates[0].val); }, - COLOR_THEME_PRIMARY1); + line, rect_t{}, [] { return getTimerString(timersStates[0].val); }); new DynamicText( - line, rect_t{}, [] { return getTimerString(timersStates[1].val); }, - COLOR_THEME_PRIMARY1); + line, rect_t{}, [] { return getTimerString(timersStates[1].val); }); new DynamicText( - line, rect_t{}, [] { return getTimerString(timersStates[2].val); }, - COLOR_THEME_PRIMARY1); + line, rect_t{}, [] { return getTimerString(timersStates[2].val); }); line = window->newLine(grid); line->padAll(PAD_ZERO); @@ -269,11 +262,11 @@ void DebugViewPage::build(Window* window) new StaticText(line, rect_t{}, STR_TMIXMAXMS); new DynamicNumber( line, rect_t{}, [] { return DURATION_MS_PREC2(maxMixerDuration); }, - PREC2 | COLOR_THEME_PRIMARY1, nullptr, pad_STR_MS.c_str()); + COLOR_THEME_PRIMARY1_INDEX, PREC2, nullptr, pad_STR_MS.c_str()); new DynamicNumber( line, rect_t{}, [] { return getMixerSchedulerPeriod() / 1000; }, - COLOR_THEME_PRIMARY1, pad_STR_PERIOD.c_str(), pad_STR_MS.c_str()); + COLOR_THEME_PRIMARY1_INDEX, 0, pad_STR_PERIOD.c_str(), pad_STR_MS.c_str()); line = window->newLine(grid); line->padAll(PAD_TINY); @@ -282,7 +275,7 @@ void DebugViewPage::build(Window* window) static std::string pad_STR_BYTES = " " + std::string(STR_BYTES); new StaticText(line, rect_t{}, STR_FREE_MEM_LABEL); new DynamicNumber( - line, rect_t{}, [] { return availableMemory(); }, COLOR_THEME_PRIMARY1, + line, rect_t{}, [] { return availableMemory(); }, COLOR_THEME_PRIMARY1_INDEX, 0, nullptr, pad_STR_BYTES.c_str()); #if defined(LUA) @@ -380,8 +373,7 @@ void DebugViewPage::build(Window* window) line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT}, [] { return std::string(gpsData.fix ? STR_GPS_FIX_YES : STR_GPS_FIX_NO); - }, - COLOR_THEME_PRIMARY1); + }); new DebugInfoNumber( line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT}, [] { return gpsData.numSat; }, STR_GPS_SATS); diff --git a/radio/src/gui/colorlcd/widgets/gauge.cpp b/radio/src/gui/colorlcd/widgets/gauge.cpp index 7e15594fc7b..781cd5524e5 100644 --- a/radio/src/gui/colorlcd/widgets/gauge.cpp +++ b/radio/src/gui/colorlcd/widgets/gauge.cpp @@ -31,11 +31,11 @@ class GaugeWidget : public Widget { // Gauge label sourceText = new StaticText(this, {0, 0, LV_SIZE_CONTENT, 16}, "", - FONT(XS) | COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX, FONT(XS)); valueText = new DynamicNumber( this, {0, 0, lv_pct(100), 16}, [=]() { return getGuageValue(); }, - FONT(XS) | CENTERED | COLOR_THEME_PRIMARY2, "", "%"); + COLOR_THEME_PRIMARY2_INDEX, FONT(XS) | CENTERED, "", "%"); etx_obj_add_style(valueText->getLvObj(), styles->text_align_right, LV_STATE_USER_1); diff --git a/radio/src/gui/colorlcd/widgets/modelbmp.cpp b/radio/src/gui/colorlcd/widgets/modelbmp.cpp index 3df4952d9d3..504f958911f 100644 --- a/radio/src/gui/colorlcd/widgets/modelbmp.cpp +++ b/radio/src/gui/colorlcd/widgets/modelbmp.cpp @@ -118,7 +118,6 @@ class ModelBitmapWidget : public Widget protected: bool isLarge = false; - // std::unique_ptr buffer; uint32_t deps_hash = 0; StaticText* label = nullptr; StaticImage* image = nullptr; diff --git a/radio/src/gui/colorlcd/widgets/radio_info.cpp b/radio/src/gui/colorlcd/widgets/radio_info.cpp index 98291df2aa0..8e2e7cb89b7 100644 --- a/radio/src/gui/colorlcd/widgets/radio_info.cpp +++ b/radio/src/gui/colorlcd/widgets/radio_info.cpp @@ -44,24 +44,24 @@ class RadioInfoWidget : public TopBarWidget { // Logs logsIcon = new StaticIcon(this, W_LOG_X, W_LOG_Y, ICON_DOT, - COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX); logsIcon->hide(); usbIcon = new StaticIcon(this, W_USB_X, W_USB_Y, ICON_TOPMENU_USB, - COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX); usbIcon->hide(); #if defined(AUDIO) audioScale = new StaticIcon(this, W_AUDIO_SCALE_X, 2, ICON_TOPMENU_VOLUME_SCALE, - COLOR_THEME_PRIMARY3); + COLOR_THEME_PRIMARY3_INDEX); for (int i = 0; i < 5; i += 1) { audioVol[i] = new StaticIcon( this, W_AUDIO_X, 2, (EdgeTxIcon)(ICON_TOPMENU_VOLUME_0 + i), - COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX); audioVol[i]->hide(); } audioVol[0]->show(); @@ -69,18 +69,18 @@ class RadioInfoWidget : public TopBarWidget batteryIcon = new StaticIcon(this, W_AUDIO_X, W_BATT_Y, ICON_TOPMENU_TXBATT, - COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX); #if defined(USB_CHARGER) batteryChargeIcon = new StaticIcon( this, W_BATT_CHG_X, W_BATT_CHG_Y, - ICON_TOPMENU_TXBATT_CHARGE, COLOR_THEME_PRIMARY2); + ICON_TOPMENU_TXBATT_CHARGE, COLOR_THEME_PRIMARY2_INDEX); batteryChargeIcon->hide(); #endif #if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA) extAntenna = new StaticIcon(this, W_RSSI_X - 4, 1, ICON_TOPMENU_ANTENNA, - COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX); extAntenna->hide(); #endif @@ -280,11 +280,11 @@ class InternalGPSWidget : public TopBarWidget { icon = new StaticIcon(this, width() / 2 - 10, 19, - ICON_TOPMENU_GPS, COLOR_THEME_PRIMARY3); + ICON_TOPMENU_GPS, COLOR_THEME_PRIMARY3_INDEX); numSats = new DynamicNumber( this, {0, 1, width(), 12}, [=] { return gpsData.numSat; }, - COLOR_THEME_PRIMARY2 | CENTERED | FONT(XS)); + COLOR_THEME_PRIMARY2_INDEX, CENTERED | FONT(XS)); } void checkEvents() override diff --git a/radio/src/gui/colorlcd/widgets/timer.cpp b/radio/src/gui/colorlcd/widgets/timer.cpp index 07afe950949..887c28011bd 100644 --- a/radio/src/gui/colorlcd/widgets/timer.cpp +++ b/radio/src/gui/colorlcd/widgets/timer.cpp @@ -43,8 +43,8 @@ class TimerWidget : public Widget lv_style_set_width(&style, lv_pct(100)); lv_style_set_height(&style, LV_SIZE_CONTENT); - timerBg = new StaticIcon(this, 0, 0, ICON_TIMER_BG, COLOR_THEME_PRIMARY2); - timerIcon = new StaticIcon(this, 3, 4, ICON_TIMER, COLOR_THEME_SECONDARY1); + timerBg = new StaticIcon(this, 0, 0, ICON_TIMER_BG, COLOR_THEME_PRIMARY2_INDEX); + timerIcon = new StaticIcon(this, 3, 4, ICON_TIMER, COLOR_THEME_SECONDARY1_INDEX); // Timer name nameLabel = lv_label_create(lvobj); diff --git a/radio/src/lua/api_model.cpp b/radio/src/lua/api_model.cpp index d2b5622f921..acc14b943e3 100644 --- a/radio/src/lua/api_model.cpp +++ b/radio/src/lua/api_model.cpp @@ -555,9 +555,9 @@ static int luaModelSetFlightMode(lua_State * L) if (idx < 0 || idx >= max_trims) continue; int16_t val = luaL_checkinteger(L, -1); if (g_model.extendedTrims) - val = limit(val, TRIM_EXTENDED_MIN, TRIM_EXTENDED_MAX); + val = limit(TRIM_EXTENDED_MIN, val, TRIM_EXTENDED_MAX); else - val = limit(val, TRIM_MIN, TRIM_MAX); + val = limit(TRIM_MIN, val, TRIM_MAX); if (idx < max_trims) fm->trim[idx].value = val; } diff --git a/radio/src/lua/lua_widget.cpp b/radio/src/lua/lua_widget.cpp index ad7e1206c86..0ca43c7b0b9 100644 --- a/radio/src/lua/lua_widget.cpp +++ b/radio/src/lua/lua_widget.cpp @@ -200,13 +200,8 @@ void LuaWidget::redraw_cb(lv_event_t* e) } else { lv_draw_ctx_t* draw_ctx = lv_event_get_draw_ctx(e); - lv_area_t a, clipping, obj_coords; - lv_area_copy(&a, draw_ctx->buf_area); - lv_area_copy(&clipping, draw_ctx->clip_area); - lv_obj_get_coords(target, &obj_coords); - - auto w = a.x2 - a.x1 + 1; - auto h = a.y2 - a.y1 + 1; + auto w = draw_ctx->buf_area->x2 - draw_ctx->buf_area->x1 + 1; + auto h = draw_ctx->buf_area->y2 - draw_ctx->buf_area->y1 + 1; TRACE_WINDOWS("Draw %s", widget->getWindowDebugString().c_str()); @@ -215,10 +210,6 @@ void LuaWidget::redraw_cb(lv_event_t* e) buf.setDrawCtx(draw_ctx); - buf.setOffset(obj_coords.x1 - a.x1, obj_coords.y1 - a.y1); - buf.setClippingRect(clipping.x1 - a.x1, clipping.x2 + 1 - a.x1, - clipping.y1 - a.y1, clipping.y2 + 1 - a.y1); - widget->refresh(&buf); } } diff --git a/radio/src/storage/modelslist.h b/radio/src/storage/modelslist.h index 9866e49a5af..0a806286a8c 100644 --- a/radio/src/storage/modelslist.h +++ b/radio/src/storage/modelslist.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _MODELSLIST_H_ -#define _MODELSLIST_H_ +#pragma once #include @@ -281,5 +280,3 @@ ModelLabelsVector getUniqueLabels(); extern ModelsList modelslist; extern ModelMap modelslabels; - -#endif // _MODELSLIST_H_ diff --git a/radio/src/storage/sdcard_yaml.h b/radio/src/storage/sdcard_yaml.h index a6a461f1bba..301bf2c3acb 100644 --- a/radio/src/storage/sdcard_yaml.h +++ b/radio/src/storage/sdcard_yaml.h @@ -22,7 +22,8 @@ #pragma once enum class ChecksumResult {Success, Failed, None}; -#include "sdcard_common.h" // TODO CHECK REQUIRED + +struct YamlParserCalls; constexpr uint8_t MODELIDX_STRLEN = sizeof(MODEL_FILENAME_PREFIX "00"); @@ -32,3 +33,7 @@ const char * readModelYaml(const char * filename, uint8_t * buffer, uint32_t siz bool YamlFileChecksum(const YamlNode* root_node, uint8_t* data, uint16_t* checksum); void getModelNumberStr(uint8_t idx, char* model_idx); + +const char* readYamlFile(const char* fullpath, + const YamlParserCalls* calls, void* parser_ctx, + ChecksumResult* checksum_result); diff --git a/radio/src/storage/yaml/yaml_bits.h b/radio/src/storage/yaml/yaml_bits.h index de4d6a4e9d9..c223d88be1b 100644 --- a/radio/src/storage/yaml/yaml_bits.h +++ b/radio/src/storage/yaml/yaml_bits.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _yaml_bits_h_ -#define _yaml_bits_h_ +#pragma once #include @@ -45,5 +44,3 @@ char* yaml_unsigned2hex(uint32_t i); char* yaml_rgb2hex(uint32_t i); int32_t yaml_to_signed(uint32_t i, uint32_t bits); - -#endif diff --git a/radio/src/storage/yaml/yaml_datastructs.h b/radio/src/storage/yaml/yaml_datastructs.h index 5e245a0190e..4499e2796ed 100644 --- a/radio/src/storage/yaml/yaml_datastructs.h +++ b/radio/src/storage/yaml/yaml_datastructs.h @@ -19,13 +19,10 @@ * GNU General Public License for more details. */ -#ifndef _YAML_DATASTRUCTS_H_ -#define _YAML_DATASTRUCTS_H_ +#pragma once struct YamlNode; const YamlNode* get_radiodata_nodes(); const YamlNode* get_modeldata_nodes(); const YamlNode* get_partialmodel_nodes(); - -#endif diff --git a/radio/src/storage/yaml/yaml_defs.h b/radio/src/storage/yaml/yaml_defs.h index 0e0f6d04f91..8da891a0229 100644 --- a/radio/src/storage/yaml/yaml_defs.h +++ b/radio/src/storage/yaml/yaml_defs.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _YAML_DEFS_H_ -#define _YAML_DEFS_H_ +#pragma once #if defined(YAML_GENERATOR) @@ -71,5 +70,3 @@ #define CUST_IDX(tag, read, write) #endif - -#endif diff --git a/radio/src/storage/yaml/yaml_labelslist.h b/radio/src/storage/yaml/yaml_labelslist.h index 030fdfb8fb3..ecd6493c500 100644 --- a/radio/src/storage/yaml/yaml_labelslist.h +++ b/radio/src/storage/yaml/yaml_labelslist.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _YAML_LABELSLIST_H_ -#define _YAML_LABELSLIST_H_ +#pragma once #define MODULE_ID_STR "mod%did" #define MODULE_TYPE_STR "mod%dtype" @@ -30,5 +29,3 @@ struct YamlParserCalls; void* get_labelslist_iter(); const YamlParserCalls* get_labelslist_parser_calls(); - -#endif diff --git a/radio/src/storage/yaml/yaml_modelslist.h b/radio/src/storage/yaml/yaml_modelslist.h index 7614253eb73..e90f4cea276 100644 --- a/radio/src/storage/yaml/yaml_modelslist.h +++ b/radio/src/storage/yaml/yaml_modelslist.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _YAML_MODELSLIST_H_ -#define _YAML_MODELSLIST_H_ +#pragma once #include #include @@ -29,5 +28,3 @@ struct YamlParserCalls; void* get_modelslist_iter(std::vector* filelist); const YamlParserCalls* get_modelslist_parser_calls(); - -#endif \ No newline at end of file diff --git a/radio/src/storage/yaml/yaml_node.h b/radio/src/storage/yaml/yaml_node.h index afa14b08ff5..49b5647476c 100644 --- a/radio/src/storage/yaml/yaml_node.h +++ b/radio/src/storage/yaml/yaml_node.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _node_h_ -#define _node_h_ +#pragma once #include #include @@ -210,5 +209,3 @@ struct YamlNode { 0, YDT_ARRAY, 1, NULL, {{ (nodes), {{ NULL }}}} } #endif - -#endif diff --git a/radio/src/storage/yaml/yaml_parser.h b/radio/src/storage/yaml/yaml_parser.h index 39b32f2d874..bfc01116fc1 100644 --- a/radio/src/storage/yaml/yaml_parser.h +++ b/radio/src/storage/yaml/yaml_parser.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _yaml_parser_h_ -#define _yaml_parser_h_ +#pragma once #include @@ -102,5 +101,3 @@ class YamlParser void set_eof() { eof = true; } }; - -#endif diff --git a/radio/src/storage/yaml/yaml_tree_walker.h b/radio/src/storage/yaml/yaml_tree_walker.h index 369bc6f85fd..4dfed0e8345 100644 --- a/radio/src/storage/yaml/yaml_tree_walker.h +++ b/radio/src/storage/yaml/yaml_tree_walker.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _YAML_TREE_WALKER_H_ -#define _YAML_TREE_WALKER_H_ +#pragma once #include #include "yaml_node.h" @@ -168,6 +167,3 @@ class YamlTreeWalker // utils uint32_t yaml_parse_enum(const struct YamlIdStr* choices, const char* val, uint8_t val_len); const char* yaml_output_enum(int32_t i, const struct YamlIdStr* choices); - - -#endif diff --git a/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp b/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp index 503df0db6c3..1520216dba3 100644 --- a/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp +++ b/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp @@ -90,7 +90,7 @@ void BitmapBuffer::setData(uint16_t *d) void BitmapBuffer::clear(LcdFlags flags) { - drawSolidFilledRect(0, 0, _width - offsetX, _height - offsetY, flags); + drawSolidFilledRect(0, 0, _width, _height, flags); } void BitmapBuffer::clearClippingRect() @@ -119,10 +119,36 @@ void BitmapBuffer::getClippingRect(coord_t &xmin, coord_t &xmax, coord_t &ymin, ymax = this->ymax; } -void BitmapBuffer::setOffset(coord_t offsetX, coord_t offsetY) +bool BitmapBuffer::applyClippingRect(coord_t& x, coord_t& y, coord_t& w, + coord_t& h) const { - this->offsetX = offsetX; - this->offsetY = offsetY; + if (h < 0) { + y += h; + h = -h; + } + + if (w < 0) { + x += w; + w = -w; + } + + if (x >= xmax || y >= ymax) return false; + + if (y < ymin) { + h += y - ymin; + y = ymin; + } + + if (x < xmin) { + w += x - xmin; + x = xmin; + } + + if (y + h > ymax) h = ymax - y; + + if (x + w > xmax) w = xmax - x; + + return data && h > 0 && w > 0; } void BitmapBuffer::drawBitmap(coord_t x, coord_t y, const BitmapBuffer *bmp, @@ -130,7 +156,6 @@ void BitmapBuffer::drawBitmap(coord_t x, coord_t y, const BitmapBuffer *bmp, coord_t srch, float scale) { if (!data || !bmp) return; - APPLY_OFFSET(); if (x >= xmax || y >= ymax) return; coord_t bmpw = bmp->width(); @@ -182,7 +207,7 @@ void BitmapBuffer::drawBitmap(coord_t x, coord_t y, const BitmapBuffer *bmp, } if (scale == 0) { - if (bmp->getFormat() == BMP_ARGB4444) { + if (bmp->format == BMP_ARGB4444) { DMACopyAlphaBitmap(data, _width, _height, x, y, bmp->getData(), bmpw, bmph, srcx, srcy, srcw, srch); } else { @@ -211,11 +236,11 @@ void BitmapBuffer::drawBitmap(coord_t x, coord_t y, const BitmapBuffer *bmp, const pixel_t *q = qstart; MOVE_PIXEL_RIGHT(q, int(j / scale)); - if (bmp->getFormat() == BMP_RGB565) { + if (bmp->format == BMP_RGB565) { RGB_SPLIT(*q, r, g, b); drawPixel(p, ARGB_JOIN(0xF, r >> 1, g >> 2, b >> 1)); - } else { // bmp->getFormat() == BMP_ARGB4444 + } else { // bmp->format == BMP_ARGB4444 drawPixel(p, *q); } MOVE_TO_NEXT_RIGHT_PIXEL(p); @@ -232,9 +257,9 @@ void BitmapBuffer::drawBitmap(coord_t x, coord_t y, const BitmapBuffer *bmp, const pixel_t *q = qstart; MOVE_PIXEL_RIGHT(q, int(j / scale)); - if (bmp->getFormat() == BMP_RGB565) { + if (bmp->format == BMP_RGB565) { drawPixel(p, *q); - } else { // bmp->getFormat() == BMP_ARGB4444 + } else { // bmp->format == BMP_ARGB4444 ARGB_SPLIT(*q, a, r, g, b); drawAlphaPixel(p, a, RGB_JOIN(r << 1, g << 2, b << 1)); } @@ -267,8 +292,6 @@ void BitmapBuffer::drawHorizontalLine(coord_t x, coord_t y, coord_t w, { if (opacity == OPACITY_MAX) return; - APPLY_OFFSET(); - coord_t h = 1; if (!applyClippingRect(x, y, w, h)) return; @@ -320,8 +343,6 @@ void BitmapBuffer::drawVerticalLine(coord_t x, coord_t y, coord_t h, { if (opacity == OPACITY_MAX) return; - APPLY_OFFSET(); - coord_t w = 1; if (!applyClippingRect(x, y, w, h)) return; @@ -385,7 +406,6 @@ void BitmapBuffer::drawFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, { if (opacity == OPACITY_MAX) return; - APPLY_OFFSET(); if (!applyClippingRect(x, y, w, h)) return; if (SOLID != pat) { @@ -428,7 +448,6 @@ coord_t BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char *s, uint8_t len, LcdFlags flags) { if (!s) return x; - MOVE_OFFSET(); // LVGL does not handle non-null terminated strings static char buffer[256]; @@ -490,11 +509,9 @@ coord_t BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char *s, } #endif - RESTORE_OFFSET(); - pos += p.x; - return ((flags & RIGHT) ? orig_pos : pos) - offsetX; + return ((flags & RIGHT) ? orig_pos : pos); } // Resize and convert to LVGL image data format with alpha blending to diff --git a/radio/src/thirdparty/libopenui/src/bitmapbuffer.h b/radio/src/thirdparty/libopenui/src/bitmapbuffer.h index ff337723402..4fb056e9140 100644 --- a/radio/src/thirdparty/libopenui/src/bitmapbuffer.h +++ b/radio/src/thirdparty/libopenui/src/bitmapbuffer.h @@ -27,18 +27,6 @@ constexpr uint8_t SOLID = 0xFF; constexpr uint8_t DOTTED = 0x55; constexpr uint8_t STASHED = 0x33; -#define MOVE_OFFSET() \ - coord_t offsetX = this->offsetX; \ - x += offsetX; \ - this->offsetX = 0; \ - coord_t offsetY = this->offsetY; \ - y += offsetY; \ - this->offsetY = 0 -#define APPLY_OFFSET() \ - x += this->offsetX; \ - y += this->offsetY -#define RESTORE_OFFSET() this->offsetX = offsetX, this->offsetY = offsetY - #define MOVE_PIXEL_RIGHT(p, count) p += count #define MOVE_TO_NEXT_RIGHT_PIXEL(p) MOVE_PIXEL_RIGHT(p, 1) @@ -73,8 +61,6 @@ class BitmapBuffer inline void drawPixel(coord_t x, coord_t y, pixel_t value) { - APPLY_OFFSET(); - coord_t w = 1, h = 1; if (!applyClippingRect(x, y, w, h)) return; @@ -86,8 +72,6 @@ class BitmapBuffer inline void drawAlphaPixel(coord_t x, coord_t y, uint8_t opacity, pixel_t value) { - APPLY_OFFSET(); - coord_t w = 1, h = 1; if (!applyClippingRect(x, y, w, h)) return; @@ -118,35 +102,11 @@ class BitmapBuffer uint8_t pat = SOLID, LcdFlags flags = 0, uint8_t opacity = 0); - void invertRect(coord_t x, coord_t y, coord_t w, coord_t h, - LcdFlags flags = 0); - - void drawFilledTriangle(coord_t x1, coord_t y1, coord_t x2, coord_t y2, - coord_t x3, coord_t y3, LcdFlags flags = 0, - uint8_t opacity = 0); - - void drawCircle(coord_t x, coord_t y, coord_t radius, LcdFlags flags = 0, coord_t thickness = 1); - - void drawFilledCircle(coord_t x, coord_t y, coord_t radius, - LcdFlags flags = 0); - - void drawAnnulusSector(coord_t x, coord_t y, coord_t internalRadius, - coord_t externalRadius, int startAngle, int endAngle, - LcdFlags flags = 0); - - void drawBitmapPatternPie(coord_t x0, coord_t y0, const MaskBitmap* img, - LcdFlags flags, int startAngle, int endAngle); - static BitmapBuffer* loadBitmap(const char* filename, BitmapFormats fmt = BMP_INVALID); void resizeToLVGL(coord_t w, coord_t h); - MaskBitmap* to8bitMask(size_t* size) const; - - void drawBitmapPattern(coord_t x, coord_t y, const MaskBitmap* bmp, - LcdFlags flags, coord_t offset = 0, coord_t width = 0); - coord_t drawSizedText(coord_t x, coord_t y, const char* s, uint8_t len, LcdFlags flags = 0); @@ -156,60 +116,61 @@ class BitmapBuffer return drawSizedText(x, y, s, strlen(s), flags); } - coord_t drawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags = 0, - uint8_t len = 0, const char* prefix = nullptr, - const char* suffix = nullptr); - void drawBitmap(coord_t x, coord_t y, const BitmapBuffer* bmp, coord_t srcx = 0, coord_t srcy = 0, coord_t srcw = 0, coord_t srch = 0, float scale = 0); - void drawScaledBitmap(const BitmapBuffer* bitmap, coord_t x, coord_t y, - coord_t w, coord_t h); - - void drawTextLines(coord_t left, coord_t top, coord_t width, coord_t height, - const char* str, LcdFlags flags); - - void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags flags = 0); - - coord_t drawSwitch(coord_t x, coord_t y, int32_t idx, LcdFlags flags = 0); - - void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags flags = 0); - - void drawSensorCustomValue(coord_t x, coord_t y, uint8_t sensor, - int32_t value, LcdFlags flags = 0); - void clearClippingRect(); - void setClippingRect(coord_t xmin, coord_t xmax, coord_t ymin, coord_t ymax); - - void getClippingRect(coord_t& xmin, coord_t& xmax, coord_t& ymin, - coord_t& ymax); - - void setOffset(coord_t offsetX, coord_t offsetY); - - inline void clearOffset() { setOffset(0, 0); } - inline void reset() { - clearOffset(); clearClippingRect(); } - coord_t getOffsetX() const { return offsetX; } - - coord_t getOffsetY() const { return offsetY; } - - inline uint8_t getFormat() const { return format; } - inline uint16_t width() const { return _width; } - inline uint16_t height() const { return _height; } inline pixel_t* getData() const { return data; } uint32_t getDataSize() const { return _width * _height * sizeof(pixel_t); } + // Lua API functions + void setClippingRect(coord_t xmin, coord_t xmax, coord_t ymin, coord_t ymax); + void getClippingRect(coord_t& xmin, coord_t& xmax, coord_t& ymin, + coord_t& ymax); + + MaskBitmap* to8bitMask(size_t* size) const; + + void invertRect(coord_t x, coord_t y, coord_t w, coord_t h, + LcdFlags flags = 0); + + void drawFilledTriangle(coord_t x1, coord_t y1, coord_t x2, coord_t y2, + coord_t x3, coord_t y3, LcdFlags flags = 0, + uint8_t opacity = 0); + void drawCircle(coord_t x, coord_t y, coord_t radius, LcdFlags flags = 0, coord_t thickness = 1); + void drawFilledCircle(coord_t x, coord_t y, coord_t radius, + LcdFlags flags = 0); + void drawAnnulusSector(coord_t x, coord_t y, coord_t internalRadius, + coord_t externalRadius, int startAngle, int endAngle, + LcdFlags flags = 0); + + void drawBitmapPatternPie(coord_t x0, coord_t y0, const MaskBitmap* img, + LcdFlags flags, int startAngle, int endAngle); + void drawBitmapPattern(coord_t x, coord_t y, const MaskBitmap* bmp, + LcdFlags flags, coord_t offset = 0, coord_t width = 0); + void drawScaledBitmap(const BitmapBuffer* bitmap, coord_t x, coord_t y, + coord_t w, coord_t h); + coord_t drawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags = 0, + uint8_t len = 0, const char* prefix = nullptr, + const char* suffix = nullptr); + void drawTextLines(coord_t left, coord_t top, coord_t width, coord_t height, + const char* str, LcdFlags flags); + void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags flags = 0); + void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags flags = 0); + coord_t drawSwitch(coord_t x, coord_t y, int32_t idx, LcdFlags flags = 0); + void drawSensorCustomValue(coord_t x, coord_t y, uint8_t sensor, + int32_t value, LcdFlags flags = 0); + protected: void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags flags = 0); @@ -223,37 +184,8 @@ class BitmapBuffer void drawDate(coord_t x, coord_t y, TelemetryItem& telemetryItem, LcdFlags att); - inline bool applyClippingRect(coord_t& x, coord_t& y, coord_t& w, - coord_t& h) const - { - if (h < 0) { - y += h; - h = -h; - } - - if (w < 0) { - x += w; - w = -w; - } - - if (x >= xmax || y >= ymax) return false; - - if (y < ymin) { - h += y - ymin; - y = ymin; - } - - if (x < xmin) { - w += x - xmin; - x = xmin; - } - - if (y + h > ymax) h = ymax - y; - - if (x + w > xmax) w = xmax - x; - - return data && h > 0 && w > 0; - } + bool applyClippingRect(coord_t& x, coord_t& y, coord_t& w, + coord_t& h) const; inline void drawPixel(pixel_t* p, pixel_t value) { @@ -290,8 +222,6 @@ class BitmapBuffer coord_t xmax; coord_t ymin = 0; coord_t ymax; - coord_t offsetX = 0; - coord_t offsetY = 0; pixel_t* data; pixel_t* data_end; diff --git a/radio/src/thirdparty/libopenui/src/bitmapbuffer_draw_extra.cpp b/radio/src/thirdparty/libopenui/src/bitmapbuffer_draw_extra.cpp index b51de4934d6..8dc20cbd790 100644 --- a/radio/src/thirdparty/libopenui/src/bitmapbuffer_draw_extra.cpp +++ b/radio/src/thirdparty/libopenui/src/bitmapbuffer_draw_extra.cpp @@ -32,8 +32,6 @@ void BitmapBuffer::invertRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags flags) { - APPLY_OFFSET(); - if (!applyClippingRect(x, y, w, h)) return; // No 'opacity' here, only 'color' @@ -333,12 +331,6 @@ bool BitmapBuffer::liangBarskyClipper(coord_t &x1, coord_t &y1, coord_t &x2, void BitmapBuffer::drawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags flags) { - // Offsets - x1 += offsetX; - y1 += offsetY; - x2 += offsetX; - y2 += offsetY; - if (!liangBarskyClipper(x1, y1, x2, y2)) return; // TODO; Replace with LVGL line draw - currently does not support dotted line drawing @@ -493,8 +485,6 @@ void BitmapBuffer::drawFilledTriangle(coord_t x0, coord_t y0, coord_t x1, void BitmapBuffer::drawFilledCircle(coord_t x, coord_t y, coord_t radius, LcdFlags flags) { - APPLY_OFFSET(); - lv_draw_rect_dsc_t rect_dsc; lv_draw_rect_dsc_init(&rect_dsc); rect_dsc.bg_opa = LV_OPA_COVER; @@ -527,8 +517,6 @@ void BitmapBuffer::drawFilledCircle(coord_t x, coord_t y, coord_t radius, void BitmapBuffer::drawCircle(coord_t x, coord_t y, coord_t radius, LcdFlags flags, coord_t thickness) { - APPLY_OFFSET(); - lv_draw_rect_dsc_t rect_dsc; lv_draw_rect_dsc_init(&rect_dsc); rect_dsc.bg_opa = LV_OPA_TRANSP; @@ -690,8 +678,6 @@ void BitmapBuffer::drawAnnulusSector(coord_t x, coord_t y, coord_t externalRadius, int startAngle, int endAngle, LcdFlags flags) { - APPLY_OFFSET(); - if (endAngle == startAngle) endAngle += 1; @@ -731,7 +717,7 @@ MaskBitmap *BitmapBuffer::to8bitMask(size_t *size) const const pixel_t *p = getPixelPtrAbs(0, 0); int ofs = 0; - if (getFormat() == BMP_ARGB4444) { + if (format == BMP_ARGB4444) { for (int i = width() * height(); i > 0; i--) { ARGB_SPLIT(*p, a __attribute__((unused)), r, g, b); int v = (r + g + b) / 3; @@ -760,8 +746,6 @@ void BitmapBuffer::drawBitmapPattern(coord_t x, coord_t y, const MaskBitmap *bmp LcdFlags flags, coord_t offset, coord_t width) { - APPLY_OFFSET(); - coord_t bmpw = bmp->width; coord_t bmph = bmp->height; diff --git a/radio/src/thirdparty/libopenui/src/button.cpp b/radio/src/thirdparty/libopenui/src/button.cpp index 48fa22391be..75bd2d794ba 100644 --- a/radio/src/thirdparty/libopenui/src/button.cpp +++ b/radio/src/thirdparty/libopenui/src/button.cpp @@ -54,8 +54,7 @@ Button::Button(Window* parent, const rect_t& rect, ButtonBase::ButtonBase(Window* parent, const rect_t& rect, std::function pressHandler, LvglCreate objConstruct) : - FormField(parent, rect, 0, - objConstruct ? objConstruct : lv_btn_create), + FormField(parent, rect, objConstruct ? objConstruct : lv_btn_create), pressHandler(std::move(pressHandler)) { } @@ -113,7 +112,7 @@ IconButton::IconButton(Window* parent, EdgeTxIcon icon, coord_t x, coord_t y, ButtonBase(parent, {x, y, 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 = new StaticIcon(this, 0, 0, icon, COLOR_THEME_SECONDARY1_INDEX); iconImage->center(EdgeTxStyles::UI_ELEMENT_HEIGHT - 4, EdgeTxStyles::UI_ELEMENT_HEIGHT - 4); } diff --git a/radio/src/thirdparty/libopenui/src/button_matrix.cpp b/radio/src/thirdparty/libopenui/src/button_matrix.cpp index ea1687619d0..9b50750f2db 100644 --- a/radio/src/thirdparty/libopenui/src/button_matrix.cpp +++ b/radio/src/thirdparty/libopenui/src/button_matrix.cpp @@ -77,7 +77,7 @@ static void btn_matrix_event(lv_event_t* e) } ButtonMatrix::ButtonMatrix(Window* parent, const rect_t& r) : - FormField(parent, r, 0, btnmatrix_create) + FormField(parent, r, btnmatrix_create) { lv_obj_add_flag(lvobj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); diff --git a/radio/src/thirdparty/libopenui/src/choice.cpp b/radio/src/thirdparty/libopenui/src/choice.cpp index 93fc45c9ed5..947a72c76ba 100644 --- a/radio/src/thirdparty/libopenui/src/choice.cpp +++ b/radio/src/thirdparty/libopenui/src/choice.cpp @@ -65,7 +65,7 @@ ChoiceBase::ChoiceBase(Window* parent, const rect_t& rect, std::function _getValue, std::function _setValue, ChoiceType type) : - FormField(parent, rect, 0, choice_create), + FormField(parent, rect, choice_create), vmin(vmin), vmax(vmax), menuTitle(title), _getValue(std::move(_getValue)), _setValue(std::move(_setValue)) diff --git a/radio/src/thirdparty/libopenui/src/dialog.cpp b/radio/src/thirdparty/libopenui/src/dialog.cpp index 3298509e611..627e215ff67 100644 --- a/radio/src/thirdparty/libopenui/src/dialog.cpp +++ b/radio/src/thirdparty/libopenui/src/dialog.cpp @@ -51,7 +51,7 @@ BaseDialog::BaseDialog(Window* parent, const char* title, etx_solid_bg(content->getLvObj()); lv_obj_center(content->getLvObj()); - header = new StaticText(content, {0, 0, LV_PCT(100), 0}, title ? title : "", COLOR_THEME_PRIMARY2); + header = new StaticText(content, {0, 0, LV_PCT(100), 0}, title ? title : "", COLOR_THEME_PRIMARY2_INDEX); etx_solid_bg(header->getLvObj(), COLOR_THEME_SECONDARY1_INDEX); header->padAll(PAD_SMALL); header->show(title != nullptr); @@ -102,11 +102,11 @@ MessageDialog::MessageDialog(Window* parent, const char* title, BaseDialog(parent, title, true) { messageWidget = new StaticText(form, {0, 0, LV_PCT(100), LV_SIZE_CONTENT}, - message, messageFlags); + message, COLOR_THEME_PRIMARY1_INDEX, messageFlags); if (info) { infoWidget = new StaticText(form, {0, 0, LV_PCT(100), LV_SIZE_CONTENT}, - info, infoFlags); + info, COLOR_THEME_PRIMARY1_INDEX, infoFlags); } } @@ -116,14 +116,14 @@ void MessageDialog::onClicked() { deleteLater(); } DynamicMessageDialog::DynamicMessageDialog( Window* parent, const char* title, std::function textHandler, - const char* message, const int lineHeight, const LcdFlags textFlags) : + const char* message, const int lineHeight, LcdColorIndex color, LcdFlags textFlags) : BaseDialog(parent, title, true) { messageWidget = new StaticText(form, {0, 0, LV_PCT(100), LV_SIZE_CONTENT}, - message, CENTERED | COLOR_THEME_PRIMARY1); + message, COLOR_THEME_PRIMARY1_INDEX, CENTERED); infoWidget = new DynamicText(form, {0, 0, LV_PCT(100), LV_SIZE_CONTENT}, - textHandler, textFlags); + textHandler, color, textFlags); } void DynamicMessageDialog::onClicked() { deleteLater(); } @@ -139,7 +139,7 @@ ConfirmDialog::ConfirmDialog(Window* parent, const char* title, cancelHandler(std::move(cancelHandler)) { if (message) { - new StaticText(form, {0, 0, LV_PCT(100), 0}, message, CENTERED); + new StaticText(form, {0, 0, LV_PCT(100), 0}, message, COLOR_THEME_PRIMARY1_INDEX, CENTERED); } auto box = new Window(form, rect_t{}); @@ -185,7 +185,7 @@ LabelDialog::LabelDialog(Window *parent, const char *label, int length, const ch lv_obj_center(form->getLvObj()); auto hdr = new StaticText(form, {0, 0, LV_PCT(100), 0}, title, - COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX); etx_solid_bg(hdr->getLvObj(), COLOR_THEME_SECONDARY1_INDEX); hdr->padAll(PAD_MEDIUM); diff --git a/radio/src/thirdparty/libopenui/src/dialog.h b/radio/src/thirdparty/libopenui/src/dialog.h index d8ef6021235..abd90c646df 100644 --- a/radio/src/thirdparty/libopenui/src/dialog.h +++ b/radio/src/thirdparty/libopenui/src/dialog.h @@ -98,7 +98,7 @@ class DynamicMessageDialog : public BaseDialog std::function textHandler, const char* message = "", const int lineHeight = EdgeTxStyles::PAGE_LINE_HEIGHT, - const LcdFlags textFlags = CENTERED); + LcdColorIndex color = COLOR_THEME_PRIMARY1_INDEX, LcdFlags textFlags = CENTERED); // Attn.: FONT(XXL) is not supported by DynamicMessageDialog protected: diff --git a/radio/src/thirdparty/libopenui/src/form.cpp b/radio/src/thirdparty/libopenui/src/form.cpp index e6791bfea72..8150169ee68 100644 --- a/radio/src/thirdparty/libopenui/src/form.cpp +++ b/radio/src/thirdparty/libopenui/src/form.cpp @@ -39,8 +39,7 @@ void FlexGridLayout::add(Window* w) } } -FormField::FormField(Window* parent, const rect_t& rect, LcdFlags textFlags, - LvglCreate objConstruct) : +FormField::FormField(Window* parent, const rect_t& rect, LvglCreate objConstruct) : Window(parent, rect, objConstruct) { setTextFlag(textFlags); diff --git a/radio/src/thirdparty/libopenui/src/form.h b/radio/src/thirdparty/libopenui/src/form.h index 850547e4aad..e672e1f3f6e 100644 --- a/radio/src/thirdparty/libopenui/src/form.h +++ b/radio/src/thirdparty/libopenui/src/form.h @@ -77,8 +77,7 @@ class FlexGridLayout class FormField : public Window { public: - FormField(Window* parent, const rect_t& rect, LcdFlags textFlags = 0, - LvglCreate objConstruct = nullptr); + FormField(Window* parent, const rect_t& rect, LvglCreate objConstruct = nullptr); virtual void changeEnd(bool forceChanged = false) { diff --git a/radio/src/thirdparty/libopenui/src/menu.cpp b/radio/src/thirdparty/libopenui/src/menu.cpp index 32ba0a776a3..d4440b6da0a 100644 --- a/radio/src/thirdparty/libopenui/src/menu.cpp +++ b/radio/src/thirdparty/libopenui/src/menu.cpp @@ -327,7 +327,7 @@ class MenuWindowContent : public Window setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO, MENUS_WIDTH, LV_SIZE_CONTENT); header = new StaticText(this, {0, 0, LV_PCT(100), 0}, "", - COLOR_THEME_PRIMARY2); + COLOR_THEME_PRIMARY2_INDEX); etx_solid_bg(header->getLvObj(), COLOR_THEME_SECONDARY1_INDEX); header->padAll(PAD_SMALL); header->hide(); diff --git a/radio/src/thirdparty/libopenui/src/numberedit.cpp b/radio/src/thirdparty/libopenui/src/numberedit.cpp index 10ca0249bc8..2070118579d 100644 --- a/radio/src/thirdparty/libopenui/src/numberedit.cpp +++ b/radio/src/thirdparty/libopenui/src/numberedit.cpp @@ -26,21 +26,16 @@ class NumberArea : public FormField { public: - NumberArea(Window* parent, const rect_t& rect, int vmin, int vmax, - std::function getValue, - std::function setValue = nullptr, - LcdFlags textFlags = 0) : - FormField(parent, rect, textFlags, etx_textarea_create), - vmin(vmin), - vmax(vmax), - _getValue(std::move(getValue)), - _setValue(std::move(setValue)) + NumberArea(NumberEdit* parent, const rect_t& rect) : + FormField(parent, rect, etx_textarea_create), + numEdit(parent) { - if (rect.w == 0) setWidth(DEF_W); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); - etx_obj_add_style(lvobj, styles->text_align_right, LV_PART_MAIN); + if (parent->getTextFlags() & CENTERED) + etx_obj_add_style(lvobj, styles->text_align_center, LV_PART_MAIN); + else + etx_obj_add_style(lvobj, styles->text_align_right, LV_PART_MAIN); // Allow encoder acceleration lv_obj_add_flag(lvobj, LV_OBJ_FLAG_ENCODER_ACCEL); @@ -71,45 +66,44 @@ class NumberArea : public FormField event); if (editMode) { + int value = numEdit->getValue(); switch (event) { #if defined(HARDWARE_KEYS) case EVT_ROTARY_RIGHT: { - int value = getValue(); - auto step = vstep; - step += (rotaryEncoderGetAccel() * accelFactor) / 8; + auto step = numEdit->step; + step += (rotaryEncoderGetAccel() * numEdit->accelFactor) / 8; do { #if defined(USE_HATS_AS_KEYS) value -= step; #else value += step; #endif - } while (isValueAvailable && !isValueAvailable(value) && - value <= vmax); - if (value <= vmax) { - setValue(value); + } while (numEdit->isValueAvailable && !numEdit->isValueAvailable(value) && + value <= numEdit->vmax); + if (value <= numEdit->vmax) { + numEdit->setValue(value); } else { - setValue(vmax); + numEdit->setValue(numEdit->vmax); onKeyError(); } return; } case EVT_ROTARY_LEFT: { - int value = getValue(); - auto step = vstep; - step += (rotaryEncoderGetAccel() * accelFactor) / 8; + auto step = numEdit->step; + step += (rotaryEncoderGetAccel() * numEdit->accelFactor) / 8; do { #if defined(USE_HATS_AS_KEYS) value += step; #else value -= step; #endif - } while (isValueAvailable && !isValueAvailable(value) && - value >= vmin); - if (value >= vmin) { - setValue(value); + } while (numEdit->isValueAvailable && !numEdit->isValueAvailable(value) && + value >= numEdit->vmin); + if (value >= numEdit->vmin) { + numEdit->setValue(value); } else { - setValue(vmin); + numEdit->setValue(numEdit->vmin); onKeyError(); } return; @@ -117,35 +111,35 @@ class NumberArea : public FormField #endif case EVT_VIRTUAL_KEY_PLUS: - setValue(getValue() + vstep); + numEdit->setValue(value + numEdit->step); break; case EVT_VIRTUAL_KEY_MINUS: - setValue(getValue() - vstep); + numEdit->setValue(value - numEdit->step); break; case EVT_VIRTUAL_KEY_FORWARD: - setValue(getValue() + fastStep * vstep); + numEdit->setValue(value + numEdit->fastStep * numEdit->step); break; case EVT_VIRTUAL_KEY_BACKWARD: - setValue(getValue() - fastStep * vstep); + numEdit->setValue(value - numEdit->fastStep * numEdit->step); break; case EVT_VIRTUAL_KEY_DEFAULT: - setValue(vdefault); + numEdit->setValue(numEdit->vdefault); break; case EVT_VIRTUAL_KEY_MAX: - setValue(vmax); + numEdit->setValue(numEdit->vmax); break; case EVT_VIRTUAL_KEY_MIN: - setValue(vmin); + numEdit->setValue(numEdit->vmin); break; case EVT_VIRTUAL_KEY_SIGN: - setValue(-getValue()); + numEdit->setValue(-value); break; } } @@ -164,108 +158,21 @@ class NumberArea : public FormField } } - void setMin(int value) { vmin = value; } - void setMax(int value) { vmax = value; } - void setDefault(int value) { vdefault = value; } - void setStep(int value) { vstep = value; } - void setFastStep(int value) { fastStep = value; } - void setAccelFactor(int value) { accelFactor = value; } - void setValue(int value) - { - auto newValue = limit(vmin, value, vmax); - if (newValue != currentValue) { - currentValue = newValue; - if (_setValue != nullptr) { - _setValue(currentValue); - } - } - updateDisplay(); - } - - int32_t getValue() const { return _getValue != nullptr ? _getValue() : 0; } - - void setPrefix(std::string value) { prefix = std::move(value); } - - void setSuffix(std::string value) { suffix = std::move(value); } - - void setZeroText(std::string value) { zeroText = std::move(value); } - - void setAvailableHandler(std::function handler) - { - isValueAvailable = std::move(handler); - } - - void setSetValueHandler(std::function handler) - { - _setValue = std::move(handler); - } - - void setGetValueHandler(std::function handler) - { - _getValue = std::move(handler); - } - - void setDisplayHandler(std::function function) - { - displayFunction = std::move(function); - } - - void setCancelHandler(std::function handler) - { - cancelHandler = std::move(handler); - } - void openKeyboard() { NumberKeyboard::show(this); } void directEdit() { FormField::onClicked(); } void update() { - if (_getValue == nullptr) return; - currentValue = _getValue(); - updateDisplay(); + if (lvobj != nullptr) + lv_textarea_set_text(lvobj, numEdit->getDisplayVal().c_str()); } - static LAYOUT_VAL(DEF_W, 100, 100) - protected: - int vdefault = 0; - int vmin; - int vmax; - int vstep = 1; - int fastStep = 10; - int accelFactor = 4; - int currentValue; - std::string prefix; - std::string suffix; - std::string zeroText; - std::function _getValue; - std::function _setValue; - std::function displayFunction; - std::function isValueAvailable; - std::function cancelHandler = nullptr; - - void updateDisplay() - { - if (lvobj != nullptr) { - std::string str; - if (displayFunction != nullptr) { - str = displayFunction(currentValue); - } else if (!zeroText.empty() && currentValue == 0) { - str = zeroText; - } else { - str = formatNumberAsString(currentValue, textFlags, 0, prefix.c_str(), - suffix.c_str()); - } - lv_textarea_set_text(lvobj, str.c_str()); - } - } + NumberEdit* numEdit = nullptr; void onCancel() override { - if (cancelHandler) - cancelHandler(); - else - FormField::onCancel(); + onClicked(); } static void numberedit_cb(lv_event_t* e) @@ -304,7 +211,7 @@ NumberEdit::NumberEdit(Window* parent, const rect_t& rect, int vmin, int vmax, vmin(vmin), vmax(vmax) { - if (rect.w == 0) setWidth(NumberArea::DEF_W); + if (rect.w == 0) setWidth(DEF_W); setTextFlag(textFlags); @@ -323,32 +230,14 @@ void NumberEdit::openEdit() edit = new NumberArea( this, {-(PAD_MEDIUM + 2), -(PAD_TINY + 2), - lv_obj_get_width(lvobj), lv_obj_get_height(lvobj)}, - this->vmin, this->vmax, _getValue, _setValue, textFlags); + lv_obj_get_width(lvobj), lv_obj_get_height(lvobj)}); edit->setChangeHandler([=]() { update(); if (edit->hasFocus()) lv_group_focus_obj(lvobj); edit->hide(); }); - edit->setCancelHandler([=]() { - edit->onClicked(); - }); } - edit->setTextFlag(textFlags); - edit->setSetValueHandler(_setValue); - edit->setGetValueHandler(_getValue); - edit->setAvailableHandler(isValueAvailable); - edit->setDisplayHandler(displayFunction); - edit->setDefault(vdefault); - edit->setMin(vmin); - edit->setMax(vmax); - edit->setStep(step); - edit->setFastStep(fastStep); - edit->setAccelFactor(accelFactor); - edit->setPrefix(prefix); - edit->setSuffix(suffix); - edit->setZeroText(zeroText); edit->update(); edit->show(); lv_group_focus_obj(edit->getLvObj()); @@ -369,7 +258,7 @@ void NumberEdit::update() updateDisplay(); } -void NumberEdit::updateDisplay() +std::string NumberEdit::getDisplayVal() { std::string str; if (displayFunction != nullptr) { @@ -380,7 +269,12 @@ void NumberEdit::updateDisplay() str = formatNumberAsString(currentValue, textFlags, 0, prefix.c_str(), suffix.c_str()); } - setText(str); + return str; +} + +void NumberEdit::updateDisplay() +{ + setText(getDisplayVal()); } void NumberEdit::setValue(int value) @@ -393,5 +287,5 @@ void NumberEdit::setValue(int value) } } updateDisplay(); - if (edit) edit->setValue(value); + if (edit) edit->update(); } diff --git a/radio/src/thirdparty/libopenui/src/numberedit.h b/radio/src/thirdparty/libopenui/src/numberedit.h index da7ca7da78a..4596850454f 100644 --- a/radio/src/thirdparty/libopenui/src/numberedit.h +++ b/radio/src/thirdparty/libopenui/src/numberedit.h @@ -91,7 +91,11 @@ class NumberEdit : public TextButton int32_t getValue() const { return _getValue != nullptr ? _getValue() : 0; } + static LAYOUT_VAL(DEF_W, 100, 100) + protected: + friend class NumberArea; + NumberArea* edit = nullptr; std::function _getValue; std::function _setValue; @@ -108,6 +112,8 @@ class NumberEdit : public TextButton std::function displayFunction; std::function isValueAvailable; + std::string getDisplayVal(); + void updateDisplay(); void openEdit(); }; diff --git a/radio/src/thirdparty/libopenui/src/slider.cpp b/radio/src/thirdparty/libopenui/src/slider.cpp index 5fb13945adc..9fa55c3b3f4 100644 --- a/radio/src/thirdparty/libopenui/src/slider.cpp +++ b/radio/src/thirdparty/libopenui/src/slider.cpp @@ -92,7 +92,7 @@ Slider::Slider(Window* parent, coord_t width, int32_t vmin, int32_t vmax, padLeft(8); padRight(8); - slider = (new FormField(this, rect_t{}, 0, slider_create))->getLvObj(); + slider = (new FormField(this, rect_t{}, slider_create))->getLvObj(); lv_obj_set_width(slider, lv_pct(100)); lv_obj_add_event_cb(slider, slider_changed_cb, LV_EVENT_VALUE_CHANGED, this); diff --git a/radio/src/thirdparty/libopenui/src/static.cpp b/radio/src/thirdparty/libopenui/src/static.cpp index f3c559b385b..b3c43a65dd2 100644 --- a/radio/src/thirdparty/libopenui/src/static.cpp +++ b/radio/src/thirdparty/libopenui/src/static.cpp @@ -26,7 +26,7 @@ //----------------------------------------------------------------------------- StaticText::StaticText(Window* parent, const rect_t& rect, std::string txt, - LcdFlags textFlags) : + LcdColorIndex color, LcdFlags textFlags) : Window(parent, rect, lv_label_create), text(std::move(txt)) { setTextFlag(textFlags); @@ -34,7 +34,7 @@ StaticText::StaticText(Window* parent, const rect_t& rect, std::string txt, lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); etx_font(lvobj, FONT_INDEX(textFlags)); - etx_txt_color(lvobj, indexFromColor(textFlags)); + etx_txt_color(lvobj, color); if (textFlags & CENTERED) etx_obj_add_style(lvobj, styles->text_align_center, LV_PART_MAIN); @@ -144,9 +144,9 @@ void DynamicNumber::updateText() //----------------------------------------------------------------------------- StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, EdgeTxIcon icon, - LcdFlags color) : + LcdColorIndex color) : Window(parent, rect_t{x, y, 0, 0}, lv_canvas_create), - currentColor(indexFromColor(color)) + currentColor(color) { setWindowFlag(NO_FOCUS); @@ -158,9 +158,9 @@ StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, EdgeTxIcon icon, } StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, const char* filename, - LcdFlags color) : + LcdColorIndex color) : Window(parent, rect_t{x, y, 0, 0}, lv_canvas_create), - currentColor(indexFromColor(color)) + currentColor(color) { setWindowFlag(NO_FOCUS); diff --git a/radio/src/thirdparty/libopenui/src/static.h b/radio/src/thirdparty/libopenui/src/static.h index 1ff63925e67..58b333440ea 100644 --- a/radio/src/thirdparty/libopenui/src/static.h +++ b/radio/src/thirdparty/libopenui/src/static.h @@ -30,7 +30,7 @@ class StaticText : public Window { public: StaticText(Window *parent, const rect_t &rect, std::string text = "", - LcdFlags textFlags = COLOR_THEME_PRIMARY1); + LcdColorIndex color = COLOR_THEME_PRIMARY1_INDEX, LcdFlags textFlags = 0); #if defined(DEBUG_WINDOWS) std::string getName() const override; @@ -44,7 +44,7 @@ class StaticText : public Window }; #define Subtitle(parent, text) \ - StaticText(parent, rect_t{}, text, COLOR_THEME_PRIMARY1 | FONT(BOLD)) + StaticText(parent, rect_t{}, text, COLOR_THEME_PRIMARY1_INDEX, FONT(BOLD)) //----------------------------------------------------------------------------- @@ -53,8 +53,8 @@ class DynamicText : public StaticText public: DynamicText(Window *parent, const rect_t &rect, std::function textHandler, - LcdFlags textFlags = COLOR_THEME_PRIMARY1) : - StaticText(parent, rect, "", textFlags), + LcdColorIndex color = COLOR_THEME_PRIMARY1_INDEX, LcdFlags textFlags = 0) : + StaticText(parent, rect, "", color, textFlags), textHandler(std::move(textHandler)) { } @@ -75,9 +75,9 @@ class DynamicNumber : public StaticText public: DynamicNumber(Window *parent, const rect_t &rect, std::function numberHandler, - LcdFlags textFlags = COLOR_THEME_PRIMARY1, + LcdColorIndex color = COLOR_THEME_PRIMARY1_INDEX, LcdFlags textFlags = 0, const char *prefix = nullptr, const char *suffix = nullptr) : - StaticText(parent, rect, "", textFlags), + StaticText(parent, rect, "", color, textFlags), numberHandler(std::move(numberHandler)), prefix(prefix), suffix(suffix) @@ -122,9 +122,9 @@ class StaticIcon : public Window { public: StaticIcon(Window *parent, coord_t x, coord_t y, EdgeTxIcon icon, - LcdFlags color); + LcdColorIndex color); StaticIcon(Window *parent, coord_t x, coord_t y, const char* filename, - LcdFlags color); + LcdColorIndex color); void deleteLater(bool detach = true, bool trash = true) override; diff --git a/radio/src/thirdparty/libopenui/src/textedit.cpp b/radio/src/thirdparty/libopenui/src/textedit.cpp index 92e8becd71a..95710f173cc 100644 --- a/radio/src/thirdparty/libopenui/src/textedit.cpp +++ b/radio/src/thirdparty/libopenui/src/textedit.cpp @@ -31,15 +31,13 @@ class TextArea : public FormField { public: TextArea(Window* parent, const rect_t& rect, char* value, uint8_t length) : - FormField(parent, rect, 0, etx_textarea_create), value(value), length(length) + FormField(parent, rect, etx_textarea_create), value(value), length(length) { lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); lv_textarea_set_max_length(lvobj, length); lv_textarea_set_placeholder_text(lvobj, "---"); - if (rect.w == 0) setWidth(DEF_W); - update(); } @@ -67,8 +65,6 @@ class TextArea : public FormField cancelHandler = std::move(handler); } - static LAYOUT_VAL(DEF_W, 100, 100) - protected: char* value; uint8_t length; @@ -127,7 +123,7 @@ TextEdit::TextEdit(Window* parent, const rect_t& rect, char* text, }), updateHandler(updateHandler), text(text), length(length) { - if (rect.w == 0) setWidth(TextArea::DEF_W); + if (rect.w == 0) setWidth(DEF_W); update(); lv_obj_align(label, LV_ALIGN_OUT_LEFT_MID, 0, PAD_TINY); diff --git a/radio/src/thirdparty/libopenui/src/toggleswitch.cpp b/radio/src/thirdparty/libopenui/src/toggleswitch.cpp index a90c9773e63..336ac47f79b 100644 --- a/radio/src/thirdparty/libopenui/src/toggleswitch.cpp +++ b/radio/src/thirdparty/libopenui/src/toggleswitch.cpp @@ -77,7 +77,7 @@ static void toggleswitch_event_handler(lv_event_t* e) ToggleSwitch::ToggleSwitch(Window* parent, const rect_t& rect, std::function getValue, std::function setValue) : - FormField(parent, rect, 0, switch_create), + FormField(parent, rect, switch_create), _getValue(std::move(getValue)), _setValue(std::move(setValue)) { diff --git a/radio/src/thirdparty/libopenui/src/window.cpp b/radio/src/thirdparty/libopenui/src/window.cpp index 66007a88542..dbd25d8a7e3 100644 --- a/radio/src/thirdparty/libopenui/src/window.cpp +++ b/radio/src/thirdparty/libopenui/src/window.cpp @@ -528,7 +528,7 @@ SetupLine::SetupLine(Window* parent, coord_t y, coord_t col2, PaddingSize paddin createEdit(this, col2, editY); } else { setHeight(h); - new StaticText(this, {0, titleY, 0, titleH}, title, COLOR_THEME_PRIMARY1 | FONT(BOLD)); + new StaticText(this, {0, titleY, 0, titleH}, title, COLOR_THEME_PRIMARY1_INDEX, FONT(BOLD)); } } diff --git a/radio/src/thirdparty/libopenui/src/window.h b/radio/src/thirdparty/libopenui/src/window.h index a08cef77490..ae9f069abea 100644 --- a/radio/src/thirdparty/libopenui/src/window.h +++ b/radio/src/thirdparty/libopenui/src/window.h @@ -67,6 +67,7 @@ class Window void setTextFlag(LcdFlags flag); void clearTextFlag(LcdFlags flag); + LcdFlags getTextFlags() const { return textFlags; } typedef std::function CloseHandler; void setCloseHandler(CloseHandler h) { closeHandler = std::move(h); }