diff --git a/radio/src/boards/jumper-h750/board.cpp b/radio/src/boards/jumper-h750/board.cpp index ced92f564..80c077da7 100644 --- a/radio/src/boards/jumper-h750/board.cpp +++ b/radio/src/boards/jumper-h750/board.cpp @@ -46,14 +46,11 @@ #include "globals.h" #include "sdcard.h" #include "debug.h" +#include "keys.h" #include "flysky_gimbal_driver.h" #include "timers_driver.h" -#include "bitmapbuffer.h" -#include "colors.h" - - #include "touch_driver.h" #include diff --git a/radio/src/boards/rm-h750/board.cpp b/radio/src/boards/rm-h750/board.cpp index 1085e16e9..51e019501 100644 --- a/radio/src/boards/rm-h750/board.cpp +++ b/radio/src/boards/rm-h750/board.cpp @@ -48,13 +48,11 @@ #include "globals.h" #include "sdcard.h" #include "debug.h" +#include "keys.h" #include "flysky_gimbal_driver.h" #include "timers_driver.h" -#include "bitmapbuffer.h" -#include "colors.h" - #include "touch_driver.h" #include diff --git a/radio/src/edgetx.cpp b/radio/src/edgetx.cpp index c80c60fc9..dc450fdbf 100644 --- a/radio/src/edgetx.cpp +++ b/radio/src/edgetx.cpp @@ -55,13 +55,10 @@ #if defined(COLORLCD) #include "radio_calibration.h" - #include "view_main.h" #include "view_text.h" #include "theme_manager.h" #include "switch_warn_dialog.h" #include "startup_shutdown.h" - - #include "LvglWrapper.h" #endif #if defined(CROSSFIRE) @@ -1421,11 +1418,7 @@ void edgeTxInit() if (!(startOptions & OPENTX_START_NO_SPLASH)) startSplash(); -#if defined(COLORLCD) - initLvglTheme(); - // create ViewMain - ViewMain::instance(); -#elif defined(GUI) +#if !defined(COLORLCD) // TODO add a function for this (duplicated) menuHandlers[0] = menuMainView; menuHandlers[1] = menuModelSelect; diff --git a/radio/src/edgetx.h b/radio/src/edgetx.h index f5044fb35..295c9dea1 100644 --- a/radio/src/edgetx.h +++ b/radio/src/edgetx.h @@ -38,9 +38,7 @@ #include "usbd_msc_conf.h" #endif -#if defined(COLORLCD) - #include "libopenui.h" -#else +#if !defined(COLORLCD) #include "lib_file.h" #endif diff --git a/radio/src/gui/colorlcd/LvglWrapper.cpp b/radio/src/gui/colorlcd/LvglWrapper.cpp index f169abdba..348d359cc 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.cpp +++ b/radio/src/gui/colorlcd/LvglWrapper.cpp @@ -19,15 +19,15 @@ * GNU General Public License for more details. */ -#include "edgetx.h" -#include "hal/rotary_encoder.h" -#include "os/time.h" - #include "LvglWrapper.h" -#include "etx_lv_theme.h" -#include "view_main.h" +#include "edgetx.h" +#include "etx_lv_theme.h" +#include "hal/rotary_encoder.h" #include "keyboard_base.h" +#include "mainwindow.h" +#include "os/time.h" +#include "view_main.h" LvglWrapper* LvglWrapper::_instance = nullptr; @@ -144,7 +144,7 @@ static void keyboardDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data) // no focused item ? auto obj = get_focus_obj(keyboardDevice); if (!obj) { - auto w = Layer::back(); + auto w = Window::topWindow(); dispatch_kb_event(w, evt); backup_kb_data(data); return; @@ -323,11 +323,13 @@ static void init_lvgl_drivers() keyboardDevice = lv_indev_drv_register(&keyboard_drv); } -void initLvglTheme() +LvglWrapper::LvglWrapper() { + init_lvgl_drivers(); + static lv_theme_t theme; - /* Initialize the ETX theme */ + /* Initialize default theme */ theme.disp = NULL; theme.color_primary = lv_palette_main(LV_PALETTE_BLUE); theme.color_secondary = lv_palette_main(LV_PALETTE_RED); @@ -338,18 +340,17 @@ void initLvglTheme() /* Assign the theme to the current display*/ lv_disp_set_theme(NULL, &theme); -} - -LvglWrapper::LvglWrapper() -{ - init_lvgl_drivers(); + // Integrate STB image handling into lvgl extern void lv_stb_init(); lv_stb_init(); // Create main window and load that screen auto window = MainWindow::instance(); - window->setActiveScreen(); + lv_scr_load(window->getLvObj()); + + // create ViewMain window + ViewMain::instance(); } LvglWrapper* LvglWrapper::instance() @@ -360,26 +361,22 @@ LvglWrapper* LvglWrapper::instance() void LvglWrapper::run() { -#if defined(SIMU) - static uint32_t last_tick = 0; - uint32_t tick = time_get_ms(); - lv_tick_inc(tick - last_tick); - last_tick = tick; -#endif - lv_timer_handler(); -} + // Detect nested calls + static bool updating = false; -void LvglWrapper::runNested() -{ - // Manual refresh - lv_refr_now(nullptr); - pollInputs(); -} + if (!updating) { + // Normal UI loop - call lgvl timer handler + updating = true; + lv_timer_handler(); + updating = false; + } else { + // Used when running the loop manually from within + // the LVGL timer handler (blocking UI code) + lv_refr_now(nullptr); -void LvglWrapper::pollInputs() -{ - lv_indev_t* indev = nullptr; - while((indev = lv_indev_get_next(indev)) != nullptr) { - lv_indev_read_timer_cb(indev->driver->read_timer); + lv_indev_t* indev = nullptr; + while((indev = lv_indev_get_next(indev)) != nullptr) { + lv_indev_read_timer_cb(indev->driver->read_timer); + } } } diff --git a/radio/src/gui/colorlcd/LvglWrapper.h b/radio/src/gui/colorlcd/LvglWrapper.h index b65732bd7..05cb6a4b5 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.h +++ b/radio/src/gui/colorlcd/LvglWrapper.h @@ -21,31 +21,19 @@ #pragma once -#include -#include "edgetx_types.h" - -void initLvglTheme(); - -typedef std::function LvObjConstructor; +#include "lvgl/lvgl.h" class LvglWrapper { - static LvglWrapper *_instance; - static void pollInputs(); - - LvglWrapper(); - ~LvglWrapper() {} - public: static LvglWrapper* instance(); // Called from UI task: executes the LVGL timer handler void run(); - // Call it when running the loop manually from within - // the LVGL timer handler (blocking UI code) - static void runNested(); -}; + protected: + static LvglWrapper *_instance; -// multiplication factor between 0 and 25 -int8_t rotaryEncoderGetAccel(); + LvglWrapper(); + ~LvglWrapper() {} +}; diff --git a/radio/src/gui/colorlcd/controls/channel_bar.cpp b/radio/src/gui/colorlcd/controls/channel_bar.cpp index 4c38acb99..35d43098c 100644 --- a/radio/src/gui/colorlcd/controls/channel_bar.cpp +++ b/radio/src/gui/colorlcd/controls/channel_bar.cpp @@ -23,6 +23,7 @@ #include "bitmaps.h" #include "etx_lv_theme.h" +#include "static.h" #define VIEW_CHANNELS_LIMIT_PCT \ (g_model.extendedLimits ? LIMIT_EXT_PERCENT : LIMIT_STD_PERCENT) @@ -35,7 +36,7 @@ ChannelBar::ChannelBar(Window* parent, const rect_t& rect, uint8_t channel, Window(parent, rect), channel(channel), getValue(std::move(getValueFunc)) { - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_CLICK); etx_solid_bg(lvobj, COLOR_THEME_PRIMARY2_INDEX); @@ -241,14 +242,14 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect, char chanString[10]; char* s = strAppend(chanString, STR_CH); strAppendSigned(s, channel + 1); - new StaticText(this, {PAD_TINY + invMask->width, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, chanString, + new StaticText(this, {PAD_TINY + invMask->width, 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, {PAD_TINY + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm, + new StaticText(this, {PAD_TINY + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm, txtColIdx, FONT(XS) | LEFT); } diff --git a/radio/src/gui/colorlcd/controls/channel_bar.h b/radio/src/gui/colorlcd/controls/channel_bar.h index 3c8df14d2..e46bc54fa 100644 --- a/radio/src/gui/colorlcd/controls/channel_bar.h +++ b/radio/src/gui/colorlcd/controls/channel_bar.h @@ -22,6 +22,9 @@ #pragma once #include "edgetx.h" +#include "window.h" + +class StaticIcon; class ChannelBar : public Window { diff --git a/radio/src/gui/colorlcd/controls/channel_range.cpp b/radio/src/gui/colorlcd/controls/channel_range.cpp index 5530d1eff..883d596a6 100644 --- a/radio/src/gui/colorlcd/controls/channel_range.cpp +++ b/radio/src/gui/colorlcd/controls/channel_range.cpp @@ -22,6 +22,8 @@ #include "channel_range.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "numberedit.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/controls/color_editor.cpp b/radio/src/gui/colorlcd/controls/color_editor.cpp index fc1c9ff3d..8449bfa18 100644 --- a/radio/src/gui/colorlcd/controls/color_editor.cpp +++ b/radio/src/gui/colorlcd/controls/color_editor.cpp @@ -23,6 +23,7 @@ #include "button.h" #include "etx_lv_theme.h" +#include "hal/rotary_encoder.h" static const char* const RGBChars[MAX_BARS] = {"R", "G", "B"}; static const char* const HSVChars[MAX_BARS] = {"H", "S", "V"}; @@ -477,7 +478,7 @@ ColorEditor::ColorEditor(Window* parent, const rect_t& rect, uint32_t color, lv_obj_add_event_cb(lvobj, ColorEditor::value_changed, LV_EVENT_VALUE_CHANGED, nullptr); - if (_preview) _preview(_color); + if (_preview) _preview(_color); } void ColorEditor::setColorEditorType(COLOR_EDITOR_TYPE colorType) diff --git a/radio/src/gui/colorlcd/controls/color_picker.cpp b/radio/src/gui/colorlcd/controls/color_picker.cpp index fd0fe0d0c..5f24e554b 100644 --- a/radio/src/gui/colorlcd/controls/color_picker.cpp +++ b/radio/src/gui/colorlcd/controls/color_picker.cpp @@ -22,6 +22,7 @@ #include "color_picker.h" #include "color_list.h" +#include "dialog.h" #include "etx_lv_theme.h" #if LANDSCAPE diff --git a/radio/src/gui/colorlcd/controls/curve.cpp b/radio/src/gui/colorlcd/controls/curve.cpp index 124d14724..45f49d76f 100644 --- a/radio/src/gui/colorlcd/controls/curve.cpp +++ b/radio/src/gui/colorlcd/controls/curve.cpp @@ -23,6 +23,7 @@ #include "bitmaps.h" #include "edgetx.h" +#include "static.h" #include "strhelpers.h" //----------------------------------------------------------------------------- @@ -130,9 +131,7 @@ Curve::Curve(Window* parent, const rect_t& rect, valueFunc(std::move(function)), positionFunc(std::move(position)) { - setWindowFlag(NO_FOCUS); - - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_FOCUS | NO_CLICK); etx_solid_bg(lvobj, COLOR_THEME_PRIMARY2_INDEX); diff --git a/radio/src/gui/colorlcd/controls/curve_param.cpp b/radio/src/gui/colorlcd/controls/curve_param.cpp index f32c89c4d..c6b83475b 100644 --- a/radio/src/gui/colorlcd/controls/curve_param.cpp +++ b/radio/src/gui/colorlcd/controls/curve_param.cpp @@ -21,14 +21,15 @@ #include "curve_param.h" -#include "gvar_numberedit.h" -#include "source_numberedit.h" -#include "model_curves.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "gvar_numberedit.h" +#include "model_curves.h" +#include "source_numberedit.h" #define SET_DIRTY() storageDirty(EE_MODEL) -CurveChoice::CurveChoice(Window* parent, std::function getRefValue, +CurveChoice::CurveChoice(Window* parent, std::function getRefValue, std::function setRefValue, std::function refreshView, mixsrc_t source) : Choice(parent, rect_t{}, -MAX_CURVES, MAX_CURVES, getRefValue, setRefValue), source(source), refreshView(std::move(refreshView)) @@ -86,7 +87,7 @@ CurveParam::CurveParam(Window* parent, const rect_t& rect, CurveRef* ref, }); // CURVE_REF_CUSTOM - cust_choice = new CurveChoice(this, + cust_choice = new CurveChoice(this, [=]() { SourceNumVal v; v.rawValue = ref->value; diff --git a/radio/src/gui/colorlcd/controls/gvar_numberedit.cpp b/radio/src/gui/colorlcd/controls/gvar_numberedit.cpp index 13c76e53f..4fac9bed3 100644 --- a/radio/src/gui/colorlcd/controls/gvar_numberedit.cpp +++ b/radio/src/gui/colorlcd/controls/gvar_numberedit.cpp @@ -31,11 +31,11 @@ GVarNumberEdit::GVarNumberEdit(Window* parent, int32_t vmin, vmax(vmax), getValue(getValue), setValue(setValue), - textFlags(textFlags), voffset(voffset) { + setTextFlag(textFlags); padAll(PAD_TINY); - + // GVAR field gvar_field = new Choice( this, {0, 0, EdgeTxStyles::EDIT_FLD_WIDTH_NARROW, 0}, -MAX_GVARS, MAX_GVARS - 1, @@ -103,7 +103,7 @@ void GVarNumberEdit::update() gvar_field->hide(); num_field->hide(); - + int32_t value = getValue(); if (GV_IS_GV_VALUE(value)) { // GVAR mode diff --git a/radio/src/gui/colorlcd/controls/gvar_numberedit.h b/radio/src/gui/colorlcd/controls/gvar_numberedit.h index 2a11d584e..0190e49b0 100644 --- a/radio/src/gui/colorlcd/controls/gvar_numberedit.h +++ b/radio/src/gui/colorlcd/controls/gvar_numberedit.h @@ -56,7 +56,6 @@ class GVarNumberEdit : public Window int32_t vmax; std::function getValue; std::function setValue; - LcdFlags textFlags; int32_t voffset; void onEvent(event_t event) override; diff --git a/radio/src/gui/colorlcd/controls/input_source.cpp b/radio/src/gui/colorlcd/controls/input_source.cpp index db547d6a7..fb79c8ed2 100644 --- a/radio/src/gui/colorlcd/controls/input_source.cpp +++ b/radio/src/gui/colorlcd/controls/input_source.cpp @@ -22,7 +22,10 @@ #include "input_source.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "numberedit.h" #include "sourcechoice.h" +#include "static.h" #include "switchchoice.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/controls/source_numberedit.cpp b/radio/src/gui/colorlcd/controls/source_numberedit.cpp index 32f28dc73..e2a674b09 100644 --- a/radio/src/gui/colorlcd/controls/source_numberedit.cpp +++ b/radio/src/gui/colorlcd/controls/source_numberedit.cpp @@ -37,9 +37,10 @@ SourceNumberEdit::SourceNumberEdit(Window* parent, sourceMin(sourceMin), getValue(getValue), setValue(setValue), - textFlags(textFlags), voffset(voffset) { + setTextFlag(textFlags); + padAll(PAD_TINY); lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_ROW_WRAP); lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0); diff --git a/radio/src/gui/colorlcd/controls/source_numberedit.h b/radio/src/gui/colorlcd/controls/source_numberedit.h index 0d4533940..0f7efd409 100644 --- a/radio/src/gui/colorlcd/controls/source_numberedit.h +++ b/radio/src/gui/colorlcd/controls/source_numberedit.h @@ -58,7 +58,6 @@ class SourceNumberEdit : public Window int16_t sourceMin; std::function getValue; std::function setValue; - LcdFlags textFlags; int32_t voffset; bool isSource(); diff --git a/radio/src/gui/colorlcd/controls/switch_warn_dialog.cpp b/radio/src/gui/colorlcd/controls/switch_warn_dialog.cpp index 8ac372ee2..d00afa167 100644 --- a/radio/src/gui/colorlcd/controls/switch_warn_dialog.cpp +++ b/radio/src/gui/colorlcd/controls/switch_warn_dialog.cpp @@ -21,6 +21,7 @@ #include "switch_warn_dialog.h" +#include "static.h" #include "switches.h" SwitchWarnDialog::SwitchWarnDialog() : diff --git a/radio/src/gui/colorlcd/fonts.cpp b/radio/src/gui/colorlcd/fonts.cpp index 3d9f2c7f2..d187b33e9 100644 --- a/radio/src/gui/colorlcd/fonts.cpp +++ b/radio/src/gui/colorlcd/fonts.cpp @@ -27,7 +27,6 @@ #include "fonts.h" #include "lz4/lz4.h" -#include "libopenui_defines.h" #include "lz4_fonts.h" #include "translations/tts/tts.h" diff --git a/radio/src/gui/colorlcd/libui/bitmapbuffer.h b/radio/src/gui/colorlcd/libui/bitmapbuffer.h index 0d9f2ca08..3eccce8a8 100644 --- a/radio/src/gui/colorlcd/libui/bitmapbuffer.h +++ b/radio/src/gui/colorlcd/libui/bitmapbuffer.h @@ -18,7 +18,11 @@ #pragma once -#include "libopenui_defines.h" +#include "colors.h" + +#if defined(DEBUG) +#include "debug.h" +#endif struct MaskBitmap; class TelemetryItem; diff --git a/radio/src/gui/colorlcd/libui/bitmapbuffer_fileio.cpp b/radio/src/gui/colorlcd/libui/bitmapbuffer_fileio.cpp index dddf7a1bf..bcbbbfe3e 100644 --- a/radio/src/gui/colorlcd/libui/bitmapbuffer_fileio.cpp +++ b/radio/src/gui/colorlcd/libui/bitmapbuffer_fileio.cpp @@ -21,6 +21,7 @@ #include "bitmapbuffer.h" #include "lib_file.h" #include "edgetx_helpers.h" +#include "debug.h" FIL imgFile __DMA; diff --git a/radio/src/gui/colorlcd/libui/button.h b/radio/src/gui/colorlcd/libui/button.h index 8fc2fd62c..3527a389c 100644 --- a/radio/src/gui/colorlcd/libui/button.h +++ b/radio/src/gui/colorlcd/libui/button.h @@ -119,7 +119,7 @@ class IconButton : public ButtonBase public: IconButton(Window* parent, EdgeTxIcon icon, coord_t x, coord_t y, std::function pressHandler = nullptr); - + void setIcon(EdgeTxIcon icon); protected: diff --git a/radio/src/gui/colorlcd/libui/button_matrix.cpp b/radio/src/gui/colorlcd/libui/button_matrix.cpp index c6190b062..6722fbd17 100644 --- a/radio/src/gui/colorlcd/libui/button_matrix.cpp +++ b/radio/src/gui/colorlcd/libui/button_matrix.cpp @@ -81,7 +81,7 @@ ButtonMatrix::ButtonMatrix(Window* parent, const rect_t& r) : 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); + setWindowFlag(NO_FOCUS); lv_obj_add_event_cb(lvobj, btn_matrix_event, LV_EVENT_VALUE_CHANGED, this); } diff --git a/radio/src/gui/colorlcd/libui/dialog.cpp b/radio/src/gui/colorlcd/libui/dialog.cpp index 29f3863de..be5ec9265 100644 --- a/radio/src/gui/colorlcd/libui/dialog.cpp +++ b/radio/src/gui/colorlcd/libui/dialog.cpp @@ -19,10 +19,12 @@ #include "dialog.h" #include "edgetx.h" -#include "mainwindow.h" -#include "progress.h" #include "etx_lv_theme.h" #include "keyboard_base.h" +#include "mainwindow.h" +#include "progress.h" +#include "static.h" +#include "textedit.h" //----------------------------------------------------------------------------- diff --git a/radio/src/gui/colorlcd/libui/etx_lv_theme.h b/radio/src/gui/colorlcd/libui/etx_lv_theme.h index f559aca53..c1c69ef45 100644 --- a/radio/src/gui/colorlcd/libui/etx_lv_theme.h +++ b/radio/src/gui/colorlcd/libui/etx_lv_theme.h @@ -271,7 +271,7 @@ class EdgeTxStyles static const lv_style_t border_transparent; static const lv_style_t border_thin; static const lv_style_t outline; - + EdgeTxStyles(); void init(); diff --git a/radio/src/gui/colorlcd/libui/file_browser.cpp b/radio/src/gui/colorlcd/libui/file_browser.cpp index 394b65582..82656e9c0 100644 --- a/radio/src/gui/colorlcd/libui/file_browser.cpp +++ b/radio/src/gui/colorlcd/libui/file_browser.cpp @@ -197,7 +197,7 @@ void FileBrowser::onSelected(uint16_t row, uint16_t col) void FileBrowser::onPress(uint16_t row, uint16_t col) { bool is_dir = lv_table_has_cell_ctrl(lvobj, row, col, CELL_CTRL_DIR); - onPress(lv_table_get_cell_value(lvobj, row, col), is_dir); + onPress(lv_table_get_cell_value(lvobj, row, col), is_dir); } void FileBrowser::onDrawBegin(uint16_t row, uint16_t col, lv_obj_draw_part_dsc_t* dsc) @@ -245,7 +245,7 @@ void FileBrowser::onSelected(const char* name, bool is_dir) } const char* path = getCurrentPath(); - const char* fullpath = getFullPath(name); + const char* fullpath = getFullPath(name); if (fileSelected) fileSelected(path, name, fullpath, is_dir); selected = name; } @@ -253,7 +253,7 @@ void FileBrowser::onSelected(const char* name, bool is_dir) void FileBrowser::onPress(const char* name, bool is_dir) { const char* path = getCurrentPath(); - const char* fullpath = getFullPath(name); + const char* fullpath = getFullPath(name); if (is_dir) { f_chdir(fullpath); if (fileSelected) fileSelected(nullptr, nullptr, nullptr, is_dir); @@ -266,7 +266,7 @@ void FileBrowser::onPress(const char* name, bool is_dir) onSelected(name, is_dir); return; } - + if (fileAction){ fileAction(path, name, fullpath, is_dir); } @@ -275,12 +275,12 @@ void FileBrowser::onPress(const char* name, bool is_dir) void FileBrowser::onPressLong(const char* name, bool is_dir) { const char* path = getCurrentPath(); - const char* fullpath = getFullPath(name); + const char* fullpath = getFullPath(name); if (!selected || (selected != name)) { onSelected(name, is_dir); } - + if (fileAction){ fileAction(path, name, fullpath, is_dir); } diff --git a/radio/src/gui/colorlcd/libui/file_carosell.cpp b/radio/src/gui/colorlcd/libui/file_carosell.cpp index 2b749abe2..71d7312f7 100644 --- a/radio/src/gui/colorlcd/libui/file_carosell.cpp +++ b/radio/src/gui/colorlcd/libui/file_carosell.cpp @@ -22,6 +22,7 @@ #include "file_carosell.h" #include "translations/translations.h" +#include "timers_driver.h" extern inline tmr10ms_t getTicks() { @@ -58,7 +59,7 @@ void FileCarosell::setSelected(int n) } else fp->setFile(""); } - + message->show(selected == -1); if (selected == -1) message->setText(_fileNames.size() > 0 ? STR_LOADING : STR_NO_THEME_IMAGE); diff --git a/radio/src/gui/colorlcd/libui/filechoice.cpp b/radio/src/gui/colorlcd/libui/filechoice.cpp index 39f4efbc6..61bf98cdc 100644 --- a/radio/src/gui/colorlcd/libui/filechoice.cpp +++ b/radio/src/gui/colorlcd/libui/filechoice.cpp @@ -20,6 +20,7 @@ #include +#include "dialog.h" #include "edgetx.h" #include "lib_file.h" #include "menu.h" diff --git a/radio/src/gui/colorlcd/libui/form.cpp b/radio/src/gui/colorlcd/libui/form.cpp index 1f8ac49d7..576258658 100644 --- a/radio/src/gui/colorlcd/libui/form.cpp +++ b/radio/src/gui/colorlcd/libui/form.cpp @@ -73,10 +73,12 @@ void FormField::onCancel() } } -void FormField::deleteLater(bool detach, bool trash) +void FormField::deleteLater() { + if (_deleted) return; + if (isEditMode()) setEditMode(false); - Window::deleteLater(detach, trash); + Window::deleteLater(); } FormLine::FormLine(Window* parent, FlexGridLayout& layout) : diff --git a/radio/src/gui/colorlcd/libui/form.h b/radio/src/gui/colorlcd/libui/form.h index d7dc3498c..6b16915b7 100644 --- a/radio/src/gui/colorlcd/libui/form.h +++ b/radio/src/gui/colorlcd/libui/form.h @@ -95,7 +95,7 @@ class FormField : public Window void onClicked() override; void onCancel() override; - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; protected: bool editMode = false; diff --git a/radio/src/gui/colorlcd/libui/fullscreen_dialog.cpp b/radio/src/gui/colorlcd/libui/fullscreen_dialog.cpp index d4df80d13..037053c5b 100644 --- a/radio/src/gui/colorlcd/libui/fullscreen_dialog.cpp +++ b/radio/src/gui/colorlcd/libui/fullscreen_dialog.cpp @@ -21,13 +21,13 @@ #include "fullscreen_dialog.h" -#include "LvglWrapper.h" -#include "mainwindow.h" #include "edgetx.h" #include "etx_lv_theme.h" -#include "os/sleep.h" -#include "view_main.h" #include "hal/watchdog_driver.h" +#include "mainwindow.h" +#include "os/sleep.h" +#include "static.h" +#include "view_main.h" FullScreenDialog::FullScreenDialog( uint8_t type, std::string title, std::string message, std::string action, @@ -47,8 +47,6 @@ FullScreenDialog::FullScreenDialog( pushLayer(); - bringToTop(); - build(); } @@ -150,12 +148,14 @@ void FullScreenDialog::checkEvents() } } -void FullScreenDialog::deleteLater(bool detach, bool trash) +void FullScreenDialog::deleteLater() { + if (_deleted) return; + if (running) { running = false; } else { - Window::deleteLater(detach, trash); + Window::deleteLater(); } } @@ -164,16 +164,6 @@ void FullScreenDialog::setMessage(const char* text) if (messageLabel) messageLabel->setText(text); } -static void run_ui_manually() -{ - checkBacklight(); - WDG_RESET(); - - sleep_ms(10); - LvglWrapper::runNested(); - MainWindow::instance()->run(false); -} - void FullScreenDialog::runForever(bool checkPwr) { running = true; @@ -199,7 +189,11 @@ void FullScreenDialog::runForever(bool checkPwr) } } - run_ui_manually(); + checkBacklight(); + WDG_RESET(); + + MainWindow::instance()->run(); + sleep_ms(10); } deleteLater(); diff --git a/radio/src/gui/colorlcd/libui/fullscreen_dialog.h b/radio/src/gui/colorlcd/libui/fullscreen_dialog.h index 77ad51e2b..7b7f54a4b 100644 --- a/radio/src/gui/colorlcd/libui/fullscreen_dialog.h +++ b/radio/src/gui/colorlcd/libui/fullscreen_dialog.h @@ -45,7 +45,7 @@ class FullScreenDialog : public Window void onCancel() override; bool onLongPress() override; - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; void checkEvents() override; diff --git a/radio/src/gui/colorlcd/libui/keyboard_base.cpp b/radio/src/gui/colorlcd/libui/keyboard_base.cpp index 07e4c31ab..e6af3eb07 100644 --- a/radio/src/gui/colorlcd/libui/keyboard_base.cpp +++ b/radio/src/gui/colorlcd/libui/keyboard_base.cpp @@ -21,6 +21,8 @@ #include "form.h" #include "mainwindow.h" #include "etx_lv_theme.h" +#include "debug.h" +#include "keys.h" static void keyboard_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) { @@ -71,16 +73,6 @@ static void keyboard_event_cb(lv_event_t* e) static void field_focus_leave(lv_event_t* e) { Keyboard::hide(false); } -static void _assign_lv_group(lv_group_t* g) -{ - // associate it with all input devices - lv_indev_t* indev = lv_indev_get_next(NULL); - while (indev) { - lv_indev_set_group(indev, g); - indev = lv_indev_get_next(indev); - } -} - Keyboard::Keyboard(coord_t height) : NavWindow(MainWindow::instance(), {0, LCD_H - height, LCD_W, height}) { @@ -138,7 +130,7 @@ void Keyboard::clearField(bool wasCancelled) field = nullptr; if (fieldGroup) { - _assign_lv_group(fieldGroup); + assignLvGroup(fieldGroup, false); lv_group_set_editing(fieldGroup, false); fieldGroup = nullptr; } @@ -147,7 +139,7 @@ void Keyboard::clearField(bool wasCancelled) void Keyboard::hide(bool wasCancelled) { - if (activeKeyboard) { + if (activeKeyboard && !activeKeyboard->_deleted) { activeKeyboard->clearField(wasCancelled); lv_obj_add_flag(activeKeyboard->lvobj, LV_OBJ_FLAG_HIDDEN); activeKeyboard = nullptr; @@ -189,7 +181,7 @@ void Keyboard::setField(FormField* newField) lv_keyboard_set_textarea(keyboard, obj); lv_obj_add_event_cb(obj, field_focus_leave, LV_EVENT_DEFOCUSED, nullptr); - _assign_lv_group(group); + assignLvGroup(group, false); field = newField; fieldGroup = (lv_group_t*)lv_obj_get_group(obj); diff --git a/radio/src/gui/colorlcd/libui/keyboard_number.cpp b/radio/src/gui/colorlcd/libui/keyboard_number.cpp index de9efde63..8f525a391 100644 --- a/radio/src/gui/colorlcd/libui/keyboard_number.cpp +++ b/radio/src/gui/colorlcd/libui/keyboard_number.cpp @@ -19,6 +19,7 @@ #include "keyboard_number.h" #include "numberedit.h" +#include "keys.h" constexpr coord_t KEYBOARD_HEIGHT = 90; NumberKeyboard* NumberKeyboard::_instance = nullptr; diff --git a/radio/src/gui/colorlcd/libui/layer.cpp b/radio/src/gui/colorlcd/libui/layer.cpp deleted file mode 100644 index f9f3ff706..000000000 --- a/radio/src/gui/colorlcd/libui/layer.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * libopenui - https://github.com/opentx/libopenui - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "layer.h" - -std::list Layer::stack; - -Layer::Layer(Window* w, lv_group_t* g, lv_group_t* pg) : window(w), group(g), prevGroup(pg) {} -Layer::~Layer() { lv_group_del(group); } - -void _assign_lv_group(lv_group_t* g) -{ - lv_group_set_default(g); - - // associate it with all input devices - lv_indev_t* indev = lv_indev_get_next(NULL); - while (indev) { - lv_indev_set_group(indev, g); - indev = lv_indev_get_next(indev); - } -} - -void Layer::push(Window* w) -{ - // save prev group - auto pg = lv_group_get_default(); - - // create a new group - auto g = lv_group_create(); - _assign_lv_group(g); - - // and store - stack.emplace_back(w, g, pg); -} - -void Layer::pop(Window* w) -{ - if (stack.empty()) return; - - if (back() == w) { - lv_group_t* prevGroup = stack.back().prevGroup; - if (prevGroup) { - _assign_lv_group(prevGroup); - } else if (!stack.empty()) { - _assign_lv_group(stack.back().group); - } else { - lv_group_set_default(NULL); - } - stack.pop_back(); - } else { - for (auto layer = stack.crbegin(); layer != stack.crend(); layer++) { - if (layer->window == w) { - stack.erase(layer.base()); - return; - } - } - return; - } -} - -Window* Layer::back() -{ - if (stack.empty()) return nullptr; - return stack.back().window; -} - -Window* Layer::getFirstOpaque() -{ - for (auto layer = stack.crbegin(); layer != stack.crend(); layer++) { - auto w = layer->window; - if (w && w->hasWindowFlag(OPAQUE)) return w; - } - - return nullptr; -} - -Window* Layer::walk(std::function check) -{ - for (auto layer = stack.crbegin(); layer != stack.crend(); layer++) { - if (layer->window && check(layer->window)) - return layer->window; - } - - return nullptr; -} - -Window* Layer::getPageGroup() -{ - Window* w = Layer::walk([=](Window *w) mutable -> bool { - return w->isPageGroup(); - }); - return w; -} diff --git a/radio/src/gui/colorlcd/libui/layer.h b/radio/src/gui/colorlcd/libui/layer.h deleted file mode 100644 index d00e4da5a..000000000 --- a/radio/src/gui/colorlcd/libui/layer.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * libopenui - https://github.com/opentx/libopenui - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#pragma once - -#include "window.h" - -class Layer -{ - static std::list stack; - - Window* window; - lv_group_t* group; - lv_group_t* prevGroup; - - public: - explicit Layer(Window* w, lv_group_t* g, lv_group_t* pg); - ~Layer(); - - static void push(Window* window); - static void pop(Window* window); - - static Window* back(); - static Window* getFirstOpaque(); - static Window* getPageGroup(); - static Window* walk(std::function check); -}; diff --git a/radio/src/gui/colorlcd/libui/libopenui.h b/radio/src/gui/colorlcd/libui/libopenui.h deleted file mode 100644 index 657712bd4..000000000 --- a/radio/src/gui/colorlcd/libui/libopenui.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#pragma once - -#if !defined(BOOT) -#include "libopenui_defines.h" -#include "fonts.h" -#include "window.h" -#include "mainwindow.h" -#include "static.h" -#include "button.h" -#include "toggleswitch.h" -#include "numberedit.h" -#include "choice.h" -#include "textedit.h" -#include "menu.h" -#include "dialog.h" -#include "getset_helpers.h" -#include "LvglWrapper.h" -#endif diff --git a/radio/src/gui/colorlcd/libui/libopenui_defines.h b/radio/src/gui/colorlcd/libui/libopenui_defines.h index fd58f169a..fd7305468 100644 --- a/radio/src/gui/colorlcd/libui/libopenui_defines.h +++ b/radio/src/gui/colorlcd/libui/libopenui_defines.h @@ -18,10 +18,6 @@ #pragma once -#include "debug.h" -#include "colors.h" -#include "keys.h" - // Used by Lua API #define INVERS 0x01u #define BLINK 0x1000u diff --git a/radio/src/gui/colorlcd/libui/list_line_button.cpp b/radio/src/gui/colorlcd/libui/list_line_button.cpp index 7cc260143..0d1c13137 100644 --- a/radio/src/gui/colorlcd/libui/list_line_button.cpp +++ b/radio/src/gui/colorlcd/libui/list_line_button.cpp @@ -245,10 +245,7 @@ static lv_obj_t* group_create(lv_obj_t* parent) InputMixGroupBase::InputMixGroupBase(Window* parent, mixsrc_t idx) : Window(parent, rect_t{}, group_create), idx(idx) { - setWindowFlag(NO_FOCUS); - - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); - padAll(PAD_ZERO); + setWindowFlag(NO_FOCUS | NO_CLICK); label = etx_label_create(lvobj); etx_font(label, FONT_XS_INDEX, LV_STATE_USER_1); diff --git a/radio/src/gui/colorlcd/libui/list_line_button.h b/radio/src/gui/colorlcd/libui/list_line_button.h index 677d70fc0..96c9301af 100644 --- a/radio/src/gui/colorlcd/libui/list_line_button.h +++ b/radio/src/gui/colorlcd/libui/list_line_button.h @@ -127,7 +127,7 @@ class InputMixGroupBase : public Window class InputMixPageBase : public PageGroupItem { public: - InputMixPageBase(PageDef& pageDef) : PageGroupItem(pageDef) {} + InputMixPageBase(const PageDef& pageDef) : PageGroupItem(pageDef) {} protected: std::list lines; diff --git a/radio/src/gui/colorlcd/libui/listbox.cpp b/radio/src/gui/colorlcd/libui/listbox.cpp index 6375697a9..0a3d9e182 100644 --- a/radio/src/gui/colorlcd/libui/listbox.cpp +++ b/radio/src/gui/colorlcd/libui/listbox.cpp @@ -21,6 +21,8 @@ #include "listbox.h" +#include "debug.h" + ListBox::ListBox(Window* parent, const rect_t& rect, const std::vector& names, uint8_t lineHeight) : TableField(parent, rect) diff --git a/radio/src/gui/colorlcd/libui/mainwindow.cpp b/radio/src/gui/colorlcd/libui/mainwindow.cpp index bed6a91ae..ddf5caa2b 100644 --- a/radio/src/gui/colorlcd/libui/mainwindow.cpp +++ b/radio/src/gui/colorlcd/libui/mainwindow.cpp @@ -19,8 +19,10 @@ #include "mainwindow.h" #include "board.h" +#include "debug.h" #include "keyboard_base.h" #include "layout.h" +#include "LvglWrapper.h" #include "etx_lv_theme.h" #include "sdcard.h" #include "view_main.h" @@ -54,13 +56,17 @@ void MainWindow::emptyTrash() trash.clear(); } -void MainWindow::run(bool trash) +void MainWindow::run() { + LvglWrapper::instance()->run(); + +#if defined(DEBUG_WINDOWS) auto start = timersGetMsTick(); +#endif ViewMain::refreshWidgets(); - auto opaque = Layer::getFirstOpaque(); + auto opaque = Window::firstOpaque(); if (opaque) { opaque->checkEvents(); } @@ -72,12 +78,14 @@ void MainWindow::run(bool trash) } } - if (trash) emptyTrash(); + emptyTrash(); +#if defined(DEBUG_WINDOWS) auto delta = timersGetMsTick() - start; if (delta > 10) { TRACE_WINDOWS("MainWindow::run took %dms", delta); } +#endif } void MainWindow::shutdown() @@ -88,9 +96,8 @@ void MainWindow::shutdown() LayoutFactory::deleteCustomScreens(); // clear layer stack first - for (Window* w = Layer::back(); w; w = Layer::back()) { + for (Window* w = Window::topWindow(); w; w = Window::topWindow()) { w->deleteLater(); - Layer::pop(w); } children.clear(); @@ -102,27 +109,21 @@ void MainWindow::shutdown() lv_obj_center(background); } -void MainWindow::setBackgroundImage(const char* fileName) +bool MainWindow::setBackgroundImage(std::string& fileName) { + if (fileName.empty()) return false; + // ensure you delete old bitmap if (backgroundBitmap != nullptr) delete backgroundBitmap; - if (fileName == nullptr) fileName = ""; - - backgroundImageFileName = fileName; - - // Try to load bitmap. If this fails backgroundBitmap will be NULL and default - // will be loaded in update() method - backgroundBitmap = - BitmapBuffer::loadBitmap(backgroundImageFileName.c_str(), BMP_RGB565); - - if (!backgroundBitmap) { - backgroundBitmap = BitmapBuffer::loadBitmap( - THEMES_PATH "/EdgeTX/background.png", BMP_RGB565); - } + // Try to load bitmap. + backgroundBitmap = BitmapBuffer::loadBitmap(fileName.c_str(), BMP_RGB565); if (backgroundBitmap) { lv_canvas_set_buffer(background, backgroundBitmap->getData(), backgroundBitmap->width(), backgroundBitmap->height(), LV_IMG_CF_TRUE_COLOR); + return true; } + + return false; } diff --git a/radio/src/gui/colorlcd/libui/mainwindow.h b/radio/src/gui/colorlcd/libui/mainwindow.h index b475af07f..5273eb159 100644 --- a/radio/src/gui/colorlcd/libui/mainwindow.h +++ b/radio/src/gui/colorlcd/libui/mainwindow.h @@ -18,9 +18,10 @@ #pragma once -#include "layer.h" #include "window.h" +class BitmapBuffer; + class MainWindow: public Window { protected: @@ -44,21 +45,17 @@ class MainWindow: public Window } #endif - void setActiveScreen() { - lv_scr_load(lvobj); - } + void run(); - void run(bool trash=true); - - void setBackgroundImage(const char* fileName); + bool setBackgroundImage(std::string& fileName); void shutdown(); protected: lv_obj_t* background = nullptr; - std::string backgroundImageFileName; const BitmapBuffer *backgroundBitmap = nullptr; static MainWindow * _instance; - static void emptyTrash(); + + void emptyTrash(); }; diff --git a/radio/src/gui/colorlcd/libui/menu.cpp b/radio/src/gui/colorlcd/libui/menu.cpp index fbe79cce8..8ba6e4c80 100644 --- a/radio/src/gui/colorlcd/libui/menu.cpp +++ b/radio/src/gui/colorlcd/libui/menu.cpp @@ -18,13 +18,12 @@ #include "menu.h" -#include - -#include "menutoolbar.h" #include "edgetx.h" -#include "table.h" #include "etx_lv_theme.h" #include "keyboard_base.h" +#include "menutoolbar.h" +#include "static.h" +#include "table.h" //----------------------------------------------------------------------------- @@ -314,7 +313,7 @@ class MenuWindowContent : public Window lv_obj_center(lvobj); setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO, w, LV_SIZE_CONTENT); - header = new StaticText(this, {0, 0, LV_PCT(100), 0}, "", + header = new StaticText(this, {0, 0, LV_PCT(100), 0}, "", COLOR_THEME_PRIMARY2_INDEX); etx_solid_bg(header->getLvObj(), COLOR_THEME_SECONDARY1_INDEX); header->padAll(PAD_SMALL); diff --git a/radio/src/gui/colorlcd/libui/menu.h b/radio/src/gui/colorlcd/libui/menu.h index 2ecd36e0a..44db44b71 100644 --- a/radio/src/gui/colorlcd/libui/menu.h +++ b/radio/src/gui/colorlcd/libui/menu.h @@ -20,6 +20,7 @@ #include "modal_window.h" +class MaskBitmap; class Menu; class MenuWindowContent; class MenuToolbar; diff --git a/radio/src/gui/colorlcd/libui/menutoolbar.cpp b/radio/src/gui/colorlcd/libui/menutoolbar.cpp index 83099b3b2..b6f158df2 100644 --- a/radio/src/gui/colorlcd/libui/menutoolbar.cpp +++ b/radio/src/gui/colorlcd/libui/menutoolbar.cpp @@ -18,6 +18,7 @@ #include "menutoolbar.h" +#include "keys.h" #include "menu.h" #include "etx_lv_theme.h" #include "translations/translations.h" @@ -51,7 +52,6 @@ MenuToolbarButton::MenuToolbarButton(Window* parent, const rect_t& rect, const char* picto) : ButtonBase(parent, rect, nullptr, menu_button_create) { - lv_obj_add_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); lv_obj_add_flag(lvobj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); lv_obj_add_event_cb(lvobj, toolbar_btn_defocus, LV_EVENT_DEFOCUSED, nullptr); diff --git a/radio/src/gui/colorlcd/libui/modal_window.cpp b/radio/src/gui/colorlcd/libui/modal_window.cpp index b8ac01af7..a2a11da61 100644 --- a/radio/src/gui/colorlcd/libui/modal_window.cpp +++ b/radio/src/gui/colorlcd/libui/modal_window.cpp @@ -18,7 +18,6 @@ #include "modal_window.h" -#include "layer.h" #include "etx_lv_theme.h" #include "mainwindow.h" diff --git a/radio/src/gui/colorlcd/libui/numberedit.cpp b/radio/src/gui/colorlcd/libui/numberedit.cpp index 1c67ef220..ee1d869e1 100644 --- a/radio/src/gui/colorlcd/libui/numberedit.cpp +++ b/radio/src/gui/colorlcd/libui/numberedit.cpp @@ -19,7 +19,10 @@ #include "numberedit.h" #include "audio.h" +#include "debug.h" +#include "hal/rotary_encoder.h" #include "keyboard_number.h" +#include "keys.h" #include "strhelpers.h" #include "etx_lv_theme.h" @@ -30,7 +33,7 @@ class NumberArea : public FormField FormField(parent, rect, etx_textarea_create), numEdit(parent) { - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + setWindowFlag(NO_FOCUS); if (parent->getTextFlags() & CENTERED) etx_obj_add_style(lvobj, styles->text_align_center, LV_PART_MAIN); diff --git a/radio/src/gui/colorlcd/libui/page.cpp b/radio/src/gui/colorlcd/libui/page.cpp index e18a2771f..c9b4f8061 100644 --- a/radio/src/gui/colorlcd/libui/page.cpp +++ b/radio/src/gui/colorlcd/libui/page.cpp @@ -21,12 +21,13 @@ #include "page.h" -#include "theme_manager.h" #include "etx_lv_theme.h" -#include "view_main.h" #include "keyboard_base.h" -#include "quick_menu.h" +#include "mainwindow.h" #include "pagegroup.h" +#include "quick_menu.h" +#include "theme_manager.h" +#include "view_main.h" PageHeader::PageHeader(Window* parent, EdgeTxIcon icon) : Window(parent, {0, 0, LCD_W, EdgeTxStyles::MENU_HEADER_HEIGHT}) @@ -107,27 +108,26 @@ Page::Page(EdgeTxIcon icon, PaddingSize padding, bool pauseRefresh) : void Page::openMenu() { - PageGroup* p = (PageGroup*)Layer::getPageGroup(); + PageGroup* p = Window::pageGroup(); QMPage qmPage = QM_NONE; if (p) qmPage = p->getCurrentTab()->pageId(); - quickMenu = QuickMenu::openQuickMenu([=]() { quickMenu = nullptr; }, + QuickMenu::openQuickMenu( [=](bool close) { onCancel(); if (p) { - while (!Layer::back()->isPageGroup()) { - Layer::back()->deleteLater(); + while (!Window::topWindow()->isPageGroup()) { + Window::topWindow()->deleteLater(); } if (close) - Layer::back()->onCancel(); + Window::topWindow()->onCancel(); } }, p, qmPage); } void Page::onCancel() { - if (quickMenu) quickMenu->closeMenu(); - quickMenu = nullptr; + QuickMenu::closeQuickMenu(); deleteLater(); } @@ -141,7 +141,7 @@ void Page::enableRefresh() NavWindow* Page::navWindow() { - auto p = Layer::back(); + auto p = Window::topWindow(); if (p->isNavWindow()) return (NavWindow*)p; return nullptr; } @@ -151,7 +151,7 @@ void Page::onPressSYS() { QMPage pg = g_eeGeneral.getKeyShortcut(EVT_KEY_BREAK(KEY_SYS)); if (pg == QM_OPEN_QUICK_MENU) { - if (!quickMenu) openMenu(); + if (!QuickMenu::isOpen()) openMenu(); } else { auto p = navWindow(); if (p) { diff --git a/radio/src/gui/colorlcd/libui/page.h b/radio/src/gui/colorlcd/libui/page.h index 2ded5f507..d2a6d418e 100644 --- a/radio/src/gui/colorlcd/libui/page.h +++ b/radio/src/gui/colorlcd/libui/page.h @@ -23,8 +23,6 @@ #include "static.h" -class QuickMenu; - class PageHeader : public Window { public: @@ -61,7 +59,6 @@ class Page : public NavWindow protected: PageHeader* header = nullptr; Window* body = nullptr; - QuickMenu* quickMenu = nullptr; bool bubbleEvents() override { return false; } diff --git a/radio/src/gui/colorlcd/libui/popups.cpp b/radio/src/gui/colorlcd/libui/popups.cpp index 0b5bef26d..a23fbc631 100644 --- a/radio/src/gui/colorlcd/libui/popups.cpp +++ b/radio/src/gui/colorlcd/libui/popups.cpp @@ -21,12 +21,14 @@ #include "popups.h" +#include "dialog.h" #include "edgetx.h" +#include "etx_lv_theme.h" +#include "hal/watchdog_driver.h" #include "lvgl/src/hal/lv_hal_tick.h" +#include "mainwindow.h" #include "os/sleep.h" #include "pwr.h" -#include "hal/watchdog_driver.h" -#include "etx_lv_theme.h" static void _run_popup_dialog(const char* title, const char* msg, const char* info = nullptr) @@ -59,7 +61,6 @@ static void _run_popup_dialog(const char* title, const char* msg, checkBacklight(); WDG_RESET(); MainWindow::instance()->run(); - LvglWrapper::runNested(); sleep_ms(20); } } diff --git a/radio/src/gui/colorlcd/libui/slider.cpp b/radio/src/gui/colorlcd/libui/slider.cpp index 48525d7a2..30dd8f920 100644 --- a/radio/src/gui/colorlcd/libui/slider.cpp +++ b/radio/src/gui/colorlcd/libui/slider.cpp @@ -58,11 +58,11 @@ void SliderBase::update() } } -void SliderBase::deleteLater(bool detach, bool trash) +void SliderBase::deleteLater() { if (!deleted()) { if (tickPts) delete tickPts; - Window::deleteLater(detach, trash); + Window::deleteLater(); } } diff --git a/radio/src/gui/colorlcd/libui/slider.h b/radio/src/gui/colorlcd/libui/slider.h index 6a9605974..033d84fab 100644 --- a/radio/src/gui/colorlcd/libui/slider.h +++ b/radio/src/gui/colorlcd/libui/slider.h @@ -42,7 +42,7 @@ class SliderBase : public Window std::function _getValue; std::function _setValue; - void deleteLater(bool detach, bool trash) override; + void deleteLater() override; void checkEvents() override; static void slider_changed_cb(lv_event_t* e); diff --git a/radio/src/gui/colorlcd/libui/static.cpp b/radio/src/gui/colorlcd/libui/static.cpp index 515e3fa6e..26baeb0c8 100644 --- a/radio/src/gui/colorlcd/libui/static.cpp +++ b/radio/src/gui/colorlcd/libui/static.cpp @@ -19,6 +19,7 @@ #include "static.h" #include "bitmaps.h" +#include "debug.h" #include "lz4/lz4.h" #include "sdcard.h" #include "etx_lv_theme.h" @@ -31,8 +32,7 @@ StaticText::StaticText(Window* parent, const rect_t& rect, std::string txt, Window(parent, rect, lv_label_create), text(std::move(txt)) { setTextFlag(textFlags); - - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + setWindowFlag(NO_FOCUS); etx_font(lvobj, FONT_INDEX(textFlags)); etx_txt_color(lvobj, color); @@ -149,9 +149,7 @@ StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, EdgeTxIcon icon, Window(parent, rect_t{x, y, 0, 0}, lv_canvas_create), currentColor(color) { - setWindowFlag(NO_FOCUS); - - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_FOCUS | NO_CLICK); setIcon(icon); @@ -163,9 +161,7 @@ StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, const char* filenam Window(parent, rect_t{x, y, 0, 0}, lv_canvas_create), currentColor(color) { - setWindowFlag(NO_FOCUS); - - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_FOCUS | NO_CLICK); auto bm = BitmapBuffer::loadBitmap(filename, BMP_RGB565); if (bm) { @@ -182,12 +178,12 @@ StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, const char* filenam etx_img_color(lvobj, currentColor, LV_PART_MAIN); } -void StaticIcon::deleteLater(bool detach, bool trash) +void StaticIcon::deleteLater() { if (_deleted) return; if (mask) free(mask); mask = nullptr; - Window::deleteLater(detach, trash); + Window::deleteLater(); } void StaticIcon::setColor(LcdColorIndex color) @@ -219,9 +215,7 @@ StaticImage::StaticImage(Window* parent, const rect_t& rect, const char* filename, bool fillFrame, bool dontEnlarge) : Window(parent, rect), fillFrame(fillFrame), dontEnlarge(dontEnlarge) { - setWindowFlag(NO_FOCUS); - - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_FOCUS | NO_CLICK); if (!filename) filename = ""; setSource(filename); @@ -282,8 +276,7 @@ StaticBitmap::StaticBitmap(Window* parent, const rect_t& rect, const char* filename) : Window(parent, rect) { - setWindowFlag(NO_FOCUS); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_FOCUS | NO_CLICK); setSource(filename); } @@ -329,9 +322,7 @@ StaticLZ4Image::StaticLZ4Image(Window* parent, coord_t x, coord_t y, Window(parent, {x, y, lz4Bitmap->width, lz4Bitmap->height}, lv_canvas_create) { - setWindowFlag(NO_FOCUS); - - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_FOCUS | NO_CLICK); // Convert ARGB4444 to LV_IMG_CF_TRUE_COLOR_ALPHA uint16_t w = lz4Bitmap->width; @@ -359,12 +350,12 @@ StaticLZ4Image::StaticLZ4Image(Window* parent, coord_t x, coord_t y, lv_canvas_set_buffer(lvobj, imgData, w, h, LV_IMG_CF_TRUE_COLOR_ALPHA); } -void StaticLZ4Image::deleteLater(bool detach, bool trash) +void StaticLZ4Image::deleteLater() { if (!deleted()) { if (imgData) lv_mem_free(imgData); imgData = nullptr; - Window::deleteLater(detach, trash); + Window::deleteLater(); } } @@ -374,8 +365,9 @@ QRCode::QRCode(Window *parent, coord_t x, coord_t y, coord_t sz, std::string dat LcdFlags color, LcdFlags bgColor) : Window(parent, {x, y, sz, sz}) { + setWindowFlag(NO_CLICK); + qr = lv_qrcode_create(lvobj, sz, makeLvColor(color), makeLvColor(bgColor)); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); setData(data); } diff --git a/radio/src/gui/colorlcd/libui/static.h b/radio/src/gui/colorlcd/libui/static.h index d0c6d26b3..417af8212 100644 --- a/radio/src/gui/colorlcd/libui/static.h +++ b/radio/src/gui/colorlcd/libui/static.h @@ -126,7 +126,7 @@ class StaticIcon : public Window StaticIcon(Window *parent, coord_t x, coord_t y, const char* filename, LcdColorIndex color); - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; #if defined(DEBUG_WINDOWS) std::string getName() const override { return "StaticIcon"; } @@ -201,7 +201,7 @@ class StaticLZ4Image : public Window protected: uint8_t *imgData = nullptr; - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; }; //----------------------------------------------------------------------------- diff --git a/radio/src/gui/colorlcd/libui/table.cpp b/radio/src/gui/colorlcd/libui/table.cpp index c8e28c536..ac206c38a 100644 --- a/radio/src/gui/colorlcd/libui/table.cpp +++ b/radio/src/gui/colorlcd/libui/table.cpp @@ -18,7 +18,9 @@ #include "table.h" +#include "debug.h" #include "etx_lv_theme.h" +#include "keys.h" // Table const lv_style_const_prop_t table_cell_props[] = { @@ -305,8 +307,6 @@ bool TableField::onLongPress() return true; } -extern void _assign_lv_group(lv_group_t* g); - void TableField::setAutoEdit() { if (autoedit) return; @@ -316,7 +316,7 @@ void TableField::setAutoEdit() oldGroup = lv_group_get_default(); group = lv_group_create(); lv_group_add_obj(group, lvobj); - _assign_lv_group(group); + assignLvGroup(group, true); lv_group_set_editing(group, true); @@ -329,16 +329,16 @@ void TableField::setAutoEdit() }); } -void TableField::deleteLater(bool detach, bool trash) +void TableField::deleteLater() { if (!deleted()) { if (autoedit) { lv_group_del(group); if (oldGroup) - _assign_lv_group(oldGroup); + assignLvGroup(oldGroup, true); else lv_group_set_default(nullptr); } - Window::deleteLater(detach, trash); + Window::deleteLater(); } } diff --git a/radio/src/gui/colorlcd/libui/table.h b/radio/src/gui/colorlcd/libui/table.h index 3cfb75a74..94bdcf172 100644 --- a/radio/src/gui/colorlcd/libui/table.h +++ b/radio/src/gui/colorlcd/libui/table.h @@ -28,10 +28,10 @@ class TableField : public Window #if defined(DEBUG_WINDOWS) std::string getName() const override { return "Table"; } #endif - + void setRowCount(uint16_t rows); uint16_t getRowCount() const; - + void setColumnWidth(uint16_t col, coord_t w); void select(uint16_t row, uint16_t col, bool force = false); @@ -66,7 +66,7 @@ class TableField : public Window void onEvent(event_t event) override; bool onLongPress() override; - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; static void force_editing(lv_group_t* g) { lv_group_set_editing(g, true); } }; diff --git a/radio/src/gui/colorlcd/libui/textedit.cpp b/radio/src/gui/colorlcd/libui/textedit.cpp index f62e00d60..a58707ddc 100644 --- a/radio/src/gui/colorlcd/libui/textedit.cpp +++ b/radio/src/gui/colorlcd/libui/textedit.cpp @@ -33,7 +33,7 @@ class TextArea : public FormField TextArea(Window* parent, const rect_t& rect, char* value, uint8_t length) : FormField(parent, rect, etx_textarea_create), value(value), length(length) { - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + setWindowFlag(NO_FOCUS); lv_textarea_set_max_length(lvobj, length); lv_textarea_set_placeholder_text(lvobj, "---"); @@ -174,13 +174,13 @@ void TextEdit::openEdit() void TextEdit::preview(bool edited, char* text, uint8_t length) { + setWindowFlag(NO_FOCUS | NO_CLICK); + edit = new TextArea(this, {-(PAD_MEDIUM + 2), -(PAD_BORDER * 2), width(), height()}, text, length); + edit->setWindowFlag(NO_CLICK); lv_group_focus_obj(edit->getLvObj()); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); - lv_obj_clear_flag(edit->getLvObj(), LV_OBJ_FLAG_CLICKABLE); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); lv_obj_add_state(edit->getLvObj(), LV_STATE_FOCUSED); if (edited) lv_obj_add_state(edit->getLvObj(), LV_STATE_EDITED); } diff --git a/radio/src/gui/colorlcd/libui/view_text.cpp b/radio/src/gui/colorlcd/libui/view_text.cpp index 1757ab2a1..479ea5367 100644 --- a/radio/src/gui/colorlcd/libui/view_text.cpp +++ b/radio/src/gui/colorlcd/libui/view_text.cpp @@ -20,12 +20,13 @@ #include "view_text.h" -#include "menu.h" +#include "button.h" #include "edgetx.h" -#include "sdcard.h" #include "etx_lv_theme.h" #include "fullscreen_dialog.h" #include "lib_file.h" +#include "menu.h" +#include "sdcard.h" // Used on startup to block until checklist is closed. static bool checkListOpen = false; @@ -109,12 +110,10 @@ class TextViewer { if (openFile()) { auto obj = window->getLvObj(); - lv_obj_add_flag( - obj, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_WITH_ARROW | - LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_CLICK_FOCUSABLE); + lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_WITH_ARROW | LV_OBJ_FLAG_SCROLL_MOMENTUM); etx_scrollbar(obj); // prevents resetting the group's edit mode - lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + window->setWindowFlag(NO_FOCUS); auto g = lv_group_get_default(); lb = lv_label_create(obj); @@ -375,12 +374,10 @@ class ViewChecklistWindow : public Page, public TextViewer { if (openFile()) { auto obj = window->getLvObj(); - lv_obj_add_flag( - obj, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_WITH_ARROW | - LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_CLICK_FOCUSABLE); + lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_WITH_ARROW | LV_OBJ_FLAG_SCROLL_MOMENTUM); etx_scrollbar(obj); // prevents resetting the group's edit mode - lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + window->setWindowFlag(NO_FOCUS); lv_obj_set_layout(obj, LV_LAYOUT_FLEX); lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN); @@ -551,7 +548,7 @@ void readChecklist() } } -ModelNotesPage::ModelNotesPage(PageDef& pageDef) : PageGroupItem(pageDef, PAD_ZERO) +ModelNotesPage::ModelNotesPage(const PageDef& pageDef) : PageGroupItem(pageDef, PAD_ZERO) { } diff --git a/radio/src/gui/colorlcd/libui/view_text.h b/radio/src/gui/colorlcd/libui/view_text.h index c7b835e89..cc787002e 100644 --- a/radio/src/gui/colorlcd/libui/view_text.h +++ b/radio/src/gui/colorlcd/libui/view_text.h @@ -52,7 +52,7 @@ class ViewTextWindow : public Page class ModelNotesPage : public PageGroupItem { public: - ModelNotesPage(PageDef& pageDef); + ModelNotesPage(const PageDef& pageDef); void build(Window* window) override; diff --git a/radio/src/gui/colorlcd/libui/window.cpp b/radio/src/gui/colorlcd/libui/window.cpp index 2008c56d4..d1e79d135 100644 --- a/radio/src/gui/colorlcd/libui/window.cpp +++ b/radio/src/gui/colorlcd/libui/window.cpp @@ -19,13 +19,118 @@ #include "window.h" #include "button.h" -#include "form.h" -#include "static.h" +#include "debug.h" #include "etx_lv_theme.h" -#include "layer.h" +#include "form.h" +#include "keys.h" +#include "pagegroup.h" +#include "static.h" + +//----------------------------------------------------------------------------- + +class Layer +{ + static std::list stack; + + Window* window; + lv_group_t* group; + lv_group_t* prevGroup; + + public: + explicit Layer(Window* w, lv_group_t* g, lv_group_t* pg) : + window(w), group(g), prevGroup(pg) + { + } + + ~Layer() { lv_group_del(group); } + + static void push(Window* window); + static void pop(Window* window); + + static Window* back(); + static Window* walk(std::function check); +}; + +std::list Layer::stack; + +void Layer::push(Window* w) +{ + // save prev group + auto pg = lv_group_get_default(); + + // create a new group + auto g = lv_group_create(); + w->assignLvGroup(g, true); + + // and store + stack.emplace_back(w, g, pg); +} + +void Layer::pop(Window* w) +{ + if (stack.empty()) return; + + if (back() == w) { + lv_group_t* prevGroup = stack.back().prevGroup; + stack.pop_back(); + w = back(); + if (prevGroup) { + w->assignLvGroup(prevGroup, true); + } else if (!stack.empty()) { + w->assignLvGroup(stack.back().group, true); + } else { + lv_group_set_default(NULL); + } + } else { + for (auto layer = stack.crbegin(); layer != stack.crend(); layer++) { + if (layer->window == w) { + stack.erase(layer.base()); + return; + } + } + return; + } +} + +Window* Layer::back() +{ + if (stack.empty()) return nullptr; + return stack.back().window; +} + +Window* Layer::walk(std::function check) +{ + for (auto layer = stack.crbegin(); layer != stack.crend(); layer++) { + if (layer->window && check(layer->window)) + return layer->window; + } + + return nullptr; +} + +//----------------------------------------------------------------------------- std::list Window::trash; -bool Window::_longPressed = false; + +Window* Window::topWindow() { return Layer::back(); } + +Window* Window::firstOpaque() +{ + Window* w = Layer::walk([=](Window *w) mutable -> bool { + return w->hasWindowFlag(OPAQUE); + }); + return w; +} + +PageGroup* Window::pageGroup() +{ + Window* w = Layer::walk([=](Window *w) mutable -> bool { + return w->isPageGroup(); + }); + return (PageGroup*)w; +} + +//----------------------------------------------------------------------------- const lv_obj_class_t window_base_class = { .base_class = &lv_obj_class, @@ -47,12 +152,14 @@ lv_obj_t *window_create(lv_obj_t *parent) void Window::window_event_cb(lv_event_t *e) { Window *window = (Window *)lv_obj_get_user_data(lv_event_get_target(e)); - if (window) + if (window) window->eventHandler(e); } void Window::eventHandler(lv_event_t *e) { + static bool _longPressed = false; + lv_obj_t *target = lv_event_get_target(e); lv_event_code_t code = lv_event_get_code(e); @@ -113,6 +220,8 @@ void Window::eventHandler(lv_event_t *e) } } +//----------------------------------------------------------------------------- + // Constructor to allow lvobj to be created separately - used by NumberEdit and // TextEdit Window::Window(const rect_t &rect) : rect(rect), parent(nullptr) @@ -202,7 +311,7 @@ void Window::pushLayer(bool hideParent) if (!layerCreated) { parentHidden = hideParent; layerCreated = true; - if (parentHidden) Layer::back()->hide(); + if (parentHidden) Window::topWindow()->hide(); Layer::push(this); } } @@ -211,12 +320,25 @@ void Window::popLayer() { if (layerCreated) { Layer::pop(this); - if (parentHidden) Layer::back()->show(); + if (parentHidden) Window::topWindow()->show(); layerCreated = false; parentHidden = false; } } +void Window::assignLvGroup(lv_group_t* g, bool setDefault) +{ + if (setDefault) + lv_group_set_default(g); + + // associate it with all input devices + lv_indev_t* indev = lv_indev_get_next(NULL); + while (indev) { + lv_indev_set_group(indev, g); + indev = lv_indev_get_next(indev); + } +} + Window *Window::getFullScreenWindow() { if (width() == LCD_W && height() == LCD_H) return this; @@ -229,8 +351,14 @@ void Window::setWindowFlag(WindowFlags flag) windowFlags |= flag; // honor the no focus flag of libopenui - if (this->windowFlags & NO_FOCUS) + if (windowFlags & NO_FOCUS) lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + + if (windowFlags & NO_SCROLL) + lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_SCROLLABLE); + + if (windowFlags & NO_CLICK) + lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); } void Window::clearWindowFlag(WindowFlags flag) { windowFlags &= ~flag; } @@ -250,23 +378,19 @@ void Window::attach(Window *newParent) void Window::detach() { if (parent) { - parent->removeChild(this); + parent->children.remove(this); parent = nullptr; } } -void Window::deleteLater(bool detach, bool trash) +void Window::deleteLater() { if (_deleted) return; _deleted = true; TRACE_WINDOWS("Delete %p %s", this, getWindowDebugString().c_str()); - if (detach) - this->detach(); - else - parent = nullptr; - + detach(); deleteChildren(); popLayer(); @@ -274,8 +398,7 @@ void Window::deleteLater(bool detach, bool trash) if (closeHandler) closeHandler(); - if (trash) - Window::trash.push_back(this); + Window::trash.push_back(this); if (lvobj != nullptr) { auto obj = lvobj; @@ -295,13 +418,8 @@ void Window::clear() void Window::deleteChildren() { - // prevent LVGL refocus while mass-deleting - // inhibit_focus = true; - for (auto window : children) { - window->deleteLater(false); - } - // inhibit_focus = false; - children.clear(); + while (!children.empty()) + children.back()->deleteLater(); } bool Window::hasFocus() const @@ -325,19 +443,6 @@ void Window::padBottom(coord_t pad) void Window::padAll(PaddingSize pad) { etx_padding(lvobj, pad, LV_PART_MAIN); } -void Window::padRow(coord_t pad) { lv_obj_set_style_pad_row(lvobj, pad, 0); } - -void Window::padColumn(coord_t pad) -{ - lv_obj_set_style_pad_column(lvobj, pad, 0); -} - -void Window::bringToTop() -{ - attach(parent); // does a detach + attach - if (lvobj && lv_obj_get_parent(lvobj)) lv_obj_move_foreground(lvobj); -} - void Window::checkEvents() { auto copy = children; @@ -383,12 +488,6 @@ void Window::addChild(Window *window) children.push_back(window); } -void Window::removeChild(Window *window) -{ - children.remove(window); - invalidate(); -} - void Window::invalidate() { if (lvobj) lv_obj_invalidate(lvobj); @@ -475,6 +574,8 @@ void Window::addCustomButton(coord_t x, coord_t y, std::function action) } #endif +//----------------------------------------------------------------------------- + void NavWindow::onEvent(event_t event) { switch (event) { @@ -536,6 +637,8 @@ NavWindow::NavWindow(Window *parent, const rect_t &rect, setWindowFlag(OPAQUE); } +//----------------------------------------------------------------------------- + class SetupTextButton : public TextButton { public: @@ -638,3 +741,5 @@ coord_t SetupLine::showLines(Window* parent, coord_t y, coord_t col2, PaddingSiz return y; } + +//----------------------------------------------------------------------------- diff --git a/radio/src/gui/colorlcd/libui/window.h b/radio/src/gui/colorlcd/libui/window.h index 4d8df68ae..1012c0d6b 100644 --- a/radio/src/gui/colorlcd/libui/window.h +++ b/radio/src/gui/colorlcd/libui/window.h @@ -23,25 +23,25 @@ #include #include "definitions.h" -#include "LvglWrapper.h" -#include "bitmapbuffer.h" -#include "libopenui_defines.h" #include "edgetx_helpers.h" #include "etx_lv_theme.h" +class FlexGridLayout; +class FormLine; +class PageGroup; + typedef uint32_t WindowFlags; +typedef lv_obj_t *(*LvglCreate)(lv_obj_t *); + #if !defined(_GNUC_) #undef OPAQUE #endif constexpr WindowFlags OPAQUE = 1u << 0u; constexpr WindowFlags NO_FOCUS = 1u << 1u; - -typedef lv_obj_t *(*LvglCreate)(lv_obj_t *); - -class FlexGridLayout; -class FormLine; +constexpr WindowFlags NO_SCROLL = 1u << 2u; +constexpr WindowFlags NO_CLICK = 1u << 3u; class Window { @@ -80,7 +80,7 @@ class Window void setScrollHandler(ScrollHandler h) { scrollHandler = std::move(h); } virtual void clear(); - virtual void deleteLater(bool detach = true, bool trash = true); + virtual void deleteLater(); bool hasFocus() const; @@ -124,15 +124,11 @@ class Window } coord_t left() const { return rect.x; } - coord_t right() const { return rect.x + rect.w; } - coord_t top() const { return rect.y; } - coord_t bottom() const { return rect.y + rect.h; } coord_t width() const { return rect.w; } - coord_t height() const { return rect.h; } rect_t getRect() const { return rect; } @@ -143,9 +139,6 @@ class Window void padBottom(coord_t pad); void padAll(PaddingSize pad); - void padRow(coord_t pad); - void padColumn(coord_t pad); - virtual void onEvent(event_t event); virtual void onClicked(); virtual void onCancel(); @@ -155,8 +148,6 @@ class Window void invalidate(); - void bringToTop(); - virtual void checkEvents(); void attach(Window *window); @@ -195,6 +186,11 @@ class Window void pushLayer(bool hideParent = false); void popLayer(); + static Window* topWindow(); + static Window* firstOpaque(); + static PageGroup* pageGroup(); + + void assignLvGroup(lv_group_t* g, bool setDefault); protected: static std::list trash; @@ -211,7 +207,6 @@ class Window bool noForcedScroll = false; bool _deleted = false; - static bool _longPressed; bool loaded = false; bool layerCreated = false; @@ -219,12 +214,11 @@ class Window CloseHandler closeHandler; FocusHandler focusHandler; - std::function scrollHandler; + ScrollHandler scrollHandler; void deleteChildren(); virtual void addChild(Window *window); - void removeChild(Window *window); void eventHandler(lv_event_t *e); static void window_event_cb(lv_event_t *e); diff --git a/radio/src/gui/colorlcd/mainview/layout.cpp b/radio/src/gui/colorlcd/mainview/layout.cpp index 811b7b987..ad1789366 100644 --- a/radio/src/gui/colorlcd/mainview/layout.cpp +++ b/radio/src/gui/colorlcd/mainview/layout.cpp @@ -193,10 +193,8 @@ WidgetsContainer* LayoutFactory::createCustomScreen( auto& screen = customScreens[customScreenIndex]; - if (screen != nullptr) { - screen->deleteLater(true, false); - delete screen; - } + if (screen != nullptr) + screen->deleteLater(); auto viewMain = ViewMain::instance(); screen = create(viewMain, customScreenIndex); @@ -261,7 +259,7 @@ inline LayoutOptionValueEnum layoutValueEnumFromType(LayoutOption::Type type) case LayoutOption::Color: return LOV_Color; - + default: return LOV_None; } @@ -410,8 +408,6 @@ Widget* Layout::createWidget(unsigned int index, } widgets[index] = widget; - if (widget) widget->attach(this); - return widget; } diff --git a/radio/src/gui/colorlcd/mainview/screen_setup.cpp b/radio/src/gui/colorlcd/mainview/screen_setup.cpp index 1797cee22..aa0a73ad0 100644 --- a/radio/src/gui/colorlcd/mainview/screen_setup.cpp +++ b/radio/src/gui/colorlcd/mainview/screen_setup.cpp @@ -24,8 +24,12 @@ #include #include "color_picker.h" -#include "layout.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "layout.h" +#include "menu.h" +#include "static.h" +#include "toggleswitch.h" #include "topbar.h" #include "view_main.h" #include "widget_settings.h" @@ -112,7 +116,7 @@ static const lv_coord_t line_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; -ScreenSetupPage::ScreenSetupPage(unsigned index, PageDef& pageDef) : +ScreenSetupPage::ScreenSetupPage(unsigned index, const PageDef& pageDef) : PageGroupItem(pageDef) { update(index + QuickMenu::pageIndex(QM_UI_SCREEN1)); @@ -281,8 +285,41 @@ void ScreenSetupPage::buildLayoutOptions() } } +void ScreenSetupPage::addScreen() +{ + int newIdx = 1; + for (; newIdx < MAX_CUSTOM_SCREENS; newIdx += 1) + if (customScreens[newIdx] == nullptr) + break; + + TRACE("Add screen: add screen: newIdx = %d", newIdx); + + auto& screen = customScreens[newIdx]; + + const LayoutFactory* factory = defaultLayout; + if (factory) { + TRACE("Add screen: add screen: factory = %p", factory); + + auto viewMain = ViewMain::instance(); + screen = factory->create(viewMain, newIdx); + viewMain->addMainView(screen, newIdx); + + g_model.setScreenLayoutId(newIdx, factory->getId()); + TRACE("Add screen: add screen: LayoutId = %s", g_model.getScreenLayoutId(newIdx)); + #if VERSION_MAJOR == 2 -ScreenAddPage::ScreenAddPage(PageDef& pageDef) : PageGroupItem(pageDef) + Window::pageGroup()->deleteLater(); +#endif + QuickMenu::openPage((QMPage)(QM_UI_SCREEN1 + newIdx)); + + storageDirty(EE_MODEL); + } else { + TRACE("Add screen: factory is NULL"); + } +} + +#if VERSION_MAJOR == 2 +ScreenAddPage::ScreenAddPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } @@ -293,33 +330,7 @@ void ScreenAddPage::build(Window* window) new TextButton(window, rect_t{LCD_W / 2 - ADD_TXT_W / 2, window->height() / 2 - EdgeTxStyles::UI_ELEMENT_HEIGHT, ADD_TXT_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, s, [this]() -> uint8_t { - int newIdx = 1; - for (; newIdx < MAX_CUSTOM_SCREENS; newIdx += 1) - if (customScreens[newIdx] == nullptr) - break; - - TRACE("Add screen: add screen: newIdx = %d", newIdx); - - auto& screen = customScreens[newIdx]; - - const LayoutFactory* factory = defaultLayout; - if (factory) { - TRACE("Add screen: add screen: factory = %p", factory); - - auto viewMain = ViewMain::instance(); - screen = factory->create(viewMain, newIdx); - viewMain->addMainView(screen, newIdx); - - g_model.setScreenLayoutId(newIdx, factory->getId()); - TRACE("Add screen: add screen: LayoutId = %s", g_model.getScreenLayoutId(newIdx)); - - Layer::getPageGroup()->deleteLater(); - QuickMenu::openPage((QMPage)(QM_UI_SCREEN1 + newIdx)); - - storageDirty(EE_MODEL); - } else { - TRACE("Add screen: factory is NULL"); - } + ScreenSetupPage::addScreen(); return 0; }); } diff --git a/radio/src/gui/colorlcd/mainview/screen_setup.h b/radio/src/gui/colorlcd/mainview/screen_setup.h index 249cda217..7c1659ec5 100644 --- a/radio/src/gui/colorlcd/mainview/screen_setup.h +++ b/radio/src/gui/colorlcd/mainview/screen_setup.h @@ -29,7 +29,7 @@ class ScreenAddPage : public PageGroupItem { public: - ScreenAddPage(PageDef& pageDef); + ScreenAddPage(const PageDef& pageDef); void build(Window* window) override; @@ -41,12 +41,14 @@ class ScreenAddPage : public PageGroupItem class ScreenSetupPage : public PageGroupItem { public: - ScreenSetupPage(unsigned customScreenIndex, PageDef& pageDef); + ScreenSetupPage(unsigned customScreenIndex, const PageDef& pageDef); void build(Window* form) override; void update(uint8_t index) override; + static void addScreen(); + protected: unsigned customScreenIndex; Window* layoutOptions = nullptr; diff --git a/radio/src/gui/colorlcd/mainview/screen_user_interface.cpp b/radio/src/gui/colorlcd/mainview/screen_user_interface.cpp index 704fc0a65..955b25d2b 100644 --- a/radio/src/gui/colorlcd/mainview/screen_user_interface.cpp +++ b/radio/src/gui/colorlcd/mainview/screen_user_interface.cpp @@ -21,6 +21,7 @@ #include "screen_user_interface.h" +#include "choice.h" #include "file_preview.h" #include "theme_manager.h" #include "view_main.h" @@ -43,7 +44,7 @@ static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT, #endif -ScreenUserInterfacePage::ScreenUserInterfacePage(PageDef& pageDef) : +ScreenUserInterfacePage::ScreenUserInterfacePage(const PageDef& pageDef) : PageGroupItem(pageDef, PAD_TINY) { } diff --git a/radio/src/gui/colorlcd/mainview/screen_user_interface.h b/radio/src/gui/colorlcd/mainview/screen_user_interface.h index dc6c0cd32..0f4c742f4 100644 --- a/radio/src/gui/colorlcd/mainview/screen_user_interface.h +++ b/radio/src/gui/colorlcd/mainview/screen_user_interface.h @@ -30,7 +30,7 @@ class Choice; class ScreenUserInterfacePage : public PageGroupItem { public: - ScreenUserInterfacePage(PageDef& pageDef); + ScreenUserInterfacePage(const PageDef& pageDef); void build(Window* window) override; diff --git a/radio/src/gui/colorlcd/mainview/topbar.cpp b/radio/src/gui/colorlcd/mainview/topbar.cpp index 4212e11c0..d869b2452 100644 --- a/radio/src/gui/colorlcd/mainview/topbar.cpp +++ b/radio/src/gui/colorlcd/mainview/topbar.cpp @@ -21,7 +21,6 @@ #include "topbar.h" -#include "layer.h" #include "edgetx.h" #include "storage/storage.h" #include "etx_lv_theme.h" @@ -104,10 +103,12 @@ void SetupTopBarWidgetsPage::onClicked() void SetupTopBarWidgetsPage::onCancel() { deleteLater(); } -void SetupTopBarWidgetsPage::deleteLater(bool detach, bool trash) +void SetupTopBarWidgetsPage::deleteLater() { + if (_deleted) return; + // and continue async deletion... - Window::deleteLater(detach, trash); + Window::deleteLater(); // restore screen setting tab on top QuickMenu::openPage(QM_UI_SETUP); @@ -270,8 +271,6 @@ Widget* TopBar::createWidget(unsigned int index, } widgets[index] = widget; - if (widget) widget->attach(this); - return widget; } diff --git a/radio/src/gui/colorlcd/mainview/topbar.h b/radio/src/gui/colorlcd/mainview/topbar.h index b04d638d6..9be71762a 100644 --- a/radio/src/gui/colorlcd/mainview/topbar.h +++ b/radio/src/gui/colorlcd/mainview/topbar.h @@ -39,7 +39,7 @@ class SetupTopBarWidgetsPage : public Window void onClicked() override; void onCancel() override; void onEvent(event_t event) override; - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; }; //----------------------------------------------------------------------------- diff --git a/radio/src/gui/colorlcd/mainview/trims.cpp b/radio/src/gui/colorlcd/mainview/trims.cpp index 19854b6f4..fbb9c3c0d 100644 --- a/radio/src/gui/colorlcd/mainview/trims.cpp +++ b/radio/src/gui/colorlcd/mainview/trims.cpp @@ -203,7 +203,7 @@ void MainViewTrim::checkEvents() int newValue = getTrimValue(mixerCurrentFlightMode, inputMappingConvertMode(idx)); bool update = false; - + if (extendedTrims != g_model.extendedTrims) { update = true; setRange(); diff --git a/radio/src/gui/colorlcd/mainview/trims.h b/radio/src/gui/colorlcd/mainview/trims.h index 16da99f5f..9c07b6150 100644 --- a/radio/src/gui/colorlcd/mainview/trims.h +++ b/radio/src/gui/colorlcd/mainview/trims.h @@ -30,7 +30,7 @@ class MainViewTrim : public Window public: MainViewTrim(Window* parent, const rect_t& rect, uint8_t idx, bool isVertical); - + void setVisible(bool visible); protected: @@ -47,7 +47,7 @@ class MainViewTrim : public Window void setRange(); void setPos(); - + bool setDisplayState(); void checkEvents() override; diff --git a/radio/src/gui/colorlcd/mainview/view_channels.cpp b/radio/src/gui/colorlcd/mainview/view_channels.cpp index bfdb180dd..8ce60763d 100644 --- a/radio/src/gui/colorlcd/mainview/view_channels.cpp +++ b/radio/src/gui/colorlcd/mainview/view_channels.cpp @@ -22,7 +22,6 @@ #include "view_channels.h" #include "channel_bar.h" -#include "libopenui.h" #include "model_select.h" #include "edgetx.h" #if VERSION_MAJOR == 2 @@ -126,8 +125,6 @@ class ChannelsViewPage : public PageGroupItem ChannelsViewMenu::ChannelsViewMenu() : TabsGroup(ICON_MONITOR, STR_MAIN_MENU_CHANNEL_MONITOR) { - QuickMenu::setCurrentPage(QM_TOOLS_CHAN_MON); - #if PORTRAIT int cols = 1; int rows = 8; diff --git a/radio/src/gui/colorlcd/mainview/view_logical_switches.cpp b/radio/src/gui/colorlcd/mainview/view_logical_switches.cpp index ee166f130..953bf6935 100644 --- a/radio/src/gui/colorlcd/mainview/view_logical_switches.cpp +++ b/radio/src/gui/colorlcd/mainview/view_logical_switches.cpp @@ -21,10 +21,11 @@ #include "view_logical_switches.h" +#include "button.h" #include "edgetx.h" -#include "switches.h" #include "etx_lv_theme.h" #include "quick_menu.h" +#include "switches.h" #if PORTRAIT @@ -241,7 +242,7 @@ LogicalSwitchesViewPage::LogicalSwitchesViewPage() : setIcon(ICON_MONITOR_LOGICAL_SWITCHES); } -LogicalSwitchesViewPage::LogicalSwitchesViewPage(PageDef& pageDef) : +LogicalSwitchesViewPage::LogicalSwitchesViewPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/mainview/view_logical_switches.h b/radio/src/gui/colorlcd/mainview/view_logical_switches.h index 7f24251b7..ae675c507 100644 --- a/radio/src/gui/colorlcd/mainview/view_logical_switches.h +++ b/radio/src/gui/colorlcd/mainview/view_logical_switches.h @@ -29,7 +29,7 @@ class LogicalSwitchesViewPage : public PageGroupItem { public: LogicalSwitchesViewPage(); - LogicalSwitchesViewPage(PageDef& pageDef); + LogicalSwitchesViewPage(const PageDef& pageDef); static LAYOUT_ORIENTATION_SCALED(FOOTER_HEIGHT, 20, 40) static LAYOUT_ORIENTATION(BTN_MATRIX_COL, 8, 6) diff --git a/radio/src/gui/colorlcd/mainview/view_main.cpp b/radio/src/gui/colorlcd/mainview/view_main.cpp index 8bd0443c1..c26905003 100644 --- a/radio/src/gui/colorlcd/mainview/view_main.cpp +++ b/radio/src/gui/colorlcd/mainview/view_main.cpp @@ -21,12 +21,13 @@ #include "view_main.h" -#include "model_select.h" #include "edgetx.h" -#include "topbar.h" +#include "mainwindow.h" +#include "model_select.h" #include "quick_menu.h" -#include "view_channels.h" #include "screen_setup.h" +#include "topbar.h" +#include "view_channels.h" #include "widget.h" static void tile_view_deleted_cb(lv_event_t* e) @@ -78,7 +79,8 @@ ViewMain* ViewMain::_instance = nullptr; ViewMain* ViewMain::instance() { - if (!_instance) _instance = new ViewMain(); + if (!_instance) + _instance = new ViewMain(); return _instance; } @@ -106,9 +108,11 @@ ViewMain::ViewMain() : ViewMain::~ViewMain() { _instance = nullptr; } -void ViewMain::deleteLater(bool detach, bool trash) +void ViewMain::deleteLater() { - NavWindow::deleteLater(detach, trash); + if (_deleted) return; + + NavWindow::deleteLater(); QuickMenu::shutdownQuickMenu(); } @@ -126,7 +130,7 @@ void ViewMain::addMainView(WidgetsContainer* view, uint32_t viewId) lv_obj_add_event_cb(tile, tile_view_deleted_cb, LV_EVENT_CHILD_DELETED, user_data); - view->show(); + view->show(); } void ViewMain::setTopbarVisible(float visible) { topbar->setVisible(visible); } @@ -244,10 +248,9 @@ void ViewMain::doKeyShortcut(event_t event) { QMPage pg = g_eeGeneral.getKeyShortcut(event); if (pg == QM_OPEN_QUICK_MENU) { - if (!viewMainMenu) openMenu(); + if (!QuickMenu::isOpen()) openMenu(); } else { - if (viewMainMenu) - viewMainMenu->closeMenu(); + QuickMenu::closeQuickMenu(); QuickMenu::openPage(pg); } } @@ -260,14 +263,14 @@ void ViewMain::onLongPressTELE() { doKeyShortcut(EVT_KEY_LONG(KEY_TELE)); } void ViewMain::onPressPGUP() { if (!widget_select) { - if (viewMainMenu) viewMainMenu->closeMenu(); + QuickMenu::closeQuickMenu(); previousMainView(); } } void ViewMain::onPressPGDN() { if (!widget_select) { - if (viewMainMenu) viewMainMenu->closeMenu(); + QuickMenu::closeQuickMenu(); nextMainView(); } } @@ -332,7 +335,7 @@ bool ViewMain::enableWidgetSelect(bool enable) void ViewMain::openMenu() { - viewMainMenu = QuickMenu::openQuickMenu([=]() { viewMainMenu = nullptr; }); + QuickMenu::openQuickMenu(); } void ViewMain::ws_timer(lv_timer_t* t) diff --git a/radio/src/gui/colorlcd/mainview/view_main.h b/radio/src/gui/colorlcd/mainview/view_main.h index dc78c81c9..7fcc66ad5 100644 --- a/radio/src/gui/colorlcd/mainview/view_main.h +++ b/radio/src/gui/colorlcd/mainview/view_main.h @@ -24,7 +24,6 @@ #include "topbar.h" #include "window.h" -class QuickMenu; class TopBar; class ViewMain : public NavWindow @@ -85,9 +84,8 @@ class ViewMain : public NavWindow TopBar* topbar = nullptr; bool widget_select = false; lv_timer_t* widget_select_timer = nullptr; - QuickMenu* viewMainMenu = nullptr; - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; // Set topbar visibility [0.0 -> 1.0] void setTopbarVisible(float visible); diff --git a/radio/src/gui/colorlcd/mainview/view_statistics.cpp b/radio/src/gui/colorlcd/mainview/view_statistics.cpp index 2ddc0b900..1e8b41c1f 100644 --- a/radio/src/gui/colorlcd/mainview/view_statistics.cpp +++ b/radio/src/gui/colorlcd/mainview/view_statistics.cpp @@ -20,14 +20,16 @@ */ #include "view_statistics.h" -#include "os/task.h" +#include "button.h" #include "edgetx.h" +#include "lua/lua_states.h" +#include "mixer_scheduler.h" +#include "os/task.h" +#include "quick_menu.h" +#include "static.h" #include "tasks.h" #include "tasks/mixer_task.h" -#include "mixer_scheduler.h" -#include "lua/lua_states.h" -#include "quick_menu.h" static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), @@ -129,7 +131,7 @@ class ThrottleCurveWindow : public Window int16_t graphSize = 0; }; -StatisticsViewPage::StatisticsViewPage(PageDef& pageDef) : +StatisticsViewPage::StatisticsViewPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } @@ -207,7 +209,7 @@ void StatisticsViewPage::build(Window* window) LV_GRID_ALIGN_START, 0, 1); } -DebugViewPage::DebugViewPage(PageDef& pageDef) : +DebugViewPage::DebugViewPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/mainview/view_statistics.h b/radio/src/gui/colorlcd/mainview/view_statistics.h index 7e1482d9a..acc0efa82 100644 --- a/radio/src/gui/colorlcd/mainview/view_statistics.h +++ b/radio/src/gui/colorlcd/mainview/view_statistics.h @@ -26,7 +26,7 @@ class StatisticsViewPage : public PageGroupItem { public: - StatisticsViewPage(PageDef& pageDef); + StatisticsViewPage(const PageDef& pageDef); protected: void build(Window* window) override; @@ -35,7 +35,7 @@ class StatisticsViewPage : public PageGroupItem class DebugViewPage : public PageGroupItem { public: - DebugViewPage(PageDef& pageDef); + DebugViewPage(const PageDef& pageDef); protected: void build(Window* window) override; diff --git a/radio/src/gui/colorlcd/mainview/widget.cpp b/radio/src/gui/colorlcd/mainview/widget.cpp index f6e6b71d8..48d6ea661 100644 --- a/radio/src/gui/colorlcd/mainview/widget.cpp +++ b/radio/src/gui/colorlcd/mainview/widget.cpp @@ -23,6 +23,7 @@ #include "edgetx.h" #include "etx_lv_theme.h" +#include "menu.h" #include "view_main.h" #include "widget_settings.h" @@ -50,7 +51,7 @@ inline WidgetOptionValueEnum widgetValueEnumFromType(WidgetOption::Type type) case WidgetOption::Color: return WOV_Color; - + default: return WOV_Unsigned; } @@ -157,8 +158,7 @@ Widget::Widget(const WidgetFactory* factory, Window* parent, const rect_t& rect, factory(factory), screenNum(screenNum), zoneNum(zoneNum) { - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + setWindowFlag(NO_FOCUS | NO_SCROLL); if (parent->isTopBar()) fsAllowed = false; @@ -239,8 +239,6 @@ void Widget::setFullscreen(bool enable) updateZoneRect(parent->getRect(), false); setRect(parent->getRect()); - bringToTop(); - if (!lv_obj_get_group(lvobj)) lv_group_add_obj(lv_group_get_default(), lvobj); @@ -297,7 +295,6 @@ void Widget::enableFocus(bool enable) setFocusHandler([=](bool hasFocus) { if (hasFocus) { - bringToTop(); lv_obj_clear_flag(focusBorder, LV_OBJ_FLAG_HIDDEN); } else { lv_obj_add_flag(focusBorder, LV_OBJ_FLAG_HIDDEN); diff --git a/radio/src/gui/colorlcd/mainview/widget_settings.cpp b/radio/src/gui/colorlcd/mainview/widget_settings.cpp index d8d1c6ff6..99a1003a9 100644 --- a/radio/src/gui/colorlcd/mainview/widget_settings.cpp +++ b/radio/src/gui/colorlcd/mainview/widget_settings.cpp @@ -23,11 +23,15 @@ #include "color_picker.h" #include "edgetx.h" -#include "sourcechoice.h" -#include "switchchoice.h" -#include "view_main.h" #include "filechoice.h" +#include "numberedit.h" #include "slider.h" +#include "sourcechoice.h" +#include "static.h" +#include "switchchoice.h" +#include "textedit.h" +#include "toggleswitch.h" +#include "view_main.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/mainview/widgets_container.cpp b/radio/src/gui/colorlcd/mainview/widgets_container.cpp index e9847db0b..94ab7c552 100644 --- a/radio/src/gui/colorlcd/mainview/widgets_container.cpp +++ b/radio/src/gui/colorlcd/mainview/widgets_container.cpp @@ -29,14 +29,14 @@ WidgetsContainer::WidgetsContainer(Window* parent, const rect_t& rect, uint8_t z for (int i = 0; i < zoneCount; i += 1) widgets[i] = nullptr; } -void WidgetsContainer::deleteLater(bool detach, bool trash) +void WidgetsContainer::deleteLater() { if (deleted()) return; for (int i = 0; i < zoneCount; i += 1) if (widgets[i]) widgets[i]->deleteLater(); if (widgets) delete[] widgets; widgets = nullptr; - Window::deleteLater(detach, trash); + Window::deleteLater(); } Widget* WidgetsContainer::getWidget(unsigned int index) diff --git a/radio/src/gui/colorlcd/mainview/widgets_container.h b/radio/src/gui/colorlcd/mainview/widgets_container.h index 20f76b92a..05bc870ad 100644 --- a/radio/src/gui/colorlcd/mainview/widgets_container.h +++ b/radio/src/gui/colorlcd/mainview/widgets_container.h @@ -47,7 +47,7 @@ class WidgetsContainer: public Window virtual bool isAppMode() const { return false; } bool isWidgetsContainer() override { return true; } - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; protected: uint8_t zoneCount = 0; diff --git a/radio/src/gui/colorlcd/mainview/widgets_setup.cpp b/radio/src/gui/colorlcd/mainview/widgets_setup.cpp index 282820e1a..6becb8e25 100644 --- a/radio/src/gui/colorlcd/mainview/widgets_setup.cpp +++ b/radio/src/gui/colorlcd/mainview/widgets_setup.cpp @@ -21,7 +21,6 @@ #include "widgets_setup.h" -#include "layer.h" #include "menu.h" #include "myeeprom.h" #include "storage/storage.h" @@ -82,7 +81,6 @@ SetupWidgetsPageSlot::SetupWidgetsPageSlot(Window* parent, const rect_t& rect, void SetupWidgetsPageSlot::setFocusState() { if (hasFocus()) { - bringToTop(); lv_obj_add_flag(border, LV_OBJ_FLAG_HIDDEN); } else { lv_obj_clear_flag(border, LV_OBJ_FLAG_HIDDEN); @@ -158,9 +156,11 @@ void SetupWidgetsPage::onCancel() QuickMenu::openPage((QMPage)(QM_UI_SCREEN1 + customScreenIdx)); } -void SetupWidgetsPage::deleteLater(bool detach, bool trash) +void SetupWidgetsPage::deleteLater() { - Window::deleteLater(detach, trash); + if (_deleted) return; + + Window::deleteLater(); // and continue async deletion... auto screen = customScreens[customScreenIdx]; diff --git a/radio/src/gui/colorlcd/mainview/widgets_setup.h b/radio/src/gui/colorlcd/mainview/widgets_setup.h index f9e37db73..9db629c62 100644 --- a/radio/src/gui/colorlcd/mainview/widgets_setup.h +++ b/radio/src/gui/colorlcd/mainview/widgets_setup.h @@ -46,7 +46,7 @@ class SetupWidgetsPage : public Window unsigned savedView = 0; void onEvent(event_t event) override; - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; }; class SetupWidgetsPageSlot : public ButtonBase diff --git a/radio/src/gui/colorlcd/model/curveedit.cpp b/radio/src/gui/colorlcd/model/curveedit.cpp index c6100e1da..1154a2fbe 100644 --- a/radio/src/gui/colorlcd/model/curveedit.cpp +++ b/radio/src/gui/colorlcd/model/curveedit.cpp @@ -21,8 +21,12 @@ #include "curveedit.h" -#include "edgetx.h" // TODO for applyCustomCurve +#include "choice.h" +#include "edgetx.h" #include "etx_lv_theme.h" +#include "getset_helpers.h" +#include "numberedit.h" +#include "textedit.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -31,15 +35,14 @@ static const lv_coord_t default_col_dsc[] = {LV_GRID_CONTENT, static const lv_coord_t default_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; -class CurveEdit : public Window +class CurveEdit : public Curve { public: CurveEdit(Window* parent, const rect_t& rect, uint8_t index) : - Window(parent, rect), - preview( - this, {0, 0, width(), height()}, + Curve(parent, rect, [=](int x) -> int { return applyCustomCurve(x, index); }, - [=]() -> int { return getValue(currentSource); }), + [=]() -> int { return getValue(currentSource); } + ), index(index), current(0) { @@ -58,28 +61,19 @@ class CurveEdit : public Window void updatePreview() { - preview.clearPoints(); + clearPoints(); CurveHeader& curve = g_model.curves[index]; for (uint8_t i = 0; i < 5 + curve.points; i++) { - preview.addPoint(getPoint(index, i)); + addPoint(getPoint(index, i)); } } protected: - Curve preview; uint8_t index; uint8_t current; mixsrc_t currentSource = 0; bool lockSource = false; - void deleteLater(bool detach = true, bool trash = true) override - { - if (!_deleted) { - preview.deleteLater(true, false); - Window::deleteLater(detach, trash); - } - } - void checkEvents(void) override { if (!lockSource) { diff --git a/radio/src/gui/colorlcd/model/function_switches.cpp b/radio/src/gui/colorlcd/model/function_switches.cpp index 28f3f866e..73c45bb61 100644 --- a/radio/src/gui/colorlcd/model/function_switches.cpp +++ b/radio/src/gui/colorlcd/model/function_switches.cpp @@ -23,11 +23,15 @@ #include "function_switches.h" +#include "choice.h" +#include "color_picker.h" #include "edgetx.h" +#include "getset_helpers.h" #include "hal/rgbleds.h" #include "strhelpers.h" #include "switches.h" -#include "color_picker.h" +#include "textedit.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/model/input_edit.cpp b/radio/src/gui/colorlcd/model/input_edit.cpp index 87d64d333..5b8548fc4 100644 --- a/radio/src/gui/colorlcd/model/input_edit.cpp +++ b/radio/src/gui/colorlcd/model/input_edit.cpp @@ -23,13 +23,15 @@ #include "curve_param.h" #include "curveedit.h" -#include "gvar_numberedit.h" -#include "source_numberedit.h" -#include "input_source.h" #include "edgetx.h" #include "etx_lv_theme.h" -#include "switchchoice.h" #include "fm_matrix.h" +#include "getset_helpers.h" +#include "gvar_numberedit.h" +#include "input_source.h" +#include "source_numberedit.h" +#include "switchchoice.h" +#include "textedit.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/model/mixer_edit.cpp b/radio/src/gui/colorlcd/model/mixer_edit.cpp index 11c3187de..9e786a9f9 100644 --- a/radio/src/gui/colorlcd/model/mixer_edit.cpp +++ b/radio/src/gui/colorlcd/model/mixer_edit.cpp @@ -22,17 +22,19 @@ #include "mixer_edit.h" #include "channel_bar.h" -#include "gvar_numberedit.h" -#include "source_numberedit.h" #include "curve_param.h" -#include "mixer_edit_adv.h" -#include "mixes.h" +#include "curveedit.h" #include "edgetx.h" #include "etx_lv_theme.h" +#include "getset_helpers.h" +#include "gvar_numberedit.h" +#include "mixer_edit_adv.h" +#include "mixes.h" +#include "pagegroup.h" +#include "source_numberedit.h" #include "sourcechoice.h" #include "switchchoice.h" -#include "curveedit.h" -#include "pagegroup.h" +#include "textedit.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/model/mixer_edit_adv.cpp b/radio/src/gui/colorlcd/model/mixer_edit_adv.cpp index 07f74cb1f..e146ca010 100644 --- a/radio/src/gui/colorlcd/model/mixer_edit_adv.cpp +++ b/radio/src/gui/colorlcd/model/mixer_edit_adv.cpp @@ -21,11 +21,14 @@ #include "mixer_edit_adv.h" -#include "fm_matrix.h" -#include "mixes.h" -#include "numberedit.h" +#include "choice.h" #include "edgetx.h" #include "etx_lv_theme.h" +#include "fm_matrix.h" +#include "getset_helpers.h" +#include "mixes.h" +#include "numberedit.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/model/model_curves.cpp b/radio/src/gui/colorlcd/model/model_curves.cpp index 973d1b282..b3855c7e0 100644 --- a/radio/src/gui/colorlcd/model/model_curves.cpp +++ b/radio/src/gui/colorlcd/model/model_curves.cpp @@ -21,8 +21,10 @@ #include "model_curves.h" +#include "button.h" #include "curveedit.h" #include "edgetx.h" +#include "menu.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -41,7 +43,7 @@ class CurveButton : public Button s = strAppend(s, ":"); strAppend(s, g_model.curves[index].name, LEN_CURVE_NAME); } - title = new StaticText(this, {PAD_SMALL, -1, width() - PAD_MEDIUM * 2, EdgeTxStyles::STD_FONT_HEIGHT}, buf, + title = new StaticText(this, {PAD_SMALL, -1, width() - PAD_MEDIUM * 2, EdgeTxStyles::STD_FONT_HEIGHT}, buf, COLOR_THEME_SECONDARY1_INDEX, CENTERED | FONT(BOLD)); etx_txt_color(title->getLvObj(), COLOR_THEME_PRIMARY2_INDEX, LV_PART_MAIN | LV_STATE_USER_1); @@ -67,14 +69,14 @@ class CurveButton : public Button CurveHeader &curve = g_model.curves[index]; snprintf(buf, 32, "%s %d %s", STR_CURVE_TYPES[curve.type], 5 + curve.points, STR_PTS); - new StaticText(this, {0, height() - EdgeTxStyles::STD_FONT_HEIGHT - PAD_MEDIUM, LV_PCT(100), EdgeTxStyles::STD_FONT_HEIGHT}, buf, + new StaticText(this, {0, height() - EdgeTxStyles::STD_FONT_HEIGHT - PAD_MEDIUM, LV_PCT(100), EdgeTxStyles::STD_FONT_HEIGHT}, buf, COLOR_THEME_SECONDARY1_INDEX, CENTERED | FONT(BOLD)); } void update() { preview->update(); } static LAYOUT_VAL_SCALED(INFO_H, 27) - static constexpr coord_t CURVE_BTN_W = (LCD_W - PAD_LARGE * (ModelCurvesPage::PER_ROW + 1)) / ModelCurvesPage::PER_ROW; + static constexpr coord_t CURVE_BTN_W = (LCD_W - PAD_LARGE * (ModelCurvesPage::PER_ROW + 1)) / ModelCurvesPage::PER_ROW; static constexpr coord_t CURVE_BTH_H = CURVE_BTN_W + EdgeTxStyles::STD_FONT_HEIGHT * 2; protected: @@ -109,7 +111,7 @@ void initPoints(const CurveHeader &curve, int8_t *points) } } -ModelCurvesPage::ModelCurvesPage(PageDef& pageDef) : PageGroupItem(pageDef) +ModelCurvesPage::ModelCurvesPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/model/model_curves.h b/radio/src/gui/colorlcd/model/model_curves.h index 4bfcc17d5..8fe364fc6 100644 --- a/radio/src/gui/colorlcd/model/model_curves.h +++ b/radio/src/gui/colorlcd/model/model_curves.h @@ -27,7 +27,7 @@ class ModelCurvesPage : public PageGroupItem { public: - ModelCurvesPage(PageDef& pageDef); + ModelCurvesPage(const PageDef& pageDef); static void pushEditCurve(int index, std::function refreshView, mixsrc_t source); diff --git a/radio/src/gui/colorlcd/model/model_flightmodes.cpp b/radio/src/gui/colorlcd/model/model_flightmodes.cpp index 2325ef70b..7f5e025f5 100644 --- a/radio/src/gui/colorlcd/model/model_flightmodes.cpp +++ b/radio/src/gui/colorlcd/model/model_flightmodes.cpp @@ -21,11 +21,15 @@ #include "model_flightmodes.h" -#include "list_line_button.h" +#include "button.h" #include "edgetx.h" +#include "etx_lv_theme.h" +#include "getset_helpers.h" +#include "list_line_button.h" +#include "numberedit.h" #include "page.h" #include "switchchoice.h" -#include "etx_lv_theme.h" +#include "textedit.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -204,7 +208,6 @@ class FlightModeBtn : public ListLineButton FlightModeBtn(Window* parent, int index) : ListLineButton(parent, index) { padAll(PAD_ZERO); - padColumn(PAD_ZERO); setHeight(BTN_H); delayLoad(); @@ -239,7 +242,7 @@ class FlightModeBtn : public ListLineButton fmFadeOut = etx_create(&fm_fade_class, lvobj); lv_obj_set_pos(fmFadeOut, FADE_X + FADE_W + PAD_TINY, FADE_Y); lv_obj_update_layout(lvobj); - + lv_obj_enable_style_refresh(true); lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY); @@ -462,7 +465,7 @@ const lv_obj_class_t FlightModeBtn::fm_trim_value_class = { .instance_size = sizeof(lv_label_t), }; -ModelFlightModesPage::ModelFlightModesPage(PageDef& pageDef) : +ModelFlightModesPage::ModelFlightModesPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/model/model_flightmodes.h b/radio/src/gui/colorlcd/model/model_flightmodes.h index 84a9a7d48..d002a5b8e 100644 --- a/radio/src/gui/colorlcd/model/model_flightmodes.h +++ b/radio/src/gui/colorlcd/model/model_flightmodes.h @@ -24,10 +24,12 @@ #include "edgetx.h" #include "pagegroup.h" +class TextButton; + class ModelFlightModesPage : public PageGroupItem { public: - ModelFlightModesPage(PageDef& pageDef); + ModelFlightModesPage(const PageDef& pageDef); void build(Window* window) override; diff --git a/radio/src/gui/colorlcd/model/model_gvars.cpp b/radio/src/gui/colorlcd/model/model_gvars.cpp index a9def005b..3500948fd 100644 --- a/radio/src/gui/colorlcd/model/model_gvars.cpp +++ b/radio/src/gui/colorlcd/model/model_gvars.cpp @@ -21,11 +21,16 @@ #include "model_gvars.h" -#include "list_line_button.h" -#include "numberedit.h" +#include "choice.h" #include "edgetx.h" -#include "page.h" #include "etx_lv_theme.h" +#include "getset_helpers.h" +#include "list_line_button.h" +#include "menu.h" +#include "numberedit.h" +#include "page.h" +#include "textedit.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -135,7 +140,7 @@ class GVarButton : public ListLineButton } lv_obj_update_layout(lvobj); - + lv_obj_enable_style_refresh(true); lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY); } @@ -507,7 +512,7 @@ class GVarEditWindow : public Page } }; -ModelGVarsPage::ModelGVarsPage(PageDef& pageDef) : +ModelGVarsPage::ModelGVarsPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/model/model_gvars.h b/radio/src/gui/colorlcd/model/model_gvars.h index fe0d43b20..710c7e7ce 100644 --- a/radio/src/gui/colorlcd/model/model_gvars.h +++ b/radio/src/gui/colorlcd/model/model_gvars.h @@ -27,7 +27,7 @@ class ModelGVarsPage : public PageGroupItem { public: - ModelGVarsPage(PageDef& pageDef); + ModelGVarsPage(const PageDef& pageDef); void cleanup() override; diff --git a/radio/src/gui/colorlcd/model/model_heli.cpp b/radio/src/gui/colorlcd/model/model_heli.cpp index 1abc81744..1dbfeca58 100644 --- a/radio/src/gui/colorlcd/model/model_heli.cpp +++ b/radio/src/gui/colorlcd/model/model_heli.cpp @@ -20,7 +20,10 @@ */ #include "model_heli.h" + #include "edgetx.h" +#include "getset_helpers.h" +#include "numberedit.h" #include "sourcechoice.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/model/model_inputs.cpp b/radio/src/gui/colorlcd/model/model_inputs.cpp index 10d77dee5..f5a329813 100644 --- a/radio/src/gui/colorlcd/model/model_inputs.cpp +++ b/radio/src/gui/colorlcd/model/model_inputs.cpp @@ -23,9 +23,11 @@ #include +#include "dialog.h" +#include "edgetx.h" #include "hal/adc_driver.h" #include "input_edit.h" -#include "edgetx.h" +#include "menu.h" #include "tasks/mixer_task.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -195,7 +197,7 @@ class InputGroup : public InputMixGroupBase } }; -ModelInputsPage::ModelInputsPage(PageDef& pageDef) : InputMixPageBase(pageDef) +ModelInputsPage::ModelInputsPage(const PageDef& pageDef) : InputMixPageBase(pageDef) { } diff --git a/radio/src/gui/colorlcd/model/model_inputs.h b/radio/src/gui/colorlcd/model/model_inputs.h index bff6f3be2..dee71f997 100644 --- a/radio/src/gui/colorlcd/model/model_inputs.h +++ b/radio/src/gui/colorlcd/model/model_inputs.h @@ -27,13 +27,13 @@ class ModelInputsPage : public InputMixPageBase { public: - ModelInputsPage(PageDef& pageDef); + ModelInputsPage(const PageDef& pageDef); void build(Window *window) override; protected: InputMixGroupBase* getGroupByIndex(uint8_t index) override; - + void addLineButton(uint8_t index) override; InputMixGroupBase* createGroup(Window* form, mixsrc_t src) override; InputMixButtonBase* createLineButton(InputMixGroupBase *group, uint8_t index) override; diff --git a/radio/src/gui/colorlcd/model/model_logical_switches.cpp b/radio/src/gui/colorlcd/model/model_logical_switches.cpp index 58a73a460..bd80787d6 100644 --- a/radio/src/gui/colorlcd/model/model_logical_switches.cpp +++ b/radio/src/gui/colorlcd/model/model_logical_switches.cpp @@ -21,13 +21,17 @@ #include "model_logical_switches.h" -#include "list_line_button.h" #include "edgetx.h" +#include "etx_lv_theme.h" +#include "getset_helpers.h" +#include "list_line_button.h" +#include "menu.h" +#include "numberedit.h" #include "page.h" #include "sourcechoice.h" #include "switchchoice.h" #include "switches.h" -#include "etx_lv_theme.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -522,7 +526,7 @@ class LogicalSwitchButton : public ListLineButton lv_obj_t* lsDelay = nullptr; }; -ModelLogicalSwitchesPage::ModelLogicalSwitchesPage(PageDef& pageDef) : +ModelLogicalSwitchesPage::ModelLogicalSwitchesPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/model/model_logical_switches.h b/radio/src/gui/colorlcd/model/model_logical_switches.h index bd52b620d..f25427682 100644 --- a/radio/src/gui/colorlcd/model/model_logical_switches.h +++ b/radio/src/gui/colorlcd/model/model_logical_switches.h @@ -27,7 +27,7 @@ class ModelLogicalSwitchesPage : public PageGroupItem { public: - ModelLogicalSwitchesPage(PageDef& pageDef); + ModelLogicalSwitchesPage(const PageDef& pageDef); virtual void build(Window* window) override; diff --git a/radio/src/gui/colorlcd/model/model_mixer_scripts.cpp b/radio/src/gui/colorlcd/model/model_mixer_scripts.cpp index da48b02e9..ca4ab8846 100644 --- a/radio/src/gui/colorlcd/model/model_mixer_scripts.cpp +++ b/radio/src/gui/colorlcd/model/model_mixer_scripts.cpp @@ -21,15 +21,18 @@ #include "model_mixer_scripts.h" -#include "dataconstants.h" +#include "edgetx.h" +#include "etx_lv_theme.h" #include "filechoice.h" +#include "getset_helpers.h" #include "list_line_button.h" #include "lua/lua_api.h" +#include "menu.h" #include "menus.h" -#include "edgetx.h" +#include "numberedit.h" #include "page.h" #include "sourcechoice.h" -#include "etx_lv_theme.h" +#include "textedit.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -251,7 +254,7 @@ class ScriptLineButton : public ListLineButton const ScriptInternalData* runtimeData; }; -ModelMixerScriptsPage::ModelMixerScriptsPage(PageDef& pageDef) : +ModelMixerScriptsPage::ModelMixerScriptsPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/model/model_mixer_scripts.h b/radio/src/gui/colorlcd/model/model_mixer_scripts.h index 62d81b545..551427a6d 100644 --- a/radio/src/gui/colorlcd/model/model_mixer_scripts.h +++ b/radio/src/gui/colorlcd/model/model_mixer_scripts.h @@ -27,7 +27,7 @@ class ModelMixerScriptsPage : public PageGroupItem { public: - ModelMixerScriptsPage(PageDef& pageDef); + ModelMixerScriptsPage(const PageDef& pageDef); virtual void build(Window* window) override { build(window, 0); } diff --git a/radio/src/gui/colorlcd/model/model_mixes.cpp b/radio/src/gui/colorlcd/model/model_mixes.cpp index 8a7df44df..0f850b141 100644 --- a/radio/src/gui/colorlcd/model/model_mixes.cpp +++ b/radio/src/gui/colorlcd/model/model_mixes.cpp @@ -20,13 +20,17 @@ */ #include "model_mixes.h" -#include "edgetx.h" -#include "mixer_edit.h" -#include "mixes.h" -#include "channel_bar.h" #include +#include "channel_bar.h" +#include "dialog.h" +#include "edgetx.h" +#include "menu.h" +#include "mixer_edit.h" +#include "mixes.h" +#include "toggleswitch.h" + #define SET_DIRTY() storageDirty(EE_MODEL) class MPlexIcon : public Window @@ -81,10 +85,10 @@ class MixLineButton : public InputMixButtonBase delayLoad(); } - void deleteLater(bool detach = true, bool trash = true) override + void deleteLater() override { - if (mplex) mplex->deleteLater(detach, trash); - InputMixButtonBase::deleteLater(detach, trash); + if (mplex) mplex->deleteLater(); + InputMixButtonBase::deleteLater(); } void delayedInit() override @@ -229,7 +233,7 @@ class MixGroup : public InputMixGroupBase bool monitorVisible = false; }; -ModelMixesPage::ModelMixesPage(PageDef& pageDef) : InputMixPageBase(pageDef) +ModelMixesPage::ModelMixesPage(const PageDef& pageDef) : InputMixPageBase(pageDef) { } diff --git a/radio/src/gui/colorlcd/model/model_mixes.h b/radio/src/gui/colorlcd/model/model_mixes.h index b8ae1f91c..711353289 100644 --- a/radio/src/gui/colorlcd/model/model_mixes.h +++ b/radio/src/gui/colorlcd/model/model_mixes.h @@ -27,7 +27,7 @@ class ModelMixesPage : public InputMixPageBase { public: - ModelMixesPage(PageDef& pageDef); + ModelMixesPage(const PageDef& pageDef); void build(Window* window) override; diff --git a/radio/src/gui/colorlcd/model/model_outputs.cpp b/radio/src/gui/colorlcd/model/model_outputs.cpp index a98de594c..7ddd89937 100644 --- a/radio/src/gui/colorlcd/model/model_outputs.cpp +++ b/radio/src/gui/colorlcd/model/model_outputs.cpp @@ -21,11 +21,15 @@ #include "model_outputs.h" +#include "dialog.h" #include "channel_bar.h" -#include "list_line_button.h" #include "edgetx.h" -#include "output_edit.h" #include "etx_lv_theme.h" +#include "getset_helpers.h" +#include "list_line_button.h" +#include "menu.h" +#include "output_edit.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -91,7 +95,7 @@ class OutputLineButton : public ListLineButton checkEvents(); lv_obj_update_layout(lvobj); - + lv_obj_enable_style_refresh(true); lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY); @@ -213,7 +217,7 @@ class OutputLineButton : public ListLineButton } }; -ModelOutputsPage::ModelOutputsPage(PageDef& pageDef) : +ModelOutputsPage::ModelOutputsPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/model/model_outputs.h b/radio/src/gui/colorlcd/model/model_outputs.h index 0700d59c9..20bdf4727 100644 --- a/radio/src/gui/colorlcd/model/model_outputs.h +++ b/radio/src/gui/colorlcd/model/model_outputs.h @@ -30,7 +30,7 @@ class OutputLineButton; class ModelOutputsPage : public PageGroupItem { public: - ModelOutputsPage(PageDef& pageDef); + ModelOutputsPage(const PageDef& pageDef); void build(Window* window) override; diff --git a/radio/src/gui/colorlcd/model/model_select.cpp b/radio/src/gui/colorlcd/model/model_select.cpp index 18f10f313..da77e2427 100644 --- a/radio/src/gui/colorlcd/model/model_select.cpp +++ b/radio/src/gui/colorlcd/model/model_select.cpp @@ -21,13 +21,16 @@ #include "model_select.h" +#include "choice.h" +#include "dialog.h" #include "edgetx.h" -#include "model_templates.h" -#include "standalone_lua.h" #include "etx_lv_theme.h" -#include "view_main.h" -#include "view_channels.h" +#include "menu.h" +#include "model_templates.h" #include "screen_setup.h" +#include "standalone_lua.h" +#include "view_channels.h" +#include "view_main.h" inline tmr10ms_t getTicks() { return g_tmr10ms; } @@ -63,8 +66,7 @@ class ModelButton : public Button m_setSelected(std::move(setSelected)) { padAll(PAD_ZERO); - - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + setWindowFlag(NO_FOCUS); delayLoad(); } @@ -363,9 +365,7 @@ class ModelsPageBody : public Window } } - // Exit to main view - auto w = Layer::back(); - if (w) w->onCancel(); + closeHandler(); // Skip reloading model if re-selecting the active model if (model != modelslist.getCurrentModel()) { @@ -521,8 +521,6 @@ class ModelLayoutButton : public IconButton ModelLabelsWindow::ModelLabelsWindow() : Page(ICON_MODEL_SELECT, PAD_ZERO, true) { - QuickMenu::setCurrentPage(QM_MANAGE_MODELS); - buildHead(header); buildBody(body); @@ -623,8 +621,7 @@ void ModelLabelsWindow::newModel() createModel(); // Close Window - auto w = Layer::back(); - if (w) w->onCancel(); + onCancel(); // Check for not 'Blank Model' if (name.size() > 0) { @@ -703,6 +700,7 @@ void ModelLabelsWindow::buildBody(Window *window) { // Models List mdlselector = new ModelsPageBody(window, {MDLS_X, MDLS_Y, MDLS_W, MDLS_H}); + mdlselector->setCloseHandler([=]() { onCancel(); }); 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/model_setup.cpp b/radio/src/gui/colorlcd/model/model_setup.cpp index f0f7a9356..effd3ea4d 100644 --- a/radio/src/gui/colorlcd/model/model_setup.cpp +++ b/radio/src/gui/colorlcd/model/model_setup.cpp @@ -21,39 +21,36 @@ #include "model_setup.h" -#include "button_matrix.h" -#include "filechoice.h" +#include +#include "button_matrix.h" +#include "edgetx.h" +#include "etx_lv_theme.h" +#include "filechoice.h" +#include "getset_helpers.h" #include "hal/adc_driver.h" -#include "storage/modelslist.h" -#include "trainer_setup.h" +#include "menu.h" +#include "model_heli.h" #include "module_setup.h" -#include "timer_setup.h" -#include "trims_setup.h" -#include "throttle_params.h" #include "preflight_checks.h" +#include "storage/modelslist.h" +#include "textedit.h" +#include "throttle_params.h" +#include "timer_setup.h" +#include "trainer_setup.h" +#include "trims_setup.h" + #if defined(FUNCTION_SWITCHES) #include "function_switches.h" #endif -#include "throttle_params.h" -#include "timer_setup.h" -#include "trainer_setup.h" -#include "trims_setup.h" -#include "module_setup.h" -#include "edgetx.h" -#include "storage/modelslist.h" -#include "etx_lv_theme.h" -#include "model_heli.h" #if defined(USBJ_EX) #include "model_usbjoystick.h" #endif -#include - #define SET_DIRTY() storageDirty(EE_MODEL) -ModelSetupPage::ModelSetupPage(PageDef& pageDef) : +ModelSetupPage::ModelSetupPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/model/model_setup.h b/radio/src/gui/colorlcd/model/model_setup.h index 34078da9e..19faceffe 100644 --- a/radio/src/gui/colorlcd/model/model_setup.h +++ b/radio/src/gui/colorlcd/model/model_setup.h @@ -27,7 +27,7 @@ class TextButton; class ModelSetupPage: public PageGroupItem { public: - ModelSetupPage(PageDef& pageDef); + ModelSetupPage(const PageDef& pageDef); void build(Window * window) override; diff --git a/radio/src/gui/colorlcd/model/model_telemetry.cpp b/radio/src/gui/colorlcd/model/model_telemetry.cpp index 424a2bd6c..e07c763e7 100644 --- a/radio/src/gui/colorlcd/model/model_telemetry.cpp +++ b/radio/src/gui/colorlcd/model/model_telemetry.cpp @@ -21,12 +21,17 @@ #include "model_telemetry.h" -#include "fullscreen_dialog.h" -#include "list_line_button.h" #include "edgetx.h" +#include "etx_lv_theme.h" +#include "fullscreen_dialog.h" +#include "getset_helpers.h" +#include "list_line_button.h" +#include "menu.h" +#include "numberedit.h" #include "page.h" #include "sourcechoice.h" -#include "etx_lv_theme.h" +#include "textedit.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -280,7 +285,7 @@ class SensorButton : public ListLineButton lv_obj_set_pos(valLabel, TSStyle::NUM_W + TSStyle::NAME_W + PAD_LARGE * 3, PAD_MEDIUM/2); lv_obj_update_layout(lvobj); - + lv_obj_enable_style_refresh(true); lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY); } @@ -748,7 +753,7 @@ class SensorEditWindow : public SubPage static LAYOUT_SIZE(NUM_EDIT_W, EdgeTxStyles::EDIT_FLD_WIDTH_NARROW, LAYOUT_SCALE(80)) }; -ModelTelemetryPage::ModelTelemetryPage(PageDef& pageDef) : +ModelTelemetryPage::ModelTelemetryPage(const PageDef& pageDef) : PageGroupItem(pageDef) { tsStyle.init(); diff --git a/radio/src/gui/colorlcd/model/model_telemetry.h b/radio/src/gui/colorlcd/model/model_telemetry.h index 2e5f2510f..c3a39771c 100644 --- a/radio/src/gui/colorlcd/model/model_telemetry.h +++ b/radio/src/gui/colorlcd/model/model_telemetry.h @@ -24,10 +24,12 @@ #include "edgetx.h" #include "pagegroup.h" +class TextButton; + class ModelTelemetryPage : public PageGroupItem { public: - ModelTelemetryPage(PageDef& pageDef); + ModelTelemetryPage(const PageDef& pageDef); void build(Window* window) override; diff --git a/radio/src/gui/colorlcd/model/model_usbjoystick.cpp b/radio/src/gui/colorlcd/model/model_usbjoystick.cpp index 50280519c..54832c49a 100644 --- a/radio/src/gui/colorlcd/model/model_usbjoystick.cpp +++ b/radio/src/gui/colorlcd/model/model_usbjoystick.cpp @@ -23,9 +23,13 @@ #include "button_matrix.h" #include "channel_bar.h" -#include "list_line_button.h" +#include "choice.h" #include "edgetx.h" #include "etx_lv_theme.h" +#include "getset_helpers.h" +#include "list_line_button.h" +#include "menu.h" +#include "toggleswitch.h" #include "usb_joystick.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -100,10 +104,11 @@ class USBChannelButtonSel : public ButtonMatrix m_channel(channel), m_setValue(std::move(_setValue)) { + padAll(PAD_OUTLINE); + bg_color[0] = makeLvColor(COLOR_THEME_PRIMARY2); // Unused fg_color[0] = makeLvColor(COLOR_THEME_SECONDARY1); - bg_color[1] = - makeLvColor(COLOR_THEME_DISABLED); // Used by other channel_bar + bg_color[1] = makeLvColor(COLOR_THEME_DISABLED); // Used by other channel_bar fg_color[1] = makeLvColor(COLOR_THEME_PRIMARY1); bg_color[2] = makeLvColor(COLOR_THEME_ACTIVE); // Used by this channel fg_color[2] = makeLvColor(COLOR_THEME_PRIMARY1); @@ -429,7 +434,7 @@ class USBChannelLineButton : public ListLineButton const char* param = ""; bool hasCollision = false; - + if (cch->mode == USBJOYS_CH_BUTTON) { param = STR_VUSBJOYSTICK_CH_BTNMODE[cch->param]; } else if (cch->mode == USBJOYS_CH_AXIS) { @@ -535,8 +540,7 @@ ModelUSBJoystickPage::ModelUSBJoystickPage() : Page(ICON_MODEL_USB, PAD_BORDER) auto btngrp = new Window(body, rect_t{}); btngrp->padAll(PAD_TINY); _ChannelsGroup = btngrp; - btngrp->setFlexLayout(); - btngrp->padRow(PAD_SMALL); + btngrp->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY); for (uint8_t ch = 0; ch < USBJ_MAX_JOYSTICK_CHANNELS; ch++) { // Channel settings auto btn = new USBChannelLineButton(btngrp, ch); diff --git a/radio/src/gui/colorlcd/model/output_edit.cpp b/radio/src/gui/colorlcd/model/output_edit.cpp index 5524ed497..4c9e34c76 100644 --- a/radio/src/gui/colorlcd/model/output_edit.cpp +++ b/radio/src/gui/colorlcd/model/output_edit.cpp @@ -22,12 +22,15 @@ #include "output_edit.h" #include "channel_bar.h" -#include "curveedit.h" #include "curve_param.h" -#include "gvar_numberedit.h" +#include "curveedit.h" #include "edgetx.h" #include "etx_lv_theme.h" +#include "getset_helpers.h" +#include "gvar_numberedit.h" #include "pagegroup.h" +#include "textedit.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/model/preflight_checks.cpp b/radio/src/gui/colorlcd/model/preflight_checks.cpp index eca67c324..e735538c8 100644 --- a/radio/src/gui/colorlcd/model/preflight_checks.cpp +++ b/radio/src/gui/colorlcd/model/preflight_checks.cpp @@ -22,11 +22,15 @@ #include "preflight_checks.h" #include "button_matrix.h" +#include "choice.h" +#include "edgetx.h" +#include "etx_lv_theme.h" +#include "getset_helpers.h" #include "hal/adc_driver.h" #include "hal/switch_driver.h" -#include "edgetx.h" +#include "numberedit.h" #include "strhelpers.h" -#include "etx_lv_theme.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/model/special_functions.cpp b/radio/src/gui/colorlcd/model/special_functions.cpp index 4091b4203..a3c9fdd59 100644 --- a/radio/src/gui/colorlcd/model/special_functions.cpp +++ b/radio/src/gui/colorlcd/model/special_functions.cpp @@ -22,11 +22,14 @@ #include "special_functions.h" #include "filechoice.h" +#include "getset_helpers.h" #include "hal/adc_driver.h" +#include "menu.h" #include "page.h" #include "sourcechoice.h" #include "switchchoice.h" #include "timeedit.h" +#include "toggleswitch.h" #include "view_main.h" #define SET_DIRTY() setDirty() @@ -691,7 +694,7 @@ void FunctionEditPage::buildBody(Window *form) //----------------------------------------------------------------------------- -FunctionsPage::FunctionsPage(CustomFunctionData *functions, PageDef& pageDef, +FunctionsPage::FunctionsPage(CustomFunctionData *functions, const PageDef& pageDef, const char *prefix) : PageGroupItem(pageDef), functions(functions), prefix(prefix) { @@ -961,7 +964,7 @@ class SpecialFunctionEditPage : public FunctionEditPage //----------------------------------------------------------------------------- -SpecialFunctionsPage::SpecialFunctionsPage(PageDef& pageDef) : +SpecialFunctionsPage::SpecialFunctionsPage(const PageDef& pageDef) : FunctionsPage(g_model.customFn, pageDef, "SF") { } @@ -1041,7 +1044,7 @@ class GlobalFunctionEditPage : public FunctionEditPage //----------------------------------------------------------------------------- -GlobalFunctionsPage::GlobalFunctionsPage(PageDef& pageDef) : +GlobalFunctionsPage::GlobalFunctionsPage(const PageDef& pageDef) : FunctionsPage(g_eeGeneral.customFn, pageDef, "GF") { } diff --git a/radio/src/gui/colorlcd/model/special_functions.h b/radio/src/gui/colorlcd/model/special_functions.h index 9a7720467..d2adf5ad1 100644 --- a/radio/src/gui/colorlcd/model/special_functions.h +++ b/radio/src/gui/colorlcd/model/special_functions.h @@ -29,6 +29,7 @@ struct CustomFunctionData; class FunctionEditPage; class FunctionLineButton; +class NumberEdit; //----------------------------------------------------------------------------- @@ -118,7 +119,7 @@ class FunctionEditPage : public Page class FunctionsPage : public PageGroupItem { public: - FunctionsPage(CustomFunctionData* functions, PageDef& pageDef, const char* prefix); + FunctionsPage(CustomFunctionData* functions, const PageDef& pageDef, const char* prefix); void build(Window* window) override; @@ -152,7 +153,7 @@ class FunctionsPage : public PageGroupItem class SpecialFunctionsPage : public FunctionsPage { public: - SpecialFunctionsPage(PageDef& pageDef); + SpecialFunctionsPage(const PageDef& pageDef); protected: CustomFunctionData* customFunctionData(uint8_t index) const override; @@ -167,7 +168,7 @@ class SpecialFunctionsPage : public FunctionsPage class GlobalFunctionsPage : public FunctionsPage { public: - GlobalFunctionsPage(PageDef& pageDef); + GlobalFunctionsPage(const PageDef& pageDef); protected: CustomFunctionData* customFunctionData(uint8_t index) const override; diff --git a/radio/src/gui/colorlcd/model/throttle_params.cpp b/radio/src/gui/colorlcd/model/throttle_params.cpp index 0f7bef7e7..6f074417d 100644 --- a/radio/src/gui/colorlcd/model/throttle_params.cpp +++ b/radio/src/gui/colorlcd/model/throttle_params.cpp @@ -20,9 +20,12 @@ */ #include "throttle_params.h" + #include "edgetx.h" +#include "getset_helpers.h" #include "sourcechoice.h" #include "switchchoice.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/model/timer_setup.cpp b/radio/src/gui/colorlcd/model/timer_setup.cpp index 7162b343b..a0c444cde 100644 --- a/radio/src/gui/colorlcd/model/timer_setup.cpp +++ b/radio/src/gui/colorlcd/model/timer_setup.cpp @@ -21,9 +21,13 @@ #include "timer_setup.h" +#include "choice.h" #include "edgetx.h" +#include "getset_helpers.h" #include "switchchoice.h" +#include "textedit.h" #include "timeedit.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/model/trainer_bluetooth.cpp b/radio/src/gui/colorlcd/model/trainer_bluetooth.cpp index b5758e09d..bf76ef867 100644 --- a/radio/src/gui/colorlcd/model/trainer_bluetooth.cpp +++ b/radio/src/gui/colorlcd/model/trainer_bluetooth.cpp @@ -20,8 +20,10 @@ */ #include "trainer_bluetooth.h" -#include "edgetx.h" +#include "dialog.h" +#include "edgetx.h" +#include "menu.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -33,7 +35,7 @@ static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, class BTDiscoverMenu : public Menu { uint8_t devCount = 0; - + void checkEvents() override; void selectAddr(const char* addr); @@ -71,7 +73,7 @@ void BTDiscoverMenu::selectAddr(const char* addr) { strncpy(bluetooth.distantAddr, addr, LEN_BLUETOOTH_ADDR); bluetooth.state = BLUETOOTH_STATE_BIND_REQUESTED; - SET_DIRTY(); + SET_DIRTY(); } BluetoothTrainerWindow::BluetoothTrainerWindow(Window* parent) : diff --git a/radio/src/gui/colorlcd/model/trainer_bluetooth.h b/radio/src/gui/colorlcd/model/trainer_bluetooth.h index 9142563e7..c1f5c25f8 100644 --- a/radio/src/gui/colorlcd/model/trainer_bluetooth.h +++ b/radio/src/gui/colorlcd/model/trainer_bluetooth.h @@ -42,7 +42,7 @@ class BluetoothTrainerWindow : public Window public: BluetoothTrainerWindow(Window* parent); - + void setMaster(bool master); void checkEvents() override; void refresh(); diff --git a/radio/src/gui/colorlcd/model/trainer_setup.cpp b/radio/src/gui/colorlcd/model/trainer_setup.cpp index 1150405eb..4698863c3 100644 --- a/radio/src/gui/colorlcd/model/trainer_setup.cpp +++ b/radio/src/gui/colorlcd/model/trainer_setup.cpp @@ -20,22 +20,25 @@ */ #include "trainer_setup.h" -#include "edgetx.h" -#define SET_DIRTY() storageDirty(EE_MODEL) - -#include "form.h" -#include "menu.h" -#include "static.h" #include "button.h" -#include "numberedit.h" #include "channel_range.h" +#include "choice.h" +#include "edgetx.h" +#include "form.h" +#include "getset_helpers.h" +#include "menu.h" +#include "numberedit.h" #include "ppm_settings.h" +#include "static.h" +#include "textedit.h" #if defined(BLUETOOTH) #include "trainer_bluetooth.h" #endif +#define SET_DIRTY() storageDirty(EE_MODEL) + static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2), LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, @@ -114,7 +117,7 @@ void TrainerModuleWindow::update() #if defined(BLUETOOTH) if (td->mode == TRAINER_MODE_MASTER_BLUETOOTH || td->mode == TRAINER_MODE_SLAVE_BLUETOOTH) { - + auto bt = new BluetoothTrainerWindow(this); if (td->mode == TRAINER_MODE_SLAVE_BLUETOOTH) bt->setMaster(false); @@ -135,7 +138,7 @@ void TrainerModuleWindow::update() line = newLine(grid); new StaticText(line, rect_t{}, STR_PPMFRAME); auto obj = new PpmFrameSettings(line, td); - + // copy pointer to frame len edit object to channel range chRange->setPpmFrameLenEditObject(obj->getPpmFrameLenEditObject()); } diff --git a/radio/src/gui/colorlcd/model/trims_setup.cpp b/radio/src/gui/colorlcd/model/trims_setup.cpp index 8e4967ec0..f18d99b85 100644 --- a/radio/src/gui/colorlcd/model/trims_setup.cpp +++ b/radio/src/gui/colorlcd/model/trims_setup.cpp @@ -21,7 +21,12 @@ #include "trims_setup.h" +#include "button.h" +#include "choice.h" +#include "dialog.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/module/access_settings.cpp b/radio/src/gui/colorlcd/module/access_settings.cpp index 19e176f9e..49ee88add 100644 --- a/radio/src/gui/colorlcd/module/access_settings.cpp +++ b/radio/src/gui/colorlcd/module/access_settings.cpp @@ -23,8 +23,12 @@ #include +#include "choice.h" #include "channel_bar.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "menu.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/module/access_settings.h b/radio/src/gui/colorlcd/module/access_settings.h index 4018c3481..5a8e5cdbb 100644 --- a/radio/src/gui/colorlcd/module/access_settings.h +++ b/radio/src/gui/colorlcd/module/access_settings.h @@ -78,7 +78,7 @@ class ModuleOptions : public BaseDialog MO_WriteSettings, MO_WritingSettings, }; - + uint8_t moduleIdx; uint8_t state = MO_Init; diff --git a/radio/src/gui/colorlcd/module/afhds2a_settings.cpp b/radio/src/gui/colorlcd/module/afhds2a_settings.cpp index 30aebc1be..0348f0057 100644 --- a/radio/src/gui/colorlcd/module/afhds2a_settings.cpp +++ b/radio/src/gui/colorlcd/module/afhds2a_settings.cpp @@ -20,8 +20,10 @@ */ #include "afhds2a_settings.h" -#include "edgetx.h" +#include "choice.h" +#include "edgetx.h" +#include "getset_helpers.h" #include "pulses/flysky.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -30,7 +32,7 @@ class FSProtoOpts : public Window { std::function _getMode; std::function _setMode; - + public: FSProtoOpts(Window* parent, std::function getMode, std::function setMode); diff --git a/radio/src/gui/colorlcd/module/afhds2a_settings.h b/radio/src/gui/colorlcd/module/afhds2a_settings.h index b22b9d2ff..98b30c596 100644 --- a/radio/src/gui/colorlcd/module/afhds2a_settings.h +++ b/radio/src/gui/colorlcd/module/afhds2a_settings.h @@ -40,13 +40,13 @@ class AFHDS2ASettings : public Window, public ModuleOptions bool hasRFPower = false; Window* afhds2RFPowerText = nullptr; Choice* afhds2RFPowerChoice = nullptr; -#endif +#endif void hideAFHDS2Options(); void showAFHDS2Options(); void checkEvents() override; void update() override; - + public: AFHDS2ASettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx); }; diff --git a/radio/src/gui/colorlcd/module/afhds3_options.cpp b/radio/src/gui/colorlcd/module/afhds3_options.cpp index 73f5bdc14..7179bfe14 100644 --- a/radio/src/gui/colorlcd/module/afhds3_options.cpp +++ b/radio/src/gui/colorlcd/module/afhds3_options.cpp @@ -20,7 +20,12 @@ */ #include "afhds3_options.h" + +#include "choice.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "numberedit.h" +#include "toggleswitch.h" static const lv_coord_t col_dsc[] = {LV_GRID_FR(2), LV_GRID_FR(3), LV_GRID_TEMPLATE_LAST}; @@ -115,7 +120,7 @@ PWMfrequencyChoice::PWMfrequencyChoice(Window* parent, uint8_t moduleIdx ) : vCfg->PWMFrequency.Frequency = newVal; DIRTY_CMD(cfg, afhds3::DirtyConfig::DC_RX_CMD_FREQUENCY_V0); }); - num_edit->show(pwmvalue_type == 2); + num_edit->show(pwmvalue_type == 2); } AFHDS3_Options::AFHDS3_Options(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP) @@ -197,7 +202,7 @@ AFHDS3_Options::AFHDS3_Options(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP) if(!newValue) { vCfg->NewPortTypes[i] = newValue; - DIRTY_CMD(cfg, afhds3::DirtyConfig::DC_RX_CMD_PORT_TYPE_V1); + DIRTY_CMD(cfg, afhds3::DirtyConfig::DC_RX_CMD_PORT_TYPE_V1); } else { uint8_t j = 0; diff --git a/radio/src/gui/colorlcd/module/afhds3_settings.cpp b/radio/src/gui/colorlcd/module/afhds3_settings.cpp index 97664c2f7..8c07f6845 100644 --- a/radio/src/gui/colorlcd/module/afhds3_settings.cpp +++ b/radio/src/gui/colorlcd/module/afhds3_settings.cpp @@ -22,7 +22,9 @@ #include "afhds3_settings.h" #include "afhds3_options.h" +#include "button.h" #include "edgetx.h" +#include "getset_helpers.h" static const char* const _afhds3_region[] = {"CE", "FCC"}; @@ -89,7 +91,7 @@ AFHDS3Settings::AFHDS3Settings(Window* parent, const FlexGridLayout& g, bool hasPowerOption = false; int maxPower; - if (moduleIdx == INTERNAL_MODULE) { + if (moduleIdx == INTERNAL_MODULE) { #if defined(RADIO_PL18U) || defined(PCBPA01) hasPowerOption = true; maxPower = AFHDS3_POWER_500; diff --git a/radio/src/gui/colorlcd/module/afhds3_settings.h b/radio/src/gui/colorlcd/module/afhds3_settings.h index 9d2c20485..30912994a 100644 --- a/radio/src/gui/colorlcd/module/afhds3_settings.h +++ b/radio/src/gui/colorlcd/module/afhds3_settings.h @@ -46,7 +46,7 @@ class AFHDS3Settings : public Window, public ModuleOptions void checkEvents() override; void update() override; - + public: AFHDS3Settings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx); }; diff --git a/radio/src/gui/colorlcd/module/crossfire_settings.cpp b/radio/src/gui/colorlcd/module/crossfire_settings.cpp index 575d271ae..0c7110895 100644 --- a/radio/src/gui/colorlcd/module/crossfire_settings.cpp +++ b/radio/src/gui/colorlcd/module/crossfire_settings.cpp @@ -20,10 +20,10 @@ */ #include "crossfire_settings.h" + #include "edgetx.h" - +#include "getset_helpers.h" #include "mixer_scheduler.h" - #include "telemetry/crossfire.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -66,7 +66,7 @@ CrossfireSettings::CrossfireSettings(Window* parent, const FlexGridLayout& g, sprintf(msg, "%d Hz", 1000000 / getMixerSchedulerPeriod()); return std::string(msg); }); - + moduleIdx = moduleIdx; auto armingLine = newLine(grid); @@ -78,7 +78,7 @@ CrossfireSettings::CrossfireSettings(Window* parent, const FlexGridLayout& g, choArmSwitch = new SwitchChoice(box, rect_t{}, SWSRC_FIRST, SWSRC_LAST, GET_SET_DEFAULT(md->crsf.crsfArmingTrigger)); choArmSwitch->setAvailableHandler([=](int sw) { return isSwitchAvailableForArming(sw); }); - update(); + update(); } void CrossfireSettings::update() { diff --git a/radio/src/gui/colorlcd/module/crossfire_settings.h b/radio/src/gui/colorlcd/module/crossfire_settings.h index 13685285b..bad211f1e 100644 --- a/radio/src/gui/colorlcd/module/crossfire_settings.h +++ b/radio/src/gui/colorlcd/module/crossfire_settings.h @@ -37,7 +37,7 @@ class CrossfireSettings : public Window, public ModuleOptions void checkEvents() override; void update() override; - + public: CrossfireSettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx); }; diff --git a/radio/src/gui/colorlcd/module/custom_failsafe.cpp b/radio/src/gui/colorlcd/module/custom_failsafe.cpp index 1c8586c41..804f5fd13 100644 --- a/radio/src/gui/colorlcd/module/custom_failsafe.cpp +++ b/radio/src/gui/colorlcd/module/custom_failsafe.cpp @@ -24,6 +24,7 @@ #include "channel_bar.h" #include "edgetx.h" #include "etx_lv_theme.h" +#include "numberedit.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/module/dsmp_settings.cpp b/radio/src/gui/colorlcd/module/dsmp_settings.cpp index 2ece07ada..40899c064 100644 --- a/radio/src/gui/colorlcd/module/dsmp_settings.cpp +++ b/radio/src/gui/colorlcd/module/dsmp_settings.cpp @@ -23,6 +23,8 @@ #include "choice.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/module/module_setup.cpp b/radio/src/gui/colorlcd/module/module_setup.cpp index b2cafa257..a3cea7b53 100644 --- a/radio/src/gui/colorlcd/module/module_setup.cpp +++ b/radio/src/gui/colorlcd/module/module_setup.cpp @@ -26,13 +26,15 @@ #include "channel_range.h" #include "choice.h" #include "custom_failsafe.h" -#include "form.h" -#include "mixer_scheduler.h" #include "edgetx.h" +#include "etx_lv_theme.h" +#include "form.h" +#include "getset_helpers.h" +#include "mixer_scheduler.h" +#include "os/sleep.h" #include "ppm_settings.h" #include "storage/modelslist.h" -#include "etx_lv_theme.h" -#include "os/sleep.h" +#include "toggleswitch.h" #if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA) #include "pxx1_settings.h" diff --git a/radio/src/gui/colorlcd/module/mpm_settings.cpp b/radio/src/gui/colorlcd/module/mpm_settings.cpp index a977f2a23..c34abff49 100644 --- a/radio/src/gui/colorlcd/module/mpm_settings.cpp +++ b/radio/src/gui/colorlcd/module/mpm_settings.cpp @@ -22,9 +22,12 @@ #include "mpm_settings.h" #include "choice.h" +#include "edgetx.h" +#include "getset_helpers.h" #include "io/multi_protolist.h" #include "multi_rfprotos.h" -#include "edgetx.h" +#include "numberedit.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -309,7 +312,7 @@ MultimoduleSettings::MultimoduleSettings(Window* parent, // TODO: needs to be placed differently // MultiModuleStatus &status = getMultiModuleStatus(moduleIdx); // if (status.protocolName[0] && status.isValid()) { - // new StaticText(this, grid.getFieldSlot(2, 1), status.protocolName, + // new StaticText(this, grid.getFieldSlot(2, 1), status.protocolName, // COLOR_THEME_PRIMARY1); // grid.nextLine(); // } diff --git a/radio/src/gui/colorlcd/module/multi_rfprotos.cpp b/radio/src/gui/colorlcd/module/multi_rfprotos.cpp index 888002d12..4faea408e 100644 --- a/radio/src/gui/colorlcd/module/multi_rfprotos.cpp +++ b/radio/src/gui/colorlcd/module/multi_rfprotos.cpp @@ -39,7 +39,7 @@ void RfScanDialog::showProgress() { updateProgress((int)(protos->getProgress() * 100.0)); } - + void RfScanDialog::checkEvents() { if (!protos->isScanning()) { @@ -48,7 +48,7 @@ void RfScanDialog::checkEvents() showProgress(); lastUpdate = lv_tick_get(); } - + ProgressDialog::checkEvents(); } diff --git a/radio/src/gui/colorlcd/module/ppm_settings.cpp b/radio/src/gui/colorlcd/module/ppm_settings.cpp index e8b701f74..2cd380c01 100644 --- a/radio/src/gui/colorlcd/module/ppm_settings.cpp +++ b/radio/src/gui/colorlcd/module/ppm_settings.cpp @@ -21,7 +21,9 @@ #include "ppm_settings.h" +#include "choice.h" #include "edgetx.h" +#include "getset_helpers.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/module/ppm_settings.h b/radio/src/gui/colorlcd/module/ppm_settings.h index 187f04504..5ef92192f 100644 --- a/radio/src/gui/colorlcd/module/ppm_settings.h +++ b/radio/src/gui/colorlcd/module/ppm_settings.h @@ -31,7 +31,7 @@ struct PpmFrameSettings : public Window { public: PpmFrameSettings(Window* parent, T* ppm); - + NumberEdit* getPpmFrameLenEditObject() { return ppmFrameLenEditObject; }; diff --git a/radio/src/gui/colorlcd/module/pxx1_settings.cpp b/radio/src/gui/colorlcd/module/pxx1_settings.cpp index 047837281..eb9ad050b 100644 --- a/radio/src/gui/colorlcd/module/pxx1_settings.cpp +++ b/radio/src/gui/colorlcd/module/pxx1_settings.cpp @@ -23,6 +23,7 @@ #include "choice.h" #include "edgetx.h" +#include "getset_helpers.h" #define SET_DIRTY() storageDirty(EE_MODEL) diff --git a/radio/src/gui/colorlcd/module/pxx1_settings.h b/radio/src/gui/colorlcd/module/pxx1_settings.h index 011ad8420..9842d7ffb 100644 --- a/radio/src/gui/colorlcd/module/pxx1_settings.h +++ b/radio/src/gui/colorlcd/module/pxx1_settings.h @@ -31,7 +31,7 @@ class PXX1AntennaSettings : public Window, public ModuleOptions ModuleData* md; void update() override {} - + public: PXX1AntennaSettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx); }; diff --git a/radio/src/gui/colorlcd/radio/hw_bluetooth.cpp b/radio/src/gui/colorlcd/radio/hw_bluetooth.cpp index a3480a4f4..e97c83ccc 100644 --- a/radio/src/gui/colorlcd/radio/hw_bluetooth.cpp +++ b/radio/src/gui/colorlcd/radio/hw_bluetooth.cpp @@ -21,7 +21,12 @@ #include "hw_bluetooth.h" +#include "choice.h" +#include "dialog.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "static.h" +#include "textedit.h" #define SET_DIRTY() storageDirty(EE_GENERAL) diff --git a/radio/src/gui/colorlcd/radio/hw_extmodule.cpp b/radio/src/gui/colorlcd/radio/hw_extmodule.cpp index c44193e8f..2c0e3e6a8 100644 --- a/radio/src/gui/colorlcd/radio/hw_extmodule.cpp +++ b/radio/src/gui/colorlcd/radio/hw_extmodule.cpp @@ -21,7 +21,10 @@ #include "hw_extmodule.h" +#include "choice.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "static.h" #define SET_DIRTY() storageDirty(EE_GENERAL) diff --git a/radio/src/gui/colorlcd/radio/hw_inputs.cpp b/radio/src/gui/colorlcd/radio/hw_inputs.cpp index d93918b73..843754983 100644 --- a/radio/src/gui/colorlcd/radio/hw_inputs.cpp +++ b/radio/src/gui/colorlcd/radio/hw_inputs.cpp @@ -22,10 +22,15 @@ #include "hw_inputs.h" #include "analogs.h" +#include "choice.h" +#include "edgetx.h" +#include "getset_helpers.h" #include "hal/adc_driver.h" #include "hal/switch_driver.h" -#include "edgetx.h" +#include "layout.h" +#include "static.h" #include "switches.h" +#include "textedit.h" #define SET_DIRTY() storageDirty(EE_GENERAL) diff --git a/radio/src/gui/colorlcd/radio/hw_intmodule.cpp b/radio/src/gui/colorlcd/radio/hw_intmodule.cpp index 7b80b298e..4f4d20afb 100644 --- a/radio/src/gui/colorlcd/radio/hw_intmodule.cpp +++ b/radio/src/gui/colorlcd/radio/hw_intmodule.cpp @@ -21,7 +21,10 @@ #include "hw_intmodule.h" +#include "choice.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "static.h" #if defined(CROSSFIRE) #include "telemetry/crossfire.h" diff --git a/radio/src/gui/colorlcd/radio/hw_serial.cpp b/radio/src/gui/colorlcd/radio/hw_serial.cpp index e93ee72cc..50f6598dd 100644 --- a/radio/src/gui/colorlcd/radio/hw_serial.cpp +++ b/radio/src/gui/colorlcd/radio/hw_serial.cpp @@ -20,7 +20,11 @@ */ #include "hw_serial.h" + +#include "choice.h" #include "edgetx.h" +#include "static.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_GENERAL) @@ -38,7 +42,7 @@ SerialConfigWindow::SerialConfigWindow(Window *parent, FlexGridLayout& grid) box->setFlexLayout(LV_FLEX_FLOW_ROW, PAD_MEDIUM); lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0); lv_obj_set_style_flex_cross_place(box->getLvObj(), LV_FLEX_ALIGN_CENTER, 0); - + auto aux = new Choice( box, rect_t{}, STR_AUX_SERIAL_MODES, 0, UART_MODE_MAX, [=]() { return serialGetMode(port_nr); }, @@ -59,7 +63,7 @@ SerialConfigWindow::SerialConfigWindow(Window *parent, FlexGridLayout& grid) SET_DIRTY(); }); } - + if (port_nr != SP_VCP) { grid.setColSpan(2); auto line = parent->newLine(grid); diff --git a/radio/src/gui/colorlcd/radio/preview_window.cpp b/radio/src/gui/colorlcd/radio/preview_window.cpp index b1df7c029..1d165ce73 100644 --- a/radio/src/gui/colorlcd/radio/preview_window.cpp +++ b/radio/src/gui/colorlcd/radio/preview_window.cpp @@ -22,11 +22,13 @@ #include "preview_window.h" #include "edgetx.h" -#include "sliders.h" #include "etx_lv_theme.h" -#include "trims.h" -#include "topbar.h" #include "quick_menu_group.h" +#include "sliders.h" +#include "textedit.h" +#include "toggleswitch.h" +#include "topbar.h" +#include "trims.h" // class to hold a color list and apply / restore it while drawing standard // controls @@ -77,8 +79,7 @@ class ThemedCheckBox : public ToggleSwitch [=](uint8_t value) { update(); }), checked(checked) { - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + setWindowFlag(NO_FOCUS | NO_CLICK); setFocusHandler([](bool focus) {}); } @@ -99,8 +100,7 @@ class ThemedButton : public TextButton bool isChecked) : TextButton(window, rect, text, nullptr) { - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + setWindowFlag(NO_FOCUS | NO_CLICK); setPressHandler([=]() { return isChecked; }); } @@ -156,9 +156,9 @@ PreviewWindow::PreviewWindow(Window *window, rect_t rect, new ThemedButton(this, {BTN_X, BTN2_Y, BTN_W, 0}, STR_THEME_REGULAR, false); new MainViewTrim(this, {CBT_X, TRIM_Y, MainViewSlider::HORIZONTAL_SLIDERS_WIDTH, EdgeTxStyles::STD_FONT_HEIGHT}, 0, false); new MainViewSlider(this, {CBT_X, SLIDER_Y, MainViewSlider::HORIZONTAL_SLIDERS_WIDTH, EdgeTxStyles::STD_FONT_HEIGHT}, 0, false); - new StaticText(this, {CBT_X, TXT1_Y, TXT_W, EdgeTxStyles::STD_FONT_HEIGHT}, STR_THEME_WARNING, + new StaticText(this, {CBT_X, TXT1_Y, TXT_W, EdgeTxStyles::STD_FONT_HEIGHT}, STR_THEME_WARNING, COLOR_THEME_WARNING_INDEX); - new StaticText(this, {CBT_X, TXT2_Y, TXT_W, EdgeTxStyles::STD_FONT_HEIGHT}, STR_THEME_DISABLED, + new StaticText(this, {CBT_X, TXT2_Y, TXT_W, EdgeTxStyles::STD_FONT_HEIGHT}, STR_THEME_DISABLED, COLOR_THEME_DISABLED_INDEX); new ThemedTextEdit(this, {CBT_X, EDT_Y, EDY_W, 0}, STR_THEME_EDIT, true); diff --git a/radio/src/gui/colorlcd/radio/radio_cfs.cpp b/radio/src/gui/colorlcd/radio/radio_cfs.cpp index 7b208ba4a..2b4555965 100644 --- a/radio/src/gui/colorlcd/radio/radio_cfs.cpp +++ b/radio/src/gui/colorlcd/radio/radio_cfs.cpp @@ -23,11 +23,14 @@ #include "radio_cfs.h" +#include "choice.h" +#include "color_picker.h" #include "edgetx.h" #include "hal/rgbleds.h" #include "strhelpers.h" #include "switches.h" -#include "color_picker.h" +#include "textedit.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_GENERAL) diff --git a/radio/src/gui/colorlcd/radio/radio_cfs.h b/radio/src/gui/colorlcd/radio/radio_cfs.h index 23e6d09f0..fa86257fd 100644 --- a/radio/src/gui/colorlcd/radio/radio_cfs.h +++ b/radio/src/gui/colorlcd/radio/radio_cfs.h @@ -22,21 +22,21 @@ #pragma once #if defined(FUNCTION_SWITCHES) - + #include "page.h" - + class RadioFunctionSwitches : public Page { public: RadioFunctionSwitches(); - + protected: BitmapBuffer* qrcode = nullptr; StaticText* startupHeader = nullptr; - + void setState(); void checkEvents() override; }; - + #endif \ No newline at end of file diff --git a/radio/src/gui/colorlcd/radio/radio_diaganas.cpp b/radio/src/gui/colorlcd/radio/radio_diaganas.cpp index 7ff29c094..700998b91 100644 --- a/radio/src/gui/colorlcd/radio/radio_diaganas.cpp +++ b/radio/src/gui/colorlcd/radio/radio_diaganas.cpp @@ -21,9 +21,10 @@ #include "radio_diaganas.h" -#include "hal/adc_driver.h" #include "edgetx.h" #include "etx_lv_theme.h" +#include "hal/adc_driver.h" +#include "static.h" // #if defined(IMU_LSM6DS33) // #include "imu_lsm6ds33.h" @@ -247,13 +248,13 @@ class AnaCalibratedViewWindow : public AnaViewWindow } } - void deleteLater(bool detach, bool trash) override + void deleteLater() override { if (!deleted()) { // Attached to parent->parent window lv_obj_del(touchLines[0]); lv_obj_del(touchLines[1]); - AnaViewWindow::deleteLater(detach, trash); + AnaViewWindow::deleteLater(); } } #endif diff --git a/radio/src/gui/colorlcd/radio/radio_diagcustswitches.cpp b/radio/src/gui/colorlcd/radio/radio_diagcustswitches.cpp index 9a346548c..433d303a4 100644 --- a/radio/src/gui/colorlcd/radio/radio_diagcustswitches.cpp +++ b/radio/src/gui/colorlcd/radio/radio_diagcustswitches.cpp @@ -78,7 +78,7 @@ class RadioCustSwitchesDiagsWindow : public Window new DynamicText( this, {FS_2ND_COLUMN + 10, y, FS_LBL_WIDTH, LV_SIZE_CONTENT}, [=]() { return g_model.cfsState(i) ? CHAR_DOWN : CHAR_UP; }); - + #if defined(FUNCTION_SWITCHES_RGB_LEDS) colorBox[r] = new ColorSwatch(this, {FS_3RD_COLUMN, y, FS_COLOR_WIDTH, FS_COLOR_HEIGHT}, getLedColor(r)); @@ -91,7 +91,7 @@ class RadioCustSwitchesDiagsWindow : public Window } } } - + #if defined(FUNCTION_SWITCHES_RGB_LEDS) void checkEvents() override { Window::checkEvents(); diff --git a/radio/src/gui/colorlcd/radio/radio_ghost_module_config.cpp b/radio/src/gui/colorlcd/radio/radio_ghost_module_config.cpp index 2dd2fa8a3..26d73d11d 100644 --- a/radio/src/gui/colorlcd/radio/radio_ghost_module_config.cpp +++ b/radio/src/gui/colorlcd/radio/radio_ghost_module_config.cpp @@ -127,11 +127,11 @@ static void ghostmoduleconfig_cb(lv_event_t* e) RadioGhostModuleConfig::RadioGhostModuleConfig(uint8_t moduleIdx) : Page(ICON_RADIO_TOOLS), moduleIdx(moduleIdx) { + setWindowFlag(NO_FOCUS | NO_SCROLL); + init(); buildHeader(header); buildBody(body); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); lv_group_add_obj(lv_group_get_default(), lvobj); lv_group_set_editing(lv_group_get_default(), true); lv_obj_add_event_cb(lvobj, ghostmoduleconfig_cb, LV_EVENT_KEY, this); diff --git a/radio/src/gui/colorlcd/radio/radio_gps_tool.cpp b/radio/src/gui/colorlcd/radio/radio_gps_tool.cpp index 22902a7e5..5bf7d4e63 100644 --- a/radio/src/gui/colorlcd/radio/radio_gps_tool.cpp +++ b/radio/src/gui/colorlcd/radio/radio_gps_tool.cpp @@ -21,6 +21,7 @@ #include "radio_gps_tool.h" +#include "button.h" #include "edgetx.h" RadioGpsTool::RadioGpsTool() : @@ -42,7 +43,7 @@ void RadioGpsTool::buildBody(Window* window) window->padAll(PAD_ZERO); gpsLabel = new StaticText(window, {PAD_LARGE, PAD_LARGE, LV_SIZE_CONTENT, 0}, "", COLOR_THEME_PRIMARY1_INDEX, FONT(L)); gpsQR = new QRCode(window, (window->width() - QR_SZ) / 2, (window->height() - QR_SZ) / 2, QR_SZ, ""); - new TextButton(window, + new TextButton(window, {window->width() - BTN_SZ - PAD_LARGE * 2, window->height() - EdgeTxStyles::UI_ELEMENT_HEIGHT - PAD_LARGE * 2, BTN_SZ, 0}, STR_REFRESH, [=]() { refresh(); diff --git a/radio/src/gui/colorlcd/radio/radio_hardware.cpp b/radio/src/gui/colorlcd/radio/radio_hardware.cpp index bf4f84131..ca50b359a 100644 --- a/radio/src/gui/colorlcd/radio/radio_hardware.cpp +++ b/radio/src/gui/colorlcd/radio/radio_hardware.cpp @@ -21,12 +21,14 @@ #include "radio_hardware.h" +#include "edgetx.h" +#include "getset_helpers.h" #include "hal/adc_driver.h" #include "hw_extmodule.h" #include "hw_inputs.h" #include "hw_intmodule.h" #include "hw_serial.h" -#include "edgetx.h" +#include "numberedit.h" #include "radio_calibration.h" #include "radio_diaganas.h" #include "radio_diagkeys.h" @@ -53,7 +55,7 @@ static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2), static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; -RadioHardwarePage::RadioHardwarePage(PageDef& pageDef) : +RadioHardwarePage::RadioHardwarePage(const PageDef& pageDef) : PageGroupItem(pageDef, PAD_TINY) { enableVBatBridge(); @@ -201,7 +203,7 @@ void RadioHardwarePage::build(Window* window) {STR_DEF(STR_ANALOGS_BTN), [=]() { new RadioAnalogsDiagsViewPageGroup(qmPageId); }}, {STR_DEF(STR_KEYS_BTN), []() { new RadioKeyDiagsPage(); }}, #if defined(FUNCTION_SWITCHES) - {STR_DEF(STR_FS_BTN), []() { new RadioCustSwitchesDiagsPage(); }}, -#endif + {STR_DEF(STR_FS_BTN), []() { new RadioCustSwitchesDiagsPage(); }}, +#endif }); } diff --git a/radio/src/gui/colorlcd/radio/radio_hardware.h b/radio/src/gui/colorlcd/radio/radio_hardware.h index 092327645..4b1690bf5 100644 --- a/radio/src/gui/colorlcd/radio/radio_hardware.h +++ b/radio/src/gui/colorlcd/radio/radio_hardware.h @@ -28,7 +28,7 @@ class RadioHardwarePage : public PageGroupItem void checkEvents() override; public: - RadioHardwarePage(PageDef& pageDef); + RadioHardwarePage(const PageDef& pageDef); void build(Window* window) override; diff --git a/radio/src/gui/colorlcd/radio/radio_sdmanager.cpp b/radio/src/gui/colorlcd/radio/radio_sdmanager.cpp index eaaafab9c..611008772 100644 --- a/radio/src/gui/colorlcd/radio/radio_sdmanager.cpp +++ b/radio/src/gui/colorlcd/radio/radio_sdmanager.cpp @@ -20,28 +20,29 @@ */ #include "radio_sdmanager.h" + #include "edgetx.h" -#include "LvglWrapper.h" +#include "etx_lv_theme.h" +#include "file_browser.h" +#include "file_preview.h" +#include "fullscreen_dialog.h" +#include "io/bootloader_flash.h" #include "io/frsky_firmware_update.h" #include "io/multi_firmware_update.h" -#include "io/bootloader_flash.h" #include "io/uf2_flash.h" -#include "standalone_lua.h" -#include "sdcard.h" -#include "view_text.h" -#include "file_preview.h" -#include "file_browser.h" -#include "progress.h" -#include "etx_lv_theme.h" -#include "fullscreen_dialog.h" #include "lib_file.h" +#include "menu.h" +#include "progress.h" +#include "sdcard.h" +#include "standalone_lua.h" +#include "view_text.h" constexpr int WARN_FILE_LENGTH = 40 * 1024; #define CELL_CTRL_DIR LV_TABLE_CELL_CTRL_CUSTOM_1 #define CELL_CTRL_FILE LV_TABLE_CELL_CTRL_CUSTOM_2 -RadioSdManagerPage::RadioSdManagerPage(PageDef& pageDef) : +RadioSdManagerPage::RadioSdManagerPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } @@ -52,18 +53,9 @@ class FlashDialog: public FullScreenDialog public: explicit FlashDialog(const T & device): FullScreenDialog(WARNING_TYPE_INFO, STR_FLASH_DEVICE), - device(device), - progress(this, {LCD_W / 2 - PROGRESS_W / 2, LCD_H / 2 + PROGRESS_YO, PROGRESS_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}) + device(device) { - } - - void deleteLater(bool detach = true, bool trash = true) override - { - if (_deleted) - return; - - progress.deleteLater(true, false); - FullScreenDialog::deleteLater(detach, trash); + progress = new Progress(this, {LCD_W / 2 - PROGRESS_W / 2, LCD_H / 2 + PROGRESS_YO, PROGRESS_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}); } void flash(const char * filename) @@ -74,7 +66,7 @@ class FlashDialog: public FullScreenDialog [=](const char *title, const char *message, int count, int total) -> void { setMessage(message); - progress.setValue(total > 0 ? count * 100 / total : 0); + progress->setValue(total > 0 ? count * 100 / total : 0); lv_refr_now(nullptr); }); deleteLater(); @@ -82,7 +74,7 @@ class FlashDialog: public FullScreenDialog protected: T device; - Progress progress; + Progress* progress = nullptr; static LAYOUT_VAL_SCALED(PROGRESS_YO, 27) static LAYOUT_VAL_SCALED(PROGRESS_W, 200) diff --git a/radio/src/gui/colorlcd/radio/radio_sdmanager.h b/radio/src/gui/colorlcd/radio/radio_sdmanager.h index 2d7c32974..d976caa4f 100644 --- a/radio/src/gui/colorlcd/radio/radio_sdmanager.h +++ b/radio/src/gui/colorlcd/radio/radio_sdmanager.h @@ -33,9 +33,9 @@ class RadioSdManagerPage : public PageGroupItem { FileBrowser* browser = nullptr; FilePreview* preview = nullptr; - + public: - RadioSdManagerPage(PageDef& pageDef); + RadioSdManagerPage(const PageDef& pageDef); void build(Window* window) override; protected: @@ -60,5 +60,5 @@ class RadioSdManagerPage : public PageGroupItem MultiModuleType type); #endif - void checkEvents() override; + void checkEvents() override; }; diff --git a/radio/src/gui/colorlcd/radio/radio_setup.cpp b/radio/src/gui/colorlcd/radio/radio_setup.cpp index cb16f6cce..53c4740ea 100644 --- a/radio/src/gui/colorlcd/radio/radio_setup.cpp +++ b/radio/src/gui/colorlcd/radio/radio_setup.cpp @@ -23,19 +23,24 @@ #include "radio_setup.h" -#include "hal/adc_driver.h" -#include "hal/usb_driver.h" -#include "hal/audio_driver.h" - -#include "input_mapping.h" +#include "choice.h" +#include "dialog.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "hal/adc_driver.h" +#include "hal/audio_driver.h" +#include "hal/usb_driver.h" +#include "input_mapping.h" +#include "key_shortcuts.h" +#include "numberedit.h" #include "page.h" +#include "quick_menu_favorites.h" +#include "slider.h" #include "storage/modelslist.h" #include "sourcechoice.h" #include "tasks/mixer_task.h" -#include "slider.h" -#include "key_shortcuts.h" -#include "quick_menu_favorites.h" +#include "textedit.h" +#include "toggleswitch.h" #define SET_DIRTY() storageDirty(EE_GENERAL) @@ -884,11 +889,11 @@ static SetupLineDef setupLines[] = { currentLangStrings = langStrings[newValue]; extern void setLanguageFont(int idx); setLanguageFont(newValue); - PageGroup* pg = (PageGroup*)Layer::getPageGroup(); + PageGroup* pg = Window::pageGroup(); coord_t y = pg->getScrollY(); pg->onCancel(); QuickMenu::openPage(QM_RADIO_SETUP); - pg = (PageGroup*)Layer::getPageGroup(); + pg = Window::pageGroup(); pg->setScrollY(y); // Force QM rebuild for language change QuickMenu::shutdownQuickMenu(); @@ -1010,7 +1015,7 @@ static SetupLineDef setupLines[] = { }, }; -RadioSetupPage::RadioSetupPage(PageDef& pageDef) : PageGroupItem(pageDef, PAD_TINY) {} +RadioSetupPage::RadioSetupPage(const PageDef& pageDef) : PageGroupItem(pageDef, PAD_TINY) {} #if VERSION_MAJOR > 2 static bool hasShortcutKeys() diff --git a/radio/src/gui/colorlcd/radio/radio_setup.h b/radio/src/gui/colorlcd/radio/radio_setup.h index 6f5a786cb..de419788f 100644 --- a/radio/src/gui/colorlcd/radio/radio_setup.h +++ b/radio/src/gui/colorlcd/radio/radio_setup.h @@ -26,7 +26,7 @@ class RadioSetupPage: public PageGroupItem { public: - RadioSetupPage(PageDef& pageDef); + RadioSetupPage(const PageDef& pageDef); void build(Window * window) override; diff --git a/radio/src/gui/colorlcd/radio/radio_spectrum_analyser.cpp b/radio/src/gui/colorlcd/radio/radio_spectrum_analyser.cpp index 8b6480fa5..f32c7e1b0 100644 --- a/radio/src/gui/colorlcd/radio/radio_spectrum_analyser.cpp +++ b/radio/src/gui/colorlcd/radio/radio_spectrum_analyser.cpp @@ -22,6 +22,8 @@ #include "radio_spectrum_analyser.h" #include "edgetx.h" +#include "getset_helpers.h" +#include "numberedit.h" #define SET_DIRTY() storageDirty(EE_GENERAL) diff --git a/radio/src/gui/colorlcd/radio/radio_theme.cpp b/radio/src/gui/colorlcd/radio/radio_theme.cpp index e0d99f723..fa973147d 100644 --- a/radio/src/gui/colorlcd/radio/radio_theme.cpp +++ b/radio/src/gui/colorlcd/radio/radio_theme.cpp @@ -21,13 +21,16 @@ #include "radio_theme.h" -#include "file_carosell.h" #include "color_editor.h" #include "color_list.h" +#include "dialog.h" #include "edgetx.h" +#include "etx_lv_theme.h" +#include "file_carosell.h" +#include "menu.h" #include "page.h" #include "preview_window.h" -#include "etx_lv_theme.h" +#include "textedit.h" class ThemeColorPreview : public Window { @@ -218,10 +221,10 @@ class ColorEditPage : public Page ColorSwatch *_colorSquare = nullptr; StaticText *_hexBox = nullptr; - void deleteLater(bool detach = true, bool trash = true) override + void deleteLater() override { if (_updateHandler != nullptr) _updateHandler(); - Page::deleteLater(detach, trash); + Page::deleteLater(); } void setHexStr(uint32_t rgb) @@ -432,7 +435,7 @@ class ThemeEditPage : public Page StaticText *_themeName = nullptr; }; -ThemeSetupPage::ThemeSetupPage(PageDef& pageDef) : +ThemeSetupPage::ThemeSetupPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } @@ -455,20 +458,11 @@ void ThemeSetupPage::setName(ThemeFile *theme) } } -bool isTopWindow(Window *window) -{ - Window *parent = window->getParent(); - if (parent != nullptr) { - return parent == Layer::back(); - } - return false; -} - void ThemeSetupPage::checkEvents() { PageGroupItem::checkEvents(); - if (fileCarosell) fileCarosell->pause(!isTopWindow(pageWindow)); + if (fileCarosell) fileCarosell->pause(!isVisible()); } void ThemeSetupPage::displayThemeMenu(Window *window, ThemePersistance *tp) @@ -572,7 +566,7 @@ void ThemeSetupPage::displayThemeMenu(Window *window, ThemePersistance *tp) void ThemeSetupPage::setSelected(ThemePersistance *tp) { auto value = listBox->getSelected(); - if (themeColorPreview && authorText && nameText && fileCarosell) { + if (currentTheme != value && themeColorPreview && authorText && nameText && fileCarosell) { ThemeFile *theme = tp->getThemeByIndex(value); if (theme) { themeColorPreview->setColorList(theme->getColorList()); diff --git a/radio/src/gui/colorlcd/radio/radio_theme.h b/radio/src/gui/colorlcd/radio/radio_theme.h index 35ba5996f..410dd29a5 100644 --- a/radio/src/gui/colorlcd/radio/radio_theme.h +++ b/radio/src/gui/colorlcd/radio/radio_theme.h @@ -24,17 +24,18 @@ #include "edgetx.h" #include "pagegroup.h" +class FileCarosell; class ListBox; class PageGroup; +class StaticText; class ThemeColorPreview; -class ThemePersistance; class ThemeFile; -class FileCarosell; +class ThemePersistance; class ThemeSetupPage : public PageGroupItem { public: - ThemeSetupPage(PageDef& pageDef); + ThemeSetupPage(const PageDef& pageDef); void build(Window *window) override; void checkEvents() override; diff --git a/radio/src/gui/colorlcd/radio/radio_tools.cpp b/radio/src/gui/colorlcd/radio/radio_tools.cpp index 41fbfa667..114bf4e3e 100644 --- a/radio/src/gui/colorlcd/radio/radio_tools.cpp +++ b/radio/src/gui/colorlcd/radio/radio_tools.cpp @@ -35,7 +35,7 @@ extern uint8_t g_moduleIdx; -RadioToolsPage::RadioToolsPage(PageDef& pageDef) : PageGroupItem(pageDef) {} +RadioToolsPage::RadioToolsPage(const PageDef& pageDef) : PageGroupItem(pageDef) {} void RadioToolsPage::build(Window* window) { diff --git a/radio/src/gui/colorlcd/radio/radio_tools.h b/radio/src/gui/colorlcd/radio/radio_tools.h index cd5f32ad7..3aa0abc96 100644 --- a/radio/src/gui/colorlcd/radio/radio_tools.h +++ b/radio/src/gui/colorlcd/radio/radio_tools.h @@ -26,7 +26,7 @@ class RadioToolsPage : public PageGroupItem { public: - RadioToolsPage(PageDef& pageDef); + RadioToolsPage(const PageDef& pageDefageDef); void build(Window* window) override; diff --git a/radio/src/gui/colorlcd/radio/radio_trainer.cpp b/radio/src/gui/colorlcd/radio/radio_trainer.cpp index 04c420e31..306866799 100644 --- a/radio/src/gui/colorlcd/radio/radio_trainer.cpp +++ b/radio/src/gui/colorlcd/radio/radio_trainer.cpp @@ -21,14 +21,18 @@ #include "radio_trainer.h" +#include "choice.h" +#include "edgetx.h" +#include "getset_helpers.h" #include "hal/adc_driver.h" #include "input_mapping.h" -#include "edgetx.h" +#include "numberedit.h" +#include "static.h" #include "strhelpers.h" #define SET_DIRTY() storageDirty(EE_GENERAL) -RadioTrainerPage::RadioTrainerPage(PageDef& pageDef) : +RadioTrainerPage::RadioTrainerPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/radio/radio_trainer.h b/radio/src/gui/colorlcd/radio/radio_trainer.h index e5d7df45c..fad770c80 100644 --- a/radio/src/gui/colorlcd/radio/radio_trainer.h +++ b/radio/src/gui/colorlcd/radio/radio_trainer.h @@ -27,7 +27,7 @@ class RadioTrainerPage : public PageGroupItem { public: - RadioTrainerPage(PageDef& pageDef); + RadioTrainerPage(const PageDef& pageDef); void build(Window* window) override; }; diff --git a/radio/src/gui/colorlcd/radio/radio_version.cpp b/radio/src/gui/colorlcd/radio/radio_version.cpp index 868d22f72..d5c4c1039 100644 --- a/radio/src/gui/colorlcd/radio/radio_version.cpp +++ b/radio/src/gui/colorlcd/radio/radio_version.cpp @@ -21,11 +21,14 @@ #include "radio_version.h" +#include "button.h" +#include "dialog.h" +#include "edgetx.h" +#include "etx_lv_theme.h" #include "fw_version.h" #include "hal/module_port.h" -#include "edgetx.h" #include "options.h" -#include "etx_lv_theme.h" +#include "static.h" #if defined(CROSSFIRE) #include "mixer_scheduler.h" @@ -101,7 +104,6 @@ class VersionDialog : public BaseDialog auto g = lv_group_get_default(); lv_group_set_editing(g, true); - lv_obj_add_flag(form->getLvObj(), LV_OBJ_FLAG_SCROLLABLE); lv_group_add_obj(g, form->getLvObj()); // headline "Internal module" @@ -339,7 +341,7 @@ const std::string copyright_str = "Copyright (C) " BUILD_YEAR " EdgeTX"; #endif const std::string edgetx_url = "https://edgetx.org"; -RadioVersionPage::RadioVersionPage(PageDef& pageDef) : +RadioVersionPage::RadioVersionPage(const PageDef& pageDef) : PageGroupItem(pageDef) { } diff --git a/radio/src/gui/colorlcd/radio/radio_version.h b/radio/src/gui/colorlcd/radio/radio_version.h index dc5ea558c..30fc304cf 100644 --- a/radio/src/gui/colorlcd/radio/radio_version.h +++ b/radio/src/gui/colorlcd/radio/radio_version.h @@ -26,7 +26,7 @@ class RadioVersionPage: public PageGroupItem { public: - RadioVersionPage(PageDef& pageDef); + RadioVersionPage(const PageDef& pageDef); void build(Window * window) override; diff --git a/radio/src/gui/colorlcd/setup_menus/key_shortcuts.cpp b/radio/src/gui/colorlcd/setup_menus/key_shortcuts.cpp index 659f18a4f..17ce8b494 100644 --- a/radio/src/gui/colorlcd/setup_menus/key_shortcuts.cpp +++ b/radio/src/gui/colorlcd/setup_menus/key_shortcuts.cpp @@ -20,7 +20,11 @@ */ #include "key_shortcuts.h" + +#include "button.h" +#include "choice.h" #include "edgetx.h" +#include "getset_helpers.h" #include "pagegroup.h" #define SET_DIRTY() storageDirty(EE_GENERAL) diff --git a/radio/src/gui/colorlcd/setup_menus/pagegroup.cpp b/radio/src/gui/colorlcd/setup_menus/pagegroup.cpp index 462ab1f58..17e8b3afd 100644 --- a/radio/src/gui/colorlcd/setup_menus/pagegroup.cpp +++ b/radio/src/gui/colorlcd/setup_menus/pagegroup.cpp @@ -21,15 +21,16 @@ #include "pagegroup.h" -#include "theme_manager.h" #include "etx_lv_theme.h" -#include "view_main.h" -#include "topbar.h" +#include "keyboard_base.h" +#include "mainwindow.h" #include "model_select.h" #include "os/time.h" -#include "view_channels.h" #include "screen_setup.h" -#include "keyboard_base.h" +#include "theme_manager.h" +#include "topbar.h" +#include "view_channels.h" +#include "view_main.h" #if defined(DEBUG) static uint32_t dsms, dems, end_ms, start_ms; @@ -144,7 +145,7 @@ PageGroupHeaderBase::PageGroupHeaderBase(Window* parent, coord_t height, EdgeTxI setTitle(""); #if VERSION_MAJOR == 2 - carousel = new Window(this, + carousel = new Window(this, {MENU_HEADER_BUTTONS_LEFT, 0, LCD_W - MENU_HEADER_BUTTONS_LEFT, EdgeTxStyles::MENU_HEADER_HEIGHT + ICON_EXTRA_H}); carousel->padAll(PAD_ZERO); @@ -230,7 +231,7 @@ bool PageGroupHeaderBase::hasSubMenu(QMPage qmPage) return false; } -void PageGroupHeaderBase::deleteLater(bool detach, bool trash) +void PageGroupHeaderBase::deleteLater() { if (deleted()) return; @@ -238,7 +239,7 @@ void PageGroupHeaderBase::deleteLater(bool detach, bool trash) delete pages[i]; pages.clear(); - Window::deleteLater(detach, trash); + Window::deleteLater(); } #if VERSION_MAJOR == 2 @@ -326,8 +327,7 @@ void PageGroupBase::onClicked() { Keyboard::hide(false); } void PageGroupBase::onCancel() { - if (quickMenu) quickMenu->closeMenu(); - quickMenu = nullptr; + QuickMenu::closeQuickMenu(); deleteLater(); } @@ -358,7 +358,8 @@ void PageGroupBase::setCurrentTab(unsigned index) header->setIcon(tab->getIcon()); #endif - QuickMenu::setCurrentPage(tab->pageId(), icon); + if (isPageGroup()) + QuickMenu::setCurrentPage(tab->pageId(), icon); lv_obj_enable_style_refresh(false); @@ -398,7 +399,7 @@ void PageGroupBase::doKeyShortcut(event_t event) { QMPage pg = g_eeGeneral.getKeyShortcut(event); if (pg == QM_OPEN_QUICK_MENU) { - if (!quickMenu) openMenu(); + if (!QuickMenu::isOpen()) openMenu(); } else { if (QuickMenu::subMenuIcon(pg) == icon) { setCurrentTab(QuickMenu::pageIndex(pg)); @@ -439,7 +440,7 @@ void PageGroupBase::setScrollY(coord_t y) //----------------------------------------------------------------------------- -PageGroup::PageGroup(EdgeTxIcon icon, const char* title, PageDef* pages) : +PageGroup::PageGroup(EdgeTxIcon icon, const char* title, const PageDef* pages) : PageGroupBase(PAGE_GROUP_BODY_Y, icon) { header = new PageGroupHeader(this, icon, title); @@ -466,7 +467,7 @@ PageGroup::PageGroup(EdgeTxIcon icon, const char* title, PageDef* pages) : void PageGroup::openMenu() { - quickMenu = QuickMenu::openQuickMenu([=]() { quickMenu = nullptr; }, + QuickMenu::openQuickMenu( [=](bool close) { if (close) onCancel(); @@ -552,19 +553,19 @@ TabsGroup::TabsGroup(EdgeTxIcon icon, const char* parentLabel) : void TabsGroup::openMenu() { - PageGroup* p = (PageGroup*)Layer::getPageGroup(); + PageGroup* p = Window::pageGroup(); QMPage qmPage = QM_NONE; if (p) qmPage = p->getCurrentTab()->pageId(); - quickMenu = QuickMenu::openQuickMenu([=]() { quickMenu = nullptr; }, + QuickMenu::openQuickMenu( [=](bool close) { onCancel(); if (p) { - while (!Layer::back()->isPageGroup()) { - Layer::back()->deleteLater(); + while (!Window::topWindow()->isPageGroup()) { + Window::topWindow()->deleteLater(); } if (close) - Layer::back()->onCancel(); + Window::topWindow()->onCancel(); } }, p, qmPage); } diff --git a/radio/src/gui/colorlcd/setup_menus/pagegroup.h b/radio/src/gui/colorlcd/setup_menus/pagegroup.h index e18cb3601..b109007ab 100644 --- a/radio/src/gui/colorlcd/setup_menus/pagegroup.h +++ b/radio/src/gui/colorlcd/setup_menus/pagegroup.h @@ -44,7 +44,7 @@ struct PageDef { STR_TYP title; PageDefAction pageAction; QMPage qmPage; - std::function create; + std::function create; std::function enabled; std::function action; }; @@ -64,12 +64,12 @@ struct QMTopDef { STR_TYP title; QMTopDefAction pageAction; QMPage qmPage; - PageDef* subMenuItems; + const PageDef* subMenuItems; std::function action; std::function enabled; }; -extern QMTopDef qmTopItems[]; +extern const QMTopDef qmTopItems[]; //----------------------------------------------------------------------------- @@ -80,7 +80,7 @@ class PageGroupItem title(std::move(title)), icon(ICON_EDGETX), qmPageId(qmPage), padding(PAD_SMALL) {} - PageGroupItem(PageDef& pageDef, PaddingSize padding = PAD_SMALL) : + PageGroupItem(const PageDef& pageDef, PaddingSize padding = PAD_SMALL) : title(STR_VAL(pageDef.title)), icon(pageDef.icon), qmPageId(pageDef.qmPage), padding(padding), pageDef(&pageDef) {} @@ -111,7 +111,7 @@ class PageGroupItem EdgeTxIcon icon; QMPage qmPageId = QM_NONE; PaddingSize padding; - PageDef* pageDef = nullptr; + const PageDef* pageDef = nullptr; }; //----------------------------------------------------------------------------- @@ -139,7 +139,7 @@ class PageGroupHeaderBase : public Window bool isCurrent(uint8_t idx) const { return currentIndex == idx; } uint8_t tabCount() const { return pages.size(); } - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; #if VERSION_MAJOR == 2 static LAYOUT_VAL_SCALED(ICON_EXTRA_H, 10) @@ -190,7 +190,6 @@ class PageGroupBase : public NavWindow PageGroupHeaderBase* header = nullptr; Window* body = nullptr; PageGroupItem* currentTab = nullptr; - QuickMenu* quickMenu = nullptr; EdgeTxIcon icon; virtual void openMenu() = 0; @@ -218,7 +217,7 @@ class PageGroupBase : public NavWindow class PageGroup : public PageGroupBase { public: - explicit PageGroup(EdgeTxIcon icon, const char* title, PageDef* pages); + explicit PageGroup(EdgeTxIcon icon, const char* title, const PageDef* pages); #if defined(DEBUG_WINDOWS) std::string getName() const override { return "PageGroup"; } @@ -259,6 +258,8 @@ class TabsGroup : public PageGroupBase void hidePageButtons(); + bool isPageGroup() override { return false; } + #if VERSION_MAJOR == 2 static LAYOUT_VAL_SCALED(TABS_GROUP_TOP_BAR_H, 48) static constexpr coord_t TABS_GROUP_ALT_TITLE_H = EdgeTxStyles::STD_FONT_HEIGHT; diff --git a/radio/src/gui/colorlcd/setup_menus/quick_menu.cpp b/radio/src/gui/colorlcd/setup_menus/quick_menu.cpp index addbb2aa0..7c6e8ad1d 100644 --- a/radio/src/gui/colorlcd/setup_menus/quick_menu.cpp +++ b/radio/src/gui/colorlcd/setup_menus/quick_menu.cpp @@ -21,14 +21,15 @@ #include "quick_menu.h" -#include "model_select.h" #include "edgetx.h" -#include "quick_menu_group.h" #include "etx_lv_theme.h" -#include "view_main.h" +#include "mainwindow.h" +#include "model_select.h" +#include "quick_menu_group.h" #include "screen_setup.h" #include "theme_manager.h" #include "view_channels.h" +#include "view_main.h" //----------------------------------------------------------------------------- @@ -38,7 +39,7 @@ class QuickSubMenu public: QuickSubMenu(Window* parent, QuickMenu* quickMenu, EdgeTxIcon icon, const char* title, const char* parentTitle, - PageDef* items): + const PageDef* items): parent(parent), quickMenu(quickMenu), icon(icon), title(title), parentTitle(parentTitle), items(items) {} @@ -96,10 +97,7 @@ class QuickSubMenu void enableSubMenu() { - subMenu->setGroup(); - subMenu->setFocus(); - subMenu->setEnabled(); - subMenu->show(); + subMenu->activate(); quickMenu->enableSubMenu(); } @@ -193,7 +191,7 @@ class QuickSubMenu EdgeTxIcon icon; const char* title; const char* parentTitle; - PageDef* items; + const PageDef* items; QuickMenuGroup* subMenu = nullptr; ButtonBase* menuButton = nullptr; }; @@ -205,17 +203,27 @@ QuickMenu* QuickMenu::instance = nullptr; QMPage QuickMenu::curPage = QM_NONE; EdgeTxIcon QuickMenu::curIcon = EDGETX_ICONS_COUNT; -QuickMenu* QuickMenu::openQuickMenu(std::function cancelHandler, - std::function selectHandler, +QuickMenu* QuickMenu::openQuickMenu(std::function selectHandler, PageGroupBase* pageGroup, QMPage curPage) { if (!instance) { instance = new QuickMenu(); } - instance->openQM(cancelHandler, selectHandler, pageGroup, curPage); + instance->openQM(selectHandler, pageGroup, curPage); return instance; } +void QuickMenu::closeQuickMenu() +{ + if (instance) + instance->closeQM(); +} + +bool QuickMenu::isOpen() +{ + return instance && instance->isVisible(); +} + void QuickMenu::shutdownQuickMenu() { if (instance) instance->deleteLater(); @@ -266,7 +274,7 @@ QuickMenu::QuickMenu() : for (int i = 0; qmTopItems[i].icon != EDGETX_ICONS_COUNT; i += 1) { if ((qmTopItems[i].enabled == nullptr) || qmTopItems[i].enabled()) { if (qmTopItems[i].pageAction == QM_ACTION) { - mainMenu->addButton(qmTopItems[i].icon, STR_VAL(qmTopItems[i].qmTitle), qmTopItems[i].action); + mainMenu->addButton(qmTopItems[i].icon, STR_VAL(qmTopItems[i].qmTitle), [=]() { onSelect(true); qmTopItems[i].action(); }); #if VERSION_MAJOR > 2 } else { auto sub = new QuickSubMenu(box, this, qmTopItems[i].icon, STR_VAL(qmTopItems[i].qmTitle), STR_VAL(qmTopItems[i].title), qmTopItems[i].subMenuItems); @@ -278,17 +286,16 @@ QuickMenu::QuickMenu() : } } -void QuickMenu::deleteLater(bool detach, bool trash) +void QuickMenu::deleteLater() { if (_deleted) return; instance = nullptr; - NavWindow::deleteLater(detach, trash); + NavWindow::deleteLater(); } -void QuickMenu::openQM(std::function cancelHandler, - std::function selectHandler, +void QuickMenu::openQM(std::function selectHandler, PageGroupBase* newPageGroup, QMPage newCurPage) { pushLayer(); @@ -303,7 +310,6 @@ void QuickMenu::openQM(std::function cancelHandler, subMenus[i]->doLayout(); #endif - this->cancelHandler = std::move(cancelHandler); this->selectHandler = std::move(selectHandler); show(); lv_obj_move_foreground(lvobj); @@ -316,9 +322,9 @@ void QuickMenu::openQM(std::function cancelHandler, setFocus(curPage); } else { pageGroup = nullptr; + mainMenu->clearFocus(); if (curPage != QM_MANAGE_MODELS && curPage != QM_NONE) { mainMenu->setDisabled(false); - mainMenu->clearFocus(); setFocus(curPage); } else { #if VERSION_MAJOR > 2 @@ -342,15 +348,17 @@ void QuickMenu::openPage(QMPage page) if (qmTopItems[i].pageAction == QM_ACTION) { if (qmTopItems[i].qmPage == page) { QuickMenu::selected(); + setCurrentPage(page, qmTopItems[i].icon); qmTopItems[i].action(); return; } } else { - PageDef* sub = qmTopItems[i].subMenuItems; + const PageDef* sub = qmTopItems[i].subMenuItems; for (int j = 0, k = 0; sub[j].icon != EDGETX_ICONS_COUNT; j += 1) { if (sub[j].qmPage == page) { if (sub[j].pageAction == PAGE_ACTION) { QuickMenu::selected(); + setCurrentPage(page, qmTopItems[i].icon); sub[j].action(); } else { QuickMenu::selected(); @@ -374,7 +382,7 @@ EdgeTxIcon QuickMenu::subMenuIcon(QMPage page) return qmTopItems[i].icon; } } else { - PageDef* sub = qmTopItems[i].subMenuItems; + const PageDef* sub = qmTopItems[i].subMenuItems; for (int j = 0; sub[j].icon != EDGETX_ICONS_COUNT; j += 1) { if (sub[j].qmPage == page) { return qmTopItems[i].icon; @@ -393,7 +401,7 @@ int QuickMenu::pageIndex(QMPage page) return 0; } } else { - PageDef* sub = qmTopItems[i].subMenuItems; + const PageDef* sub = qmTopItems[i].subMenuItems; for (int j = 0, k = 0; sub[j].icon != EDGETX_ICONS_COUNT; j += 1) { if (sub[j].qmPage == page) { if (sub[j].pageAction == PAGE_CREATE) @@ -432,7 +440,7 @@ std::vector QuickMenu::menuPageNames(bool forFavorites) if (qmTopItems[i].pageAction == QM_ACTION) { qmPages.emplace_back(STR_VAL(qmTopItems[i].title)); } else { - PageDef* sub = qmTopItems[i].subMenuItems; + const PageDef* sub = qmTopItems[i].subMenuItems; for (int j = 0; sub[j].icon != EDGETX_ICONS_COUNT; j += 1) { std::string s(STR_VAL(qmTopItems[i].title)); s += " - "; @@ -468,7 +476,7 @@ void QuickMenu::setupFavorite(QMPage page, int f) return; } } else { - PageDef* sub = qmTopItems[i].subMenuItems; + const PageDef* sub = qmTopItems[i].subMenuItems; for (int j = 0; sub[j].icon != EDGETX_ICONS_COUNT; j += 1) { if (sub[j].qmPage == page) { fav.icon = sub[j].icon; @@ -496,9 +504,7 @@ void QuickMenu::setCurrentPage(QMPage newPage, EdgeTxIcon newIcon) void QuickMenu::focusMainMenu() { inSubMenu = false; - mainMenu->setFocus(); - mainMenu->setEnabled(); - mainMenu->setGroup(); + mainMenu->activate(); #if VERSION_MAJOR > 2 for(auto sub : subMenus) sub->setDisabled(true); @@ -507,17 +513,18 @@ void QuickMenu::focusMainMenu() void QuickMenu::onSelect(bool close) { - closeMenu(); if (selectHandler) selectHandler(close); selectHandler = nullptr; + closeQM(); } -void QuickMenu::closeMenu() +void QuickMenu::closeQM() { - popLayer(); - hide(); - if (cancelHandler) cancelHandler(); - cancelHandler = nullptr; + if (isVisible()) { + popLayer(); + hide(); + selectHandler = nullptr; + } } void QuickMenu::onCancel() @@ -526,7 +533,7 @@ void QuickMenu::onCancel() focusMainMenu(); curPage = QM_NONE; } else { - closeMenu(); + closeQM(); } } @@ -552,7 +559,7 @@ void QuickMenu::doKeyShortcut(event_t event) { QMPage pg = g_eeGeneral.getKeyShortcut(event); if (pg == QM_OPEN_QUICK_MENU) { - closeMenu(); + closeQM(); } else { onSelect(true); QuickMenu::openPage(pg); @@ -564,7 +571,7 @@ void QuickMenu::onPressMDL() { doKeyShortcut(EVT_KEY_BREAK(KEY_MODEL)); } void QuickMenu::onLongPressMDL() { doKeyShortcut(EVT_KEY_LONG(KEY_MODEL)); } void QuickMenu::onPressTELE() { doKeyShortcut(EVT_KEY_BREAK(KEY_TELE)); } void QuickMenu::onLongPressTELE() { doKeyShortcut(EVT_KEY_LONG(KEY_TELE)); } -void QuickMenu::onLongPressRTN() { closeMenu(); } +void QuickMenu::onLongPressRTN() { closeQM(); } void QuickMenu::afterPG() { diff --git a/radio/src/gui/colorlcd/setup_menus/quick_menu.h b/radio/src/gui/colorlcd/setup_menus/quick_menu.h index 1c5bcd288..bee497cf3 100644 --- a/radio/src/gui/colorlcd/setup_menus/quick_menu.h +++ b/radio/src/gui/colorlcd/setup_menus/quick_menu.h @@ -52,7 +52,6 @@ class QuickMenu : public NavWindow void onCancel() override; void onSelect(bool close); - void closeMenu(); void setFocus(QMPage selection); @@ -63,12 +62,12 @@ class QuickMenu : public NavWindow PageGroupBase* getPageGroup() const { return pageGroup; } QuickMenuGroup* getTopMenu() const { return mainMenu; } - static QuickMenu* openQuickMenu(std::function cancelHandler, - std::function selectHandler = nullptr, + static QuickMenu* openQuickMenu(std::function selectHandler = nullptr, PageGroupBase* pageGroup = nullptr, QMPage curPage = QM_NONE); + static void closeQuickMenu(); + static bool isOpen(); static void shutdownQuickMenu(); - static void selected(); static void openPage(QMPage page); static EdgeTxIcon subMenuIcon(QMPage page); static int pageIndex(QMPage page); @@ -120,7 +119,6 @@ class QuickMenu : public NavWindow protected: static QuickMenu* instance; - std::function cancelHandler = nullptr; std::function selectHandler = nullptr; bool inSubMenu = false; QuickMenuGroup* mainMenu = nullptr; @@ -131,13 +129,15 @@ class QuickMenu : public NavWindow static QMPage curPage; static EdgeTxIcon curIcon; - void openQM(std::function cancelHandler, - std::function selectHandler, + void openQM(std::function selectHandler, PageGroupBase* pageGroup, QMPage curPage); + void closeQM(); void focusMainMenu(); - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; + + static void selected(); #if VERSION_MAJOR > 2 static void setupFavorite(QMPage page, int f); diff --git a/radio/src/gui/colorlcd/setup_menus/quick_menu_data.cpp b/radio/src/gui/colorlcd/setup_menus/quick_menu_data.cpp index 633aa4597..19aa0d994 100644 --- a/radio/src/gui/colorlcd/setup_menus/quick_menu_data.cpp +++ b/radio/src/gui/colorlcd/setup_menus/quick_menu_data.cpp @@ -20,7 +20,7 @@ */ #include "edgetx.h" -#include "pagegroup.h" +#include "menu.h" #include "model_curves.h" #include "model_flightmodes.h" #include "model_gvars.h" @@ -33,92 +33,100 @@ #include "model_select.h" #include "model_setup.h" #include "model_telemetry.h" -#include "special_functions.h" -#include "view_text.h" +#include "pagegroup.h" #include "radio_hardware.h" +#include "radio_sdmanager.h" #include "radio_setup.h" +#include "radio_tools.h" #include "radio_trainer.h" #include "radio_version.h" #include "screen_setup.h" -#include "view_main.h" -#include "radio_sdmanager.h" -#include "radio_tools.h" -#include "view_statistics.h" -#include "view_logical_switches.h" +#include "special_functions.h" #include "view_channels.h" +#include "view_logical_switches.h" +#include "view_main.h" +#include "view_statistics.h" +#include "view_text.h" + +const PageDef modelMenuItems[] = { + { ICON_MODEL_SETUP, STR_DEF(STR_QM_MODEL_SETTINGS), STR_DEF(STR_MAIN_MODEL_SETTINGS), PAGE_CREATE, QM_MODEL_SETUP, [](const PageDef& pageDef) { return new ModelSetupPage(pageDef); }}, +#if defined(FLIGHT_MODES) + { ICON_MODEL_FLIGHT_MODES, STR_DEF(STR_QM_FLIGHT_MODES), STR_DEF(STR_MENUFLIGHTMODES), PAGE_CREATE, QM_MODEL_FLIGHTMODES, [](const PageDef& pageDef) { return new ModelFlightModesPage(pageDef); }, modelFMEnabled}, +#endif + { ICON_MODEL_INPUTS, STR_DEF(STR_QM_INPUTS), STR_DEF(STR_MENUINPUTS), PAGE_CREATE, QM_MODEL_INPUTS, [](const PageDef& pageDef) { return new ModelInputsPage(pageDef); }}, + { ICON_MODEL_MIXER, STR_DEF(STR_QM_MIXES), STR_DEF(STR_MIXES), PAGE_CREATE, QM_MODEL_MIXES, [](const PageDef& pageDef) { return new ModelMixesPage(pageDef); }}, + { ICON_MODEL_OUTPUTS, STR_DEF(STR_QM_OUTPUTS), STR_DEF(STR_MENULIMITS), PAGE_CREATE, QM_MODEL_OUTPUTS, [](const PageDef& pageDef) { return new ModelOutputsPage(pageDef); }}, + { ICON_MODEL_CURVES, STR_DEF(STR_QM_CURVES), STR_DEF(STR_MENUCURVES), PAGE_CREATE, QM_MODEL_CURVES, [](const PageDef& pageDef) { return new ModelCurvesPage(pageDef); }, modelCurvesEnabled}, +#if defined(GVARS) + { ICON_MODEL_GVARS, STR_DEF(STR_QM_GLOBAL_VARS), STR_DEF(STR_MENU_GLOBAL_VARS), PAGE_CREATE, QM_MODEL_GVARS, [](const PageDef& pageDef) { return new ModelGVarsPage(pageDef); }, modelGVEnabled}, +#endif + { ICON_MODEL_LOGICAL_SWITCHES, STR_DEF(STR_QM_LOGICAL_SW), STR_DEF(STR_MENULOGICALSWITCHES), PAGE_CREATE, QM_MODEL_LS, [](const PageDef& pageDef) { return new ModelLogicalSwitchesPage(pageDef); }, modelLSEnabled}, + { ICON_MODEL_SPECIAL_FUNCTIONS, STR_DEF(STR_QM_SPEC_FUNC), STR_DEF(STR_MENUCUSTOMFUNC), PAGE_CREATE, QM_MODEL_SF, [](const PageDef& pageDef) { return new SpecialFunctionsPage(pageDef); }, modelSFEnabled}, +#if defined(LUA_MODEL_SCRIPTS) + { ICON_MODEL_LUA_SCRIPTS, STR_DEF(STR_QM_CUSTOM_LUA), STR_DEF(STR_MENUCUSTOMSCRIPTS), PAGE_CREATE, QM_MODEL_SCRIPTS, [](const PageDef& pageDef) { return new ModelMixerScriptsPage(pageDef); }, modelCustomScriptsEnabled}, +#endif + { ICON_MODEL_TELEMETRY, STR_DEF(STR_QM_TELEM), STR_DEF(STR_MENUTELEMETRY), PAGE_CREATE, QM_MODEL_TELEMETRY, [](const PageDef& pageDef) { return new ModelTelemetryPage(pageDef); }, modelTelemetryEnabled}, + { ICON_MODEL_NOTES, STR_DEF(STR_MAIN_MENU_MODEL_NOTES), STR_DEF(STR_MAIN_MENU_MODEL_NOTES), PAGE_CREATE, QM_MODEL_NOTES, [](const PageDef& pageDef) { return new ModelNotesPage(pageDef); }, modelHasNotes}, + { EDGETX_ICONS_COUNT } +}; + +const PageDef radioMenuItems[] = { +#if VERSION_MAJOR == 2 + { ICON_TOOLS_APPS, STR_DEF(STR_QM_APPS), STR_DEF(STR_MAIN_MENU_APPS), PAGE_CREATE, QM_TOOLS_APPS, [](const PageDef& pageDef) { return new RadioToolsPage(pageDef); }}, + { ICON_RADIO_SD_MANAGER, STR_DEF(STR_QM_STORAGE), STR_DEF(STR_SD_CARD), PAGE_CREATE, QM_TOOLS_STORAGE, [](const PageDef& pageDef) { return new RadioSdManagerPage(pageDef); }}, +#endif + { ICON_RADIO_SETUP, STR_DEF(STR_QM_RADIO_SETTINGS), STR_DEF(STR_MAIN_RADIO_SETTINGS), PAGE_CREATE, QM_RADIO_SETUP, [](const PageDef& pageDef) { return new RadioSetupPage(pageDef); }}, +#if VERSION_MAJOR == 2 + { ICON_RADIO_EDIT_THEME, STR_DEF(STR_QM_THEMES), STR_DEF(STR_MAIN_MENU_THEMES), PAGE_CREATE, QM_UI_THEMES, [](const PageDef& pageDef) { return new ThemeSetupPage(pageDef); }, radioThemesEnabled}, +#endif + { ICON_RADIO_GLOBAL_FUNCTIONS, STR_DEF(STR_QM_GLOB_FUNC), STR_DEF(STR_MENUSPECIALFUNCS), PAGE_CREATE, QM_RADIO_GF, [](const PageDef& pageDef) { return new GlobalFunctionsPage(pageDef); }, radioGFEnabled}, + { ICON_RADIO_TRAINER, STR_DEF(STR_QM_TRAINER), STR_DEF(STR_MENUTRAINER), PAGE_CREATE, QM_RADIO_TRAINER, [](const PageDef& pageDef) { return new RadioTrainerPage(pageDef); }, radioTrainerEnabled}, + { ICON_RADIO_HARDWARE, STR_DEF(STR_QM_HARDWARE), STR_DEF(STR_HARDWARE), PAGE_CREATE, QM_RADIO_HARDWARE, [](const PageDef& pageDef) { return new RadioHardwarePage(pageDef); }}, + { ICON_RADIO_VERSION, STR_DEF(STR_QM_ABOUT), STR_DEF(STR_MAIN_MENU_ABOUT_EDGETX), PAGE_CREATE, QM_RADIO_VERSION, [](const PageDef& pageDef) { return new RadioVersionPage(pageDef); }}, + { EDGETX_ICONS_COUNT } +}; + +const PageDef screensMenuItems[] = { +#if VERSION_MAJOR > 2 + { ICON_RADIO_EDIT_THEME, STR_DEF(STR_QM_THEMES), STR_DEF(STR_MAIN_MENU_THEMES), PAGE_CREATE, QM_UI_THEMES, [](const PageDef& pageDef) { return new ThemeSetupPage(pageDef); }, radioThemesEnabled}, +#endif + { ICON_THEME_SETUP, STR_DEF(STR_QM_TOP_BAR), STR_DEF(STR_USER_INTERFACE), PAGE_CREATE, QM_UI_SETUP, [](const PageDef& pageDef) { return new ScreenUserInterfacePage(pageDef); }}, + { ICON_THEME_VIEW1, STR_DEF(STR_QM_SCREEN_1), STR_DEF(STR_MAIN_VIEW_1), PAGE_CREATE, QM_UI_SCREEN1, [](const PageDef& pageDef) { return new ScreenSetupPage(0, pageDef); }}, + { ICON_THEME_VIEW2, STR_DEF(STR_QM_SCREEN_2), STR_DEF(STR_MAIN_VIEW_2), PAGE_CREATE, QM_UI_SCREEN2, [](const PageDef& pageDef) { return new ScreenSetupPage(1, pageDef); }, []() { return customScreens[1] != nullptr; }}, + { ICON_THEME_VIEW3, STR_DEF(STR_QM_SCREEN_3), STR_DEF(STR_MAIN_VIEW_3), PAGE_CREATE, QM_UI_SCREEN3, [](const PageDef& pageDef) { return new ScreenSetupPage(2, pageDef); }, []() { return customScreens[2] != nullptr; }}, + { ICON_THEME_VIEW4, STR_DEF(STR_QM_SCREEN_4), STR_DEF(STR_MAIN_VIEW_4), PAGE_CREATE, QM_UI_SCREEN4, [](const PageDef& pageDef) { return new ScreenSetupPage(3, pageDef); }, []() { return customScreens[3] != nullptr; }}, + { ICON_THEME_VIEW5, STR_DEF(STR_QM_SCREEN_5), STR_DEF(STR_MAIN_VIEW_5), PAGE_CREATE, QM_UI_SCREEN5, [](const PageDef& pageDef) { return new ScreenSetupPage(4, pageDef); }, []() { return customScreens[4] != nullptr; }}, + { ICON_THEME_VIEW6, STR_DEF(STR_QM_SCREEN_6), STR_DEF(STR_MAIN_VIEW_6), PAGE_CREATE, QM_UI_SCREEN6, [](const PageDef& pageDef) { return new ScreenSetupPage(5, pageDef); }, []() { return customScreens[5] != nullptr; }}, + { ICON_THEME_VIEW7, STR_DEF(STR_QM_SCREEN_7), STR_DEF(STR_MAIN_VIEW_7), PAGE_CREATE, QM_UI_SCREEN7, [](const PageDef& pageDef) { return new ScreenSetupPage(6, pageDef); }, []() { return customScreens[6] != nullptr; }}, + { ICON_THEME_VIEW8, STR_DEF(STR_QM_SCREEN_8), STR_DEF(STR_MAIN_VIEW_8), PAGE_CREATE, QM_UI_SCREEN8, [](const PageDef& pageDef) { return new ScreenSetupPage(7, pageDef); }, []() { return customScreens[7] != nullptr; }}, + { ICON_THEME_VIEW9, STR_DEF(STR_QM_SCREEN_9), STR_DEF(STR_MAIN_VIEW_9), PAGE_CREATE, QM_UI_SCREEN9, [](const PageDef& pageDef) { return new ScreenSetupPage(8, pageDef); }, []() { return customScreens[8] != nullptr; }}, + { ICON_THEME_VIEW10, STR_DEF(STR_QM_SCREEN_10), STR_DEF(STR_MAIN_VIEW_10), PAGE_CREATE, QM_UI_SCREEN10, [](const PageDef& pageDef) { return new ScreenSetupPage(9, pageDef); }, []() { return customScreens[9] != nullptr; }}, +#if VERSION_MAJOR == 2 + { ICON_THEME_ADD_VIEW, STR_DEF(STR_QM_ADD_SCREEN), STR_DEF(STR_QM_ADD_SCREEN), PAGE_CREATE, QM_UI_ADD_PG, [](const PageDef& pageDef) { return new ScreenAddPage(pageDef); }, []() { return customScreens[9] == nullptr; }}, +#else + { ICON_THEME_ADD_VIEW, STR_DEF(STR_QM_ADD_SCREEN), STR_DEF(STR_QM_ADD_SCREEN), PAGE_ACTION, QM_UI_ADD_PG, nullptr, []() { return customScreens[9] == nullptr; }, []() { ScreenSetupPage::addScreen(); } }, +#endif + { EDGETX_ICONS_COUNT } +}; #if VERSION_MAJOR == 2 -PageDef modelMenuItems[] = { - { ICON_MODEL_SETUP, STR_DEF(STR_QM_MODEL_SETTINGS), STR_DEF(STR_MAIN_MODEL_SETTINGS), PAGE_CREATE, QM_MODEL_SETUP, [](PageDef& pageDef) { return new ModelSetupPage(pageDef); }}, -#if defined(FLIGHT_MODES) - { ICON_MODEL_FLIGHT_MODES, STR_DEF(STR_QM_FLIGHT_MODES), STR_DEF(STR_MENUFLIGHTMODES), PAGE_CREATE, QM_MODEL_FLIGHTMODES, [](PageDef& pageDef) { return new ModelFlightModesPage(pageDef); }, modelFMEnabled}, -#endif - { ICON_MODEL_INPUTS, STR_DEF(STR_QM_INPUTS), STR_DEF(STR_MENUINPUTS), PAGE_CREATE, QM_MODEL_INPUTS, [](PageDef& pageDef) { return new ModelInputsPage(pageDef); }}, - { ICON_MODEL_MIXER, STR_DEF(STR_QM_MIXES), STR_DEF(STR_MIXES), PAGE_CREATE, QM_MODEL_MIXES, [](PageDef& pageDef) { return new ModelMixesPage(pageDef); }}, - { ICON_MODEL_OUTPUTS, STR_DEF(STR_QM_OUTPUTS), STR_DEF(STR_MENULIMITS), PAGE_CREATE, QM_MODEL_OUTPUTS, [](PageDef& pageDef) { return new ModelOutputsPage(pageDef); }}, - { ICON_MODEL_CURVES, STR_DEF(STR_QM_CURVES), STR_DEF(STR_MENUCURVES), PAGE_CREATE, QM_MODEL_CURVES, [](PageDef& pageDef) { return new ModelCurvesPage(pageDef); }, modelCurvesEnabled}, -#if defined(GVARS) - { ICON_MODEL_GVARS, STR_DEF(STR_QM_GLOBAL_VARS), STR_DEF(STR_MENU_GLOBAL_VARS), PAGE_CREATE, QM_MODEL_GVARS, [](PageDef& pageDef) { return new ModelGVarsPage(pageDef); }, modelGVEnabled}, -#endif - { ICON_MODEL_LOGICAL_SWITCHES, STR_DEF(STR_QM_LOGICAL_SW), STR_DEF(STR_MENULOGICALSWITCHES), PAGE_CREATE, QM_MODEL_LS, [](PageDef& pageDef) { return new ModelLogicalSwitchesPage(pageDef); }, modelLSEnabled}, - { ICON_MODEL_SPECIAL_FUNCTIONS, STR_DEF(STR_QM_SPEC_FUNC), STR_DEF(STR_MENUCUSTOMFUNC), PAGE_CREATE, QM_MODEL_SF, [](PageDef& pageDef) { return new SpecialFunctionsPage(pageDef); }, modelSFEnabled}, -#if defined(LUA_MODEL_SCRIPTS) - { ICON_MODEL_LUA_SCRIPTS, STR_DEF(STR_QM_CUSTOM_LUA), STR_DEF(STR_MENUCUSTOMSCRIPTS), PAGE_CREATE, QM_MODEL_SCRIPTS, [](PageDef& pageDef) { return new ModelMixerScriptsPage(pageDef); }, modelCustomScriptsEnabled}, -#endif - { ICON_MODEL_TELEMETRY, STR_DEF(STR_QM_TELEM), STR_DEF(STR_MENUTELEMETRY), PAGE_CREATE, QM_MODEL_TELEMETRY, [](PageDef& pageDef) { return new ModelTelemetryPage(pageDef); }, modelTelemetryEnabled}, +const PageDef statsMenuItems[] = { + { ICON_STATS, STR_DEF(STR_QM_STATS), STR_DEF(STR_MAIN_MENU_STATISTICS), PAGE_CREATE, QM_TOOLS_STATS, [](const PageDef& pageDef) { return new StatisticsViewPage(pageDef); }}, + { ICON_STATS_DEBUG, STR_DEF(STR_QM_DEBUG), STR_DEF(STR_DEBUG), PAGE_CREATE, QM_TOOLS_DEBUG, [](const PageDef& pageDef) { return new DebugViewPage(pageDef); }}, { EDGETX_ICONS_COUNT } }; -PageDef radioMenuItems[] = { - { ICON_TOOLS_APPS, STR_DEF(STR_QM_APPS), STR_DEF(STR_MAIN_MENU_APPS), PAGE_CREATE, QM_TOOLS_APPS, [](PageDef& pageDef) { return new RadioToolsPage(pageDef); }}, - { ICON_RADIO_SD_MANAGER, STR_DEF(STR_QM_STORAGE), STR_DEF(STR_SD_CARD), PAGE_CREATE, QM_TOOLS_STORAGE, [](PageDef& pageDef) { return new RadioSdManagerPage(pageDef); }}, - { ICON_RADIO_SETUP, STR_DEF(STR_QM_RADIO_SETTINGS), STR_DEF(STR_MAIN_RADIO_SETTINGS), PAGE_CREATE, QM_RADIO_SETUP, [](PageDef& pageDef) { return new RadioSetupPage(pageDef); }}, - { ICON_RADIO_EDIT_THEME, STR_DEF(STR_QM_THEMES), STR_DEF(STR_MAIN_MENU_THEMES), PAGE_CREATE, QM_UI_THEMES, [](PageDef& pageDef) { return new ThemeSetupPage(pageDef); }, radioThemesEnabled}, - { ICON_RADIO_GLOBAL_FUNCTIONS, STR_DEF(STR_QM_GLOB_FUNC), STR_DEF(STR_MENUSPECIALFUNCS), PAGE_CREATE, QM_RADIO_GF, [](PageDef& pageDef) { return new GlobalFunctionsPage(pageDef); }, radioGFEnabled}, - { ICON_RADIO_TRAINER, STR_DEF(STR_QM_TRAINER), STR_DEF(STR_MENUTRAINER), PAGE_CREATE, QM_RADIO_TRAINER, [](PageDef& pageDef) { return new RadioTrainerPage(pageDef); }, radioTrainerEnabled}, - { ICON_RADIO_HARDWARE, STR_DEF(STR_QM_HARDWARE), STR_DEF(STR_HARDWARE), PAGE_CREATE, QM_RADIO_HARDWARE, [](PageDef& pageDef) { return new RadioHardwarePage(pageDef); }}, - { ICON_RADIO_VERSION, STR_DEF(STR_QM_ABOUT), STR_DEF(STR_MAIN_MENU_ABOUT_EDGETX), PAGE_CREATE, QM_RADIO_VERSION, [](PageDef& pageDef) { return new RadioVersionPage(pageDef); }}, - { EDGETX_ICONS_COUNT } -}; - -PageDef screensMenuItems[] = { - { ICON_THEME_SETUP, STR_DEF(STR_QM_TOP_BAR), STR_DEF(STR_USER_INTERFACE), PAGE_CREATE, QM_UI_SETUP, [](PageDef& pageDef) { return new ScreenUserInterfacePage(pageDef); }}, - { ICON_THEME_VIEW1, STR_DEF(STR_QM_SCREEN_1), STR_DEF(STR_MAIN_VIEW_1), PAGE_CREATE, QM_UI_SCREEN1, [](PageDef& pageDef) { return new ScreenSetupPage(0, pageDef); }}, - { ICON_THEME_VIEW2, STR_DEF(STR_QM_SCREEN_2), STR_DEF(STR_MAIN_VIEW_2), PAGE_CREATE, QM_UI_SCREEN2, [](PageDef& pageDef) { return new ScreenSetupPage(1, pageDef); }, []() { return customScreens[1] != nullptr; }}, - { ICON_THEME_VIEW3, STR_DEF(STR_QM_SCREEN_3), STR_DEF(STR_MAIN_VIEW_3), PAGE_CREATE, QM_UI_SCREEN3, [](PageDef& pageDef) { return new ScreenSetupPage(2, pageDef); }, []() { return customScreens[2] != nullptr; }}, - { ICON_THEME_VIEW4, STR_DEF(STR_QM_SCREEN_4), STR_DEF(STR_MAIN_VIEW_4), PAGE_CREATE, QM_UI_SCREEN4, [](PageDef& pageDef) { return new ScreenSetupPage(3, pageDef); }, []() { return customScreens[3] != nullptr; }}, - { ICON_THEME_VIEW5, STR_DEF(STR_QM_SCREEN_5), STR_DEF(STR_MAIN_VIEW_5), PAGE_CREATE, QM_UI_SCREEN5, [](PageDef& pageDef) { return new ScreenSetupPage(4, pageDef); }, []() { return customScreens[4] != nullptr; }}, - { ICON_THEME_VIEW6, STR_DEF(STR_QM_SCREEN_6), STR_DEF(STR_MAIN_VIEW_6), PAGE_CREATE, QM_UI_SCREEN6, [](PageDef& pageDef) { return new ScreenSetupPage(5, pageDef); }, []() { return customScreens[5] != nullptr; }}, - { ICON_THEME_VIEW7, STR_DEF(STR_QM_SCREEN_7), STR_DEF(STR_MAIN_VIEW_7), PAGE_CREATE, QM_UI_SCREEN7, [](PageDef& pageDef) { return new ScreenSetupPage(6, pageDef); }, []() { return customScreens[6] != nullptr; }}, - { ICON_THEME_VIEW8, STR_DEF(STR_QM_SCREEN_8), STR_DEF(STR_MAIN_VIEW_8), PAGE_CREATE, QM_UI_SCREEN8, [](PageDef& pageDef) { return new ScreenSetupPage(7, pageDef); }, []() { return customScreens[7] != nullptr; }}, - { ICON_THEME_VIEW9, STR_DEF(STR_QM_SCREEN_9), STR_DEF(STR_MAIN_VIEW_9), PAGE_CREATE, QM_UI_SCREEN9, [](PageDef& pageDef) { return new ScreenSetupPage(8, pageDef); }, []() { return customScreens[8] != nullptr; }}, - { ICON_THEME_VIEW10, STR_DEF(STR_QM_SCREEN_10), STR_DEF(STR_MAIN_VIEW_10), PAGE_CREATE, QM_UI_SCREEN10, [](PageDef& pageDef) { return new ScreenSetupPage(9, pageDef); }, []() { return customScreens[9] != nullptr; }}, - { ICON_THEME_ADD_VIEW, STR_DEF(STR_QM_ADD_SCREEN), STR_DEF(STR_QM_ADD_SCREEN), PAGE_CREATE, QM_UI_ADD_PG, [](PageDef& pageDef) { return new ScreenAddPage(pageDef); }, []() { return customScreens[9] == nullptr; }}, - { EDGETX_ICONS_COUNT } -}; - -PageDef statsMenuItems[] = { - { ICON_STATS, STR_DEF(STR_QM_STATS), STR_DEF(STR_MAIN_MENU_STATISTICS), PAGE_CREATE, QM_TOOLS_STATS, [](PageDef& pageDef) { return new StatisticsViewPage(pageDef); }}, - { ICON_STATS_DEBUG, STR_DEF(STR_QM_DEBUG), STR_DEF(STR_DEBUG), PAGE_CREATE, QM_TOOLS_DEBUG, [](PageDef& pageDef) { return new DebugViewPage(pageDef); }}, - { EDGETX_ICONS_COUNT } -}; - -QMTopDef qmTopItems[] = { - { ICON_MODEL_SELECT, STR_DEF(STR_QM_MANAGE_MODELS), STR_DEF(STR_MANAGE_MODELS), QM_ACTION, QM_MANAGE_MODELS, nullptr, []() { QuickMenu::selected(); new ModelLabelsWindow(); }}, +const QMTopDef qmTopItems[] = { + { ICON_MODEL_SELECT, STR_DEF(STR_QM_MANAGE_MODELS), STR_DEF(STR_MANAGE_MODELS), QM_ACTION, QM_MANAGE_MODELS, nullptr, []() { new ModelLabelsWindow(); }}, { ICON_MODEL_NOTES, STR_DEF(STR_MAIN_MENU_MODEL_NOTES), STR_DEF(STR_MAIN_MENU_MODEL_NOTES), QM_ACTION, QM_NONE, nullptr, []() { QuickMenu::openPage(QM_MODEL_NOTES); }, modelHasNotes}, - { ICON_MONITOR, STR_DEF(STR_QM_CHAN_MON), STR_DEF(STR_QM_CHAN_MON), QM_ACTION, QM_TOOLS_CHAN_MON, nullptr, - []() { - QuickMenu::selected(); - new ChannelsViewMenu(); - } + { ICON_MONITOR, STR_DEF(STR_QM_CHAN_MON), STR_DEF(STR_QM_CHAN_MON), QM_ACTION, QM_TOOLS_CHAN_MON, nullptr, []() { new ChannelsViewMenu(); } }, { ICON_MODEL_SETUP, STR_DEF(STR_QM_MODEL_SETTINGS), STR_DEF(STR_MAIN_MODEL_SETTINGS), QM_ACTION, QM_NONE, nullptr, []() { QuickMenu::openPage(QM_MODEL_SETUP); }}, { ICON_RADIO_SETUP, STR_DEF(STR_QM_RADIO_SETTINGS), STR_DEF(STR_MAIN_RADIO_SETTINGS), QM_ACTION, QM_NONE, nullptr, []() { QuickMenu::openPage(QM_RADIO_SETUP); }}, { ICON_THEME, STR_DEF(STR_MAIN_MENU_SCREEN_SETTINGS), STR_DEF(STR_MAIN_MENU_SCREEN_SETTINGS), QM_ACTION, QM_NONE, nullptr, []() { QuickMenu::openPage(QM_UI_SCREEN1); }}, { ICON_TOOLS_RESET, STR_DEF(STR_QM_RESET), STR_DEF(STR_QM_RESET), QM_ACTION, QM_TOOLS_RESET, nullptr, []() { - QuickMenu::selected(); Menu* resetMenu = new Menu(); resetMenu->addLine(STR_RESET_FLIGHT, []() { flightReset(); }); resetMenu->addLine(STR_RESET_TIMER1, []() { timerReset(0); }); @@ -155,89 +163,11 @@ PageDef favoritesMenuItems[] = { { EDGETX_ICONS_COUNT } }; -PageDef modelMenuItems[] = { - { ICON_MODEL_SETUP, STR_DEF(STR_QM_MODEL_SETTINGS), STR_DEF(STR_MAIN_MODEL_SETTINGS), PAGE_CREATE, QM_MODEL_SETUP, [](PageDef& pageDef) { return new ModelSetupPage(pageDef); }}, -#if defined(FLIGHT_MODES) - { ICON_MODEL_FLIGHT_MODES, STR_DEF(STR_QM_FLIGHT_MODES), STR_DEF(STR_MENUFLIGHTMODES), PAGE_CREATE, QM_MODEL_FLIGHTMODES, [](PageDef& pageDef) { return new ModelFlightModesPage(pageDef); }, modelFMEnabled}, -#endif - { ICON_MODEL_INPUTS, STR_DEF(STR_QM_INPUTS), STR_DEF(STR_MENUINPUTS), PAGE_CREATE, QM_MODEL_INPUTS, [](PageDef& pageDef) { return new ModelInputsPage(pageDef); }}, - { ICON_MODEL_MIXER, STR_DEF(STR_QM_MIXES), STR_DEF(STR_MIXES), PAGE_CREATE, QM_MODEL_MIXES, [](PageDef& pageDef) { return new ModelMixesPage(pageDef); }}, - { ICON_MODEL_OUTPUTS, STR_DEF(STR_QM_OUTPUTS), STR_DEF(STR_MENULIMITS), PAGE_CREATE, QM_MODEL_OUTPUTS, [](PageDef& pageDef) { return new ModelOutputsPage(pageDef); }}, - { ICON_MODEL_CURVES, STR_DEF(STR_QM_CURVES), STR_DEF(STR_MENUCURVES), PAGE_CREATE, QM_MODEL_CURVES, [](PageDef& pageDef) { return new ModelCurvesPage(pageDef); }, modelCurvesEnabled}, -#if defined(GVARS) - { ICON_MODEL_GVARS, STR_DEF(STR_QM_GLOBAL_VARS), STR_DEF(STR_MENU_GLOBAL_VARS), PAGE_CREATE, QM_MODEL_GVARS, [](PageDef& pageDef) { return new ModelGVarsPage(pageDef); }, modelGVEnabled}, -#endif - { ICON_MODEL_LOGICAL_SWITCHES, STR_DEF(STR_QM_LOGICAL_SW), STR_DEF(STR_MENULOGICALSWITCHES), PAGE_CREATE, QM_MODEL_LS, [](PageDef& pageDef) { return new ModelLogicalSwitchesPage(pageDef); }, modelLSEnabled}, - { ICON_MODEL_SPECIAL_FUNCTIONS, STR_DEF(STR_QM_SPEC_FUNC), STR_DEF(STR_MENUCUSTOMFUNC), PAGE_CREATE, QM_MODEL_SF, [](PageDef& pageDef) { return new SpecialFunctionsPage(pageDef); }, modelSFEnabled}, -#if defined(LUA_MODEL_SCRIPTS) - { ICON_MODEL_LUA_SCRIPTS, STR_DEF(STR_QM_CUSTOM_LUA), STR_DEF(STR_MENUCUSTOMSCRIPTS), PAGE_CREATE, QM_MODEL_SCRIPTS, [](PageDef& pageDef) { return new ModelMixerScriptsPage(pageDef); }, modelCustomScriptsEnabled}, -#endif - { ICON_MODEL_TELEMETRY, STR_DEF(STR_QM_TELEM), STR_DEF(STR_MENUTELEMETRY), PAGE_CREATE, QM_MODEL_TELEMETRY, [](PageDef& pageDef) { return new ModelTelemetryPage(pageDef); }, modelTelemetryEnabled}, - { ICON_MODEL_NOTES, STR_DEF(STR_MAIN_MENU_MODEL_NOTES), STR_DEF(STR_MAIN_MENU_MODEL_NOTES), PAGE_CREATE, QM_MODEL_NOTES, [](PageDef& pageDef) { return new ModelNotesPage(pageDef); }, modelHasNotes}, - { EDGETX_ICONS_COUNT } -}; - -PageDef radioMenuItems[] = { - { ICON_RADIO_SETUP, STR_DEF(STR_QM_RADIO_SETTINGS), STR_DEF(STR_MAIN_RADIO_SETTINGS), PAGE_CREATE, QM_RADIO_SETUP, [](PageDef& pageDef) { return new RadioSetupPage(pageDef); }}, - { ICON_RADIO_GLOBAL_FUNCTIONS, STR_DEF(STR_QM_GLOB_FUNC), STR_DEF(STR_MENUSPECIALFUNCS), PAGE_CREATE, QM_RADIO_GF, [](PageDef& pageDef) { return new GlobalFunctionsPage(pageDef); }, radioGFEnabled}, - { ICON_RADIO_TRAINER, STR_DEF(STR_QM_TRAINER), STR_DEF(STR_MENUTRAINER), PAGE_CREATE, QM_RADIO_TRAINER, [](PageDef& pageDef) { return new RadioTrainerPage(pageDef); }, radioTrainerEnabled}, - { ICON_RADIO_HARDWARE, STR_DEF(STR_QM_HARDWARE), STR_DEF(STR_HARDWARE), PAGE_CREATE, QM_RADIO_HARDWARE, [](PageDef& pageDef) { return new RadioHardwarePage(pageDef); }}, - { ICON_RADIO_VERSION, STR_DEF(STR_QM_ABOUT), STR_DEF(STR_MAIN_MENU_ABOUT_EDGETX), PAGE_CREATE, QM_RADIO_VERSION, [](PageDef& pageDef) { return new RadioVersionPage(pageDef); }}, - { EDGETX_ICONS_COUNT } -}; - -PageDef screensMenuItems[] = { - { ICON_RADIO_EDIT_THEME, STR_DEF(STR_QM_THEMES), STR_DEF(STR_MAIN_MENU_THEMES), PAGE_CREATE, QM_UI_THEMES, [](PageDef& pageDef) { return new ThemeSetupPage(pageDef); }, radioThemesEnabled}, - { ICON_THEME_SETUP, STR_DEF(STR_QM_TOP_BAR), STR_DEF(STR_USER_INTERFACE), PAGE_CREATE, QM_UI_SETUP, [](PageDef& pageDef) { return new ScreenUserInterfacePage(pageDef); }}, - { ICON_THEME_VIEW1, STR_DEF(STR_QM_SCREEN_1), STR_DEF(STR_MAIN_VIEW_1), PAGE_CREATE, QM_UI_SCREEN1, [](PageDef& pageDef) { return new ScreenSetupPage(0, pageDef); }}, - { ICON_THEME_VIEW2, STR_DEF(STR_QM_SCREEN_2), STR_DEF(STR_MAIN_VIEW_2), PAGE_CREATE, QM_UI_SCREEN2, [](PageDef& pageDef) { return new ScreenSetupPage(1, pageDef); }, []() { return customScreens[1] != nullptr; }}, - { ICON_THEME_VIEW3, STR_DEF(STR_QM_SCREEN_3), STR_DEF(STR_MAIN_VIEW_3), PAGE_CREATE, QM_UI_SCREEN3, [](PageDef& pageDef) { return new ScreenSetupPage(2, pageDef); }, []() { return customScreens[2] != nullptr; }}, - { ICON_THEME_VIEW4, STR_DEF(STR_QM_SCREEN_4), STR_DEF(STR_MAIN_VIEW_4), PAGE_CREATE, QM_UI_SCREEN4, [](PageDef& pageDef) { return new ScreenSetupPage(3, pageDef); }, []() { return customScreens[3] != nullptr; }}, - { ICON_THEME_VIEW5, STR_DEF(STR_QM_SCREEN_5), STR_DEF(STR_MAIN_VIEW_5), PAGE_CREATE, QM_UI_SCREEN5, [](PageDef& pageDef) { return new ScreenSetupPage(4, pageDef); }, []() { return customScreens[4] != nullptr; }}, - { ICON_THEME_VIEW6, STR_DEF(STR_QM_SCREEN_6), STR_DEF(STR_MAIN_VIEW_6), PAGE_CREATE, QM_UI_SCREEN6, [](PageDef& pageDef) { return new ScreenSetupPage(5, pageDef); }, []() { return customScreens[5] != nullptr; }}, - { ICON_THEME_VIEW7, STR_DEF(STR_QM_SCREEN_7), STR_DEF(STR_MAIN_VIEW_7), PAGE_CREATE, QM_UI_SCREEN7, [](PageDef& pageDef) { return new ScreenSetupPage(6, pageDef); }, []() { return customScreens[6] != nullptr; }}, - { ICON_THEME_VIEW8, STR_DEF(STR_QM_SCREEN_8), STR_DEF(STR_MAIN_VIEW_8), PAGE_CREATE, QM_UI_SCREEN8, [](PageDef& pageDef) { return new ScreenSetupPage(7, pageDef); }, []() { return customScreens[7] != nullptr; }}, - { ICON_THEME_VIEW9, STR_DEF(STR_QM_SCREEN_9), STR_DEF(STR_MAIN_VIEW_9), PAGE_CREATE, QM_UI_SCREEN9, [](PageDef& pageDef) { return new ScreenSetupPage(8, pageDef); }, []() { return customScreens[8] != nullptr; }}, - { ICON_THEME_VIEW10, STR_DEF(STR_QM_SCREEN_10), STR_DEF(STR_MAIN_VIEW_10), PAGE_CREATE, QM_UI_SCREEN10, [](PageDef& pageDef) { return new ScreenSetupPage(9, pageDef); }, []() { return customScreens[9] != nullptr; }}, - { ICON_THEME_ADD_VIEW, STR_DEF(STR_QM_ADD_SCREEN), STR_DEF(STR_QM_ADD_SCREEN), PAGE_ACTION, QM_UI_ADD_PG, nullptr, []() { return customScreens[9] == nullptr; }, - []() { - int newIdx = 1; - for (; newIdx < MAX_CUSTOM_SCREENS; newIdx += 1) - if (customScreens[newIdx] == nullptr) - break; - - TRACE("Add screen: add screen: newIdx = %d", newIdx); - - auto& screen = customScreens[newIdx]; - - const LayoutFactory* factory = defaultLayout; - if (factory) { - TRACE("Add screen: add screen: factory = %p", factory); - - auto viewMain = ViewMain::instance(); - screen = factory->create(viewMain, newIdx); - viewMain->addMainView(screen, newIdx); - - g_model.setScreenLayoutId(newIdx, factory->getId()); - TRACE("Add screen: add screen: LayoutId = %s", g_model.getScreenLayoutId(newIdx)); - - QuickMenu::openPage((QMPage)(QM_UI_SCREEN1 + newIdx)); - - storageDirty(EE_MODEL); - } else { - TRACE("Add screen: factory is NULL"); - } - } - }, - { EDGETX_ICONS_COUNT } -}; - -PageDef toolsMenuItems[] = { - { ICON_TOOLS_APPS, STR_DEF(STR_QM_APPS), STR_DEF(STR_MAIN_MENU_APPS), PAGE_CREATE, QM_TOOLS_APPS, [](PageDef& pageDef) { return new RadioToolsPage(pageDef); }}, - { ICON_RADIO_SD_MANAGER, STR_DEF(STR_QM_STORAGE), STR_DEF(STR_SD_CARD), PAGE_CREATE, QM_TOOLS_STORAGE, [](PageDef& pageDef) { return new RadioSdManagerPage(pageDef); }}, +const PageDef toolsMenuItems[] = { + { ICON_TOOLS_APPS, STR_DEF(STR_QM_APPS), STR_DEF(STR_MAIN_MENU_APPS), PAGE_CREATE, QM_TOOLS_APPS, [](const PageDef& pageDef) { return new RadioToolsPage(pageDef); }}, + { ICON_RADIO_SD_MANAGER, STR_DEF(STR_QM_STORAGE), STR_DEF(STR_SD_CARD), PAGE_CREATE, QM_TOOLS_STORAGE, [](const PageDef& pageDef) { return new RadioSdManagerPage(pageDef); }}, { ICON_TOOLS_RESET, STR_DEF(STR_QM_RESET), STR_DEF(STR_QM_RESET), PAGE_ACTION, QM_TOOLS_RESET, nullptr, nullptr, []() { - QuickMenu::selected(); Menu* resetMenu = new Menu(); resetMenu->addLine(STR_RESET_FLIGHT, []() { flightReset(); }); resetMenu->addLine(STR_RESET_TIMER1, []() { timerReset(0); }); @@ -246,21 +176,16 @@ PageDef toolsMenuItems[] = { resetMenu->addLine(STR_RESET_TELEMETRY, []() { telemetryReset(); }); } }, - { ICON_MONITOR, STR_DEF(STR_QM_CHAN_MON), STR_DEF(STR_QM_CHAN_MON), PAGE_ACTION, QM_TOOLS_CHAN_MON, nullptr, nullptr, - []() { - QuickMenu::selected(); - new ChannelsViewMenu(); - } - }, - { ICON_MONITOR_LOGICAL_SWITCHES, STR_DEF(STR_QM_LS_MON), STR_DEF(STR_MONITOR_SWITCHES), PAGE_CREATE, QM_TOOLS_LS_MON, [](PageDef& pageDef) { return new LogicalSwitchesViewPage(pageDef); }}, - { ICON_STATS, STR_DEF(STR_QM_STATS), STR_DEF(STR_MAIN_MENU_STATISTICS), PAGE_CREATE, QM_TOOLS_STATS, [](PageDef& pageDef) { return new StatisticsViewPage(pageDef); }}, - { ICON_STATS_DEBUG, STR_DEF(STR_QM_DEBUG), STR_DEF(STR_DEBUG), PAGE_CREATE, QM_TOOLS_DEBUG, [](PageDef& pageDef) { return new DebugViewPage(pageDef); }}, + { ICON_MONITOR, STR_DEF(STR_QM_CHAN_MON), STR_DEF(STR_QM_CHAN_MON), PAGE_ACTION, QM_TOOLS_CHAN_MON, nullptr, nullptr, []() { new ChannelsViewMenu(); } }, + { ICON_MONITOR_LOGICAL_SWITCHES, STR_DEF(STR_QM_LS_MON), STR_DEF(STR_MONITOR_SWITCHES), PAGE_CREATE, QM_TOOLS_LS_MON, [](const PageDef& pageDef) { return new LogicalSwitchesViewPage(pageDef); }}, + { ICON_STATS, STR_DEF(STR_QM_STATS), STR_DEF(STR_MAIN_MENU_STATISTICS), PAGE_CREATE, QM_TOOLS_STATS, [](const PageDef& pageDef) { return new StatisticsViewPage(pageDef); }}, + { ICON_STATS_DEBUG, STR_DEF(STR_QM_DEBUG), STR_DEF(STR_DEBUG), PAGE_CREATE, QM_TOOLS_DEBUG, [](const PageDef& pageDef) { return new DebugViewPage(pageDef); }}, { EDGETX_ICONS_COUNT } }; -QMTopDef qmTopItems[] = { +const QMTopDef qmTopItems[] = { { ICON_QM_FAVORITES, STR_DEF(STR_FAVORITE_LABEL), STR_DEF(STR_FAVORITE_LABEL), QM_SUBMENU, QM_NONE, favoritesMenuItems, nullptr, []() { return favoritesMenuItems[0].icon != EDGETX_ICONS_COUNT; }}, - { ICON_MODEL_SELECT, STR_DEF(STR_QM_MANAGE_MODELS), STR_DEF(STR_MANAGE_MODELS), QM_ACTION, QM_MANAGE_MODELS, nullptr, []() { QuickMenu::selected(); new ModelLabelsWindow(); }}, + { ICON_MODEL_SELECT, STR_DEF(STR_QM_MANAGE_MODELS), STR_DEF(STR_MANAGE_MODELS), QM_ACTION, QM_MANAGE_MODELS, nullptr, []() { new ModelLabelsWindow(); }}, { ICON_MODEL, STR_DEF(STR_QM_MODEL_SETUP), STR_DEF(STR_MAIN_MENU_MODEL_SETTINGS), QM_SUBMENU, QM_NONE, modelMenuItems}, { ICON_RADIO, STR_DEF(STR_QM_RADIO_SETUP), STR_DEF(STR_MAIN_MENU_RADIO_SETTINGS), QM_SUBMENU, QM_NONE, radioMenuItems}, { ICON_THEME, STR_DEF(STR_QM_UI_SETUP), STR_DEF(STR_MAIN_MENU_SCREEN_SETTINGS), QM_SUBMENU, QM_NONE, screensMenuItems}, diff --git a/radio/src/gui/colorlcd/setup_menus/quick_menu_favorites.cpp b/radio/src/gui/colorlcd/setup_menus/quick_menu_favorites.cpp index 573aa121f..0e6753b47 100644 --- a/radio/src/gui/colorlcd/setup_menus/quick_menu_favorites.cpp +++ b/radio/src/gui/colorlcd/setup_menus/quick_menu_favorites.cpp @@ -20,7 +20,10 @@ */ #include "quick_menu_favorites.h" + +#include "choice.h" #include "edgetx.h" +#include "getset_helpers.h" #include "pagegroup.h" #define SET_DIRTY() storageDirty(EE_GENERAL) @@ -66,6 +69,6 @@ void QMFavoritesPage::onCancel() // Delete quick menu, and close parent page group (in case it is Favorites group) QuickMenu::shutdownQuickMenu(); QuickMenu::setCurrentPage(QM_NONE); - Layer::back()->onCancel(); + Window::topWindow()->onCancel(); } } diff --git a/radio/src/gui/colorlcd/setup_menus/quick_menu_group.cpp b/radio/src/gui/colorlcd/setup_menus/quick_menu_group.cpp index edf8b0040..6cb13db1c 100644 --- a/radio/src/gui/colorlcd/setup_menus/quick_menu_group.cpp +++ b/radio/src/gui/colorlcd/setup_menus/quick_menu_group.cpp @@ -175,10 +175,12 @@ void QuickMenuGroup::setGroup() } } -void QuickMenuGroup::deleteLater(bool detach, bool trash) +void QuickMenuGroup::deleteLater() { + if (_deleted) return; + if (group) lv_group_del(group); - Window::deleteLater(detach, trash); + Window::deleteLater(); } void QuickMenuGroup::setFocus() @@ -220,6 +222,14 @@ void QuickMenuGroup::setCurrent(ButtonBase* b) ((QuickMenuButton*)b)->setEnabled(); } +void QuickMenuGroup::activate() +{ + setFocus(); + setGroup(); + setEnabled(); + show(); +} + void QuickMenuGroup::doLayout(int cols) { int n = 0; diff --git a/radio/src/gui/colorlcd/setup_menus/quick_menu_group.h b/radio/src/gui/colorlcd/setup_menus/quick_menu_group.h index 752a50d49..70f542fdd 100644 --- a/radio/src/gui/colorlcd/setup_menus/quick_menu_group.h +++ b/radio/src/gui/colorlcd/setup_menus/quick_menu_group.h @@ -47,6 +47,7 @@ class QuickMenuGroup : public Window void clearFocus(); void setDisabled(bool all); void setEnabled(); + void activate(); void setCurrent(ButtonBase* b); void setCurrent(int b) { setCurrent(btns[b]); } void doLayout(int cols); @@ -69,5 +70,5 @@ class QuickMenuGroup : public Window ButtonBase* curBtn = nullptr; lv_group_t* group = nullptr; - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; }; diff --git a/radio/src/gui/colorlcd/standalone_lua.cpp b/radio/src/gui/colorlcd/standalone_lua.cpp index 30df57f57..9edf75ddf 100644 --- a/radio/src/gui/colorlcd/standalone_lua.cpp +++ b/radio/src/gui/colorlcd/standalone_lua.cpp @@ -21,9 +21,10 @@ #include "standalone_lua.h" -#include "view_main.h" #include "dma2d.h" +#include "keys.h" #include "lua/lua_event.h" +#include "view_main.h" #if defined(_WIN32) || defined(_WIN64) #define strcasecmp _stricmp @@ -133,6 +134,8 @@ StandaloneLuaWindow::StandaloneLuaWindow(bool useLvgl, int initFn, int runFn) : luaScriptManager = this; + pushLayer(true); + if (useLvglLayout()) { padAll(PAD_ZERO); etx_scrollbar(lvobj); @@ -151,20 +154,20 @@ StandaloneLuaWindow::StandaloneLuaWindow(bool useLvgl, int initFn, int runFn) : lcdBuffer->clear(); lcdBuffer->drawText(LCD_W / 2, LCD_H / 2 - EdgeTxStyles::STD_FONT_HEIGHT, STR_LOADING, FONT(L) | COLOR_THEME_PRIMARY2 | CENTERED); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); + setWindowFlag(NO_FOCUS | NO_SCROLL); auto canvas = lv_canvas_create(lvobj); lv_obj_center(canvas); lv_canvas_set_buffer(canvas, lcdBuffer->getData(), lcdBuffer->width(), lcdBuffer->height(), LV_IMG_CF_TRUE_COLOR); + + lv_group_add_obj(lv_group_get_default(), lvobj); + lv_group_set_editing(lv_group_get_default(), true); } // setup LUA event handler setupHandler(this); - attach(); - lua_gc(lsStandalone, LUA_GCCOLLECT, 0); // Pause function and mixer scripts @@ -187,22 +190,7 @@ StandaloneLuaWindow* StandaloneLuaWindow::instance() return _instance; } -void StandaloneLuaWindow::attach() -{ - if (!prevScreen) { - // backup previous screen - prevScreen = lv_scr_act(); - - pushLayer(true); - - if (!useLvglLayout()) { - lv_group_add_obj(lv_group_get_default(), lvobj); - lv_group_set_editing(lv_group_get_default(), true); - } - } -} - -void StandaloneLuaWindow::deleteLater(bool detach, bool trash) +void StandaloneLuaWindow::deleteLater() { if (_deleted) return; @@ -217,13 +205,9 @@ void StandaloneLuaWindow::deleteLater(bool detach, bool trash) luaScriptManager = nullptr; - if (prevScreen) { - prevScreen = nullptr; - } + Window::deleteLater(); - if (trash) { - _instance = nullptr; - } + _instance = nullptr; #if defined(USE_HATS_AS_KEYS) setTransposeHatsForLUA(false); @@ -233,7 +217,7 @@ void StandaloneLuaWindow::deleteLater(bool detach, bool trash) luaEmptyEventBuffer(); - Window::deleteLater(detach, trash); + Window::deleteLater(); } void StandaloneLuaWindow::checkEvents() diff --git a/radio/src/gui/colorlcd/standalone_lua.h b/radio/src/gui/colorlcd/standalone_lua.h index 6f6d8c47e..6285b069a 100644 --- a/radio/src/gui/colorlcd/standalone_lua.h +++ b/radio/src/gui/colorlcd/standalone_lua.h @@ -39,8 +39,7 @@ public: static StandaloneLuaWindow* instance(); static void setup(bool useLvgl, int initFn, int runFn); - void attach(); - void deleteLater(bool detach = true, bool trash = true) override; + void deleteLater() override; #if defined(DEBUG_WINDOWS) std::string getName() const override { return "StandaloneLuaWindow"; } @@ -70,7 +69,6 @@ public: static LAYOUT_VAL_SCALED(ERR_MSG_HO, 92) protected: - lv_obj_t* prevScreen = nullptr; lv_obj_t* errorModal = nullptr; lv_obj_t* errorTitle = nullptr; lv_obj_t* errorMsg = nullptr; diff --git a/radio/src/gui/colorlcd/startup_shutdown.cpp b/radio/src/gui/colorlcd/startup_shutdown.cpp index 81249041c..ac48fc5af 100644 --- a/radio/src/gui/colorlcd/startup_shutdown.cpp +++ b/radio/src/gui/colorlcd/startup_shutdown.cpp @@ -19,9 +19,12 @@ * GNU General Public License for more details. */ +#include "startup_shutdown.h" + +#include "edgetx.h" #include "hal/abnormal_reboot.h" #include "inactivity_timer.h" -#include "edgetx.h" +#include "mainwindow.h" #include "os/sleep.h" #include "stamp.h" #include "theme_manager.h" @@ -78,7 +81,7 @@ void drawSplash() #endif } - MainWindow::instance()->setActiveScreen(); + // Force screen refresh lv_refr_now(nullptr); } @@ -97,7 +100,6 @@ void cancelSplash() if (splashScreen) { splashScreen->deleteLater(); splashScreen = nullptr; - MainWindow::instance()->setActiveScreen(); splashStartTime = 0; } } @@ -109,7 +111,6 @@ void waitSplash() inactivityCheckInputs(); splashStartTime += SPLASH_TIMEOUT; while (splashStartTime >= get_tmr10ms()) { - LvglWrapper::instance()->run(); MainWindow::instance()->run(); WDG_RESET(); checkSpeakerVolume(); @@ -162,7 +163,8 @@ void drawSleepBitmap() (new StaticIcon(shutdownWindow, 0, 0, ICON_SHUTDOWN, COLOR_THEME_PRIMARY2_INDEX)) ->center(LCD_W, LCD_H); - LvglWrapper::instance()->run(); + // Force screen refresh + lv_refr_now(nullptr); } void cancelShutdownAnimation() @@ -212,7 +214,7 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, if (quarter < 0) quarter = 0; for (int i = 3; i >= quarter; i -= 1) shutdownAnim[i]->hide(); - LvglWrapper::instance()->run(); + MainWindow::instance()->run(); } void drawFatalErrorScreen(const char* message) @@ -230,7 +232,7 @@ void drawFatalErrorScreen(const char* message) } backlightEnable(100); - LvglWrapper::instance()->run(); + MainWindow::instance()->run(); } void runFatalErrorScreen(const char* message) diff --git a/radio/src/gui/colorlcd/startup_shutdown.h b/radio/src/gui/colorlcd/startup_shutdown.h index b9b9235f8..6d8d72e1f 100644 --- a/radio/src/gui/colorlcd/startup_shutdown.h +++ b/radio/src/gui/colorlcd/startup_shutdown.h @@ -21,6 +21,8 @@ #pragma once +#include + void drawFatalErrorScreen(const char* message); void runFatalErrorScreen(const char* message); diff --git a/radio/src/gui/colorlcd/themes/theme_manager.cpp b/radio/src/gui/colorlcd/themes/theme_manager.cpp index 6af58f8a2..fa070b4b0 100644 --- a/radio/src/gui/colorlcd/themes/theme_manager.cpp +++ b/radio/src/gui/colorlcd/themes/theme_manager.cpp @@ -20,16 +20,17 @@ */ #include "theme_manager.h" -#include "hal/abnormal_reboot.h" #include "../../storage/sdcard_common.h" #include "../../storage/yaml/yaml_bits.h" #include "../../storage/yaml/yaml_tree_walker.h" #include "etx_lv_theme.h" +#include "hal/abnormal_reboot.h" +#include "lib_file.h" +#include "mainwindow.h" +#include "pagegroup.h" +#include "storage/sdcard_yaml.h" #include "topbar.h" #include "view_main.h" -#include "storage/sdcard_yaml.h" -#include "lib_file.h" -#include "pagegroup.h" #define SET_DIRTY() storageDirty(EE_GENERAL) @@ -243,9 +244,15 @@ void ThemeFile::applyColors() } } +bool ThemeFile::tryBackground(std::string& file) +{ + if (isFileAvailable(file.c_str())) + return MainWindow::instance()->setBackgroundImage(file); + return false; +} + void ThemeFile::applyBackground() { - auto instance = MainWindow::instance(); std::string backgroundImageFileName(getPath()); auto pos = backgroundImageFileName.rfind('/'); if (pos != std::string::npos) { @@ -253,23 +260,19 @@ void ThemeFile::applyBackground() rootDir = rootDir + "background_" + std::to_string(LCD_W) + "x" + std::to_string(LCD_H) + ".png"; - if (isFileAvailable(rootDir.c_str())) { - instance->setBackgroundImage((char*)rootDir.c_str()); + if (tryBackground(rootDir)) return; - } rootDir = backgroundImageFileName.substr(0, pos + 1); rootDir = rootDir + "background.png"; - if (isFileAvailable(rootDir.c_str())) { - instance->setBackgroundImage((char*)rootDir.c_str()); + if (tryBackground(rootDir)) return; - } } // Use EdgeTxTheme default background - // TODO: This needs to be made user configurable - instance->setBackgroundImage(""); + std::string defaultBackground(THEMES_PATH "/EdgeTX/background.png"); + tryBackground(defaultBackground); } void ThemeFile::applyTheme() @@ -509,8 +512,7 @@ HeaderDateTime::HeaderDateTime(Window* parent, coord_t x, coord_t y) : lv_obj_set_style_text_align(time, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN); etx_txt_color(time, COLOR_THEME_PRIMARY2_INDEX); - lv_obj_add_flag(lvobj, LV_OBJ_FLAG_EVENT_BUBBLE); - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_CLICK); checkEvents(); } @@ -552,7 +554,7 @@ HeaderIcon::HeaderIcon(Window* parent, EdgeTxIcon icon, std::function ac this->icon->center(width() - PAD_SMALL, height()); #if defined(HARDWARE_TOUCH) if (this->action) { - lv_obj_add_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_CLICK); addCustomButton(0, 0, [=]() { this->action(); }); } #endif @@ -566,7 +568,7 @@ HeaderIcon::HeaderIcon(Window* parent, const char* iconFile, std::functionicon->center(width(), height()); #if defined(HARDWARE_TOUCH) if (this->action) { - lv_obj_add_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_CLICK); addCustomButton(0, 0, [=]() { this->action(); }); } #endif @@ -579,7 +581,7 @@ HeaderBackIcon::HeaderBackIcon(Window* parent, std::function action) : (new StaticIcon(this, 0, 0, ICON_BTN_CLOSE, COLOR_THEME_PRIMARY2_INDEX))->center(width() + PAD_MEDIUM, height()); #if defined(HARDWARE_TOUCH) if (this->action) { - lv_obj_add_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_CLICK); addCustomButton(0, 0, [=]() { this->action(); }); } #endif diff --git a/radio/src/gui/colorlcd/themes/theme_manager.h b/radio/src/gui/colorlcd/themes/theme_manager.h index 8cd24ee4e..9a24525fd 100644 --- a/radio/src/gui/colorlcd/themes/theme_manager.h +++ b/radio/src/gui/colorlcd/themes/theme_manager.h @@ -18,15 +18,17 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ -#pragma once -#include +#pragma once + +#include #include #include "colors.h" #include "debug.h" #include "edgetx.h" #include "sdcard.h" +#include "static.h" struct ColorEntry { @@ -63,7 +65,7 @@ class ThemeFile return nullptr; } - + void setName(const std::string& name) { this->name = name; } void setAuthor(const std::string& author) { this->author = author; } void setInfo(const std::string& info) { this->info = info; } @@ -88,6 +90,7 @@ class ThemeFile void applyColors(); void applyBackground(); + bool tryBackground(std::string& file); void deSerialize(); }; @@ -131,17 +134,17 @@ class ThemePersistance inline void setThemeIndex(int index) { currentTheme = index;} inline bool isDefaultTheme() { if (currentTheme == 0) return true; else return false; } - inline ThemeFile* getCurrentTheme() - { - if (currentTheme < (int)themes.size()) + inline ThemeFile* getCurrentTheme() + { + if (currentTheme < (int)themes.size()) return themes[currentTheme]; return nullptr; } - inline ThemeFile* getThemeByIndex(int index) - { + inline ThemeFile* getThemeByIndex(int index) + { if (index < (int) themes.size()) - return themes[index]; + return themes[index]; return nullptr; } diff --git a/radio/src/gui/colorlcd/widgets/gauge.cpp b/radio/src/gui/colorlcd/widgets/gauge.cpp index c47e73339..4ae9fd563 100644 --- a/radio/src/gui/colorlcd/widgets/gauge.cpp +++ b/radio/src/gui/colorlcd/widgets/gauge.cpp @@ -19,9 +19,11 @@ * GNU General Public License for more details. */ -#include "edgetx.h" #include "widget.h" +#include "edgetx.h" +#include "static.h" + class GaugeWidget : public Widget { public: @@ -35,7 +37,7 @@ class GaugeWidget : public Widget void delayedInit() override { // Gauge label - sourceText = new StaticText(this, {0, 0, LV_SIZE_CONTENT, 16}, "", + sourceText = new StaticText(this, {0, 0, LV_SIZE_CONTENT, 16}, "", COLOR_THEME_PRIMARY2_INDEX, FONT(XS)); valueText = new DynamicNumber( diff --git a/radio/src/gui/colorlcd/widgets/modelbmp.cpp b/radio/src/gui/colorlcd/widgets/modelbmp.cpp index 4f3941cb7..5e252eeb0 100644 --- a/radio/src/gui/colorlcd/widgets/modelbmp.cpp +++ b/radio/src/gui/colorlcd/widgets/modelbmp.cpp @@ -21,9 +21,11 @@ #include -#include "edgetx.h" #include "widget.h" +#include "edgetx.h" +#include "static.h" + #define ETX_STATE_BG_FILL LV_STATE_USER_1 class ModelBitmapWidget : public Widget diff --git a/radio/src/gui/colorlcd/widgets/outputs.cpp b/radio/src/gui/colorlcd/widgets/outputs.cpp index 972254cee..8e3c5a86e 100644 --- a/radio/src/gui/colorlcd/widgets/outputs.cpp +++ b/radio/src/gui/colorlcd/widgets/outputs.cpp @@ -36,9 +36,7 @@ class ChannelValue : public Window {col * colWidth, row * ROW_HEIGHT, colWidth - 1 + (colWidth & 1), (ROW_HEIGHT + 1)}), channel(channel), txtColor(txtColor), barColor(barColor) { - setWindowFlag(NO_FOCUS); - - lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); + setWindowFlag(NO_FOCUS | NO_CLICK); delayLoad(); } diff --git a/radio/src/gui/colorlcd/widgets/radio_info.cpp b/radio/src/gui/colorlcd/widgets/radio_info.cpp index cf0886785..976b531e2 100644 --- a/radio/src/gui/colorlcd/widgets/radio_info.cpp +++ b/radio/src/gui/colorlcd/widgets/radio_info.cpp @@ -192,7 +192,7 @@ class RadioInfoWidget : public TopBarWidget } static const WidgetOption options[]; - + static constexpr coord_t W_AUDIO_X = 0; static LAYOUT_VAL_SCALED(W_AUDIO_SCALE_X, 15) static LAYOUT_VAL_SCALED(W_USB_X, 32) diff --git a/radio/src/gui/colorlcd/widgets/timer.cpp b/radio/src/gui/colorlcd/widgets/timer.cpp index baeb02875..1740dbd7d 100644 --- a/radio/src/gui/colorlcd/widgets/timer.cpp +++ b/radio/src/gui/colorlcd/widgets/timer.cpp @@ -19,9 +19,11 @@ * GNU General Public License for more details. */ +#include "widget.h" + #include "bitmaps.h" #include "edgetx.h" -#include "widget.h" +#include "static.h" #define ETX_STATE_BG_WARNING LV_STATE_USER_1 #define EXT_NAME_ALIGN_RIGHT LV_STATE_USER_1 diff --git a/radio/src/gui/gui_common.cpp b/radio/src/gui/gui_common.cpp index 599642967..0f6bf6a90 100644 --- a/radio/src/gui/gui_common.cpp +++ b/radio/src/gui/gui_common.cpp @@ -713,6 +713,9 @@ bool isSourceAvailableInResetSpecialFunction(int index) #if defined(COLORLCD) +#include "menu.h" +#include "mainwindow.h" + class AntennaSelectionMenu : public Menu { bool& done; @@ -739,7 +742,6 @@ static void runAntennaSelectionMenu() while (!finished) { WDG_RESET(); MainWindow::instance()->run(); - LvglWrapper::runNested(); sleep_ms(20); } } diff --git a/radio/src/lua/lua_lvgl_widget.cpp b/radio/src/lua/lua_lvgl_widget.cpp index 0e7e757f6..96edc184a 100644 --- a/radio/src/lua/lua_lvgl_widget.cpp +++ b/radio/src/lua/lua_lvgl_widget.cpp @@ -20,18 +20,23 @@ */ #include "lua_widget.h" + #include "color_picker.h" +#include "dialog.h" #include "edgetx.h" +#include "filechoice.h" +#include "keyboard_base.h" #include "lua_event.h" +#include "menu.h" +#include "numberedit.h" #include "page.h" +#include "pagegroup.h" #include "slider.h" #include "sourcechoice.h" #include "switchchoice.h" -#include "toggleswitch.h" -#include "filechoice.h" -#include "keyboard_base.h" +#include "textedit.h" #include "theme_manager.h" -#include "pagegroup.h" +#include "toggleswitch.h" //----------------------------------------------------------------------------- @@ -1499,7 +1504,7 @@ void LvglWidgetBox::build(lua_State *L) window->setScrollHandler([=](coord_t x, coord_t y) { pcallFuncWith2Int(L, scrolledFunction, 0, x, y); }); lv_obj_add_flag(window->getLvObj(), LV_OBJ_FLAG_EVENT_BUBBLE); if (luaScriptManager->isWidget() && !luaScriptManager->isFullscreen()) { - lv_obj_clear_flag(window->getLvObj(), LV_OBJ_FLAG_CLICKABLE); + window->setWindowFlag(NO_CLICK); } else { lv_obj_set_scroll_dir(window->getLvObj(), scrollDir); if (showScrollBar) @@ -1823,8 +1828,8 @@ void LvglWidgetArc::build(lua_State *L) setRadius(radius.coord); window = new Window(lvglManager->getCurrentParent(), {x, y, w, h}, lv_arc_create); + window->setWindowFlag(NO_CLICK); lv_obj_add_flag(window->getLvObj(), LV_OBJ_FLAG_EVENT_BUBBLE); - lv_obj_clear_flag(window->getLvObj(), LV_OBJ_FLAG_CLICKABLE); lv_arc_set_range(window->getLvObj(), 0, 360); lv_obj_remove_style(window->getLvObj(), NULL, LV_PART_KNOB); lv_obj_set_style_arc_width(window->getLvObj(), thickness, LV_PART_MAIN); diff --git a/radio/src/lua/lua_widget.cpp b/radio/src/lua/lua_widget.cpp index 225a64c83..9d2c9dd2d 100644 --- a/radio/src/lua/lua_widget.cpp +++ b/radio/src/lua/lua_widget.cpp @@ -29,6 +29,7 @@ #include "touch.h" #include "view_main.h" #include "os/time.h" +#include "keys.h" #define MAX_INSTRUCTIONS (20000 / 100) diff --git a/radio/src/main.cpp b/radio/src/main.cpp index cd29db6ff..dc102e810 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -29,11 +29,12 @@ #include "lua/lua_states.h" #if defined(COLORLCD) -#include "LvglWrapper.h" #include "view_main.h" #include "startup_shutdown.h" #include "theme_manager.h" #include "etx_lv_theme.h" +#include "menu.h" +#include "mainwindow.h" #endif #if defined(CLI) @@ -349,7 +350,6 @@ void guiMain(event_t evt) } #endif - LvglWrapper::instance()->run(); MainWindow::instance()->run(); bool mainViewRequested = (mainRequestFlags & (1u << REQUEST_MAIN_VIEW)); @@ -540,7 +540,7 @@ void perMain() if (usbPlugged() && getSelectedUsbMode() == USB_MASS_STORAGE_MODE) { #if defined(COLORLCD) - LvglWrapper::instance()->run(); + MainWindow::instance()->run(); usbConnectedWindow->checkEvents(); #else // disable access to menus diff --git a/radio/src/model_init.cpp b/radio/src/model_init.cpp index ac4287de9..d8127a54b 100644 --- a/radio/src/model_init.cpp +++ b/radio/src/model_init.cpp @@ -24,6 +24,10 @@ #include "input_mapping.h" #include "mixes.h" +#if defined(COLORLCD) +#include "layout.h" +#endif + void clearInputs() { memset(g_model.expoData, 0, sizeof(g_model.expoData)); diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 835c08f1d..2bf127132 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -92,11 +92,6 @@ #define ALTERNATE_VIEW 0x10 -#if defined(COLORLCD) && !defined(BOOT) - #include "layout.h" - #include "topbar.h" -#endif - #define SWITCHES_DELAY() uint8_t(15+g_eeGeneral.switchesDelay) #define SWITCHES_DELAY_NONE (-15) #define HAPTIC_STRENGTH() (3+g_eeGeneral.hapticStrength) diff --git a/radio/src/pulses/dsmp.cpp b/radio/src/pulses/dsmp.cpp index ff179fcb6..10c544f87 100644 --- a/radio/src/pulses/dsmp.cpp +++ b/radio/src/pulses/dsmp.cpp @@ -135,7 +135,7 @@ static uint8_t isFPDataReady() static void sendFPLemonDSMP(uint8_t*& p_buf) { - auto forwardProgLen = Multi_Buffer[3] & 0x0F; + [[maybe_unused]] auto forwardProgLen = Multi_Buffer[3] & 0x0F; TRACE("LemonDSMP: DSMP FwdProg Send data len = [%d]", forwardProgLen); // Send Forward Prog Data (Includes Len + 6 bytes).. 9 bytes totat sendByte(p_buf, 0xAA); @@ -471,7 +471,7 @@ void DSMPModuleStatus::getStatusString(char* statusText) const } const auto& md = g_model.moduleData[EXTERNAL_MODULE]; - auto channels = md.getChannelsCount(); + [[maybe_unused]] auto channels = md.getChannelsCount(); char* tmp = statusText; diff --git a/radio/src/storage/sdcard_common.cpp b/radio/src/storage/sdcard_common.cpp index 33c53a1c4..03b30bb73 100644 --- a/radio/src/storage/sdcard_common.cpp +++ b/radio/src/storage/sdcard_common.cpp @@ -28,6 +28,7 @@ #include "hal/abnormal_reboot.h" #if defined(COLORLCD) + #include "layout.h" #include "theme_manager.h" #endif diff --git a/radio/src/targets/common/arm/stm32/dma2d.cpp b/radio/src/targets/common/arm/stm32/dma2d.cpp index 50b417649..c5f6e72c8 100644 --- a/radio/src/targets/common/arm/stm32/dma2d.cpp +++ b/radio/src/targets/common/arm/stm32/dma2d.cpp @@ -21,8 +21,8 @@ #include "stm32_hal_ll.h" +#include "colors.h" #include "definitions.h" -#include "libopenui_defines.h" #include "dma2d.h" #if !LV_USE_GPU_STM32_DMA2D diff --git a/radio/src/targets/pa01/battery_driver.cpp b/radio/src/targets/pa01/battery_driver.cpp index a703d63b6..4b8ad5765 100644 --- a/radio/src/targets/pa01/battery_driver.cpp +++ b/radio/src/targets/pa01/battery_driver.cpp @@ -19,12 +19,16 @@ * GNU General Public License for more details. */ -#include "edgetx.h" #include "battery_driver.h" + #include "boards/generic_stm32/rgb_leds.h" #undef UNUSED #include "bsp_io.h" +#include "edgetx.h" +#include "mainwindow.h" +#include "static.h" #include "stm32_ws2812.h" +#include "LvglWrapper.h" #define __BATTERY_DRIVER_C__ @@ -267,6 +271,8 @@ void drawChargingInfo(uint16_t chargeState) { } if (chargeWindow == nullptr) { + // Ensure lvgl is initialised before creating windows + LvglWrapper::instance(); chargeWindow = new Window(MainWindow::instance(), {0, 0, LCD_W, LCD_H}); etx_solid_bg(chargeWindow->getLvObj(), COLOR_THEME_PRIMARY1_INDEX); diff --git a/radio/src/targets/pa01/board.cpp b/radio/src/targets/pa01/board.cpp index 91126c312..9eca340dd 100644 --- a/radio/src/targets/pa01/board.cpp +++ b/radio/src/targets/pa01/board.cpp @@ -46,16 +46,13 @@ #include "globals.h" #include "sdcard.h" #include "debug.h" +#include "keys.h" #include "flysky_gimbal_driver.h" #include "timers_driver.h" #include "battery_driver.h" -#include "bitmapbuffer.h" -#include "colors.h" - - #include // common ADC driver diff --git a/radio/src/targets/pl18/battery_driver.cpp b/radio/src/targets/pl18/battery_driver.cpp index b99ea0fe8..026316730 100644 --- a/radio/src/targets/pl18/battery_driver.cpp +++ b/radio/src/targets/pl18/battery_driver.cpp @@ -19,9 +19,13 @@ * GNU General Public License for more details. */ -#include "edgetx.h" #include "battery_driver.h" + #include "boards/generic_stm32/rgb_leds.h" +#include "edgetx.h" +#include "mainwindow.h" +#include "static.h" +#include "LvglWrapper.h" #define __BATTERY_DRIVER_C__ @@ -403,6 +407,8 @@ void drawChargingInfo(uint16_t chargeState) { } if (chargeWindow == nullptr) { + // Ensure lvgl is initialised before creating windows + LvglWrapper::instance(); chargeWindow = new Window(MainWindow::instance(), {0, 0, LCD_W, LCD_H}); etx_solid_bg(chargeWindow->getLvObj(), COLOR_THEME_PRIMARY1_INDEX); diff --git a/radio/src/targets/pl18/board.cpp b/radio/src/targets/pl18/board.cpp index d8d265e5b..a55c0358f 100644 --- a/radio/src/targets/pl18/board.cpp +++ b/radio/src/targets/pl18/board.cpp @@ -42,6 +42,7 @@ #include "sdcard.h" #include "touch.h" #include "debug.h" +#include "keys.h" #if defined(AUDIO_SPI) #include "vs1053b.h" @@ -51,9 +52,6 @@ #include "battery_driver.h" #include "touch_driver.h" -#include "bitmapbuffer.h" -#include "colors.h" - #include // Common ADC driver diff --git a/radio/src/targets/st16/battery_driver.cpp b/radio/src/targets/st16/battery_driver.cpp index 6cde39811..e37c51799 100644 --- a/radio/src/targets/st16/battery_driver.cpp +++ b/radio/src/targets/st16/battery_driver.cpp @@ -19,10 +19,14 @@ * GNU General Public License for more details. */ -#include "edgetx.h" #include "battery_driver.h" + #include "boards/generic_stm32/rgb_leds.h" #include "bsp_io.h" +#include "edgetx.h" +#include "mainwindow.h" +#include "static.h" +#include "LvglWrapper.h" #define __BATTERY_DRIVER_C__ @@ -260,6 +264,8 @@ void drawChargingInfo(uint16_t chargeState) { } if (chargeWindow == nullptr) { + // Ensure lvgl is initialised before creating windows + LvglWrapper::instance(); chargeWindow = new Window(MainWindow::instance(), {0, 0, LCD_W, LCD_H}); etx_solid_bg(chargeWindow->getLvObj(), COLOR_THEME_PRIMARY1_INDEX); diff --git a/radio/src/targets/st16/board.cpp b/radio/src/targets/st16/board.cpp index bf5046d53..dd6f6aeeb 100644 --- a/radio/src/targets/st16/board.cpp +++ b/radio/src/targets/st16/board.cpp @@ -47,6 +47,7 @@ #include "globals.h" #include "sdcard.h" #include "debug.h" +#include "keys.h" #include "flysky_gimbal_driver.h" #include "timers_driver.h" diff --git a/radio/src/targets/stm32h7s78-dk/board.cpp b/radio/src/targets/stm32h7s78-dk/board.cpp index 289d77d77..69e383ec5 100644 --- a/radio/src/targets/stm32h7s78-dk/board.cpp +++ b/radio/src/targets/stm32h7s78-dk/board.cpp @@ -47,9 +47,6 @@ #include "extram_driver.h" #include "extflash_driver.h" -#include "bitmapbuffer.h" -#include "colors.h" - #include // common ADC driver diff --git a/radio/src/tasks.cpp b/radio/src/tasks.cpp index d23a62a83..9e6e28bf5 100644 --- a/radio/src/tasks.cpp +++ b/radio/src/tasks.cpp @@ -32,8 +32,8 @@ #include "tasks.h" #include "tasks/mixer_task.h" - #if defined(COLORLCD) +#include "LvglWrapper.h" #include "startup_shutdown.h" #endif @@ -136,6 +136,25 @@ static void timer10msStart() timer_start(&_timer10ms); } +#if defined(COLORLCD) && defined(SIMU) +static timer_handle_t _timer1ms = TIMER_INITIALIZER; + +static void _timer_1ms_cb(timer_handle_t* h) +{ + // Increment LVGL animation timer + lv_tick_inc(1); +} + +static void timer1msStart() +{ + if (!timer_is_created(&_timer1ms)) { + timer_create(&_timer1ms, _timer_1ms_cb, "1ms", 1, true); + } + + timer_start(&_timer1ms); +} +#endif + void tasksStart() { mutex_create(&audioMutex); @@ -144,6 +163,10 @@ void tasksStart() cliStart(); #endif +#if defined(COLORLCD) && defined(SIMU) + timer1msStart(); +#endif + timer10msStart(); task_create(&menusTaskId, menusTask, "menus", menusStack, MENUS_STACK_SIZE, diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index c2320bbcb..e527a89dd 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -29,6 +29,8 @@ #include "io/multi_protolist.h" #include "hal/module_port.h" +#include + #if !defined(SIMU) #include #include diff --git a/radio/src/tests/lcd_480x272.cpp b/radio/src/tests/lcd_480x272.cpp index 04025e653..e8c1af08f 100644 --- a/radio/src/tests/lcd_480x272.cpp +++ b/radio/src/tests/lcd_480x272.cpp @@ -26,6 +26,7 @@ #include "simpgmspace.h" #include "bitmaps.h" +#include "debug.h" #if !(defined(STM32H7) || defined(STM32H7RS)) #define STB_IMAGE_WRITE_IMPLEMENTATION