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 "sdcard.h"
#include "debug.h"
#include "keys.h"
#include "flysky_gimbal_driver.h"
#include "timers_driver.h"
#include "bitmapbuffer.h"
#include "colors.h"
#include "touch_driver.h"
#include <string.h>
+1 -3
View File
@@ -48,13 +48,11 @@
#include "globals.h"
#include "sdcard.h"
#include "debug.h"
#include "keys.h"
#include "flysky_gimbal_driver.h"
#include "timers_driver.h"
#include "bitmapbuffer.h"
#include "colors.h"
#include "touch_driver.h"
#include <string.h>
+1 -8
View File
@@ -55,13 +55,10 @@
#if defined(COLORLCD)
#include "radio_calibration.h"
#include "view_main.h"
#include "view_text.h"
#include "theme_manager.h"
#include "switch_warn_dialog.h"
#include "startup_shutdown.h"
#include "LvglWrapper.h"
#endif
#if defined(CROSSFIRE)
@@ -1421,11 +1418,7 @@ void edgeTxInit()
if (!(startOptions & OPENTX_START_NO_SPLASH))
startSplash();
#if defined(COLORLCD)
initLvglTheme();
// create ViewMain
ViewMain::instance();
#elif defined(GUI)
#if !defined(COLORLCD)
// TODO add a function for this (duplicated)
menuHandlers[0] = menuMainView;
menuHandlers[1] = menuModelSelect;
+1 -3
View File
@@ -38,9 +38,7 @@
#include "usbd_msc_conf.h"
#endif
#if defined(COLORLCD)
#include "libopenui.h"
#else
#if !defined(COLORLCD)
#include "lib_file.h"
#endif
+31 -34
View File
@@ -19,15 +19,15 @@
* GNU General Public License for more details.
*/
#include "edgetx.h"
#include "hal/rotary_encoder.h"
#include "os/time.h"
#include "LvglWrapper.h"
#include "etx_lv_theme.h"
#include "view_main.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "hal/rotary_encoder.h"
#include "keyboard_base.h"
#include "mainwindow.h"
#include "os/time.h"
#include "view_main.h"
LvglWrapper* LvglWrapper::_instance = nullptr;
@@ -144,7 +144,7 @@ static void keyboardDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
// no focused item ?
auto obj = get_focus_obj(keyboardDevice);
if (!obj) {
auto w = Layer::back();
auto w = Window::topWindow();
dispatch_kb_event(w, evt);
backup_kb_data(data);
return;
@@ -323,11 +323,13 @@ static void init_lvgl_drivers()
keyboardDevice = lv_indev_drv_register(&keyboard_drv);
}
void initLvglTheme()
LvglWrapper::LvglWrapper()
{
init_lvgl_drivers();
static lv_theme_t theme;
/* Initialize the ETX theme */
/* Initialize default theme */
theme.disp = NULL;
theme.color_primary = lv_palette_main(LV_PALETTE_BLUE);
theme.color_secondary = lv_palette_main(LV_PALETTE_RED);
@@ -338,18 +340,17 @@ void initLvglTheme()
/* Assign the theme to the current display*/
lv_disp_set_theme(NULL, &theme);
}
LvglWrapper::LvglWrapper()
{
init_lvgl_drivers();
// Integrate STB image handling into lvgl
extern void lv_stb_init();
lv_stb_init();
// Create main window and load that screen
auto window = MainWindow::instance();
window->setActiveScreen();
lv_scr_load(window->getLvObj());
// create ViewMain window
ViewMain::instance();
}
LvglWrapper* LvglWrapper::instance()
@@ -360,26 +361,22 @@ LvglWrapper* LvglWrapper::instance()
void LvglWrapper::run()
{
#if defined(SIMU)
static uint32_t last_tick = 0;
uint32_t tick = time_get_ms();
lv_tick_inc(tick - last_tick);
last_tick = tick;
#endif
lv_timer_handler();
}
// Detect nested calls
static bool updating = false;
void LvglWrapper::runNested()
{
// Manual refresh
lv_refr_now(nullptr);
pollInputs();
}
if (!updating) {
// Normal UI loop - call lgvl timer handler
updating = true;
lv_timer_handler();
updating = false;
} else {
// Used when running the loop manually from within
// the LVGL timer handler (blocking UI code)
lv_refr_now(nullptr);
void LvglWrapper::pollInputs()
{
lv_indev_t* indev = nullptr;
while((indev = lv_indev_get_next(indev)) != nullptr) {
lv_indev_read_timer_cb(indev->driver->read_timer);
lv_indev_t* indev = nullptr;
while((indev = lv_indev_get_next(indev)) != nullptr) {
lv_indev_read_timer_cb(indev->driver->read_timer);
}
}
}
+6 -18
View File
@@ -21,31 +21,19 @@
#pragma once
#include <lvgl/lvgl.h>
#include "edgetx_types.h"
void initLvglTheme();
typedef std::function<lv_obj_t *(lv_obj_t *parent)> LvObjConstructor;
#include "lvgl/lvgl.h"
class LvglWrapper
{
static LvglWrapper *_instance;
static void pollInputs();
LvglWrapper();
~LvglWrapper() {}
public:
static LvglWrapper* instance();
// Called from UI task: executes the LVGL timer handler
void run();
// Call it when running the loop manually from within
// the LVGL timer handler (blocking UI code)
static void runNested();
};
protected:
static LvglWrapper *_instance;
// multiplication factor between 0 and 25
int8_t rotaryEncoderGetAccel();
LvglWrapper();
~LvglWrapper() {}
};
@@ -23,6 +23,7 @@
#include "bitmaps.h"
#include "etx_lv_theme.h"
#include "static.h"
#define VIEW_CHANNELS_LIMIT_PCT \
(g_model.extendedLimits ? LIMIT_EXT_PERCENT : LIMIT_STD_PERCENT)
@@ -35,7 +36,7 @@ ChannelBar::ChannelBar(Window* parent, const rect_t& rect, uint8_t channel,
Window(parent, rect), channel(channel),
getValue(std::move(getValueFunc))
{
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setWindowFlag(NO_CLICK);
etx_solid_bg(lvobj, COLOR_THEME_PRIMARY2_INDEX);
@@ -241,14 +242,14 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect,
char chanString[10];
char* s = strAppend(chanString, STR_CH);
strAppendSigned(s, channel + 1);
new StaticText(this, {PAD_TINY + invMask->width, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, chanString,
new StaticText(this, {PAD_TINY + invMask->width, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, chanString,
txtColIdx, FONT(XS) | LEFT);
// Channel name
if (g_model.limitData[channel].name[0]) {
char nm[LEN_CHANNEL_NAME + 1];
strAppend(nm, g_model.limitData[channel].name, LEN_CHANNEL_NAME);
new StaticText(this, {PAD_TINY + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm,
new StaticText(this, {PAD_TINY + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm,
txtColIdx, FONT(XS) | LEFT);
}
@@ -22,6 +22,9 @@
#pragma once
#include "edgetx.h"
#include "window.h"
class StaticIcon;
class ChannelBar : public Window
{
@@ -22,6 +22,8 @@
#include "channel_range.h"
#include "edgetx.h"
#include "getset_helpers.h"
#include "numberedit.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -23,6 +23,7 @@
#include "button.h"
#include "etx_lv_theme.h"
#include "hal/rotary_encoder.h"
static const char* const RGBChars[MAX_BARS] = {"R", "G", "B"};
static const char* const HSVChars[MAX_BARS] = {"H", "S", "V"};
@@ -477,7 +478,7 @@ ColorEditor::ColorEditor(Window* parent, const rect_t& rect, uint32_t color,
lv_obj_add_event_cb(lvobj, ColorEditor::value_changed, LV_EVENT_VALUE_CHANGED,
nullptr);
if (_preview) _preview(_color);
if (_preview) _preview(_color);
}
void ColorEditor::setColorEditorType(COLOR_EDITOR_TYPE colorType)
@@ -22,6 +22,7 @@
#include "color_picker.h"
#include "color_list.h"
#include "dialog.h"
#include "etx_lv_theme.h"
#if LANDSCAPE
+2 -3
View File
@@ -23,6 +23,7 @@
#include "bitmaps.h"
#include "edgetx.h"
#include "static.h"
#include "strhelpers.h"
//-----------------------------------------------------------------------------
@@ -130,9 +131,7 @@ Curve::Curve(Window* parent, const rect_t& rect,
valueFunc(std::move(function)),
positionFunc(std::move(position))
{
setWindowFlag(NO_FOCUS);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setWindowFlag(NO_FOCUS | NO_CLICK);
etx_solid_bg(lvobj, COLOR_THEME_PRIMARY2_INDEX);
@@ -21,14 +21,15 @@
#include "curve_param.h"
#include "gvar_numberedit.h"
#include "source_numberedit.h"
#include "model_curves.h"
#include "edgetx.h"
#include "getset_helpers.h"
#include "gvar_numberedit.h"
#include "model_curves.h"
#include "source_numberedit.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
CurveChoice::CurveChoice(Window* parent, std::function<int()> getRefValue,
CurveChoice::CurveChoice(Window* parent, std::function<int()> getRefValue,
std::function<void(int32_t)> setRefValue, std::function<void(void)> refreshView, mixsrc_t source) :
Choice(parent, rect_t{}, -MAX_CURVES, MAX_CURVES, getRefValue, setRefValue),
source(source), refreshView(std::move(refreshView))
@@ -86,7 +87,7 @@ CurveParam::CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
});
// CURVE_REF_CUSTOM
cust_choice = new CurveChoice(this,
cust_choice = new CurveChoice(this,
[=]() {
SourceNumVal v;
v.rawValue = ref->value;
@@ -31,11 +31,11 @@ GVarNumberEdit::GVarNumberEdit(Window* parent, int32_t vmin,
vmax(vmax),
getValue(getValue),
setValue(setValue),
textFlags(textFlags),
voffset(voffset)
{
setTextFlag(textFlags);
padAll(PAD_TINY);
// GVAR field
gvar_field = new Choice(
this, {0, 0, EdgeTxStyles::EDIT_FLD_WIDTH_NARROW, 0}, -MAX_GVARS, MAX_GVARS - 1,
@@ -103,7 +103,7 @@ void GVarNumberEdit::update()
gvar_field->hide();
num_field->hide();
int32_t value = getValue();
if (GV_IS_GV_VALUE(value)) {
// GVAR mode
@@ -56,7 +56,6 @@ class GVarNumberEdit : public Window
int32_t vmax;
std::function<int32_t()> getValue;
std::function<void(int32_t)> setValue;
LcdFlags textFlags;
int32_t voffset;
void onEvent(event_t event) override;
@@ -22,7 +22,10 @@
#include "input_source.h"
#include "edgetx.h"
#include "getset_helpers.h"
#include "numberedit.h"
#include "sourcechoice.h"
#include "static.h"
#include "switchchoice.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -37,9 +37,10 @@ SourceNumberEdit::SourceNumberEdit(Window* parent,
sourceMin(sourceMin),
getValue(getValue),
setValue(setValue),
textFlags(textFlags),
voffset(voffset)
{
setTextFlag(textFlags);
padAll(PAD_TINY);
lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_ROW_WRAP);
lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0);
@@ -58,7 +58,6 @@ class SourceNumberEdit : public Window
int16_t sourceMin;
std::function<int32_t()> getValue;
std::function<void(int32_t)> setValue;
LcdFlags textFlags;
int32_t voffset;
bool isSource();
@@ -21,6 +21,7 @@
#include "switch_warn_dialog.h"
#include "static.h"
#include "switches.h"
SwitchWarnDialog::SwitchWarnDialog() :
-1
View File
@@ -27,7 +27,6 @@
#include "fonts.h"
#include "lz4/lz4.h"
#include "libopenui_defines.h"
#include "lz4_fonts.h"
#include "translations/tts/tts.h"
+5 -1
View File
@@ -18,7 +18,11 @@
#pragma once
#include "libopenui_defines.h"
#include "colors.h"
#if defined(DEBUG)
#include "debug.h"
#endif
struct MaskBitmap;
class TelemetryItem;
@@ -21,6 +21,7 @@
#include "bitmapbuffer.h"
#include "lib_file.h"
#include "edgetx_helpers.h"
#include "debug.h"
FIL imgFile __DMA;
+1 -1
View File
@@ -119,7 +119,7 @@ class IconButton : public ButtonBase
public:
IconButton(Window* parent, EdgeTxIcon icon, coord_t x, coord_t y,
std::function<uint8_t(void)> pressHandler = nullptr);
void setIcon(EdgeTxIcon icon);
protected:
@@ -81,7 +81,7 @@ ButtonMatrix::ButtonMatrix(Window* parent, const rect_t& r) :
FormField(parent, r, btnmatrix_create)
{
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
setWindowFlag(NO_FOCUS);
lv_obj_add_event_cb(lvobj, btn_matrix_event, LV_EVENT_VALUE_CHANGED, this);
}
+4 -2
View File
@@ -19,10 +19,12 @@
#include "dialog.h"
#include "edgetx.h"
#include "mainwindow.h"
#include "progress.h"
#include "etx_lv_theme.h"
#include "keyboard_base.h"
#include "mainwindow.h"
#include "progress.h"
#include "static.h"
#include "textedit.h"
//-----------------------------------------------------------------------------
+1 -1
View File
@@ -271,7 +271,7 @@ class EdgeTxStyles
static const lv_style_t border_transparent;
static const lv_style_t border_thin;
static const lv_style_t outline;
EdgeTxStyles();
void init();
@@ -197,7 +197,7 @@ void FileBrowser::onSelected(uint16_t row, uint16_t col)
void FileBrowser::onPress(uint16_t row, uint16_t col)
{
bool is_dir = lv_table_has_cell_ctrl(lvobj, row, col, CELL_CTRL_DIR);
onPress(lv_table_get_cell_value(lvobj, row, col), is_dir);
onPress(lv_table_get_cell_value(lvobj, row, col), is_dir);
}
void FileBrowser::onDrawBegin(uint16_t row, uint16_t col, lv_obj_draw_part_dsc_t* dsc)
@@ -245,7 +245,7 @@ void FileBrowser::onSelected(const char* name, bool is_dir)
}
const char* path = getCurrentPath();
const char* fullpath = getFullPath(name);
const char* fullpath = getFullPath(name);
if (fileSelected) fileSelected(path, name, fullpath, is_dir);
selected = name;
}
@@ -253,7 +253,7 @@ void FileBrowser::onSelected(const char* name, bool is_dir)
void FileBrowser::onPress(const char* name, bool is_dir)
{
const char* path = getCurrentPath();
const char* fullpath = getFullPath(name);
const char* fullpath = getFullPath(name);
if (is_dir) {
f_chdir(fullpath);
if (fileSelected) fileSelected(nullptr, nullptr, nullptr, is_dir);
@@ -266,7 +266,7 @@ void FileBrowser::onPress(const char* name, bool is_dir)
onSelected(name, is_dir);
return;
}
if (fileAction){
fileAction(path, name, fullpath, is_dir);
}
@@ -275,12 +275,12 @@ void FileBrowser::onPress(const char* name, bool is_dir)
void FileBrowser::onPressLong(const char* name, bool is_dir)
{
const char* path = getCurrentPath();
const char* fullpath = getFullPath(name);
const char* fullpath = getFullPath(name);
if (!selected || (selected != name)) {
onSelected(name, is_dir);
}
if (fileAction){
fileAction(path, name, fullpath, is_dir);
}
@@ -22,6 +22,7 @@
#include "file_carosell.h"
#include "translations/translations.h"
#include "timers_driver.h"
extern inline tmr10ms_t getTicks()
{
@@ -58,7 +59,7 @@ void FileCarosell::setSelected(int n)
} else
fp->setFile("");
}
message->show(selected == -1);
if (selected == -1)
message->setText(_fileNames.size() > 0 ? STR_LOADING : STR_NO_THEME_IMAGE);
@@ -20,6 +20,7 @@
#include <algorithm>
#include "dialog.h"
#include "edgetx.h"
#include "lib_file.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);
Window::deleteLater(detach, trash);
Window::deleteLater();
}
FormLine::FormLine(Window* parent, FlexGridLayout& layout) :
+1 -1
View File
@@ -95,7 +95,7 @@ class FormField : public Window
void onClicked() override;
void onCancel() override;
void deleteLater(bool detach = true, bool trash = true) override;
void deleteLater() override;
protected:
bool editMode = false;
@@ -21,13 +21,13 @@
#include "fullscreen_dialog.h"
#include "LvglWrapper.h"
#include "mainwindow.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "os/sleep.h"
#include "view_main.h"
#include "hal/watchdog_driver.h"
#include "mainwindow.h"
#include "os/sleep.h"
#include "static.h"
#include "view_main.h"
FullScreenDialog::FullScreenDialog(
uint8_t type, std::string title, std::string message, std::string action,
@@ -47,8 +47,6 @@ FullScreenDialog::FullScreenDialog(
pushLayer();
bringToTop();
build();
}
@@ -150,12 +148,14 @@ void FullScreenDialog::checkEvents()
}
}
void FullScreenDialog::deleteLater(bool detach, bool trash)
void FullScreenDialog::deleteLater()
{
if (_deleted) return;
if (running) {
running = false;
} else {
Window::deleteLater(detach, trash);
Window::deleteLater();
}
}
@@ -164,16 +164,6 @@ void FullScreenDialog::setMessage(const char* text)
if (messageLabel) messageLabel->setText(text);
}
static void run_ui_manually()
{
checkBacklight();
WDG_RESET();
sleep_ms(10);
LvglWrapper::runNested();
MainWindow::instance()->run(false);
}
void FullScreenDialog::runForever(bool checkPwr)
{
running = true;
@@ -199,7 +189,11 @@ void FullScreenDialog::runForever(bool checkPwr)
}
}
run_ui_manually();
checkBacklight();
WDG_RESET();
MainWindow::instance()->run();
sleep_ms(10);
}
deleteLater();
@@ -45,7 +45,7 @@ class FullScreenDialog : public Window
void onCancel() override;
bool onLongPress() override;
void deleteLater(bool detach = true, bool trash = true) override;
void deleteLater() override;
void checkEvents() override;
+5 -13
View File
@@ -21,6 +21,8 @@
#include "form.h"
#include "mainwindow.h"
#include "etx_lv_theme.h"
#include "debug.h"
#include "keys.h"
static void keyboard_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
{
@@ -71,16 +73,6 @@ static void keyboard_event_cb(lv_event_t* e)
static void field_focus_leave(lv_event_t* e) { Keyboard::hide(false); }
static void _assign_lv_group(lv_group_t* g)
{
// associate it with all input devices
lv_indev_t* indev = lv_indev_get_next(NULL);
while (indev) {
lv_indev_set_group(indev, g);
indev = lv_indev_get_next(indev);
}
}
Keyboard::Keyboard(coord_t height) :
NavWindow(MainWindow::instance(), {0, LCD_H - height, LCD_W, height})
{
@@ -138,7 +130,7 @@ void Keyboard::clearField(bool wasCancelled)
field = nullptr;
if (fieldGroup) {
_assign_lv_group(fieldGroup);
assignLvGroup(fieldGroup, false);
lv_group_set_editing(fieldGroup, false);
fieldGroup = nullptr;
}
@@ -147,7 +139,7 @@ void Keyboard::clearField(bool wasCancelled)
void Keyboard::hide(bool wasCancelled)
{
if (activeKeyboard) {
if (activeKeyboard && !activeKeyboard->_deleted) {
activeKeyboard->clearField(wasCancelled);
lv_obj_add_flag(activeKeyboard->lvobj, LV_OBJ_FLAG_HIDDEN);
activeKeyboard = nullptr;
@@ -189,7 +181,7 @@ void Keyboard::setField(FormField* newField)
lv_keyboard_set_textarea(keyboard, obj);
lv_obj_add_event_cb(obj, field_focus_leave, LV_EVENT_DEFOCUSED, nullptr);
_assign_lv_group(group);
assignLvGroup(group, false);
field = newField;
fieldGroup = (lv_group_t*)lv_obj_get_group(obj);
@@ -19,6 +19,7 @@
#include "keyboard_number.h"
#include "numberedit.h"
#include "keys.h"
constexpr coord_t KEYBOARD_HEIGHT = 90;
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
#include "debug.h"
#include "colors.h"
#include "keys.h"
// Used by Lua API
#define INVERS 0x01u
#define BLINK 0x1000u
@@ -245,10 +245,7 @@ static lv_obj_t* group_create(lv_obj_t* parent)
InputMixGroupBase::InputMixGroupBase(Window* parent, mixsrc_t idx) :
Window(parent, rect_t{}, group_create), idx(idx)
{
setWindowFlag(NO_FOCUS);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
padAll(PAD_ZERO);
setWindowFlag(NO_FOCUS | NO_CLICK);
label = etx_label_create(lvobj);
etx_font(label, FONT_XS_INDEX, LV_STATE_USER_1);
@@ -127,7 +127,7 @@ class InputMixGroupBase : public Window
class InputMixPageBase : public PageGroupItem
{
public:
InputMixPageBase(PageDef& pageDef) : PageGroupItem(pageDef) {}
InputMixPageBase(const PageDef& pageDef) : PageGroupItem(pageDef) {}
protected:
std::list<InputMixButtonBase*> lines;
+2
View File
@@ -21,6 +21,8 @@
#include "listbox.h"
#include "debug.h"
ListBox::ListBox(Window* parent, const rect_t& rect,
const std::vector<std::string>& names, uint8_t lineHeight) :
TableField(parent, rect)
+20 -19
View File
@@ -19,8 +19,10 @@
#include "mainwindow.h"
#include "board.h"
#include "debug.h"
#include "keyboard_base.h"
#include "layout.h"
#include "LvglWrapper.h"
#include "etx_lv_theme.h"
#include "sdcard.h"
#include "view_main.h"
@@ -54,13 +56,17 @@ void MainWindow::emptyTrash()
trash.clear();
}
void MainWindow::run(bool trash)
void MainWindow::run()
{
LvglWrapper::instance()->run();
#if defined(DEBUG_WINDOWS)
auto start = timersGetMsTick();
#endif
ViewMain::refreshWidgets();
auto opaque = Layer::getFirstOpaque();
auto opaque = Window::firstOpaque();
if (opaque) {
opaque->checkEvents();
}
@@ -72,12 +78,14 @@ void MainWindow::run(bool trash)
}
}
if (trash) emptyTrash();
emptyTrash();
#if defined(DEBUG_WINDOWS)
auto delta = timersGetMsTick() - start;
if (delta > 10) {
TRACE_WINDOWS("MainWindow::run took %dms", delta);
}
#endif
}
void MainWindow::shutdown()
@@ -88,9 +96,8 @@ void MainWindow::shutdown()
LayoutFactory::deleteCustomScreens();
// clear layer stack first
for (Window* w = Layer::back(); w; w = Layer::back()) {
for (Window* w = Window::topWindow(); w; w = Window::topWindow()) {
w->deleteLater();
Layer::pop(w);
}
children.clear();
@@ -102,27 +109,21 @@ void MainWindow::shutdown()
lv_obj_center(background);
}
void MainWindow::setBackgroundImage(const char* fileName)
bool MainWindow::setBackgroundImage(std::string& fileName)
{
if (fileName.empty()) return false;
// ensure you delete old bitmap
if (backgroundBitmap != nullptr) delete backgroundBitmap;
if (fileName == nullptr) fileName = "";
backgroundImageFileName = fileName;
// Try to load bitmap. If this fails backgroundBitmap will be NULL and default
// will be loaded in update() method
backgroundBitmap =
BitmapBuffer::loadBitmap(backgroundImageFileName.c_str(), BMP_RGB565);
if (!backgroundBitmap) {
backgroundBitmap = BitmapBuffer::loadBitmap(
THEMES_PATH "/EdgeTX/background.png", BMP_RGB565);
}
// Try to load bitmap.
backgroundBitmap = BitmapBuffer::loadBitmap(fileName.c_str(), BMP_RGB565);
if (backgroundBitmap) {
lv_canvas_set_buffer(background, backgroundBitmap->getData(), backgroundBitmap->width(),
backgroundBitmap->height(), LV_IMG_CF_TRUE_COLOR);
return true;
}
return false;
}
+6 -9
View File
@@ -18,9 +18,10 @@
#pragma once
#include "layer.h"
#include "window.h"
class BitmapBuffer;
class MainWindow: public Window
{
protected:
@@ -44,21 +45,17 @@ class MainWindow: public Window
}
#endif
void setActiveScreen() {
lv_scr_load(lvobj);
}
void run();
void run(bool trash=true);
void setBackgroundImage(const char* fileName);
bool setBackgroundImage(std::string& fileName);
void shutdown();
protected:
lv_obj_t* background = nullptr;
std::string backgroundImageFileName;
const BitmapBuffer *backgroundBitmap = nullptr;
static MainWindow * _instance;
static void emptyTrash();
void emptyTrash();
};
+4 -5
View File
@@ -18,13 +18,12 @@
#include "menu.h"
#include <lvgl/lvgl.h>
#include "menutoolbar.h"
#include "edgetx.h"
#include "table.h"
#include "etx_lv_theme.h"
#include "keyboard_base.h"
#include "menutoolbar.h"
#include "static.h"
#include "table.h"
//-----------------------------------------------------------------------------
@@ -314,7 +313,7 @@ class MenuWindowContent : public Window
lv_obj_center(lvobj);
setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO, w, LV_SIZE_CONTENT);
header = new StaticText(this, {0, 0, LV_PCT(100), 0}, "",
header = new StaticText(this, {0, 0, LV_PCT(100), 0}, "",
COLOR_THEME_PRIMARY2_INDEX);
etx_solid_bg(header->getLvObj(), COLOR_THEME_SECONDARY1_INDEX);
header->padAll(PAD_SMALL);
+1
View File
@@ -20,6 +20,7 @@
#include "modal_window.h"
class MaskBitmap;
class Menu;
class MenuWindowContent;
class MenuToolbar;
+1 -1
View File
@@ -18,6 +18,7 @@
#include "menutoolbar.h"
#include "keys.h"
#include "menu.h"
#include "etx_lv_theme.h"
#include "translations/translations.h"
@@ -51,7 +52,6 @@ MenuToolbarButton::MenuToolbarButton(Window* parent, const rect_t& rect,
const char* picto) :
ButtonBase(parent, rect, nullptr, menu_button_create)
{
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
lv_obj_add_event_cb(lvobj, toolbar_btn_defocus, LV_EVENT_DEFOCUSED, nullptr);
@@ -18,7 +18,6 @@
#include "modal_window.h"
#include "layer.h"
#include "etx_lv_theme.h"
#include "mainwindow.h"
+4 -1
View File
@@ -19,7 +19,10 @@
#include "numberedit.h"
#include "audio.h"
#include "debug.h"
#include "hal/rotary_encoder.h"
#include "keyboard_number.h"
#include "keys.h"
#include "strhelpers.h"
#include "etx_lv_theme.h"
@@ -30,7 +33,7 @@ class NumberArea : public FormField
FormField(parent, rect, etx_textarea_create),
numEdit(parent)
{
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
setWindowFlag(NO_FOCUS);
if (parent->getTextFlags() & CENTERED)
etx_obj_add_style(lvobj, styles->text_align_center, LV_PART_MAIN);
+12 -12
View File
@@ -21,12 +21,13 @@
#include "page.h"
#include "theme_manager.h"
#include "etx_lv_theme.h"
#include "view_main.h"
#include "keyboard_base.h"
#include "quick_menu.h"
#include "mainwindow.h"
#include "pagegroup.h"
#include "quick_menu.h"
#include "theme_manager.h"
#include "view_main.h"
PageHeader::PageHeader(Window* parent, EdgeTxIcon icon) :
Window(parent, {0, 0, LCD_W, EdgeTxStyles::MENU_HEADER_HEIGHT})
@@ -107,27 +108,26 @@ Page::Page(EdgeTxIcon icon, PaddingSize padding, bool pauseRefresh) :
void Page::openMenu()
{
PageGroup* p = (PageGroup*)Layer::getPageGroup();
PageGroup* p = Window::pageGroup();
QMPage qmPage = QM_NONE;
if (p)
qmPage = p->getCurrentTab()->pageId();
quickMenu = QuickMenu::openQuickMenu([=]() { quickMenu = nullptr; },
QuickMenu::openQuickMenu(
[=](bool close) {
onCancel();
if (p) {
while (!Layer::back()->isPageGroup()) {
Layer::back()->deleteLater();
while (!Window::topWindow()->isPageGroup()) {
Window::topWindow()->deleteLater();
}
if (close)
Layer::back()->onCancel();
Window::topWindow()->onCancel();
}
}, p, qmPage);
}
void Page::onCancel()
{
if (quickMenu) quickMenu->closeMenu();
quickMenu = nullptr;
QuickMenu::closeQuickMenu();
deleteLater();
}
@@ -141,7 +141,7 @@ void Page::enableRefresh()
NavWindow* Page::navWindow()
{
auto p = Layer::back();
auto p = Window::topWindow();
if (p->isNavWindow()) return (NavWindow*)p;
return nullptr;
}
@@ -151,7 +151,7 @@ void Page::onPressSYS()
{
QMPage pg = g_eeGeneral.getKeyShortcut(EVT_KEY_BREAK(KEY_SYS));
if (pg == QM_OPEN_QUICK_MENU) {
if (!quickMenu) openMenu();
if (!QuickMenu::isOpen()) openMenu();
} else {
auto p = navWindow();
if (p) {
-3
View File
@@ -23,8 +23,6 @@
#include "static.h"
class QuickMenu;
class PageHeader : public Window
{
public:
@@ -61,7 +59,6 @@ class Page : public NavWindow
protected:
PageHeader* header = nullptr;
Window* body = nullptr;
QuickMenu* quickMenu = nullptr;
bool bubbleEvents() override { return false; }
+4 -3
View File
@@ -21,12 +21,14 @@
#include "popups.h"
#include "dialog.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "hal/watchdog_driver.h"
#include "lvgl/src/hal/lv_hal_tick.h"
#include "mainwindow.h"
#include "os/sleep.h"
#include "pwr.h"
#include "hal/watchdog_driver.h"
#include "etx_lv_theme.h"
static void _run_popup_dialog(const char* title, const char* msg,
const char* info = nullptr)
@@ -59,7 +61,6 @@ static void _run_popup_dialog(const char* title, const char* msg,
checkBacklight();
WDG_RESET();
MainWindow::instance()->run();
LvglWrapper::runNested();
sleep_ms(20);
}
}
+2 -2
View File
@@ -58,11 +58,11 @@ void SliderBase::update()
}
}
void SliderBase::deleteLater(bool detach, bool trash)
void SliderBase::deleteLater()
{
if (!deleted()) {
if (tickPts) delete tickPts;
Window::deleteLater(detach, trash);
Window::deleteLater();
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ class SliderBase : public Window
std::function<int()> _getValue;
std::function<void(int)> _setValue;
void deleteLater(bool detach, bool trash) override;
void deleteLater() override;
void checkEvents() override;
static void slider_changed_cb(lv_event_t* e);
+13 -21
View File
@@ -19,6 +19,7 @@
#include "static.h"
#include "bitmaps.h"
#include "debug.h"
#include "lz4/lz4.h"
#include "sdcard.h"
#include "etx_lv_theme.h"
@@ -31,8 +32,7 @@ StaticText::StaticText(Window* parent, const rect_t& rect, std::string txt,
Window(parent, rect, lv_label_create), text(std::move(txt))
{
setTextFlag(textFlags);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
setWindowFlag(NO_FOCUS);
etx_font(lvobj, FONT_INDEX(textFlags));
etx_txt_color(lvobj, color);
@@ -149,9 +149,7 @@ StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, EdgeTxIcon icon,
Window(parent, rect_t{x, y, 0, 0}, lv_canvas_create),
currentColor(color)
{
setWindowFlag(NO_FOCUS);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setWindowFlag(NO_FOCUS | NO_CLICK);
setIcon(icon);
@@ -163,9 +161,7 @@ StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, const char* filenam
Window(parent, rect_t{x, y, 0, 0}, lv_canvas_create),
currentColor(color)
{
setWindowFlag(NO_FOCUS);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setWindowFlag(NO_FOCUS | NO_CLICK);
auto bm = BitmapBuffer::loadBitmap(filename, BMP_RGB565);
if (bm) {
@@ -182,12 +178,12 @@ StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, const char* filenam
etx_img_color(lvobj, currentColor, LV_PART_MAIN);
}
void StaticIcon::deleteLater(bool detach, bool trash)
void StaticIcon::deleteLater()
{
if (_deleted) return;
if (mask) free(mask);
mask = nullptr;
Window::deleteLater(detach, trash);
Window::deleteLater();
}
void StaticIcon::setColor(LcdColorIndex color)
@@ -219,9 +215,7 @@ StaticImage::StaticImage(Window* parent, const rect_t& rect,
const char* filename, bool fillFrame, bool dontEnlarge) :
Window(parent, rect), fillFrame(fillFrame), dontEnlarge(dontEnlarge)
{
setWindowFlag(NO_FOCUS);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setWindowFlag(NO_FOCUS | NO_CLICK);
if (!filename) filename = "";
setSource(filename);
@@ -282,8 +276,7 @@ StaticBitmap::StaticBitmap(Window* parent, const rect_t& rect,
const char* filename) :
Window(parent, rect)
{
setWindowFlag(NO_FOCUS);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setWindowFlag(NO_FOCUS | NO_CLICK);
setSource(filename);
}
@@ -329,9 +322,7 @@ StaticLZ4Image::StaticLZ4Image(Window* parent, coord_t x, coord_t y,
Window(parent, {x, y, lz4Bitmap->width, lz4Bitmap->height},
lv_canvas_create)
{
setWindowFlag(NO_FOCUS);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setWindowFlag(NO_FOCUS | NO_CLICK);
// Convert ARGB4444 to LV_IMG_CF_TRUE_COLOR_ALPHA
uint16_t w = lz4Bitmap->width;
@@ -359,12 +350,12 @@ StaticLZ4Image::StaticLZ4Image(Window* parent, coord_t x, coord_t y,
lv_canvas_set_buffer(lvobj, imgData, w, h, LV_IMG_CF_TRUE_COLOR_ALPHA);
}
void StaticLZ4Image::deleteLater(bool detach, bool trash)
void StaticLZ4Image::deleteLater()
{
if (!deleted()) {
if (imgData) lv_mem_free(imgData);
imgData = nullptr;
Window::deleteLater(detach, trash);
Window::deleteLater();
}
}
@@ -374,8 +365,9 @@ QRCode::QRCode(Window *parent, coord_t x, coord_t y, coord_t sz, std::string dat
LcdFlags color, LcdFlags bgColor) :
Window(parent, {x, y, sz, sz})
{
setWindowFlag(NO_CLICK);
qr = lv_qrcode_create(lvobj, sz, makeLvColor(color), makeLvColor(bgColor));
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
setData(data);
}
+2 -2
View File
@@ -126,7 +126,7 @@ class StaticIcon : public Window
StaticIcon(Window *parent, coord_t x, coord_t y, const char* filename,
LcdColorIndex color);
void deleteLater(bool detach = true, bool trash = true) override;
void deleteLater() override;
#if defined(DEBUG_WINDOWS)
std::string getName() const override { return "StaticIcon"; }
@@ -201,7 +201,7 @@ class StaticLZ4Image : public Window
protected:
uint8_t *imgData = nullptr;
void deleteLater(bool detach = true, bool trash = true) override;
void deleteLater() override;
};
//-----------------------------------------------------------------------------
+6 -6
View File
@@ -18,7 +18,9 @@
#include "table.h"
#include "debug.h"
#include "etx_lv_theme.h"
#include "keys.h"
// Table
const lv_style_const_prop_t table_cell_props[] = {
@@ -305,8 +307,6 @@ bool TableField::onLongPress()
return true;
}
extern void _assign_lv_group(lv_group_t* g);
void TableField::setAutoEdit()
{
if (autoedit) return;
@@ -316,7 +316,7 @@ void TableField::setAutoEdit()
oldGroup = lv_group_get_default();
group = lv_group_create();
lv_group_add_obj(group, lvobj);
_assign_lv_group(group);
assignLvGroup(group, true);
lv_group_set_editing(group, true);
@@ -329,16 +329,16 @@ void TableField::setAutoEdit()
});
}
void TableField::deleteLater(bool detach, bool trash)
void TableField::deleteLater()
{
if (!deleted()) {
if (autoedit) {
lv_group_del(group);
if (oldGroup)
_assign_lv_group(oldGroup);
assignLvGroup(oldGroup, true);
else
lv_group_set_default(nullptr);
}
Window::deleteLater(detach, trash);
Window::deleteLater();
}
}
+3 -3
View File
@@ -28,10 +28,10 @@ class TableField : public Window
#if defined(DEBUG_WINDOWS)
std::string getName() const override { return "Table"; }
#endif
void setRowCount(uint16_t rows);
uint16_t getRowCount() const;
void setColumnWidth(uint16_t col, coord_t w);
void select(uint16_t row, uint16_t col, bool force = false);
@@ -66,7 +66,7 @@ class TableField : public Window
void onEvent(event_t event) override;
bool onLongPress() override;
void deleteLater(bool detach = true, bool trash = true) override;
void deleteLater() override;
static void force_editing(lv_group_t* g) { lv_group_set_editing(g, true); }
};
+4 -4
View File
@@ -33,7 +33,7 @@ class TextArea : public FormField
TextArea(Window* parent, const rect_t& rect, char* value, uint8_t length) :
FormField(parent, rect, etx_textarea_create), value(value), length(length)
{
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
setWindowFlag(NO_FOCUS);
lv_textarea_set_max_length(lvobj, length);
lv_textarea_set_placeholder_text(lvobj, "---");
@@ -174,13 +174,13 @@ void TextEdit::openEdit()
void TextEdit::preview(bool edited, char* text, uint8_t length)
{
setWindowFlag(NO_FOCUS | NO_CLICK);
edit = new TextArea(this,
{-(PAD_MEDIUM + 2), -(PAD_BORDER * 2), width(), height()},
text, length);
edit->setWindowFlag(NO_CLICK);
lv_group_focus_obj(edit->getLvObj());
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
lv_obj_clear_flag(edit->getLvObj(), LV_OBJ_FLAG_CLICKABLE);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_add_state(edit->getLvObj(), LV_STATE_FOCUSED);
if (edited) lv_obj_add_state(edit->getLvObj(), LV_STATE_EDITED);
}
+8 -11
View File
@@ -20,12 +20,13 @@
#include "view_text.h"
#include "menu.h"
#include "button.h"
#include "edgetx.h"
#include "sdcard.h"
#include "etx_lv_theme.h"
#include "fullscreen_dialog.h"
#include "lib_file.h"
#include "menu.h"
#include "sdcard.h"
// Used on startup to block until checklist is closed.
static bool checkListOpen = false;
@@ -109,12 +110,10 @@ class TextViewer
{
if (openFile()) {
auto obj = window->getLvObj();
lv_obj_add_flag(
obj, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_WITH_ARROW |
LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_WITH_ARROW | LV_OBJ_FLAG_SCROLL_MOMENTUM);
etx_scrollbar(obj);
// prevents resetting the group's edit mode
lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
window->setWindowFlag(NO_FOCUS);
auto g = lv_group_get_default();
lb = lv_label_create(obj);
@@ -375,12 +374,10 @@ class ViewChecklistWindow : public Page, public TextViewer
{
if (openFile()) {
auto obj = window->getLvObj();
lv_obj_add_flag(
obj, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_WITH_ARROW |
LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_WITH_ARROW | LV_OBJ_FLAG_SCROLL_MOMENTUM);
etx_scrollbar(obj);
// prevents resetting the group's edit mode
lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
window->setWindowFlag(NO_FOCUS);
lv_obj_set_layout(obj, LV_LAYOUT_FLEX);
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
@@ -551,7 +548,7 @@ void readChecklist()
}
}
ModelNotesPage::ModelNotesPage(PageDef& pageDef) : PageGroupItem(pageDef, PAD_ZERO)
ModelNotesPage::ModelNotesPage(const PageDef& pageDef) : PageGroupItem(pageDef, PAD_ZERO)
{
}
+1 -1
View File
@@ -52,7 +52,7 @@ class ViewTextWindow : public Page
class ModelNotesPage : public PageGroupItem
{
public:
ModelNotesPage(PageDef& pageDef);
ModelNotesPage(const PageDef& pageDef);
void build(Window* window) override;
+148 -43
View File
@@ -19,13 +19,118 @@
#include "window.h"
#include "button.h"
#include "form.h"
#include "static.h"
#include "debug.h"
#include "etx_lv_theme.h"
#include "layer.h"
#include "form.h"
#include "keys.h"
#include "pagegroup.h"
#include "static.h"
//-----------------------------------------------------------------------------
class Layer
{
static std::list<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;
bool Window::_longPressed = false;
Window* Window::topWindow() { return Layer::back(); }
Window* Window::firstOpaque()
{
Window* w = Layer::walk([=](Window *w) mutable -> bool {
return w->hasWindowFlag(OPAQUE);
});
return w;
}
PageGroup* Window::pageGroup()
{
Window* w = Layer::walk([=](Window *w) mutable -> bool {
return w->isPageGroup();
});
return (PageGroup*)w;
}
//-----------------------------------------------------------------------------
const lv_obj_class_t window_base_class = {
.base_class = &lv_obj_class,
@@ -47,12 +152,14 @@ lv_obj_t *window_create(lv_obj_t *parent)
void Window::window_event_cb(lv_event_t *e)
{
Window *window = (Window *)lv_obj_get_user_data(lv_event_get_target(e));
if (window)
if (window)
window->eventHandler(e);
}
void Window::eventHandler(lv_event_t *e)
{
static bool _longPressed = false;
lv_obj_t *target = lv_event_get_target(e);
lv_event_code_t code = lv_event_get_code(e);
@@ -113,6 +220,8 @@ void Window::eventHandler(lv_event_t *e)
}
}
//-----------------------------------------------------------------------------
// Constructor to allow lvobj to be created separately - used by NumberEdit and
// TextEdit
Window::Window(const rect_t &rect) : rect(rect), parent(nullptr)
@@ -202,7 +311,7 @@ void Window::pushLayer(bool hideParent)
if (!layerCreated) {
parentHidden = hideParent;
layerCreated = true;
if (parentHidden) Layer::back()->hide();
if (parentHidden) Window::topWindow()->hide();
Layer::push(this);
}
}
@@ -211,12 +320,25 @@ void Window::popLayer()
{
if (layerCreated) {
Layer::pop(this);
if (parentHidden) Layer::back()->show();
if (parentHidden) Window::topWindow()->show();
layerCreated = false;
parentHidden = false;
}
}
void Window::assignLvGroup(lv_group_t* g, bool setDefault)
{
if (setDefault)
lv_group_set_default(g);
// associate it with all input devices
lv_indev_t* indev = lv_indev_get_next(NULL);
while (indev) {
lv_indev_set_group(indev, g);
indev = lv_indev_get_next(indev);
}
}
Window *Window::getFullScreenWindow()
{
if (width() == LCD_W && height() == LCD_H) return this;
@@ -229,8 +351,14 @@ void Window::setWindowFlag(WindowFlags flag)
windowFlags |= flag;
// honor the no focus flag of libopenui
if (this->windowFlags & NO_FOCUS)
if (windowFlags & NO_FOCUS)
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
if (windowFlags & NO_SCROLL)
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_SCROLLABLE);
if (windowFlags & NO_CLICK)
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
}
void Window::clearWindowFlag(WindowFlags flag) { windowFlags &= ~flag; }
@@ -250,23 +378,19 @@ void Window::attach(Window *newParent)
void Window::detach()
{
if (parent) {
parent->removeChild(this);
parent->children.remove(this);
parent = nullptr;
}
}
void Window::deleteLater(bool detach, bool trash)
void Window::deleteLater()
{
if (_deleted) return;
_deleted = true;
TRACE_WINDOWS("Delete %p %s", this, getWindowDebugString().c_str());
if (detach)
this->detach();
else
parent = nullptr;
detach();
deleteChildren();
popLayer();
@@ -274,8 +398,7 @@ void Window::deleteLater(bool detach, bool trash)
if (closeHandler)
closeHandler();
if (trash)
Window::trash.push_back(this);
Window::trash.push_back(this);
if (lvobj != nullptr) {
auto obj = lvobj;
@@ -295,13 +418,8 @@ void Window::clear()
void Window::deleteChildren()
{
// prevent LVGL refocus while mass-deleting
// inhibit_focus = true;
for (auto window : children) {
window->deleteLater(false);
}
// inhibit_focus = false;
children.clear();
while (!children.empty())
children.back()->deleteLater();
}
bool Window::hasFocus() const
@@ -325,19 +443,6 @@ void Window::padBottom(coord_t pad)
void Window::padAll(PaddingSize pad) { etx_padding(lvobj, pad, LV_PART_MAIN); }
void Window::padRow(coord_t pad) { lv_obj_set_style_pad_row(lvobj, pad, 0); }
void Window::padColumn(coord_t pad)
{
lv_obj_set_style_pad_column(lvobj, pad, 0);
}
void Window::bringToTop()
{
attach(parent); // does a detach + attach
if (lvobj && lv_obj_get_parent(lvobj)) lv_obj_move_foreground(lvobj);
}
void Window::checkEvents()
{
auto copy = children;
@@ -383,12 +488,6 @@ void Window::addChild(Window *window)
children.push_back(window);
}
void Window::removeChild(Window *window)
{
children.remove(window);
invalidate();
}
void Window::invalidate()
{
if (lvobj) lv_obj_invalidate(lvobj);
@@ -475,6 +574,8 @@ void Window::addCustomButton(coord_t x, coord_t y, std::function<void()> action)
}
#endif
//-----------------------------------------------------------------------------
void NavWindow::onEvent(event_t event)
{
switch (event) {
@@ -536,6 +637,8 @@ NavWindow::NavWindow(Window *parent, const rect_t &rect,
setWindowFlag(OPAQUE);
}
//-----------------------------------------------------------------------------
class SetupTextButton : public TextButton
{
public:
@@ -638,3 +741,5 @@ coord_t SetupLine::showLines(Window* parent, coord_t y, coord_t col2, PaddingSiz
return y;
}
//-----------------------------------------------------------------------------
+15 -21
View File
@@ -23,25 +23,25 @@
#include <string>
#include "definitions.h"
#include "LvglWrapper.h"
#include "bitmapbuffer.h"
#include "libopenui_defines.h"
#include "edgetx_helpers.h"
#include "etx_lv_theme.h"
class FlexGridLayout;
class FormLine;
class PageGroup;
typedef uint32_t WindowFlags;
typedef lv_obj_t *(*LvglCreate)(lv_obj_t *);
#if !defined(_GNUC_)
#undef OPAQUE
#endif
constexpr WindowFlags OPAQUE = 1u << 0u;
constexpr WindowFlags NO_FOCUS = 1u << 1u;
typedef lv_obj_t *(*LvglCreate)(lv_obj_t *);
class FlexGridLayout;
class FormLine;
constexpr WindowFlags NO_SCROLL = 1u << 2u;
constexpr WindowFlags NO_CLICK = 1u << 3u;
class Window
{
@@ -80,7 +80,7 @@ class Window
void setScrollHandler(ScrollHandler h) { scrollHandler = std::move(h); }
virtual void clear();
virtual void deleteLater(bool detach = true, bool trash = true);
virtual void deleteLater();
bool hasFocus() const;
@@ -124,15 +124,11 @@ class Window
}
coord_t left() const { return rect.x; }
coord_t right() const { return rect.x + rect.w; }
coord_t top() const { return rect.y; }
coord_t bottom() const { return rect.y + rect.h; }
coord_t width() const { return rect.w; }
coord_t height() const { return rect.h; }
rect_t getRect() const { return rect; }
@@ -143,9 +139,6 @@ class Window
void padBottom(coord_t pad);
void padAll(PaddingSize pad);
void padRow(coord_t pad);
void padColumn(coord_t pad);
virtual void onEvent(event_t event);
virtual void onClicked();
virtual void onCancel();
@@ -155,8 +148,6 @@ class Window
void invalidate();
void bringToTop();
virtual void checkEvents();
void attach(Window *window);
@@ -195,6 +186,11 @@ class Window
void pushLayer(bool hideParent = false);
void popLayer();
static Window* topWindow();
static Window* firstOpaque();
static PageGroup* pageGroup();
void assignLvGroup(lv_group_t* g, bool setDefault);
protected:
static std::list<Window *> trash;
@@ -211,7 +207,6 @@ class Window
bool noForcedScroll = false;
bool _deleted = false;
static bool _longPressed;
bool loaded = false;
bool layerCreated = false;
@@ -219,12 +214,11 @@ class Window
CloseHandler closeHandler;
FocusHandler focusHandler;
std::function<void(coord_t, coord_t)> scrollHandler;
ScrollHandler scrollHandler;
void deleteChildren();
virtual void addChild(Window *window);
void removeChild(Window *window);
void eventHandler(lv_event_t *e);
static void window_event_cb(lv_event_t *e);
+3 -7
View File
@@ -193,10 +193,8 @@ WidgetsContainer* LayoutFactory::createCustomScreen(
auto& screen = customScreens[customScreenIndex];
if (screen != nullptr) {
screen->deleteLater(true, false);
delete screen;
}
if (screen != nullptr)
screen->deleteLater();
auto viewMain = ViewMain::instance();
screen = create(viewMain, customScreenIndex);
@@ -261,7 +259,7 @@ inline LayoutOptionValueEnum layoutValueEnumFromType(LayoutOption::Type type)
case LayoutOption::Color:
return LOV_Color;
default:
return LOV_None;
}
@@ -410,8 +408,6 @@ Widget* Layout::createWidget(unsigned int index,
}
widgets[index] = widget;
if (widget) widget->attach(this);
return widget;
}
@@ -24,8 +24,12 @@
#include <algorithm>
#include "color_picker.h"
#include "layout.h"
#include "edgetx.h"
#include "getset_helpers.h"
#include "layout.h"
#include "menu.h"
#include "static.h"
#include "toggleswitch.h"
#include "topbar.h"
#include "view_main.h"
#include "widget_settings.h"
@@ -112,7 +116,7 @@ static const lv_coord_t line_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1),
static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT,
LV_GRID_TEMPLATE_LAST};
ScreenSetupPage::ScreenSetupPage(unsigned index, PageDef& pageDef) :
ScreenSetupPage::ScreenSetupPage(unsigned index, const PageDef& pageDef) :
PageGroupItem(pageDef)
{
update(index + QuickMenu::pageIndex(QM_UI_SCREEN1));
@@ -281,8 +285,41 @@ void ScreenSetupPage::buildLayoutOptions()
}
}
void ScreenSetupPage::addScreen()
{
int newIdx = 1;
for (; newIdx < MAX_CUSTOM_SCREENS; newIdx += 1)
if (customScreens[newIdx] == nullptr)
break;
TRACE("Add screen: add screen: newIdx = %d", newIdx);
auto& screen = customScreens[newIdx];
const LayoutFactory* factory = defaultLayout;
if (factory) {
TRACE("Add screen: add screen: factory = %p", factory);
auto viewMain = ViewMain::instance();
screen = factory->create(viewMain, newIdx);
viewMain->addMainView(screen, newIdx);
g_model.setScreenLayoutId(newIdx, factory->getId());
TRACE("Add screen: add screen: LayoutId = %s", g_model.getScreenLayoutId(newIdx));
#if VERSION_MAJOR == 2
ScreenAddPage::ScreenAddPage(PageDef& pageDef) : PageGroupItem(pageDef)
Window::pageGroup()->deleteLater();
#endif
QuickMenu::openPage((QMPage)(QM_UI_SCREEN1 + newIdx));
storageDirty(EE_MODEL);
} else {
TRACE("Add screen: factory is NULL");
}
}
#if VERSION_MAJOR == 2
ScreenAddPage::ScreenAddPage(const PageDef& pageDef) : PageGroupItem(pageDef)
{
}
@@ -293,33 +330,7 @@ void ScreenAddPage::build(Window* window)
new TextButton(window,
rect_t{LCD_W / 2 - ADD_TXT_W / 2, window->height() / 2 - EdgeTxStyles::UI_ELEMENT_HEIGHT, ADD_TXT_W, EdgeTxStyles::UI_ELEMENT_HEIGHT},
s, [this]() -> uint8_t {
int newIdx = 1;
for (; newIdx < MAX_CUSTOM_SCREENS; newIdx += 1)
if (customScreens[newIdx] == nullptr)
break;
TRACE("Add screen: add screen: newIdx = %d", newIdx);
auto& screen = customScreens[newIdx];
const LayoutFactory* factory = defaultLayout;
if (factory) {
TRACE("Add screen: add screen: factory = %p", factory);
auto viewMain = ViewMain::instance();
screen = factory->create(viewMain, newIdx);
viewMain->addMainView(screen, newIdx);
g_model.setScreenLayoutId(newIdx, factory->getId());
TRACE("Add screen: add screen: LayoutId = %s", g_model.getScreenLayoutId(newIdx));
Layer::getPageGroup()->deleteLater();
QuickMenu::openPage((QMPage)(QM_UI_SCREEN1 + newIdx));
storageDirty(EE_MODEL);
} else {
TRACE("Add screen: factory is NULL");
}
ScreenSetupPage::addScreen();
return 0;
});
}
@@ -29,7 +29,7 @@
class ScreenAddPage : public PageGroupItem
{
public:
ScreenAddPage(PageDef& pageDef);
ScreenAddPage(const PageDef& pageDef);
void build(Window* window) override;
@@ -41,12 +41,14 @@ class ScreenAddPage : public PageGroupItem
class ScreenSetupPage : public PageGroupItem
{
public:
ScreenSetupPage(unsigned customScreenIndex, PageDef& pageDef);
ScreenSetupPage(unsigned customScreenIndex, const PageDef& pageDef);
void build(Window* form) override;
void update(uint8_t index) override;
static void addScreen();
protected:
unsigned customScreenIndex;
Window* layoutOptions = nullptr;
@@ -21,6 +21,7 @@
#include "screen_user_interface.h"
#include "choice.h"
#include "file_preview.h"
#include "theme_manager.h"
#include "view_main.h"
@@ -43,7 +44,7 @@ static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT,
#endif
ScreenUserInterfacePage::ScreenUserInterfacePage(PageDef& pageDef) :
ScreenUserInterfacePage::ScreenUserInterfacePage(const PageDef& pageDef) :
PageGroupItem(pageDef, PAD_TINY)
{
}
@@ -30,7 +30,7 @@ class Choice;
class ScreenUserInterfacePage : public PageGroupItem
{
public:
ScreenUserInterfacePage(PageDef& pageDef);
ScreenUserInterfacePage(const PageDef& pageDef);
void build(Window* window) override;
+4 -5
View File
@@ -21,7 +21,6 @@
#include "topbar.h"
#include "layer.h"
#include "edgetx.h"
#include "storage/storage.h"
#include "etx_lv_theme.h"
@@ -104,10 +103,12 @@ void SetupTopBarWidgetsPage::onClicked()
void SetupTopBarWidgetsPage::onCancel() { deleteLater(); }
void SetupTopBarWidgetsPage::deleteLater(bool detach, bool trash)
void SetupTopBarWidgetsPage::deleteLater()
{
if (_deleted) return;
// and continue async deletion...
Window::deleteLater(detach, trash);
Window::deleteLater();
// restore screen setting tab on top
QuickMenu::openPage(QM_UI_SETUP);
@@ -270,8 +271,6 @@ Widget* TopBar::createWidget(unsigned int index,
}
widgets[index] = widget;
if (widget) widget->attach(this);
return widget;
}
+1 -1
View File
@@ -39,7 +39,7 @@ class SetupTopBarWidgetsPage : public Window
void onClicked() override;
void onCancel() override;
void onEvent(event_t event) override;
void deleteLater(bool detach = true, bool trash = true) override;
void deleteLater() override;
};
//-----------------------------------------------------------------------------
+1 -1
View File
@@ -203,7 +203,7 @@ void MainViewTrim::checkEvents()
int newValue = getTrimValue(mixerCurrentFlightMode, inputMappingConvertMode(idx));
bool update = false;
if (extendedTrims != g_model.extendedTrims) {
update = true;
setRange();
+2 -2
View File
@@ -30,7 +30,7 @@ class MainViewTrim : public Window
public:
MainViewTrim(Window* parent, const rect_t& rect, uint8_t idx,
bool isVertical);
void setVisible(bool visible);
protected:
@@ -47,7 +47,7 @@ class MainViewTrim : public Window
void setRange();
void setPos();
bool setDisplayState();
void checkEvents() override;
@@ -22,7 +22,6 @@
#include "view_channels.h"
#include "channel_bar.h"
#include "libopenui.h"
#include "model_select.h"
#include "edgetx.h"
#if VERSION_MAJOR == 2
@@ -126,8 +125,6 @@ class ChannelsViewPage : public PageGroupItem
ChannelsViewMenu::ChannelsViewMenu() :
TabsGroup(ICON_MONITOR, STR_MAIN_MENU_CHANNEL_MONITOR)
{
QuickMenu::setCurrentPage(QM_TOOLS_CHAN_MON);
#if PORTRAIT
int cols = 1;
int rows = 8;
@@ -21,10 +21,11 @@
#include "view_logical_switches.h"
#include "button.h"
#include "edgetx.h"
#include "switches.h"
#include "etx_lv_theme.h"
#include "quick_menu.h"
#include "switches.h"
#if PORTRAIT
@@ -241,7 +242,7 @@ LogicalSwitchesViewPage::LogicalSwitchesViewPage() :
setIcon(ICON_MONITOR_LOGICAL_SWITCHES);
}
LogicalSwitchesViewPage::LogicalSwitchesViewPage(PageDef& pageDef) :
LogicalSwitchesViewPage::LogicalSwitchesViewPage(const PageDef& pageDef) :
PageGroupItem(pageDef)
{
}
@@ -29,7 +29,7 @@ class LogicalSwitchesViewPage : public PageGroupItem
{
public:
LogicalSwitchesViewPage();
LogicalSwitchesViewPage(PageDef& pageDef);
LogicalSwitchesViewPage(const PageDef& pageDef);
static LAYOUT_ORIENTATION_SCALED(FOOTER_HEIGHT, 20, 40)
static LAYOUT_ORIENTATION(BTN_MATRIX_COL, 8, 6)
+16 -13
View File
@@ -21,12 +21,13 @@
#include "view_main.h"
#include "model_select.h"
#include "edgetx.h"
#include "topbar.h"
#include "mainwindow.h"
#include "model_select.h"
#include "quick_menu.h"
#include "view_channels.h"
#include "screen_setup.h"
#include "topbar.h"
#include "view_channels.h"
#include "widget.h"
static void tile_view_deleted_cb(lv_event_t* e)
@@ -78,7 +79,8 @@ ViewMain* ViewMain::_instance = nullptr;
ViewMain* ViewMain::instance()
{
if (!_instance) _instance = new ViewMain();
if (!_instance)
_instance = new ViewMain();
return _instance;
}
@@ -106,9 +108,11 @@ ViewMain::ViewMain() :
ViewMain::~ViewMain() { _instance = nullptr; }
void ViewMain::deleteLater(bool detach, bool trash)
void ViewMain::deleteLater()
{
NavWindow::deleteLater(detach, trash);
if (_deleted) return;
NavWindow::deleteLater();
QuickMenu::shutdownQuickMenu();
}
@@ -126,7 +130,7 @@ void ViewMain::addMainView(WidgetsContainer* view, uint32_t viewId)
lv_obj_add_event_cb(tile, tile_view_deleted_cb, LV_EVENT_CHILD_DELETED,
user_data);
view->show();
view->show();
}
void ViewMain::setTopbarVisible(float visible) { topbar->setVisible(visible); }
@@ -244,10 +248,9 @@ void ViewMain::doKeyShortcut(event_t event)
{
QMPage pg = g_eeGeneral.getKeyShortcut(event);
if (pg == QM_OPEN_QUICK_MENU) {
if (!viewMainMenu) openMenu();
if (!QuickMenu::isOpen()) openMenu();
} else {
if (viewMainMenu)
viewMainMenu->closeMenu();
QuickMenu::closeQuickMenu();
QuickMenu::openPage(pg);
}
}
@@ -260,14 +263,14 @@ void ViewMain::onLongPressTELE() { doKeyShortcut(EVT_KEY_LONG(KEY_TELE)); }
void ViewMain::onPressPGUP()
{
if (!widget_select) {
if (viewMainMenu) viewMainMenu->closeMenu();
QuickMenu::closeQuickMenu();
previousMainView();
}
}
void ViewMain::onPressPGDN()
{
if (!widget_select) {
if (viewMainMenu) viewMainMenu->closeMenu();
QuickMenu::closeQuickMenu();
nextMainView();
}
}
@@ -332,7 +335,7 @@ bool ViewMain::enableWidgetSelect(bool enable)
void ViewMain::openMenu()
{
viewMainMenu = QuickMenu::openQuickMenu([=]() { viewMainMenu = nullptr; });
QuickMenu::openQuickMenu();
}
void ViewMain::ws_timer(lv_timer_t* t)
+1 -3
View File
@@ -24,7 +24,6 @@
#include "topbar.h"
#include "window.h"
class QuickMenu;
class TopBar;
class ViewMain : public NavWindow
@@ -85,9 +84,8 @@ class ViewMain : public NavWindow
TopBar* topbar = nullptr;
bool widget_select = false;
lv_timer_t* widget_select_timer = nullptr;
QuickMenu* viewMainMenu = nullptr;
void deleteLater(bool detach = true, bool trash = true) override;
void deleteLater() override;
// Set topbar visibility [0.0 -> 1.0]
void setTopbarVisible(float visible);
@@ -20,14 +20,16 @@
*/
#include "view_statistics.h"
#include "os/task.h"
#include "button.h"
#include "edgetx.h"
#include "lua/lua_states.h"
#include "mixer_scheduler.h"
#include "os/task.h"
#include "quick_menu.h"
#include "static.h"
#include "tasks.h"
#include "tasks/mixer_task.h"
#include "mixer_scheduler.h"
#include "lua/lua_states.h"
#include "quick_menu.h"
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1),
LV_GRID_FR(1), LV_GRID_FR(1),
@@ -129,7 +131,7 @@ class ThrottleCurveWindow : public Window
int16_t graphSize = 0;
};
StatisticsViewPage::StatisticsViewPage(PageDef& pageDef) :
StatisticsViewPage::StatisticsViewPage(const PageDef& pageDef) :
PageGroupItem(pageDef)
{
}
@@ -207,7 +209,7 @@ void StatisticsViewPage::build(Window* window)
LV_GRID_ALIGN_START, 0, 1);
}
DebugViewPage::DebugViewPage(PageDef& pageDef) :
DebugViewPage::DebugViewPage(const PageDef& pageDef) :
PageGroupItem(pageDef)
{
}
@@ -26,7 +26,7 @@
class StatisticsViewPage : public PageGroupItem
{
public:
StatisticsViewPage(PageDef& pageDef);
StatisticsViewPage(const PageDef& pageDef);
protected:
void build(Window* window) override;
@@ -35,7 +35,7 @@ class StatisticsViewPage : public PageGroupItem
class DebugViewPage : public PageGroupItem
{
public:
DebugViewPage(PageDef& pageDef);
DebugViewPage(const PageDef& pageDef);
protected:
void build(Window* window) override;
+3 -6
View File
@@ -23,6 +23,7 @@
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "menu.h"
#include "view_main.h"
#include "widget_settings.h"
@@ -50,7 +51,7 @@ inline WidgetOptionValueEnum widgetValueEnumFromType(WidgetOption::Type type)
case WidgetOption::Color:
return WOV_Color;
default:
return WOV_Unsigned;
}
@@ -157,8 +158,7 @@ Widget::Widget(const WidgetFactory* factory, Window* parent, const rect_t& rect,
factory(factory),
screenNum(screenNum), zoneNum(zoneNum)
{
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
setWindowFlag(NO_FOCUS | NO_SCROLL);
if (parent->isTopBar()) fsAllowed = false;
@@ -239,8 +239,6 @@ void Widget::setFullscreen(bool enable)
updateZoneRect(parent->getRect(), false);
setRect(parent->getRect());
bringToTop();
if (!lv_obj_get_group(lvobj))
lv_group_add_obj(lv_group_get_default(), lvobj);
@@ -297,7 +295,6 @@ void Widget::enableFocus(bool enable)
setFocusHandler([=](bool hasFocus) {
if (hasFocus) {
bringToTop();
lv_obj_clear_flag(focusBorder, LV_OBJ_FLAG_HIDDEN);
} else {
lv_obj_add_flag(focusBorder, LV_OBJ_FLAG_HIDDEN);
@@ -23,11 +23,15 @@
#include "color_picker.h"
#include "edgetx.h"
#include "sourcechoice.h"
#include "switchchoice.h"
#include "view_main.h"
#include "filechoice.h"
#include "numberedit.h"
#include "slider.h"
#include "sourcechoice.h"
#include "static.h"
#include "switchchoice.h"
#include "textedit.h"
#include "toggleswitch.h"
#include "view_main.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -29,14 +29,14 @@ WidgetsContainer::WidgetsContainer(Window* parent, const rect_t& rect, uint8_t z
for (int i = 0; i < zoneCount; i += 1) widgets[i] = nullptr;
}
void WidgetsContainer::deleteLater(bool detach, bool trash)
void WidgetsContainer::deleteLater()
{
if (deleted()) return;
for (int i = 0; i < zoneCount; i += 1)
if (widgets[i]) widgets[i]->deleteLater();
if (widgets) delete[] widgets;
widgets = nullptr;
Window::deleteLater(detach, trash);
Window::deleteLater();
}
Widget* WidgetsContainer::getWidget(unsigned int index)
@@ -47,7 +47,7 @@ class WidgetsContainer: public Window
virtual bool isAppMode() const { return false; }
bool isWidgetsContainer() override { return true; }
void deleteLater(bool detach = true, bool trash = true) override;
void deleteLater() override;
protected:
uint8_t zoneCount = 0;
@@ -21,7 +21,6 @@
#include "widgets_setup.h"
#include "layer.h"
#include "menu.h"
#include "myeeprom.h"
#include "storage/storage.h"
@@ -82,7 +81,6 @@ SetupWidgetsPageSlot::SetupWidgetsPageSlot(Window* parent, const rect_t& rect,
void SetupWidgetsPageSlot::setFocusState()
{
if (hasFocus()) {
bringToTop();
lv_obj_add_flag(border, LV_OBJ_FLAG_HIDDEN);
} else {
lv_obj_clear_flag(border, LV_OBJ_FLAG_HIDDEN);
@@ -158,9 +156,11 @@ void SetupWidgetsPage::onCancel()
QuickMenu::openPage((QMPage)(QM_UI_SCREEN1 + customScreenIdx));
}
void SetupWidgetsPage::deleteLater(bool detach, bool trash)
void SetupWidgetsPage::deleteLater()
{
Window::deleteLater(detach, trash);
if (_deleted) return;
Window::deleteLater();
// and continue async deletion...
auto screen = customScreens[customScreenIdx];
@@ -46,7 +46,7 @@ class SetupWidgetsPage : public Window
unsigned savedView = 0;
void onEvent(event_t event) override;
void deleteLater(bool detach = true, bool trash = true) override;
void deleteLater() override;
};
class SetupWidgetsPageSlot : public ButtonBase
+11 -17
View File
@@ -21,8 +21,12 @@
#include "curveedit.h"
#include "edgetx.h" // TODO for applyCustomCurve
#include "choice.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "getset_helpers.h"
#include "numberedit.h"
#include "textedit.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -31,15 +35,14 @@ static const lv_coord_t default_col_dsc[] = {LV_GRID_CONTENT,
static const lv_coord_t default_row_dsc[] = {LV_GRID_CONTENT,
LV_GRID_TEMPLATE_LAST};
class CurveEdit : public Window
class CurveEdit : public Curve
{
public:
CurveEdit(Window* parent, const rect_t& rect, uint8_t index) :
Window(parent, rect),
preview(
this, {0, 0, width(), height()},
Curve(parent, rect,
[=](int x) -> int { return applyCustomCurve(x, index); },
[=]() -> int { return getValue(currentSource); }),
[=]() -> int { return getValue(currentSource); }
),
index(index),
current(0)
{
@@ -58,28 +61,19 @@ class CurveEdit : public Window
void updatePreview()
{
preview.clearPoints();
clearPoints();
CurveHeader& curve = g_model.curves[index];
for (uint8_t i = 0; i < 5 + curve.points; i++) {
preview.addPoint(getPoint(index, i));
addPoint(getPoint(index, i));
}
}
protected:
Curve preview;
uint8_t index;
uint8_t current;
mixsrc_t currentSource = 0;
bool lockSource = false;
void deleteLater(bool detach = true, bool trash = true) override
{
if (!_deleted) {
preview.deleteLater(true, false);
Window::deleteLater(detach, trash);
}
}
void checkEvents(void) override
{
if (!lockSource) {
@@ -23,11 +23,15 @@
#include "function_switches.h"
#include "choice.h"
#include "color_picker.h"
#include "edgetx.h"
#include "getset_helpers.h"
#include "hal/rgbleds.h"
#include "strhelpers.h"
#include "switches.h"
#include "color_picker.h"
#include "textedit.h"
#include "toggleswitch.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
+6 -4
View File
@@ -23,13 +23,15 @@
#include "curve_param.h"
#include "curveedit.h"
#include "gvar_numberedit.h"
#include "source_numberedit.h"
#include "input_source.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "switchchoice.h"
#include "fm_matrix.h"
#include "getset_helpers.h"
#include "gvar_numberedit.h"
#include "input_source.h"
#include "source_numberedit.h"
#include "switchchoice.h"
#include "textedit.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
+8 -6
View File
@@ -22,17 +22,19 @@
#include "mixer_edit.h"
#include "channel_bar.h"
#include "gvar_numberedit.h"
#include "source_numberedit.h"
#include "curve_param.h"
#include "mixer_edit_adv.h"
#include "mixes.h"
#include "curveedit.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "getset_helpers.h"
#include "gvar_numberedit.h"
#include "mixer_edit_adv.h"
#include "mixes.h"
#include "pagegroup.h"
#include "source_numberedit.h"
#include "sourcechoice.h"
#include "switchchoice.h"
#include "curveedit.h"
#include "pagegroup.h"
#include "textedit.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -21,11 +21,14 @@
#include "mixer_edit_adv.h"
#include "fm_matrix.h"
#include "mixes.h"
#include "numberedit.h"
#include "choice.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "fm_matrix.h"
#include "getset_helpers.h"
#include "mixes.h"
#include "numberedit.h"
#include "toggleswitch.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -21,8 +21,10 @@
#include "model_curves.h"
#include "button.h"
#include "curveedit.h"
#include "edgetx.h"
#include "menu.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -41,7 +43,7 @@ class CurveButton : public Button
s = strAppend(s, ":");
strAppend(s, g_model.curves[index].name, LEN_CURVE_NAME);
}
title = new StaticText(this, {PAD_SMALL, -1, width() - PAD_MEDIUM * 2, EdgeTxStyles::STD_FONT_HEIGHT}, buf,
title = new StaticText(this, {PAD_SMALL, -1, width() - PAD_MEDIUM * 2, EdgeTxStyles::STD_FONT_HEIGHT}, buf,
COLOR_THEME_SECONDARY1_INDEX, CENTERED | FONT(BOLD));
etx_txt_color(title->getLvObj(), COLOR_THEME_PRIMARY2_INDEX,
LV_PART_MAIN | LV_STATE_USER_1);
@@ -67,14 +69,14 @@ class CurveButton : public Button
CurveHeader &curve = g_model.curves[index];
snprintf(buf, 32, "%s %d %s", STR_CURVE_TYPES[curve.type], 5 + curve.points,
STR_PTS);
new StaticText(this, {0, height() - EdgeTxStyles::STD_FONT_HEIGHT - PAD_MEDIUM, LV_PCT(100), EdgeTxStyles::STD_FONT_HEIGHT}, buf,
new StaticText(this, {0, height() - EdgeTxStyles::STD_FONT_HEIGHT - PAD_MEDIUM, LV_PCT(100), EdgeTxStyles::STD_FONT_HEIGHT}, buf,
COLOR_THEME_SECONDARY1_INDEX, CENTERED | FONT(BOLD));
}
void update() { preview->update(); }
static LAYOUT_VAL_SCALED(INFO_H, 27)
static constexpr coord_t CURVE_BTN_W = (LCD_W - PAD_LARGE * (ModelCurvesPage::PER_ROW + 1)) / ModelCurvesPage::PER_ROW;
static constexpr coord_t CURVE_BTN_W = (LCD_W - PAD_LARGE * (ModelCurvesPage::PER_ROW + 1)) / ModelCurvesPage::PER_ROW;
static constexpr coord_t CURVE_BTH_H = CURVE_BTN_W + EdgeTxStyles::STD_FONT_HEIGHT * 2;
protected:
@@ -109,7 +111,7 @@ void initPoints(const CurveHeader &curve, int8_t *points)
}
}
ModelCurvesPage::ModelCurvesPage(PageDef& pageDef) : PageGroupItem(pageDef)
ModelCurvesPage::ModelCurvesPage(const PageDef& pageDef) : PageGroupItem(pageDef)
{
}
+1 -1
View File
@@ -27,7 +27,7 @@
class ModelCurvesPage : public PageGroupItem
{
public:
ModelCurvesPage(PageDef& pageDef);
ModelCurvesPage(const PageDef& pageDef);
static void pushEditCurve(int index, std::function<void(void)> refreshView, mixsrc_t source);
@@ -21,11 +21,15 @@
#include "model_flightmodes.h"
#include "list_line_button.h"
#include "button.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "getset_helpers.h"
#include "list_line_button.h"
#include "numberedit.h"
#include "page.h"
#include "switchchoice.h"
#include "etx_lv_theme.h"
#include "textedit.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -204,7 +208,6 @@ class FlightModeBtn : public ListLineButton
FlightModeBtn(Window* parent, int index) : ListLineButton(parent, index)
{
padAll(PAD_ZERO);
padColumn(PAD_ZERO);
setHeight(BTN_H);
delayLoad();
@@ -239,7 +242,7 @@ class FlightModeBtn : public ListLineButton
fmFadeOut = etx_create(&fm_fade_class, lvobj);
lv_obj_set_pos(fmFadeOut, FADE_X + FADE_W + PAD_TINY, FADE_Y);
lv_obj_update_layout(lvobj);
lv_obj_enable_style_refresh(true);
lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY);
@@ -462,7 +465,7 @@ const lv_obj_class_t FlightModeBtn::fm_trim_value_class = {
.instance_size = sizeof(lv_label_t),
};
ModelFlightModesPage::ModelFlightModesPage(PageDef& pageDef) :
ModelFlightModesPage::ModelFlightModesPage(const PageDef& pageDef) :
PageGroupItem(pageDef)
{
}
@@ -24,10 +24,12 @@
#include "edgetx.h"
#include "pagegroup.h"
class TextButton;
class ModelFlightModesPage : public PageGroupItem
{
public:
ModelFlightModesPage(PageDef& pageDef);
ModelFlightModesPage(const PageDef& pageDef);
void build(Window* window) override;
+10 -5
View File
@@ -21,11 +21,16 @@
#include "model_gvars.h"
#include "list_line_button.h"
#include "numberedit.h"
#include "choice.h"
#include "edgetx.h"
#include "page.h"
#include "etx_lv_theme.h"
#include "getset_helpers.h"
#include "list_line_button.h"
#include "menu.h"
#include "numberedit.h"
#include "page.h"
#include "textedit.h"
#include "toggleswitch.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -135,7 +140,7 @@ class GVarButton : public ListLineButton
}
lv_obj_update_layout(lvobj);
lv_obj_enable_style_refresh(true);
lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY);
}
@@ -507,7 +512,7 @@ class GVarEditWindow : public Page
}
};
ModelGVarsPage::ModelGVarsPage(PageDef& pageDef) :
ModelGVarsPage::ModelGVarsPage(const PageDef& pageDef) :
PageGroupItem(pageDef)
{
}
+1 -1
View File
@@ -27,7 +27,7 @@
class ModelGVarsPage : public PageGroupItem
{
public:
ModelGVarsPage(PageDef& pageDef);
ModelGVarsPage(const PageDef& pageDef);
void cleanup() override;
@@ -20,7 +20,10 @@
*/
#include "model_heli.h"
#include "edgetx.h"
#include "getset_helpers.h"
#include "numberedit.h"
#include "sourcechoice.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -23,9 +23,11 @@
#include <algorithm>
#include "dialog.h"
#include "edgetx.h"
#include "hal/adc_driver.h"
#include "input_edit.h"
#include "edgetx.h"
#include "menu.h"
#include "tasks/mixer_task.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -195,7 +197,7 @@ class InputGroup : public InputMixGroupBase
}
};
ModelInputsPage::ModelInputsPage(PageDef& pageDef) : InputMixPageBase(pageDef)
ModelInputsPage::ModelInputsPage(const PageDef& pageDef) : InputMixPageBase(pageDef)
{
}
+2 -2
View File
@@ -27,13 +27,13 @@
class ModelInputsPage : public InputMixPageBase
{
public:
ModelInputsPage(PageDef& pageDef);
ModelInputsPage(const PageDef& pageDef);
void build(Window *window) override;
protected:
InputMixGroupBase* getGroupByIndex(uint8_t index) override;
void addLineButton(uint8_t index) override;
InputMixGroupBase* createGroup(Window* form, mixsrc_t src) override;
InputMixButtonBase* createLineButton(InputMixGroupBase *group, uint8_t index) override;
@@ -21,13 +21,17 @@
#include "model_logical_switches.h"
#include "list_line_button.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "getset_helpers.h"
#include "list_line_button.h"
#include "menu.h"
#include "numberedit.h"
#include "page.h"
#include "sourcechoice.h"
#include "switchchoice.h"
#include "switches.h"
#include "etx_lv_theme.h"
#include "toggleswitch.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -522,7 +526,7 @@ class LogicalSwitchButton : public ListLineButton
lv_obj_t* lsDelay = nullptr;
};
ModelLogicalSwitchesPage::ModelLogicalSwitchesPage(PageDef& pageDef) :
ModelLogicalSwitchesPage::ModelLogicalSwitchesPage(const PageDef& pageDef) :
PageGroupItem(pageDef)
{
}

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