chore(color): cleanup UI code (#6989)

This commit is contained in:
philmoz
2026-01-21 12:48:24 +10:00
committed by GitHub
parent ca21f02afc
commit b0ecde2842
207 changed files with 1204 additions and 1208 deletions
+1 -4
View File
@@ -46,14 +46,11 @@
#include "globals.h" #include "globals.h"
#include "sdcard.h" #include "sdcard.h"
#include "debug.h" #include "debug.h"
#include "keys.h"
#include "flysky_gimbal_driver.h" #include "flysky_gimbal_driver.h"
#include "timers_driver.h" #include "timers_driver.h"
#include "bitmapbuffer.h"
#include "colors.h"
#include "touch_driver.h" #include "touch_driver.h"
#include <string.h> #include <string.h>
+1 -3
View File
@@ -48,13 +48,11 @@
#include "globals.h" #include "globals.h"
#include "sdcard.h" #include "sdcard.h"
#include "debug.h" #include "debug.h"
#include "keys.h"
#include "flysky_gimbal_driver.h" #include "flysky_gimbal_driver.h"
#include "timers_driver.h" #include "timers_driver.h"
#include "bitmapbuffer.h"
#include "colors.h"
#include "touch_driver.h" #include "touch_driver.h"
#include <string.h> #include <string.h>
+1 -8
View File
@@ -55,13 +55,10 @@
#if defined(COLORLCD) #if defined(COLORLCD)
#include "radio_calibration.h" #include "radio_calibration.h"
#include "view_main.h"
#include "view_text.h" #include "view_text.h"
#include "theme_manager.h" #include "theme_manager.h"
#include "switch_warn_dialog.h" #include "switch_warn_dialog.h"
#include "startup_shutdown.h" #include "startup_shutdown.h"
#include "LvglWrapper.h"
#endif #endif
#if defined(CROSSFIRE) #if defined(CROSSFIRE)
@@ -1421,11 +1418,7 @@ void edgeTxInit()
if (!(startOptions & OPENTX_START_NO_SPLASH)) if (!(startOptions & OPENTX_START_NO_SPLASH))
startSplash(); startSplash();
#if defined(COLORLCD) #if !defined(COLORLCD)
initLvglTheme();
// create ViewMain
ViewMain::instance();
#elif defined(GUI)
// TODO add a function for this (duplicated) // TODO add a function for this (duplicated)
menuHandlers[0] = menuMainView; menuHandlers[0] = menuMainView;
menuHandlers[1] = menuModelSelect; menuHandlers[1] = menuModelSelect;
+1 -3
View File
@@ -38,9 +38,7 @@
#include "usbd_msc_conf.h" #include "usbd_msc_conf.h"
#endif #endif
#if defined(COLORLCD) #if !defined(COLORLCD)
#include "libopenui.h"
#else
#include "lib_file.h" #include "lib_file.h"
#endif #endif
+31 -34
View File
@@ -19,15 +19,15 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "edgetx.h"
#include "hal/rotary_encoder.h"
#include "os/time.h"
#include "LvglWrapper.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 "keyboard_base.h"
#include "mainwindow.h"
#include "os/time.h"
#include "view_main.h"
LvglWrapper* LvglWrapper::_instance = nullptr; LvglWrapper* LvglWrapper::_instance = nullptr;
@@ -144,7 +144,7 @@ static void keyboardDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
// no focused item ? // no focused item ?
auto obj = get_focus_obj(keyboardDevice); auto obj = get_focus_obj(keyboardDevice);
if (!obj) { if (!obj) {
auto w = Layer::back(); auto w = Window::topWindow();
dispatch_kb_event(w, evt); dispatch_kb_event(w, evt);
backup_kb_data(data); backup_kb_data(data);
return; return;
@@ -323,11 +323,13 @@ static void init_lvgl_drivers()
keyboardDevice = lv_indev_drv_register(&keyboard_drv); keyboardDevice = lv_indev_drv_register(&keyboard_drv);
} }
void initLvglTheme() LvglWrapper::LvglWrapper()
{ {
init_lvgl_drivers();
static lv_theme_t theme; static lv_theme_t theme;
/* Initialize the ETX theme */ /* Initialize default theme */
theme.disp = NULL; theme.disp = NULL;
theme.color_primary = lv_palette_main(LV_PALETTE_BLUE); theme.color_primary = lv_palette_main(LV_PALETTE_BLUE);
theme.color_secondary = lv_palette_main(LV_PALETTE_RED); theme.color_secondary = lv_palette_main(LV_PALETTE_RED);
@@ -338,18 +340,17 @@ void initLvglTheme()
/* Assign the theme to the current display*/ /* Assign the theme to the current display*/
lv_disp_set_theme(NULL, &theme); lv_disp_set_theme(NULL, &theme);
}
LvglWrapper::LvglWrapper()
{
init_lvgl_drivers();
// Integrate STB image handling into lvgl
extern void lv_stb_init(); extern void lv_stb_init();
lv_stb_init(); lv_stb_init();
// Create main window and load that screen // Create main window and load that screen
auto window = MainWindow::instance(); auto window = MainWindow::instance();
window->setActiveScreen(); lv_scr_load(window->getLvObj());
// create ViewMain window
ViewMain::instance();
} }
LvglWrapper* LvglWrapper::instance() LvglWrapper* LvglWrapper::instance()
@@ -360,26 +361,22 @@ LvglWrapper* LvglWrapper::instance()
void LvglWrapper::run() void LvglWrapper::run()
{ {
#if defined(SIMU) // Detect nested calls
static uint32_t last_tick = 0; static bool updating = false;
uint32_t tick = time_get_ms();
lv_tick_inc(tick - last_tick);
last_tick = tick;
#endif
lv_timer_handler();
}
void LvglWrapper::runNested() if (!updating) {
{ // Normal UI loop - call lgvl timer handler
// Manual refresh updating = true;
lv_refr_now(nullptr); lv_timer_handler();
pollInputs(); 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_t* indev = nullptr; lv_indev_read_timer_cb(indev->driver->read_timer);
while((indev = lv_indev_get_next(indev)) != nullptr) { }
lv_indev_read_timer_cb(indev->driver->read_timer);
} }
} }
+6 -18
View File
@@ -21,31 +21,19 @@
#pragma once #pragma once
#include <lvgl/lvgl.h> #include "lvgl/lvgl.h"
#include "edgetx_types.h"
void initLvglTheme();
typedef std::function<lv_obj_t *(lv_obj_t *parent)> LvObjConstructor;
class LvglWrapper class LvglWrapper
{ {
static LvglWrapper *_instance;
static void pollInputs();
LvglWrapper();
~LvglWrapper() {}
public: public:
static LvglWrapper* instance(); static LvglWrapper* instance();
// Called from UI task: executes the LVGL timer handler // Called from UI task: executes the LVGL timer handler
void run(); void run();
// Call it when running the loop manually from within protected:
// the LVGL timer handler (blocking UI code) static LvglWrapper *_instance;
static void runNested();
};
// multiplication factor between 0 and 25 LvglWrapper();
int8_t rotaryEncoderGetAccel(); ~LvglWrapper() {}
};
@@ -23,6 +23,7 @@
#include "bitmaps.h" #include "bitmaps.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "static.h"
#define VIEW_CHANNELS_LIMIT_PCT \ #define VIEW_CHANNELS_LIMIT_PCT \
(g_model.extendedLimits ? LIMIT_EXT_PERCENT : LIMIT_STD_PERCENT) (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), Window(parent, rect), channel(channel),
getValue(std::move(getValueFunc)) getValue(std::move(getValueFunc))
{ {
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE); setWindowFlag(NO_CLICK);
etx_solid_bg(lvobj, COLOR_THEME_PRIMARY2_INDEX); etx_solid_bg(lvobj, COLOR_THEME_PRIMARY2_INDEX);
@@ -22,6 +22,9 @@
#pragma once #pragma once
#include "edgetx.h" #include "edgetx.h"
#include "window.h"
class StaticIcon;
class ChannelBar : public Window class ChannelBar : public Window
{ {
@@ -22,6 +22,8 @@
#include "channel_range.h" #include "channel_range.h"
#include "edgetx.h" #include "edgetx.h"
#include "getset_helpers.h"
#include "numberedit.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -23,6 +23,7 @@
#include "button.h" #include "button.h"
#include "etx_lv_theme.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 RGBChars[MAX_BARS] = {"R", "G", "B"};
static const char* const HSVChars[MAX_BARS] = {"H", "S", "V"}; static const char* const HSVChars[MAX_BARS] = {"H", "S", "V"};
@@ -22,6 +22,7 @@
#include "color_picker.h" #include "color_picker.h"
#include "color_list.h" #include "color_list.h"
#include "dialog.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#if LANDSCAPE #if LANDSCAPE
+2 -3
View File
@@ -23,6 +23,7 @@
#include "bitmaps.h" #include "bitmaps.h"
#include "edgetx.h" #include "edgetx.h"
#include "static.h"
#include "strhelpers.h" #include "strhelpers.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -130,9 +131,7 @@ Curve::Curve(Window* parent, const rect_t& rect,
valueFunc(std::move(function)), valueFunc(std::move(function)),
positionFunc(std::move(position)) positionFunc(std::move(position))
{ {
setWindowFlag(NO_FOCUS); setWindowFlag(NO_FOCUS | NO_CLICK);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
etx_solid_bg(lvobj, COLOR_THEME_PRIMARY2_INDEX); etx_solid_bg(lvobj, COLOR_THEME_PRIMARY2_INDEX);
@@ -21,10 +21,11 @@
#include "curve_param.h" #include "curve_param.h"
#include "gvar_numberedit.h"
#include "source_numberedit.h"
#include "model_curves.h"
#include "edgetx.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) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -31,9 +31,9 @@ GVarNumberEdit::GVarNumberEdit(Window* parent, int32_t vmin,
vmax(vmax), vmax(vmax),
getValue(getValue), getValue(getValue),
setValue(setValue), setValue(setValue),
textFlags(textFlags),
voffset(voffset) voffset(voffset)
{ {
setTextFlag(textFlags);
padAll(PAD_TINY); padAll(PAD_TINY);
// GVAR field // GVAR field
@@ -56,7 +56,6 @@ class GVarNumberEdit : public Window
int32_t vmax; int32_t vmax;
std::function<int32_t()> getValue; std::function<int32_t()> getValue;
std::function<void(int32_t)> setValue; std::function<void(int32_t)> setValue;
LcdFlags textFlags;
int32_t voffset; int32_t voffset;
void onEvent(event_t event) override; void onEvent(event_t event) override;
@@ -22,7 +22,10 @@
#include "input_source.h" #include "input_source.h"
#include "edgetx.h" #include "edgetx.h"
#include "getset_helpers.h"
#include "numberedit.h"
#include "sourcechoice.h" #include "sourcechoice.h"
#include "static.h"
#include "switchchoice.h" #include "switchchoice.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -37,9 +37,10 @@ SourceNumberEdit::SourceNumberEdit(Window* parent,
sourceMin(sourceMin), sourceMin(sourceMin),
getValue(getValue), getValue(getValue),
setValue(setValue), setValue(setValue),
textFlags(textFlags),
voffset(voffset) voffset(voffset)
{ {
setTextFlag(textFlags);
padAll(PAD_TINY); padAll(PAD_TINY);
lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_ROW_WRAP); lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_ROW_WRAP);
lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0); lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0);
@@ -58,7 +58,6 @@ class SourceNumberEdit : public Window
int16_t sourceMin; int16_t sourceMin;
std::function<int32_t()> getValue; std::function<int32_t()> getValue;
std::function<void(int32_t)> setValue; std::function<void(int32_t)> setValue;
LcdFlags textFlags;
int32_t voffset; int32_t voffset;
bool isSource(); bool isSource();
@@ -21,6 +21,7 @@
#include "switch_warn_dialog.h" #include "switch_warn_dialog.h"
#include "static.h"
#include "switches.h" #include "switches.h"
SwitchWarnDialog::SwitchWarnDialog() : SwitchWarnDialog::SwitchWarnDialog() :
-1
View File
@@ -27,7 +27,6 @@
#include "fonts.h" #include "fonts.h"
#include "lz4/lz4.h" #include "lz4/lz4.h"
#include "libopenui_defines.h"
#include "lz4_fonts.h" #include "lz4_fonts.h"
#include "translations/tts/tts.h" #include "translations/tts/tts.h"
+5 -1
View File
@@ -18,7 +18,11 @@
#pragma once #pragma once
#include "libopenui_defines.h" #include "colors.h"
#if defined(DEBUG)
#include "debug.h"
#endif
struct MaskBitmap; struct MaskBitmap;
class TelemetryItem; class TelemetryItem;
@@ -21,6 +21,7 @@
#include "bitmapbuffer.h" #include "bitmapbuffer.h"
#include "lib_file.h" #include "lib_file.h"
#include "edgetx_helpers.h" #include "edgetx_helpers.h"
#include "debug.h"
FIL imgFile __DMA; FIL imgFile __DMA;
@@ -81,7 +81,7 @@ ButtonMatrix::ButtonMatrix(Window* parent, const rect_t& r) :
FormField(parent, r, btnmatrix_create) FormField(parent, r, btnmatrix_create)
{ {
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); 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); lv_obj_add_event_cb(lvobj, btn_matrix_event, LV_EVENT_VALUE_CHANGED, this);
} }
+4 -2
View File
@@ -19,10 +19,12 @@
#include "dialog.h" #include "dialog.h"
#include "edgetx.h" #include "edgetx.h"
#include "mainwindow.h"
#include "progress.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "keyboard_base.h" #include "keyboard_base.h"
#include "mainwindow.h"
#include "progress.h"
#include "static.h"
#include "textedit.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -22,6 +22,7 @@
#include "file_carosell.h" #include "file_carosell.h"
#include "translations/translations.h" #include "translations/translations.h"
#include "timers_driver.h"
extern inline tmr10ms_t getTicks() extern inline tmr10ms_t getTicks()
{ {
@@ -20,6 +20,7 @@
#include <algorithm> #include <algorithm>
#include "dialog.h"
#include "edgetx.h" #include "edgetx.h"
#include "lib_file.h" #include "lib_file.h"
#include "menu.h" #include "menu.h"
+4 -2
View File
@@ -73,10 +73,12 @@ void FormField::onCancel()
} }
} }
void FormField::deleteLater(bool detach, bool trash) void FormField::deleteLater()
{ {
if (_deleted) return;
if (isEditMode()) setEditMode(false); if (isEditMode()) setEditMode(false);
Window::deleteLater(detach, trash); Window::deleteLater();
} }
FormLine::FormLine(Window* parent, FlexGridLayout& layout) : FormLine::FormLine(Window* parent, FlexGridLayout& layout) :
+1 -1
View File
@@ -95,7 +95,7 @@ class FormField : public Window
void onClicked() override; void onClicked() override;
void onCancel() override; void onCancel() override;
void deleteLater(bool detach = true, bool trash = true) override; void deleteLater() override;
protected: protected:
bool editMode = false; bool editMode = false;
@@ -21,13 +21,13 @@
#include "fullscreen_dialog.h" #include "fullscreen_dialog.h"
#include "LvglWrapper.h"
#include "mainwindow.h"
#include "edgetx.h" #include "edgetx.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "os/sleep.h"
#include "view_main.h"
#include "hal/watchdog_driver.h" #include "hal/watchdog_driver.h"
#include "mainwindow.h"
#include "os/sleep.h"
#include "static.h"
#include "view_main.h"
FullScreenDialog::FullScreenDialog( FullScreenDialog::FullScreenDialog(
uint8_t type, std::string title, std::string message, std::string action, uint8_t type, std::string title, std::string message, std::string action,
@@ -47,8 +47,6 @@ FullScreenDialog::FullScreenDialog(
pushLayer(); pushLayer();
bringToTop();
build(); build();
} }
@@ -150,12 +148,14 @@ void FullScreenDialog::checkEvents()
} }
} }
void FullScreenDialog::deleteLater(bool detach, bool trash) void FullScreenDialog::deleteLater()
{ {
if (_deleted) return;
if (running) { if (running) {
running = false; running = false;
} else { } else {
Window::deleteLater(detach, trash); Window::deleteLater();
} }
} }
@@ -164,16 +164,6 @@ void FullScreenDialog::setMessage(const char* text)
if (messageLabel) messageLabel->setText(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) void FullScreenDialog::runForever(bool checkPwr)
{ {
running = true; running = true;
@@ -199,7 +189,11 @@ void FullScreenDialog::runForever(bool checkPwr)
} }
} }
run_ui_manually(); checkBacklight();
WDG_RESET();
MainWindow::instance()->run();
sleep_ms(10);
} }
deleteLater(); deleteLater();
@@ -45,7 +45,7 @@ class FullScreenDialog : public Window
void onCancel() override; void onCancel() override;
bool onLongPress() override; bool onLongPress() override;
void deleteLater(bool detach = true, bool trash = true) override; void deleteLater() override;
void checkEvents() override; void checkEvents() override;
+5 -13
View File
@@ -21,6 +21,8 @@
#include "form.h" #include "form.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "etx_lv_theme.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) 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 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) : Keyboard::Keyboard(coord_t height) :
NavWindow(MainWindow::instance(), {0, LCD_H - height, LCD_W, height}) NavWindow(MainWindow::instance(), {0, LCD_H - height, LCD_W, height})
{ {
@@ -138,7 +130,7 @@ void Keyboard::clearField(bool wasCancelled)
field = nullptr; field = nullptr;
if (fieldGroup) { if (fieldGroup) {
_assign_lv_group(fieldGroup); assignLvGroup(fieldGroup, false);
lv_group_set_editing(fieldGroup, false); lv_group_set_editing(fieldGroup, false);
fieldGroup = nullptr; fieldGroup = nullptr;
} }
@@ -147,7 +139,7 @@ void Keyboard::clearField(bool wasCancelled)
void Keyboard::hide(bool wasCancelled) void Keyboard::hide(bool wasCancelled)
{ {
if (activeKeyboard) { if (activeKeyboard && !activeKeyboard->_deleted) {
activeKeyboard->clearField(wasCancelled); activeKeyboard->clearField(wasCancelled);
lv_obj_add_flag(activeKeyboard->lvobj, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(activeKeyboard->lvobj, LV_OBJ_FLAG_HIDDEN);
activeKeyboard = nullptr; activeKeyboard = nullptr;
@@ -189,7 +181,7 @@ void Keyboard::setField(FormField* newField)
lv_keyboard_set_textarea(keyboard, obj); lv_keyboard_set_textarea(keyboard, obj);
lv_obj_add_event_cb(obj, field_focus_leave, LV_EVENT_DEFOCUSED, nullptr); lv_obj_add_event_cb(obj, field_focus_leave, LV_EVENT_DEFOCUSED, nullptr);
_assign_lv_group(group); assignLvGroup(group, false);
field = newField; field = newField;
fieldGroup = (lv_group_t*)lv_obj_get_group(obj); fieldGroup = (lv_group_t*)lv_obj_get_group(obj);
@@ -19,6 +19,7 @@
#include "keyboard_number.h" #include "keyboard_number.h"
#include "numberedit.h" #include "numberedit.h"
#include "keys.h"
constexpr coord_t KEYBOARD_HEIGHT = 90; constexpr coord_t KEYBOARD_HEIGHT = 90;
NumberKeyboard* NumberKeyboard::_instance = nullptr; NumberKeyboard* NumberKeyboard::_instance = nullptr;
-108
View File
@@ -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> 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<bool(Window* w)> 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;
}
-42
View File
@@ -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<Layer> 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<bool(Window* w)> check);
};
-39
View File
@@ -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
@@ -18,10 +18,6 @@
#pragma once #pragma once
#include "debug.h"
#include "colors.h"
#include "keys.h"
// Used by Lua API // Used by Lua API
#define INVERS 0x01u #define INVERS 0x01u
#define BLINK 0x1000u #define BLINK 0x1000u
@@ -245,10 +245,7 @@ static lv_obj_t* group_create(lv_obj_t* parent)
InputMixGroupBase::InputMixGroupBase(Window* parent, mixsrc_t idx) : InputMixGroupBase::InputMixGroupBase(Window* parent, mixsrc_t idx) :
Window(parent, rect_t{}, group_create), idx(idx) Window(parent, rect_t{}, group_create), idx(idx)
{ {
setWindowFlag(NO_FOCUS); setWindowFlag(NO_FOCUS | NO_CLICK);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
padAll(PAD_ZERO);
label = etx_label_create(lvobj); label = etx_label_create(lvobj);
etx_font(label, FONT_XS_INDEX, LV_STATE_USER_1); etx_font(label, FONT_XS_INDEX, LV_STATE_USER_1);
@@ -127,7 +127,7 @@ class InputMixGroupBase : public Window
class InputMixPageBase : public PageGroupItem class InputMixPageBase : public PageGroupItem
{ {
public: public:
InputMixPageBase(PageDef& pageDef) : PageGroupItem(pageDef) {} InputMixPageBase(const PageDef& pageDef) : PageGroupItem(pageDef) {}
protected: protected:
std::list<InputMixButtonBase*> lines; std::list<InputMixButtonBase*> lines;
+2
View File
@@ -21,6 +21,8 @@
#include "listbox.h" #include "listbox.h"
#include "debug.h"
ListBox::ListBox(Window* parent, const rect_t& rect, ListBox::ListBox(Window* parent, const rect_t& rect,
const std::vector<std::string>& names, uint8_t lineHeight) : const std::vector<std::string>& names, uint8_t lineHeight) :
TableField(parent, rect) TableField(parent, rect)
+20 -19
View File
@@ -19,8 +19,10 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "board.h" #include "board.h"
#include "debug.h"
#include "keyboard_base.h" #include "keyboard_base.h"
#include "layout.h" #include "layout.h"
#include "LvglWrapper.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "sdcard.h" #include "sdcard.h"
#include "view_main.h" #include "view_main.h"
@@ -54,13 +56,17 @@ void MainWindow::emptyTrash()
trash.clear(); trash.clear();
} }
void MainWindow::run(bool trash) void MainWindow::run()
{ {
LvglWrapper::instance()->run();
#if defined(DEBUG_WINDOWS)
auto start = timersGetMsTick(); auto start = timersGetMsTick();
#endif
ViewMain::refreshWidgets(); ViewMain::refreshWidgets();
auto opaque = Layer::getFirstOpaque(); auto opaque = Window::firstOpaque();
if (opaque) { if (opaque) {
opaque->checkEvents(); opaque->checkEvents();
} }
@@ -72,12 +78,14 @@ void MainWindow::run(bool trash)
} }
} }
if (trash) emptyTrash(); emptyTrash();
#if defined(DEBUG_WINDOWS)
auto delta = timersGetMsTick() - start; auto delta = timersGetMsTick() - start;
if (delta > 10) { if (delta > 10) {
TRACE_WINDOWS("MainWindow::run took %dms", delta); TRACE_WINDOWS("MainWindow::run took %dms", delta);
} }
#endif
} }
void MainWindow::shutdown() void MainWindow::shutdown()
@@ -88,9 +96,8 @@ void MainWindow::shutdown()
LayoutFactory::deleteCustomScreens(); LayoutFactory::deleteCustomScreens();
// clear layer stack first // clear layer stack first
for (Window* w = Layer::back(); w; w = Layer::back()) { for (Window* w = Window::topWindow(); w; w = Window::topWindow()) {
w->deleteLater(); w->deleteLater();
Layer::pop(w);
} }
children.clear(); children.clear();
@@ -102,27 +109,21 @@ void MainWindow::shutdown()
lv_obj_center(background); 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 // ensure you delete old bitmap
if (backgroundBitmap != nullptr) delete backgroundBitmap; if (backgroundBitmap != nullptr) delete backgroundBitmap;
if (fileName == nullptr) fileName = ""; // Try to load bitmap.
backgroundBitmap = BitmapBuffer::loadBitmap(fileName.c_str(), BMP_RGB565);
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);
}
if (backgroundBitmap) { if (backgroundBitmap) {
lv_canvas_set_buffer(background, backgroundBitmap->getData(), backgroundBitmap->width(), lv_canvas_set_buffer(background, backgroundBitmap->getData(), backgroundBitmap->width(),
backgroundBitmap->height(), LV_IMG_CF_TRUE_COLOR); backgroundBitmap->height(), LV_IMG_CF_TRUE_COLOR);
return true;
} }
return false;
} }
+6 -9
View File
@@ -18,9 +18,10 @@
#pragma once #pragma once
#include "layer.h"
#include "window.h" #include "window.h"
class BitmapBuffer;
class MainWindow: public Window class MainWindow: public Window
{ {
protected: protected:
@@ -44,21 +45,17 @@ class MainWindow: public Window
} }
#endif #endif
void setActiveScreen() { void run();
lv_scr_load(lvobj);
}
void run(bool trash=true); bool setBackgroundImage(std::string& fileName);
void setBackgroundImage(const char* fileName);
void shutdown(); void shutdown();
protected: protected:
lv_obj_t* background = nullptr; lv_obj_t* background = nullptr;
std::string backgroundImageFileName;
const BitmapBuffer *backgroundBitmap = nullptr; const BitmapBuffer *backgroundBitmap = nullptr;
static MainWindow * _instance; static MainWindow * _instance;
static void emptyTrash();
void emptyTrash();
}; };
+3 -4
View File
@@ -18,13 +18,12 @@
#include "menu.h" #include "menu.h"
#include <lvgl/lvgl.h>
#include "menutoolbar.h"
#include "edgetx.h" #include "edgetx.h"
#include "table.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "keyboard_base.h" #include "keyboard_base.h"
#include "menutoolbar.h"
#include "static.h"
#include "table.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
+1
View File
@@ -20,6 +20,7 @@
#include "modal_window.h" #include "modal_window.h"
class MaskBitmap;
class Menu; class Menu;
class MenuWindowContent; class MenuWindowContent;
class MenuToolbar; class MenuToolbar;
+1 -1
View File
@@ -18,6 +18,7 @@
#include "menutoolbar.h" #include "menutoolbar.h"
#include "keys.h"
#include "menu.h" #include "menu.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "translations/translations.h" #include "translations/translations.h"
@@ -51,7 +52,6 @@ MenuToolbarButton::MenuToolbarButton(Window* parent, const rect_t& rect,
const char* picto) : const char* picto) :
ButtonBase(parent, rect, nullptr, menu_button_create) 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_flag(lvobj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
lv_obj_add_event_cb(lvobj, toolbar_btn_defocus, LV_EVENT_DEFOCUSED, nullptr); lv_obj_add_event_cb(lvobj, toolbar_btn_defocus, LV_EVENT_DEFOCUSED, nullptr);
@@ -18,7 +18,6 @@
#include "modal_window.h" #include "modal_window.h"
#include "layer.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "mainwindow.h" #include "mainwindow.h"
+4 -1
View File
@@ -19,7 +19,10 @@
#include "numberedit.h" #include "numberedit.h"
#include "audio.h" #include "audio.h"
#include "debug.h"
#include "hal/rotary_encoder.h"
#include "keyboard_number.h" #include "keyboard_number.h"
#include "keys.h"
#include "strhelpers.h" #include "strhelpers.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
@@ -30,7 +33,7 @@ class NumberArea : public FormField
FormField(parent, rect, etx_textarea_create), FormField(parent, rect, etx_textarea_create),
numEdit(parent) numEdit(parent)
{ {
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); setWindowFlag(NO_FOCUS);
if (parent->getTextFlags() & CENTERED) if (parent->getTextFlags() & CENTERED)
etx_obj_add_style(lvobj, styles->text_align_center, LV_PART_MAIN); etx_obj_add_style(lvobj, styles->text_align_center, LV_PART_MAIN);
+12 -12
View File
@@ -21,12 +21,13 @@
#include "page.h" #include "page.h"
#include "theme_manager.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "view_main.h"
#include "keyboard_base.h" #include "keyboard_base.h"
#include "quick_menu.h" #include "mainwindow.h"
#include "pagegroup.h" #include "pagegroup.h"
#include "quick_menu.h"
#include "theme_manager.h"
#include "view_main.h"
PageHeader::PageHeader(Window* parent, EdgeTxIcon icon) : PageHeader::PageHeader(Window* parent, EdgeTxIcon icon) :
Window(parent, {0, 0, LCD_W, EdgeTxStyles::MENU_HEADER_HEIGHT}) 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() void Page::openMenu()
{ {
PageGroup* p = (PageGroup*)Layer::getPageGroup(); PageGroup* p = Window::pageGroup();
QMPage qmPage = QM_NONE; QMPage qmPage = QM_NONE;
if (p) if (p)
qmPage = p->getCurrentTab()->pageId(); qmPage = p->getCurrentTab()->pageId();
quickMenu = QuickMenu::openQuickMenu([=]() { quickMenu = nullptr; }, QuickMenu::openQuickMenu(
[=](bool close) { [=](bool close) {
onCancel(); onCancel();
if (p) { if (p) {
while (!Layer::back()->isPageGroup()) { while (!Window::topWindow()->isPageGroup()) {
Layer::back()->deleteLater(); Window::topWindow()->deleteLater();
} }
if (close) if (close)
Layer::back()->onCancel(); Window::topWindow()->onCancel();
} }
}, p, qmPage); }, p, qmPage);
} }
void Page::onCancel() void Page::onCancel()
{ {
if (quickMenu) quickMenu->closeMenu(); QuickMenu::closeQuickMenu();
quickMenu = nullptr;
deleteLater(); deleteLater();
} }
@@ -141,7 +141,7 @@ void Page::enableRefresh()
NavWindow* Page::navWindow() NavWindow* Page::navWindow()
{ {
auto p = Layer::back(); auto p = Window::topWindow();
if (p->isNavWindow()) return (NavWindow*)p; if (p->isNavWindow()) return (NavWindow*)p;
return nullptr; return nullptr;
} }
@@ -151,7 +151,7 @@ void Page::onPressSYS()
{ {
QMPage pg = g_eeGeneral.getKeyShortcut(EVT_KEY_BREAK(KEY_SYS)); QMPage pg = g_eeGeneral.getKeyShortcut(EVT_KEY_BREAK(KEY_SYS));
if (pg == QM_OPEN_QUICK_MENU) { if (pg == QM_OPEN_QUICK_MENU) {
if (!quickMenu) openMenu(); if (!QuickMenu::isOpen()) openMenu();
} else { } else {
auto p = navWindow(); auto p = navWindow();
if (p) { if (p) {
-3
View File
@@ -23,8 +23,6 @@
#include "static.h" #include "static.h"
class QuickMenu;
class PageHeader : public Window class PageHeader : public Window
{ {
public: public:
@@ -61,7 +59,6 @@ class Page : public NavWindow
protected: protected:
PageHeader* header = nullptr; PageHeader* header = nullptr;
Window* body = nullptr; Window* body = nullptr;
QuickMenu* quickMenu = nullptr;
bool bubbleEvents() override { return false; } bool bubbleEvents() override { return false; }
+4 -3
View File
@@ -21,12 +21,14 @@
#include "popups.h" #include "popups.h"
#include "dialog.h"
#include "edgetx.h" #include "edgetx.h"
#include "etx_lv_theme.h"
#include "hal/watchdog_driver.h"
#include "lvgl/src/hal/lv_hal_tick.h" #include "lvgl/src/hal/lv_hal_tick.h"
#include "mainwindow.h"
#include "os/sleep.h" #include "os/sleep.h"
#include "pwr.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, static void _run_popup_dialog(const char* title, const char* msg,
const char* info = nullptr) const char* info = nullptr)
@@ -59,7 +61,6 @@ static void _run_popup_dialog(const char* title, const char* msg,
checkBacklight(); checkBacklight();
WDG_RESET(); WDG_RESET();
MainWindow::instance()->run(); MainWindow::instance()->run();
LvglWrapper::runNested();
sleep_ms(20); sleep_ms(20);
} }
} }
+2 -2
View File
@@ -58,11 +58,11 @@ void SliderBase::update()
} }
} }
void SliderBase::deleteLater(bool detach, bool trash) void SliderBase::deleteLater()
{ {
if (!deleted()) { if (!deleted()) {
if (tickPts) delete tickPts; if (tickPts) delete tickPts;
Window::deleteLater(detach, trash); Window::deleteLater();
} }
} }
+1 -1
View File
@@ -42,7 +42,7 @@ class SliderBase : public Window
std::function<int()> _getValue; std::function<int()> _getValue;
std::function<void(int)> _setValue; std::function<void(int)> _setValue;
void deleteLater(bool detach, bool trash) override; void deleteLater() override;
void checkEvents() override; void checkEvents() override;
static void slider_changed_cb(lv_event_t* e); static void slider_changed_cb(lv_event_t* e);
+13 -21
View File
@@ -19,6 +19,7 @@
#include "static.h" #include "static.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "debug.h"
#include "lz4/lz4.h" #include "lz4/lz4.h"
#include "sdcard.h" #include "sdcard.h"
#include "etx_lv_theme.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)) Window(parent, rect, lv_label_create), text(std::move(txt))
{ {
setTextFlag(textFlags); setTextFlag(textFlags);
setWindowFlag(NO_FOCUS);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
etx_font(lvobj, FONT_INDEX(textFlags)); etx_font(lvobj, FONT_INDEX(textFlags));
etx_txt_color(lvobj, color); 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), Window(parent, rect_t{x, y, 0, 0}, lv_canvas_create),
currentColor(color) currentColor(color)
{ {
setWindowFlag(NO_FOCUS); setWindowFlag(NO_FOCUS | NO_CLICK);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setIcon(icon); 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), Window(parent, rect_t{x, y, 0, 0}, lv_canvas_create),
currentColor(color) currentColor(color)
{ {
setWindowFlag(NO_FOCUS); setWindowFlag(NO_FOCUS | NO_CLICK);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
auto bm = BitmapBuffer::loadBitmap(filename, BMP_RGB565); auto bm = BitmapBuffer::loadBitmap(filename, BMP_RGB565);
if (bm) { 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); etx_img_color(lvobj, currentColor, LV_PART_MAIN);
} }
void StaticIcon::deleteLater(bool detach, bool trash) void StaticIcon::deleteLater()
{ {
if (_deleted) return; if (_deleted) return;
if (mask) free(mask); if (mask) free(mask);
mask = nullptr; mask = nullptr;
Window::deleteLater(detach, trash); Window::deleteLater();
} }
void StaticIcon::setColor(LcdColorIndex color) void StaticIcon::setColor(LcdColorIndex color)
@@ -219,9 +215,7 @@ StaticImage::StaticImage(Window* parent, const rect_t& rect,
const char* filename, bool fillFrame, bool dontEnlarge) : const char* filename, bool fillFrame, bool dontEnlarge) :
Window(parent, rect), fillFrame(fillFrame), dontEnlarge(dontEnlarge) Window(parent, rect), fillFrame(fillFrame), dontEnlarge(dontEnlarge)
{ {
setWindowFlag(NO_FOCUS); setWindowFlag(NO_FOCUS | NO_CLICK);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
if (!filename) filename = ""; if (!filename) filename = "";
setSource(filename); setSource(filename);
@@ -282,8 +276,7 @@ StaticBitmap::StaticBitmap(Window* parent, const rect_t& rect,
const char* filename) : const char* filename) :
Window(parent, rect) Window(parent, rect)
{ {
setWindowFlag(NO_FOCUS); setWindowFlag(NO_FOCUS | NO_CLICK);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setSource(filename); setSource(filename);
} }
@@ -329,9 +322,7 @@ StaticLZ4Image::StaticLZ4Image(Window* parent, coord_t x, coord_t y,
Window(parent, {x, y, lz4Bitmap->width, lz4Bitmap->height}, Window(parent, {x, y, lz4Bitmap->width, lz4Bitmap->height},
lv_canvas_create) lv_canvas_create)
{ {
setWindowFlag(NO_FOCUS); setWindowFlag(NO_FOCUS | NO_CLICK);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
// Convert ARGB4444 to LV_IMG_CF_TRUE_COLOR_ALPHA // Convert ARGB4444 to LV_IMG_CF_TRUE_COLOR_ALPHA
uint16_t w = lz4Bitmap->width; 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); 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 (!deleted()) {
if (imgData) lv_mem_free(imgData); if (imgData) lv_mem_free(imgData);
imgData = nullptr; 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) : LcdFlags color, LcdFlags bgColor) :
Window(parent, {x, y, sz, sz}) Window(parent, {x, y, sz, sz})
{ {
setWindowFlag(NO_CLICK);
qr = lv_qrcode_create(lvobj, sz, makeLvColor(color), makeLvColor(bgColor)); qr = lv_qrcode_create(lvobj, sz, makeLvColor(color), makeLvColor(bgColor));
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setData(data); setData(data);
} }
+2 -2
View File
@@ -126,7 +126,7 @@ class StaticIcon : public Window
StaticIcon(Window *parent, coord_t x, coord_t y, const char* filename, StaticIcon(Window *parent, coord_t x, coord_t y, const char* filename,
LcdColorIndex color); LcdColorIndex color);
void deleteLater(bool detach = true, bool trash = true) override; void deleteLater() override;
#if defined(DEBUG_WINDOWS) #if defined(DEBUG_WINDOWS)
std::string getName() const override { return "StaticIcon"; } std::string getName() const override { return "StaticIcon"; }
@@ -201,7 +201,7 @@ class StaticLZ4Image : public Window
protected: protected:
uint8_t *imgData = nullptr; uint8_t *imgData = nullptr;
void deleteLater(bool detach = true, bool trash = true) override; void deleteLater() override;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
+6 -6
View File
@@ -18,7 +18,9 @@
#include "table.h" #include "table.h"
#include "debug.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "keys.h"
// Table // Table
const lv_style_const_prop_t table_cell_props[] = { const lv_style_const_prop_t table_cell_props[] = {
@@ -305,8 +307,6 @@ bool TableField::onLongPress()
return true; return true;
} }
extern void _assign_lv_group(lv_group_t* g);
void TableField::setAutoEdit() void TableField::setAutoEdit()
{ {
if (autoedit) return; if (autoedit) return;
@@ -316,7 +316,7 @@ void TableField::setAutoEdit()
oldGroup = lv_group_get_default(); oldGroup = lv_group_get_default();
group = lv_group_create(); group = lv_group_create();
lv_group_add_obj(group, lvobj); lv_group_add_obj(group, lvobj);
_assign_lv_group(group); assignLvGroup(group, true);
lv_group_set_editing(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 (!deleted()) {
if (autoedit) { if (autoedit) {
lv_group_del(group); lv_group_del(group);
if (oldGroup) if (oldGroup)
_assign_lv_group(oldGroup); assignLvGroup(oldGroup, true);
else else
lv_group_set_default(nullptr); lv_group_set_default(nullptr);
} }
Window::deleteLater(detach, trash); Window::deleteLater();
} }
} }
+1 -1
View File
@@ -66,7 +66,7 @@ class TableField : public Window
void onEvent(event_t event) override; void onEvent(event_t event) override;
bool onLongPress() 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); } static void force_editing(lv_group_t* g) { lv_group_set_editing(g, true); }
}; };
+4 -4
View File
@@ -33,7 +33,7 @@ class TextArea : public FormField
TextArea(Window* parent, const rect_t& rect, char* value, uint8_t length) : TextArea(Window* parent, const rect_t& rect, char* value, uint8_t length) :
FormField(parent, rect, etx_textarea_create), value(value), length(length) FormField(parent, rect, etx_textarea_create), value(value), length(length)
{ {
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE); setWindowFlag(NO_FOCUS);
lv_textarea_set_max_length(lvobj, length); lv_textarea_set_max_length(lvobj, length);
lv_textarea_set_placeholder_text(lvobj, "---"); lv_textarea_set_placeholder_text(lvobj, "---");
@@ -174,13 +174,13 @@ void TextEdit::openEdit()
void TextEdit::preview(bool edited, char* text, uint8_t length) void TextEdit::preview(bool edited, char* text, uint8_t length)
{ {
setWindowFlag(NO_FOCUS | NO_CLICK);
edit = new TextArea(this, edit = new TextArea(this,
{-(PAD_MEDIUM + 2), -(PAD_BORDER * 2), width(), height()}, {-(PAD_MEDIUM + 2), -(PAD_BORDER * 2), width(), height()},
text, length); text, length);
edit->setWindowFlag(NO_CLICK);
lv_group_focus_obj(edit->getLvObj()); 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); lv_obj_add_state(edit->getLvObj(), LV_STATE_FOCUSED);
if (edited) lv_obj_add_state(edit->getLvObj(), LV_STATE_EDITED); if (edited) lv_obj_add_state(edit->getLvObj(), LV_STATE_EDITED);
} }
+8 -11
View File
@@ -20,12 +20,13 @@
#include "view_text.h" #include "view_text.h"
#include "menu.h" #include "button.h"
#include "edgetx.h" #include "edgetx.h"
#include "sdcard.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "fullscreen_dialog.h" #include "fullscreen_dialog.h"
#include "lib_file.h" #include "lib_file.h"
#include "menu.h"
#include "sdcard.h"
// Used on startup to block until checklist is closed. // Used on startup to block until checklist is closed.
static bool checkListOpen = false; static bool checkListOpen = false;
@@ -109,12 +110,10 @@ class TextViewer
{ {
if (openFile()) { if (openFile()) {
auto obj = window->getLvObj(); auto obj = window->getLvObj();
lv_obj_add_flag( lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_WITH_ARROW | LV_OBJ_FLAG_SCROLL_MOMENTUM);
obj, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_WITH_ARROW |
LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_CLICK_FOCUSABLE);
etx_scrollbar(obj); etx_scrollbar(obj);
// prevents resetting the group's edit mode // 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(); auto g = lv_group_get_default();
lb = lv_label_create(obj); lb = lv_label_create(obj);
@@ -375,12 +374,10 @@ class ViewChecklistWindow : public Page, public TextViewer
{ {
if (openFile()) { if (openFile()) {
auto obj = window->getLvObj(); auto obj = window->getLvObj();
lv_obj_add_flag( lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_WITH_ARROW | LV_OBJ_FLAG_SCROLL_MOMENTUM);
obj, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_WITH_ARROW |
LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_CLICK_FOCUSABLE);
etx_scrollbar(obj); etx_scrollbar(obj);
// prevents resetting the group's edit mode // 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_layout(obj, LV_LAYOUT_FLEX);
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN); 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)
{ {
} }
+1 -1
View File
@@ -52,7 +52,7 @@ class ViewTextWindow : public Page
class ModelNotesPage : public PageGroupItem class ModelNotesPage : public PageGroupItem
{ {
public: public:
ModelNotesPage(PageDef& pageDef); ModelNotesPage(const PageDef& pageDef);
void build(Window* window) override; void build(Window* window) override;
+147 -42
View File
@@ -19,13 +19,118 @@
#include "window.h" #include "window.h"
#include "button.h" #include "button.h"
#include "form.h" #include "debug.h"
#include "static.h"
#include "etx_lv_theme.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<Layer> 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<bool(Window* w)> check);
};
std::list<Layer> 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<bool(Window* w)> check)
{
for (auto layer = stack.crbegin(); layer != stack.crend(); layer++) {
if (layer->window && check(layer->window))
return layer->window;
}
return nullptr;
}
//-----------------------------------------------------------------------------
std::list<Window *> Window::trash; std::list<Window *> 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 = { const lv_obj_class_t window_base_class = {
.base_class = &lv_obj_class, .base_class = &lv_obj_class,
@@ -53,6 +158,8 @@ void Window::window_event_cb(lv_event_t *e)
void Window::eventHandler(lv_event_t *e) void Window::eventHandler(lv_event_t *e)
{ {
static bool _longPressed = false;
lv_obj_t *target = lv_event_get_target(e); lv_obj_t *target = lv_event_get_target(e);
lv_event_code_t code = lv_event_get_code(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 // Constructor to allow lvobj to be created separately - used by NumberEdit and
// TextEdit // TextEdit
Window::Window(const rect_t &rect) : rect(rect), parent(nullptr) Window::Window(const rect_t &rect) : rect(rect), parent(nullptr)
@@ -202,7 +311,7 @@ void Window::pushLayer(bool hideParent)
if (!layerCreated) { if (!layerCreated) {
parentHidden = hideParent; parentHidden = hideParent;
layerCreated = true; layerCreated = true;
if (parentHidden) Layer::back()->hide(); if (parentHidden) Window::topWindow()->hide();
Layer::push(this); Layer::push(this);
} }
} }
@@ -211,12 +320,25 @@ void Window::popLayer()
{ {
if (layerCreated) { if (layerCreated) {
Layer::pop(this); Layer::pop(this);
if (parentHidden) Layer::back()->show(); if (parentHidden) Window::topWindow()->show();
layerCreated = false; layerCreated = false;
parentHidden = 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() Window *Window::getFullScreenWindow()
{ {
if (width() == LCD_W && height() == LCD_H) return this; if (width() == LCD_W && height() == LCD_H) return this;
@@ -229,8 +351,14 @@ void Window::setWindowFlag(WindowFlags flag)
windowFlags |= flag; windowFlags |= flag;
// honor the no focus flag of libopenui // 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); 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; } void Window::clearWindowFlag(WindowFlags flag) { windowFlags &= ~flag; }
@@ -250,23 +378,19 @@ void Window::attach(Window *newParent)
void Window::detach() void Window::detach()
{ {
if (parent) { if (parent) {
parent->removeChild(this); parent->children.remove(this);
parent = nullptr; parent = nullptr;
} }
} }
void Window::deleteLater(bool detach, bool trash) void Window::deleteLater()
{ {
if (_deleted) return; if (_deleted) return;
_deleted = true; _deleted = true;
TRACE_WINDOWS("Delete %p %s", this, getWindowDebugString().c_str()); TRACE_WINDOWS("Delete %p %s", this, getWindowDebugString().c_str());
if (detach) detach();
this->detach();
else
parent = nullptr;
deleteChildren(); deleteChildren();
popLayer(); popLayer();
@@ -274,8 +398,7 @@ void Window::deleteLater(bool detach, bool trash)
if (closeHandler) if (closeHandler)
closeHandler(); closeHandler();
if (trash) Window::trash.push_back(this);
Window::trash.push_back(this);
if (lvobj != nullptr) { if (lvobj != nullptr) {
auto obj = lvobj; auto obj = lvobj;
@@ -295,13 +418,8 @@ void Window::clear()
void Window::deleteChildren() void Window::deleteChildren()
{ {
// prevent LVGL refocus while mass-deleting while (!children.empty())
// inhibit_focus = true; children.back()->deleteLater();
for (auto window : children) {
window->deleteLater(false);
}
// inhibit_focus = false;
children.clear();
} }
bool Window::hasFocus() const 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::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() void Window::checkEvents()
{ {
auto copy = children; auto copy = children;
@@ -383,12 +488,6 @@ void Window::addChild(Window *window)
children.push_back(window); children.push_back(window);
} }
void Window::removeChild(Window *window)
{
children.remove(window);
invalidate();
}
void Window::invalidate() void Window::invalidate()
{ {
if (lvobj) lv_obj_invalidate(lvobj); if (lvobj) lv_obj_invalidate(lvobj);
@@ -475,6 +574,8 @@ void Window::addCustomButton(coord_t x, coord_t y, std::function<void()> action)
} }
#endif #endif
//-----------------------------------------------------------------------------
void NavWindow::onEvent(event_t event) void NavWindow::onEvent(event_t event)
{ {
switch (event) { switch (event) {
@@ -536,6 +637,8 @@ NavWindow::NavWindow(Window *parent, const rect_t &rect,
setWindowFlag(OPAQUE); setWindowFlag(OPAQUE);
} }
//-----------------------------------------------------------------------------
class SetupTextButton : public TextButton class SetupTextButton : public TextButton
{ {
public: public:
@@ -638,3 +741,5 @@ coord_t SetupLine::showLines(Window* parent, coord_t y, coord_t col2, PaddingSiz
return y; return y;
} }
//-----------------------------------------------------------------------------
+15 -21
View File
@@ -23,25 +23,25 @@
#include <string> #include <string>
#include "definitions.h" #include "definitions.h"
#include "LvglWrapper.h"
#include "bitmapbuffer.h"
#include "libopenui_defines.h"
#include "edgetx_helpers.h" #include "edgetx_helpers.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
class FlexGridLayout;
class FormLine;
class PageGroup;
typedef uint32_t WindowFlags; typedef uint32_t WindowFlags;
typedef lv_obj_t *(*LvglCreate)(lv_obj_t *);
#if !defined(_GNUC_) #if !defined(_GNUC_)
#undef OPAQUE #undef OPAQUE
#endif #endif
constexpr WindowFlags OPAQUE = 1u << 0u; constexpr WindowFlags OPAQUE = 1u << 0u;
constexpr WindowFlags NO_FOCUS = 1u << 1u; constexpr WindowFlags NO_FOCUS = 1u << 1u;
constexpr WindowFlags NO_SCROLL = 1u << 2u;
typedef lv_obj_t *(*LvglCreate)(lv_obj_t *); constexpr WindowFlags NO_CLICK = 1u << 3u;
class FlexGridLayout;
class FormLine;
class Window class Window
{ {
@@ -80,7 +80,7 @@ class Window
void setScrollHandler(ScrollHandler h) { scrollHandler = std::move(h); } void setScrollHandler(ScrollHandler h) { scrollHandler = std::move(h); }
virtual void clear(); virtual void clear();
virtual void deleteLater(bool detach = true, bool trash = true); virtual void deleteLater();
bool hasFocus() const; bool hasFocus() const;
@@ -124,15 +124,11 @@ class Window
} }
coord_t left() const { return rect.x; } coord_t left() const { return rect.x; }
coord_t right() const { return rect.x + rect.w; } coord_t right() const { return rect.x + rect.w; }
coord_t top() const { return rect.y; } coord_t top() const { return rect.y; }
coord_t bottom() const { return rect.y + rect.h; } coord_t bottom() const { return rect.y + rect.h; }
coord_t width() const { return rect.w; } coord_t width() const { return rect.w; }
coord_t height() const { return rect.h; } coord_t height() const { return rect.h; }
rect_t getRect() const { return rect; } rect_t getRect() const { return rect; }
@@ -143,9 +139,6 @@ class Window
void padBottom(coord_t pad); void padBottom(coord_t pad);
void padAll(PaddingSize pad); void padAll(PaddingSize pad);
void padRow(coord_t pad);
void padColumn(coord_t pad);
virtual void onEvent(event_t event); virtual void onEvent(event_t event);
virtual void onClicked(); virtual void onClicked();
virtual void onCancel(); virtual void onCancel();
@@ -155,8 +148,6 @@ class Window
void invalidate(); void invalidate();
void bringToTop();
virtual void checkEvents(); virtual void checkEvents();
void attach(Window *window); void attach(Window *window);
@@ -195,6 +186,11 @@ class Window
void pushLayer(bool hideParent = false); void pushLayer(bool hideParent = false);
void popLayer(); void popLayer();
static Window* topWindow();
static Window* firstOpaque();
static PageGroup* pageGroup();
void assignLvGroup(lv_group_t* g, bool setDefault);
protected: protected:
static std::list<Window *> trash; static std::list<Window *> trash;
@@ -211,7 +207,6 @@ class Window
bool noForcedScroll = false; bool noForcedScroll = false;
bool _deleted = false; bool _deleted = false;
static bool _longPressed;
bool loaded = false; bool loaded = false;
bool layerCreated = false; bool layerCreated = false;
@@ -219,12 +214,11 @@ class Window
CloseHandler closeHandler; CloseHandler closeHandler;
FocusHandler focusHandler; FocusHandler focusHandler;
std::function<void(coord_t, coord_t)> scrollHandler; ScrollHandler scrollHandler;
void deleteChildren(); void deleteChildren();
virtual void addChild(Window *window); virtual void addChild(Window *window);
void removeChild(Window *window);
void eventHandler(lv_event_t *e); void eventHandler(lv_event_t *e);
static void window_event_cb(lv_event_t *e); static void window_event_cb(lv_event_t *e);
+2 -6
View File
@@ -193,10 +193,8 @@ WidgetsContainer* LayoutFactory::createCustomScreen(
auto& screen = customScreens[customScreenIndex]; auto& screen = customScreens[customScreenIndex];
if (screen != nullptr) { if (screen != nullptr)
screen->deleteLater(true, false); screen->deleteLater();
delete screen;
}
auto viewMain = ViewMain::instance(); auto viewMain = ViewMain::instance();
screen = create(viewMain, customScreenIndex); screen = create(viewMain, customScreenIndex);
@@ -410,8 +408,6 @@ Widget* Layout::createWidget(unsigned int index,
} }
widgets[index] = widget; widgets[index] = widget;
if (widget) widget->attach(this);
return widget; return widget;
} }
@@ -24,8 +24,12 @@
#include <algorithm> #include <algorithm>
#include "color_picker.h" #include "color_picker.h"
#include "layout.h"
#include "edgetx.h" #include "edgetx.h"
#include "getset_helpers.h"
#include "layout.h"
#include "menu.h"
#include "static.h"
#include "toggleswitch.h"
#include "topbar.h" #include "topbar.h"
#include "view_main.h" #include "view_main.h"
#include "widget_settings.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, static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT,
LV_GRID_TEMPLATE_LAST}; LV_GRID_TEMPLATE_LAST};
ScreenSetupPage::ScreenSetupPage(unsigned index, PageDef& pageDef) : ScreenSetupPage::ScreenSetupPage(unsigned index, const PageDef& pageDef) :
PageGroupItem(pageDef) PageGroupItem(pageDef)
{ {
update(index + QuickMenu::pageIndex(QM_UI_SCREEN1)); 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 #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, 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}, 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 { s, [this]() -> uint8_t {
int newIdx = 1; ScreenSetupPage::addScreen();
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");
}
return 0; return 0;
}); });
} }
@@ -29,7 +29,7 @@
class ScreenAddPage : public PageGroupItem class ScreenAddPage : public PageGroupItem
{ {
public: public:
ScreenAddPage(PageDef& pageDef); ScreenAddPage(const PageDef& pageDef);
void build(Window* window) override; void build(Window* window) override;
@@ -41,12 +41,14 @@ class ScreenAddPage : public PageGroupItem
class ScreenSetupPage : public PageGroupItem class ScreenSetupPage : public PageGroupItem
{ {
public: public:
ScreenSetupPage(unsigned customScreenIndex, PageDef& pageDef); ScreenSetupPage(unsigned customScreenIndex, const PageDef& pageDef);
void build(Window* form) override; void build(Window* form) override;
void update(uint8_t index) override; void update(uint8_t index) override;
static void addScreen();
protected: protected:
unsigned customScreenIndex; unsigned customScreenIndex;
Window* layoutOptions = nullptr; Window* layoutOptions = nullptr;
@@ -21,6 +21,7 @@
#include "screen_user_interface.h" #include "screen_user_interface.h"
#include "choice.h"
#include "file_preview.h" #include "file_preview.h"
#include "theme_manager.h" #include "theme_manager.h"
#include "view_main.h" #include "view_main.h"
@@ -43,7 +44,7 @@ static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT,
#endif #endif
ScreenUserInterfacePage::ScreenUserInterfacePage(PageDef& pageDef) : ScreenUserInterfacePage::ScreenUserInterfacePage(const PageDef& pageDef) :
PageGroupItem(pageDef, PAD_TINY) PageGroupItem(pageDef, PAD_TINY)
{ {
} }
@@ -30,7 +30,7 @@ class Choice;
class ScreenUserInterfacePage : public PageGroupItem class ScreenUserInterfacePage : public PageGroupItem
{ {
public: public:
ScreenUserInterfacePage(PageDef& pageDef); ScreenUserInterfacePage(const PageDef& pageDef);
void build(Window* window) override; void build(Window* window) override;
+4 -5
View File
@@ -21,7 +21,6 @@
#include "topbar.h" #include "topbar.h"
#include "layer.h"
#include "edgetx.h" #include "edgetx.h"
#include "storage/storage.h" #include "storage/storage.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
@@ -104,10 +103,12 @@ void SetupTopBarWidgetsPage::onClicked()
void SetupTopBarWidgetsPage::onCancel() { deleteLater(); } void SetupTopBarWidgetsPage::onCancel() { deleteLater(); }
void SetupTopBarWidgetsPage::deleteLater(bool detach, bool trash) void SetupTopBarWidgetsPage::deleteLater()
{ {
if (_deleted) return;
// and continue async deletion... // and continue async deletion...
Window::deleteLater(detach, trash); Window::deleteLater();
// restore screen setting tab on top // restore screen setting tab on top
QuickMenu::openPage(QM_UI_SETUP); QuickMenu::openPage(QM_UI_SETUP);
@@ -270,8 +271,6 @@ Widget* TopBar::createWidget(unsigned int index,
} }
widgets[index] = widget; widgets[index] = widget;
if (widget) widget->attach(this);
return widget; return widget;
} }
+1 -1
View File
@@ -39,7 +39,7 @@ class SetupTopBarWidgetsPage : public Window
void onClicked() override; void onClicked() override;
void onCancel() override; void onCancel() override;
void onEvent(event_t event) override; void onEvent(event_t event) override;
void deleteLater(bool detach = true, bool trash = true) override; void deleteLater() override;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -22,7 +22,6 @@
#include "view_channels.h" #include "view_channels.h"
#include "channel_bar.h" #include "channel_bar.h"
#include "libopenui.h"
#include "model_select.h" #include "model_select.h"
#include "edgetx.h" #include "edgetx.h"
#if VERSION_MAJOR == 2 #if VERSION_MAJOR == 2
@@ -126,8 +125,6 @@ class ChannelsViewPage : public PageGroupItem
ChannelsViewMenu::ChannelsViewMenu() : ChannelsViewMenu::ChannelsViewMenu() :
TabsGroup(ICON_MONITOR, STR_MAIN_MENU_CHANNEL_MONITOR) TabsGroup(ICON_MONITOR, STR_MAIN_MENU_CHANNEL_MONITOR)
{ {
QuickMenu::setCurrentPage(QM_TOOLS_CHAN_MON);
#if PORTRAIT #if PORTRAIT
int cols = 1; int cols = 1;
int rows = 8; int rows = 8;
@@ -21,10 +21,11 @@
#include "view_logical_switches.h" #include "view_logical_switches.h"
#include "button.h"
#include "edgetx.h" #include "edgetx.h"
#include "switches.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "quick_menu.h" #include "quick_menu.h"
#include "switches.h"
#if PORTRAIT #if PORTRAIT
@@ -241,7 +242,7 @@ LogicalSwitchesViewPage::LogicalSwitchesViewPage() :
setIcon(ICON_MONITOR_LOGICAL_SWITCHES); setIcon(ICON_MONITOR_LOGICAL_SWITCHES);
} }
LogicalSwitchesViewPage::LogicalSwitchesViewPage(PageDef& pageDef) : LogicalSwitchesViewPage::LogicalSwitchesViewPage(const PageDef& pageDef) :
PageGroupItem(pageDef) PageGroupItem(pageDef)
{ {
} }
@@ -29,7 +29,7 @@ class LogicalSwitchesViewPage : public PageGroupItem
{ {
public: public:
LogicalSwitchesViewPage(); LogicalSwitchesViewPage();
LogicalSwitchesViewPage(PageDef& pageDef); LogicalSwitchesViewPage(const PageDef& pageDef);
static LAYOUT_ORIENTATION_SCALED(FOOTER_HEIGHT, 20, 40) static LAYOUT_ORIENTATION_SCALED(FOOTER_HEIGHT, 20, 40)
static LAYOUT_ORIENTATION(BTN_MATRIX_COL, 8, 6) static LAYOUT_ORIENTATION(BTN_MATRIX_COL, 8, 6)
+15 -12
View File
@@ -21,12 +21,13 @@
#include "view_main.h" #include "view_main.h"
#include "model_select.h"
#include "edgetx.h" #include "edgetx.h"
#include "topbar.h" #include "mainwindow.h"
#include "model_select.h"
#include "quick_menu.h" #include "quick_menu.h"
#include "view_channels.h"
#include "screen_setup.h" #include "screen_setup.h"
#include "topbar.h"
#include "view_channels.h"
#include "widget.h" #include "widget.h"
static void tile_view_deleted_cb(lv_event_t* e) static void tile_view_deleted_cb(lv_event_t* e)
@@ -78,7 +79,8 @@ ViewMain* ViewMain::_instance = nullptr;
ViewMain* ViewMain::instance() ViewMain* ViewMain::instance()
{ {
if (!_instance) _instance = new ViewMain(); if (!_instance)
_instance = new ViewMain();
return _instance; return _instance;
} }
@@ -106,9 +108,11 @@ ViewMain::ViewMain() :
ViewMain::~ViewMain() { _instance = nullptr; } 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(); QuickMenu::shutdownQuickMenu();
} }
@@ -244,10 +248,9 @@ void ViewMain::doKeyShortcut(event_t event)
{ {
QMPage pg = g_eeGeneral.getKeyShortcut(event); QMPage pg = g_eeGeneral.getKeyShortcut(event);
if (pg == QM_OPEN_QUICK_MENU) { if (pg == QM_OPEN_QUICK_MENU) {
if (!viewMainMenu) openMenu(); if (!QuickMenu::isOpen()) openMenu();
} else { } else {
if (viewMainMenu) QuickMenu::closeQuickMenu();
viewMainMenu->closeMenu();
QuickMenu::openPage(pg); QuickMenu::openPage(pg);
} }
} }
@@ -260,14 +263,14 @@ void ViewMain::onLongPressTELE() { doKeyShortcut(EVT_KEY_LONG(KEY_TELE)); }
void ViewMain::onPressPGUP() void ViewMain::onPressPGUP()
{ {
if (!widget_select) { if (!widget_select) {
if (viewMainMenu) viewMainMenu->closeMenu(); QuickMenu::closeQuickMenu();
previousMainView(); previousMainView();
} }
} }
void ViewMain::onPressPGDN() void ViewMain::onPressPGDN()
{ {
if (!widget_select) { if (!widget_select) {
if (viewMainMenu) viewMainMenu->closeMenu(); QuickMenu::closeQuickMenu();
nextMainView(); nextMainView();
} }
} }
@@ -332,7 +335,7 @@ bool ViewMain::enableWidgetSelect(bool enable)
void ViewMain::openMenu() void ViewMain::openMenu()
{ {
viewMainMenu = QuickMenu::openQuickMenu([=]() { viewMainMenu = nullptr; }); QuickMenu::openQuickMenu();
} }
void ViewMain::ws_timer(lv_timer_t* t) void ViewMain::ws_timer(lv_timer_t* t)
+1 -3
View File
@@ -24,7 +24,6 @@
#include "topbar.h" #include "topbar.h"
#include "window.h" #include "window.h"
class QuickMenu;
class TopBar; class TopBar;
class ViewMain : public NavWindow class ViewMain : public NavWindow
@@ -85,9 +84,8 @@ class ViewMain : public NavWindow
TopBar* topbar = nullptr; TopBar* topbar = nullptr;
bool widget_select = false; bool widget_select = false;
lv_timer_t* widget_select_timer = nullptr; 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] // Set topbar visibility [0.0 -> 1.0]
void setTopbarVisible(float visible); void setTopbarVisible(float visible);
@@ -20,14 +20,16 @@
*/ */
#include "view_statistics.h" #include "view_statistics.h"
#include "os/task.h"
#include "button.h"
#include "edgetx.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.h"
#include "tasks/mixer_task.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), static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1),
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; int16_t graphSize = 0;
}; };
StatisticsViewPage::StatisticsViewPage(PageDef& pageDef) : StatisticsViewPage::StatisticsViewPage(const PageDef& pageDef) :
PageGroupItem(pageDef) PageGroupItem(pageDef)
{ {
} }
@@ -207,7 +209,7 @@ void StatisticsViewPage::build(Window* window)
LV_GRID_ALIGN_START, 0, 1); LV_GRID_ALIGN_START, 0, 1);
} }
DebugViewPage::DebugViewPage(PageDef& pageDef) : DebugViewPage::DebugViewPage(const PageDef& pageDef) :
PageGroupItem(pageDef) PageGroupItem(pageDef)
{ {
} }
@@ -26,7 +26,7 @@
class StatisticsViewPage : public PageGroupItem class StatisticsViewPage : public PageGroupItem
{ {
public: public:
StatisticsViewPage(PageDef& pageDef); StatisticsViewPage(const PageDef& pageDef);
protected: protected:
void build(Window* window) override; void build(Window* window) override;
@@ -35,7 +35,7 @@ class StatisticsViewPage : public PageGroupItem
class DebugViewPage : public PageGroupItem class DebugViewPage : public PageGroupItem
{ {
public: public:
DebugViewPage(PageDef& pageDef); DebugViewPage(const PageDef& pageDef);
protected: protected:
void build(Window* window) override; void build(Window* window) override;
+2 -5
View File
@@ -23,6 +23,7 @@
#include "edgetx.h" #include "edgetx.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "menu.h"
#include "view_main.h" #include "view_main.h"
#include "widget_settings.h" #include "widget_settings.h"
@@ -157,8 +158,7 @@ Widget::Widget(const WidgetFactory* factory, Window* parent, const rect_t& rect,
factory(factory), factory(factory),
screenNum(screenNum), zoneNum(zoneNum) screenNum(screenNum), zoneNum(zoneNum)
{ {
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_SCROLLABLE); setWindowFlag(NO_FOCUS | NO_SCROLL);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
if (parent->isTopBar()) fsAllowed = false; if (parent->isTopBar()) fsAllowed = false;
@@ -239,8 +239,6 @@ void Widget::setFullscreen(bool enable)
updateZoneRect(parent->getRect(), false); updateZoneRect(parent->getRect(), false);
setRect(parent->getRect()); setRect(parent->getRect());
bringToTop();
if (!lv_obj_get_group(lvobj)) if (!lv_obj_get_group(lvobj))
lv_group_add_obj(lv_group_get_default(), lvobj); lv_group_add_obj(lv_group_get_default(), lvobj);
@@ -297,7 +295,6 @@ void Widget::enableFocus(bool enable)
setFocusHandler([=](bool hasFocus) { setFocusHandler([=](bool hasFocus) {
if (hasFocus) { if (hasFocus) {
bringToTop();
lv_obj_clear_flag(focusBorder, LV_OBJ_FLAG_HIDDEN); lv_obj_clear_flag(focusBorder, LV_OBJ_FLAG_HIDDEN);
} else { } else {
lv_obj_add_flag(focusBorder, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(focusBorder, LV_OBJ_FLAG_HIDDEN);
@@ -23,11 +23,15 @@
#include "color_picker.h" #include "color_picker.h"
#include "edgetx.h" #include "edgetx.h"
#include "sourcechoice.h"
#include "switchchoice.h"
#include "view_main.h"
#include "filechoice.h" #include "filechoice.h"
#include "numberedit.h"
#include "slider.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) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -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; for (int i = 0; i < zoneCount; i += 1) widgets[i] = nullptr;
} }
void WidgetsContainer::deleteLater(bool detach, bool trash) void WidgetsContainer::deleteLater()
{ {
if (deleted()) return; if (deleted()) return;
for (int i = 0; i < zoneCount; i += 1) for (int i = 0; i < zoneCount; i += 1)
if (widgets[i]) widgets[i]->deleteLater(); if (widgets[i]) widgets[i]->deleteLater();
if (widgets) delete[] widgets; if (widgets) delete[] widgets;
widgets = nullptr; widgets = nullptr;
Window::deleteLater(detach, trash); Window::deleteLater();
} }
Widget* WidgetsContainer::getWidget(unsigned int index) Widget* WidgetsContainer::getWidget(unsigned int index)
@@ -47,7 +47,7 @@ class WidgetsContainer: public Window
virtual bool isAppMode() const { return false; } virtual bool isAppMode() const { return false; }
bool isWidgetsContainer() override { return true; } bool isWidgetsContainer() override { return true; }
void deleteLater(bool detach = true, bool trash = true) override; void deleteLater() override;
protected: protected:
uint8_t zoneCount = 0; uint8_t zoneCount = 0;
@@ -21,7 +21,6 @@
#include "widgets_setup.h" #include "widgets_setup.h"
#include "layer.h"
#include "menu.h" #include "menu.h"
#include "myeeprom.h" #include "myeeprom.h"
#include "storage/storage.h" #include "storage/storage.h"
@@ -82,7 +81,6 @@ SetupWidgetsPageSlot::SetupWidgetsPageSlot(Window* parent, const rect_t& rect,
void SetupWidgetsPageSlot::setFocusState() void SetupWidgetsPageSlot::setFocusState()
{ {
if (hasFocus()) { if (hasFocus()) {
bringToTop();
lv_obj_add_flag(border, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(border, LV_OBJ_FLAG_HIDDEN);
} else { } else {
lv_obj_clear_flag(border, LV_OBJ_FLAG_HIDDEN); lv_obj_clear_flag(border, LV_OBJ_FLAG_HIDDEN);
@@ -158,9 +156,11 @@ void SetupWidgetsPage::onCancel()
QuickMenu::openPage((QMPage)(QM_UI_SCREEN1 + customScreenIdx)); 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... // and continue async deletion...
auto screen = customScreens[customScreenIdx]; auto screen = customScreens[customScreenIdx];
@@ -46,7 +46,7 @@ class SetupWidgetsPage : public Window
unsigned savedView = 0; unsigned savedView = 0;
void onEvent(event_t event) override; void onEvent(event_t event) override;
void deleteLater(bool detach = true, bool trash = true) override; void deleteLater() override;
}; };
class SetupWidgetsPageSlot : public ButtonBase class SetupWidgetsPageSlot : public ButtonBase
+11 -17
View File
@@ -21,8 +21,12 @@
#include "curveedit.h" #include "curveedit.h"
#include "edgetx.h" // TODO for applyCustomCurve #include "choice.h"
#include "edgetx.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "getset_helpers.h"
#include "numberedit.h"
#include "textedit.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #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, static const lv_coord_t default_row_dsc[] = {LV_GRID_CONTENT,
LV_GRID_TEMPLATE_LAST}; LV_GRID_TEMPLATE_LAST};
class CurveEdit : public Window class CurveEdit : public Curve
{ {
public: public:
CurveEdit(Window* parent, const rect_t& rect, uint8_t index) : CurveEdit(Window* parent, const rect_t& rect, uint8_t index) :
Window(parent, rect), Curve(parent, rect,
preview(
this, {0, 0, width(), height()},
[=](int x) -> int { return applyCustomCurve(x, index); }, [=](int x) -> int { return applyCustomCurve(x, index); },
[=]() -> int { return getValue(currentSource); }), [=]() -> int { return getValue(currentSource); }
),
index(index), index(index),
current(0) current(0)
{ {
@@ -58,28 +61,19 @@ class CurveEdit : public Window
void updatePreview() void updatePreview()
{ {
preview.clearPoints(); clearPoints();
CurveHeader& curve = g_model.curves[index]; CurveHeader& curve = g_model.curves[index];
for (uint8_t i = 0; i < 5 + curve.points; i++) { for (uint8_t i = 0; i < 5 + curve.points; i++) {
preview.addPoint(getPoint(index, i)); addPoint(getPoint(index, i));
} }
} }
protected: protected:
Curve preview;
uint8_t index; uint8_t index;
uint8_t current; uint8_t current;
mixsrc_t currentSource = 0; mixsrc_t currentSource = 0;
bool lockSource = false; 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 void checkEvents(void) override
{ {
if (!lockSource) { if (!lockSource) {
@@ -23,11 +23,15 @@
#include "function_switches.h" #include "function_switches.h"
#include "choice.h"
#include "color_picker.h"
#include "edgetx.h" #include "edgetx.h"
#include "getset_helpers.h"
#include "hal/rgbleds.h" #include "hal/rgbleds.h"
#include "strhelpers.h" #include "strhelpers.h"
#include "switches.h" #include "switches.h"
#include "color_picker.h" #include "textedit.h"
#include "toggleswitch.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
+6 -4
View File
@@ -23,13 +23,15 @@
#include "curve_param.h" #include "curve_param.h"
#include "curveedit.h" #include "curveedit.h"
#include "gvar_numberedit.h"
#include "source_numberedit.h"
#include "input_source.h"
#include "edgetx.h" #include "edgetx.h"
#include "etx_lv_theme.h" #include "etx_lv_theme.h"
#include "switchchoice.h"
#include "fm_matrix.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) #define SET_DIRTY() storageDirty(EE_MODEL)
+8 -6
View File
@@ -22,17 +22,19 @@
#include "mixer_edit.h" #include "mixer_edit.h"
#include "channel_bar.h" #include "channel_bar.h"
#include "gvar_numberedit.h"
#include "source_numberedit.h"
#include "curve_param.h" #include "curve_param.h"
#include "mixer_edit_adv.h" #include "curveedit.h"
#include "mixes.h"
#include "edgetx.h" #include "edgetx.h"
#include "etx_lv_theme.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 "sourcechoice.h"
#include "switchchoice.h" #include "switchchoice.h"
#include "curveedit.h" #include "textedit.h"
#include "pagegroup.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -21,11 +21,14 @@
#include "mixer_edit_adv.h" #include "mixer_edit_adv.h"
#include "fm_matrix.h" #include "choice.h"
#include "mixes.h"
#include "numberedit.h"
#include "edgetx.h" #include "edgetx.h"
#include "etx_lv_theme.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) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -21,8 +21,10 @@
#include "model_curves.h" #include "model_curves.h"
#include "button.h"
#include "curveedit.h" #include "curveedit.h"
#include "edgetx.h" #include "edgetx.h"
#include "menu.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -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)
{ {
} }
+1 -1
View File
@@ -27,7 +27,7 @@
class ModelCurvesPage : public PageGroupItem class ModelCurvesPage : public PageGroupItem
{ {
public: public:
ModelCurvesPage(PageDef& pageDef); ModelCurvesPage(const PageDef& pageDef);
static void pushEditCurve(int index, std::function<void(void)> refreshView, mixsrc_t source); static void pushEditCurve(int index, std::function<void(void)> refreshView, mixsrc_t source);
@@ -21,11 +21,15 @@
#include "model_flightmodes.h" #include "model_flightmodes.h"
#include "list_line_button.h" #include "button.h"
#include "edgetx.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 "page.h"
#include "switchchoice.h" #include "switchchoice.h"
#include "etx_lv_theme.h" #include "textedit.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -204,7 +208,6 @@ class FlightModeBtn : public ListLineButton
FlightModeBtn(Window* parent, int index) : ListLineButton(parent, index) FlightModeBtn(Window* parent, int index) : ListLineButton(parent, index)
{ {
padAll(PAD_ZERO); padAll(PAD_ZERO);
padColumn(PAD_ZERO);
setHeight(BTN_H); setHeight(BTN_H);
delayLoad(); delayLoad();
@@ -462,7 +465,7 @@ const lv_obj_class_t FlightModeBtn::fm_trim_value_class = {
.instance_size = sizeof(lv_label_t), .instance_size = sizeof(lv_label_t),
}; };
ModelFlightModesPage::ModelFlightModesPage(PageDef& pageDef) : ModelFlightModesPage::ModelFlightModesPage(const PageDef& pageDef) :
PageGroupItem(pageDef) PageGroupItem(pageDef)
{ {
} }
@@ -24,10 +24,12 @@
#include "edgetx.h" #include "edgetx.h"
#include "pagegroup.h" #include "pagegroup.h"
class TextButton;
class ModelFlightModesPage : public PageGroupItem class ModelFlightModesPage : public PageGroupItem
{ {
public: public:
ModelFlightModesPage(PageDef& pageDef); ModelFlightModesPage(const PageDef& pageDef);
void build(Window* window) override; void build(Window* window) override;
+9 -4
View File
@@ -21,11 +21,16 @@
#include "model_gvars.h" #include "model_gvars.h"
#include "list_line_button.h" #include "choice.h"
#include "numberedit.h"
#include "edgetx.h" #include "edgetx.h"
#include "page.h"
#include "etx_lv_theme.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) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -507,7 +512,7 @@ class GVarEditWindow : public Page
} }
}; };
ModelGVarsPage::ModelGVarsPage(PageDef& pageDef) : ModelGVarsPage::ModelGVarsPage(const PageDef& pageDef) :
PageGroupItem(pageDef) PageGroupItem(pageDef)
{ {
} }
+1 -1
View File
@@ -27,7 +27,7 @@
class ModelGVarsPage : public PageGroupItem class ModelGVarsPage : public PageGroupItem
{ {
public: public:
ModelGVarsPage(PageDef& pageDef); ModelGVarsPage(const PageDef& pageDef);
void cleanup() override; void cleanup() override;
@@ -20,7 +20,10 @@
*/ */
#include "model_heli.h" #include "model_heli.h"
#include "edgetx.h" #include "edgetx.h"
#include "getset_helpers.h"
#include "numberedit.h"
#include "sourcechoice.h" #include "sourcechoice.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -23,9 +23,11 @@
#include <algorithm> #include <algorithm>
#include "dialog.h"
#include "edgetx.h"
#include "hal/adc_driver.h" #include "hal/adc_driver.h"
#include "input_edit.h" #include "input_edit.h"
#include "edgetx.h" #include "menu.h"
#include "tasks/mixer_task.h" #include "tasks/mixer_task.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #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)
{ {
} }
+1 -1
View File
@@ -27,7 +27,7 @@
class ModelInputsPage : public InputMixPageBase class ModelInputsPage : public InputMixPageBase
{ {
public: public:
ModelInputsPage(PageDef& pageDef); ModelInputsPage(const PageDef& pageDef);
void build(Window *window) override; void build(Window *window) override;
@@ -21,13 +21,17 @@
#include "model_logical_switches.h" #include "model_logical_switches.h"
#include "list_line_button.h"
#include "edgetx.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 "page.h"
#include "sourcechoice.h" #include "sourcechoice.h"
#include "switchchoice.h" #include "switchchoice.h"
#include "switches.h" #include "switches.h"
#include "etx_lv_theme.h" #include "toggleswitch.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -522,7 +526,7 @@ class LogicalSwitchButton : public ListLineButton
lv_obj_t* lsDelay = nullptr; lv_obj_t* lsDelay = nullptr;
}; };
ModelLogicalSwitchesPage::ModelLogicalSwitchesPage(PageDef& pageDef) : ModelLogicalSwitchesPage::ModelLogicalSwitchesPage(const PageDef& pageDef) :
PageGroupItem(pageDef) PageGroupItem(pageDef)
{ {
} }
@@ -27,7 +27,7 @@
class ModelLogicalSwitchesPage : public PageGroupItem class ModelLogicalSwitchesPage : public PageGroupItem
{ {
public: public:
ModelLogicalSwitchesPage(PageDef& pageDef); ModelLogicalSwitchesPage(const PageDef& pageDef);
virtual void build(Window* window) override; virtual void build(Window* window) override;
@@ -21,15 +21,18 @@
#include "model_mixer_scripts.h" #include "model_mixer_scripts.h"
#include "dataconstants.h" #include "edgetx.h"
#include "etx_lv_theme.h"
#include "filechoice.h" #include "filechoice.h"
#include "getset_helpers.h"
#include "list_line_button.h" #include "list_line_button.h"
#include "lua/lua_api.h" #include "lua/lua_api.h"
#include "menu.h"
#include "menus.h" #include "menus.h"
#include "edgetx.h" #include "numberedit.h"
#include "page.h" #include "page.h"
#include "sourcechoice.h" #include "sourcechoice.h"
#include "etx_lv_theme.h" #include "textedit.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -251,7 +254,7 @@ class ScriptLineButton : public ListLineButton
const ScriptInternalData* runtimeData; const ScriptInternalData* runtimeData;
}; };
ModelMixerScriptsPage::ModelMixerScriptsPage(PageDef& pageDef) : ModelMixerScriptsPage::ModelMixerScriptsPage(const PageDef& pageDef) :
PageGroupItem(pageDef) PageGroupItem(pageDef)
{ {
} }
@@ -27,7 +27,7 @@
class ModelMixerScriptsPage : public PageGroupItem class ModelMixerScriptsPage : public PageGroupItem
{ {
public: public:
ModelMixerScriptsPage(PageDef& pageDef); ModelMixerScriptsPage(const PageDef& pageDef);
virtual void build(Window* window) override { build(window, 0); } virtual void build(Window* window) override { build(window, 0); }
+12 -8
View File
@@ -20,13 +20,17 @@
*/ */
#include "model_mixes.h" #include "model_mixes.h"
#include "edgetx.h"
#include "mixer_edit.h"
#include "mixes.h"
#include "channel_bar.h"
#include <algorithm> #include <algorithm>
#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) #define SET_DIRTY() storageDirty(EE_MODEL)
class MPlexIcon : public Window class MPlexIcon : public Window
@@ -81,10 +85,10 @@ class MixLineButton : public InputMixButtonBase
delayLoad(); delayLoad();
} }
void deleteLater(bool detach = true, bool trash = true) override void deleteLater() override
{ {
if (mplex) mplex->deleteLater(detach, trash); if (mplex) mplex->deleteLater();
InputMixButtonBase::deleteLater(detach, trash); InputMixButtonBase::deleteLater();
} }
void delayedInit() override void delayedInit() override
@@ -229,7 +233,7 @@ class MixGroup : public InputMixGroupBase
bool monitorVisible = false; bool monitorVisible = false;
}; };
ModelMixesPage::ModelMixesPage(PageDef& pageDef) : InputMixPageBase(pageDef) ModelMixesPage::ModelMixesPage(const PageDef& pageDef) : InputMixPageBase(pageDef)
{ {
} }
+1 -1
View File
@@ -27,7 +27,7 @@
class ModelMixesPage : public InputMixPageBase class ModelMixesPage : public InputMixPageBase
{ {
public: public:
ModelMixesPage(PageDef& pageDef); ModelMixesPage(const PageDef& pageDef);
void build(Window* window) override; void build(Window* window) override;

Some files were not shown because too many files have changed in this diff Show More