chore(color): Libopenui refactor (#3614)

* Refactor object creation logic.
Remove unused LVGL features.

* Remove unused files.
Fix height for widgets.

* Rename 'OpenTxTheme' class to 'EdgeTxTheme'.
Cleanup commented out code.
Cleanup unused code from 'etx_lv_theme.cpp'.

* More cleanup.

* Move more style code to etx_lv_theme.cpp

* Update license

* Make default button height match other controls.

* Fix curve edit layout.

* Fix layouts.

* FormWindow and FormGroup provided identical functionality - rename FormGroup to FormWindow and remove duplicate.

* Simplify menu icon handling.
Remove unused 'flysky.cpp' file.

* Fix window size change.

* Simplify page header code.
Fix statistics view page.

* Remove unused file.
Replace redundant 'Subtitle' class with a macro.
Fix compiler warnings.

* Fix compiler warning in LvglWrapper.cpp.
Remove unused code in static.h.
Simplify about page.

* Rename ICON_OPENTX to ICON_EDGETX.

* Fix github build error.

* Fix github build error (attempt 2).

* Move ButtonMatrix styling to etx_lv_theme.cpp.

* Scroll bar consistency.

* Use styles for ButtonMatrix text color.

* Use 'active' color for selected USB advanced setup buttons. Move error message to bottom of page.

* Create style for popup window title bar.
Simplify advanced USB setup code.
Remove unused libopenui/carousel.* files.

* Add style for modal popup content.

* Remove unused BUTTON_BACKGROUND flag.

* Replace GridLayout with FormWindow. Remove unused gridlayout.h file.

* Fix rebase.

* Merge ChoiceEx class into Choice class code.
Remove unused CurveKeyboard.

* Use LVGL bar for progress indicator.
Update only style colors when theme changes (don't recreate all style settings).

* Move ProgressDialog class to dlalog.h/dialog.cpp files.

* Simplify trim and slider code in main view.
Simplify the hardware inputs code.
Fix dialog size.
Remove unused code in layout factory.

* Cleanup unused code.

* Add style for FormWindow class.
Merge BaseNumberEdit class into NumberEdit class and remove BaseNumberEdit.
Remove more unused files.
Cleanup libopenui_config.h files.

* Re-organise libopenui include files to fix build error.

* Fix build error.

* Add missed styles to etx_lv_theme.cpp.
Delete commented out #includes.
More cleaning up of libopenui_xxx.h files and dependencies.
Re-enable LVGL CHECKBOX feature.

* Merge libopenui_helpers.h into opentx_helpers.h file.

* Fix firmware build.

* Use object constructors for LVGL object creation as suggested by gagarinlg.
Add style for number edit text alignment.
Fix background color for focussed control.

* Move color related stuff from libopenui_defines.h to colors.h.
Remove need for libopenui_depends.h file.

* Merge libopenui_types.h content into opentx_types.h file.

* Rename CheckBox class to ToggleSwitch.

* Restore code to update flight mode text color when theme changes.

* Cleanup some more unused code.

* Remove redundant theme.h file.

* Fix rebase.

* Fix button matrix style.

* Fix rebase

* Fix rebase

* Ensure correct initialisation of Choice object.

* Fix rebase.

* Make the slider control bigger to make touch activation easier.

* Fix build error.

* Fix slider logic and cleanup code.

* Use ACTIVE theme color for inputs, mixes, LS, GV and SF.

* Improved border width consistency and focussed state consistency.

* Remove duplicate copy of the default theme colors.
This commit is contained in:
philmoz
2023-08-04 11:04:54 +10:00
committed by GitHub
parent c0df9e9c44
commit 69338ab0ab
231 changed files with 2178 additions and 5921 deletions
+2
View File
@@ -559,6 +559,8 @@ void audioTask(void * pdata);
#define AUDIO_ERROR_MESSAGE(e) audioEvent(e) #define AUDIO_ERROR_MESSAGE(e) audioEvent(e)
#define AUDIO_TIMER_MINUTE(t) playDuration(t, 0, 0) #define AUDIO_TIMER_MINUTE(t) playDuration(t, 0, 0)
void onKeyError();
void audioKeyPress(); void audioKeyPress();
void audioKeyError(); void audioKeyError();
void audioTrimPress(int value); void audioTrimPress(int value);
+1 -1
View File
@@ -834,7 +834,7 @@ PACK(struct TrainerData {
#define THEME_NAME_LEN 8 #define THEME_NAME_LEN 8
#define THEME_DATA \ #define THEME_DATA \
NOBACKUP(char themeName[THEME_NAME_LEN]); \ NOBACKUP(char themeName[THEME_NAME_LEN]); \
NOBACKUP(OpenTxTheme::PersistentData themeData); NOBACKUP(EdgeTxTheme::PersistentData themeData);
#else #else
#define THEME_DATA #define THEME_DATA
#endif #endif
-4
View File
@@ -27,10 +27,6 @@
#include "opentx_types.h" #include "opentx_types.h"
#include "board.h" #include "board.h"
typedef uint32_t LcdFlags;
typedef uint8_t pixel_t;
typedef int coord_t;
#define BOX_WIDTH 23 #define BOX_WIDTH 23
#define CENTER #define CENTER
#define CENTER_OFS 0 #define CENTER_OFS 0
-4
View File
@@ -27,10 +27,6 @@
#include "opentx_types.h" #include "opentx_types.h"
#include "board.h" #include "board.h"
typedef uint32_t LcdFlags;
typedef uint8_t pixel_t;
typedef int coord_t;
#define BOX_WIDTH 31 #define BOX_WIDTH 31
#define CENTER "\015" #define CENTER "\015"
#define CENTER_OFS (7*FW-FW/2) #define CENTER_OFS (7*FW-FW/2)
-6
View File
@@ -216,12 +216,6 @@ add_gui_src(input_mix_button.cpp)
add_gui_src(channel_bar.cpp) add_gui_src(channel_bar.cpp)
add_gui_src(list_line_button.cpp) add_gui_src(list_line_button.cpp)
add_gui_src(lvgl_widgets/input_mix_line.c)
add_gui_src(lvgl_widgets/input_mix_group.c)
if(HARDWARE_TOUCH)
add_gui_src(keyboard_curve.cpp)
endif()
if(USBJ_EX) if(USBJ_EX)
add_gui_src(model_usbjoystick.cpp) add_gui_src(model_usbjoystick.cpp)
+1 -4
View File
@@ -24,7 +24,6 @@
#include "LvglWrapper.h" #include "LvglWrapper.h"
#include "themes/etx_lv_theme.h" #include "themes/etx_lv_theme.h"
#include "widgets/field_edit.h"
#include "view_main.h" #include "view_main.h"
@@ -277,12 +276,10 @@ static void rotaryDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
} }
} }
// libopenui_depends.h
int8_t rotaryEncoderGetAccel() { return _rotary_enc_accel; } int8_t rotaryEncoderGetAccel() { return _rotary_enc_accel; }
#else // !defined(ROTARY_ENCODER_NAVIGATION) #else // !defined(ROTARY_ENCODER_NAVIGATION)
// libopenui_depends.h
int8_t rotaryEncoderGetAccel() { return 0; } int8_t rotaryEncoderGetAccel() { return 0; }
#endif // defined(ROTARY_ENCODER_NAVIGATION) #endif // defined(ROTARY_ENCODER_NAVIGATION)
@@ -342,7 +339,7 @@ void initLvglTheme()
/* Initialize the ETX theme */ /* Initialize the ETX theme */
lv_theme_t* th = etx_lv_theme_init( lv_theme_t* th = etx_lv_theme_init(
NULL, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), NULL, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
false, LV_FONT_DEFAULT); LV_FONT_DEFAULT);
/* Assign the theme to the current display*/ /* Assign the theme to the current display*/
lv_disp_set_theme(NULL, th); lv_disp_set_theme(NULL, th);
+3
View File
@@ -55,4 +55,7 @@ class LvglWrapper
static void runNested(); static void runNested();
}; };
// multiplication factor between 0 and 25
int8_t rotaryEncoderGetAccel();
#endif // _LVGLWRAPPER_H_ #endif // _LVGLWRAPPER_H_
+7 -7
View File
@@ -342,7 +342,7 @@ RegisterDialog::RegisterDialog(Window* parent, uint8_t moduleIdx) :
// new StaticText(line, rect_t{}, STR_STATUS, 0, COLOR_THEME_PRIMARY1); // new StaticText(line, rect_t{}, STR_STATUS, 0, COLOR_THEME_PRIMARY1);
// status = new StaticText(line, rect_t{}, STR_WAITING_FOR_RX, 0, COLOR_THEME_PRIMARY1); // status = new StaticText(line, rect_t{}, STR_WAITING_FOR_RX, 0, COLOR_THEME_PRIMARY1);
auto box = new FormGroup(form, rect_t{}); auto box = new FormWindow(form, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8)); box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8));
lv_obj_set_style_flex_main_place(box->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0); lv_obj_set_style_flex_main_place(box->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0);
box->padAll(lv_dpx(8)); box->padAll(lv_dpx(8));
@@ -522,7 +522,7 @@ void ModuleOptions::update()
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_EXT_ANTENNA, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_EXT_ANTENNA, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, new ToggleSwitch(line, rect_t{},
[]() { []() {
const auto& hwSettings = getPXX2HardwareAndSettingsBuffer(); const auto& hwSettings = getPXX2HardwareAndSettingsBuffer();
return hwSettings.moduleSettings.externalAntenna; return hwSettings.moduleSettings.externalAntenna;
@@ -581,7 +581,7 @@ void ModuleOptions::update()
line = form->newLine(&grid); line = form->newLine(&grid);
auto box = new FormGroup(form, rect_t{}); auto box = new FormWindow(form, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8)); box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8));
lv_obj_set_style_flex_main_place(box->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0); lv_obj_set_style_flex_main_place(box->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0);
box->padAll(lv_dpx(8)); box->padAll(lv_dpx(8));
@@ -750,7 +750,7 @@ void RxOptions::update()
// PWM rate // PWM rate
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, isModuleR9MAccess(moduleIdx) ? "6.67ms PWM" : "7ms PWM"); new StaticText(line, rect_t{}, isModuleR9MAccess(moduleIdx) ? "6.67ms PWM" : "7ms PWM");
new CheckBox( new ToggleSwitch(
line, rect_t{}, line, rect_t{},
[]() { []() {
auto& hwSettings = getPXX2HardwareAndSettingsBuffer(); auto& hwSettings = getPXX2HardwareAndSettingsBuffer();
@@ -764,7 +764,7 @@ void RxOptions::update()
// telemetry disabled // telemetry disabled
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_TELEMETRY_DISABLED); new StaticText(line, rect_t{}, STR_TELEMETRY_DISABLED);
auto tele25mw = new CheckBox( auto tele25mw = new ToggleSwitch(
line, rect_t{}, line, rect_t{},
[]() { []() {
auto& hwSettings = getPXX2HardwareAndSettingsBuffer(); auto& hwSettings = getPXX2HardwareAndSettingsBuffer();
@@ -785,7 +785,7 @@ void RxOptions::update()
// telemetry 25 mW // telemetry 25 mW
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, "25mw Tele"); new StaticText(line, rect_t{}, "25mw Tele");
new CheckBox( new ToggleSwitch(
line, rect_t{}, line, rect_t{},
[]() { []() {
auto& hwSettings = getPXX2HardwareAndSettingsBuffer(); auto& hwSettings = getPXX2HardwareAndSettingsBuffer();
@@ -875,7 +875,7 @@ void RxOptions::update()
line = form->newLine(&grid); line = form->newLine(&grid);
new DynamicText(line, rect_t{}, [=]() { return statusText; }); new DynamicText(line, rect_t{}, [=]() { return statusText; });
auto box = new FormGroup(form, rect_t{}); auto box = new FormWindow(form, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8)); box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8));
lv_obj_set_style_flex_main_place(box->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0); lv_obj_set_style_flex_main_place(box->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0);
box->padAll(lv_dpx(8)); box->padAll(lv_dpx(8));
+5 -7
View File
@@ -22,8 +22,6 @@
#include "afhds3_options.h" #include "afhds3_options.h"
#include "opentx.h" #include "opentx.h"
//#include "checkbox.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_TEMPLATE_LAST}; LV_GRID_TEMPLATE_LAST};
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT,
@@ -75,7 +73,7 @@ static void pwmfreq_changedV0(lv_event_t* e)
} }
} }
PWMfrequencyChoice::PWMfrequencyChoice(Window* parent, uint8_t moduleIdx, uint8_t channelIdx) : PWMfrequencyChoice::PWMfrequencyChoice(Window* parent, uint8_t moduleIdx, uint8_t channelIdx) :
FormGroup(parent, rect_t{}) FormWindow(parent, rect_t{})
{ {
setFlexLayout(LV_FLEX_FLOW_ROW); setFlexLayout(LV_FLEX_FLOW_ROW);
lv_obj_set_width(lvobj, LV_SIZE_CONTENT); lv_obj_set_width(lvobj, LV_SIZE_CONTENT);
@@ -112,7 +110,7 @@ PWMfrequencyChoice::PWMfrequencyChoice(Window* parent, uint8_t moduleIdx, uint8_
} }
PWMfrequencyChoice::PWMfrequencyChoice(Window* parent, uint8_t moduleIdx ) : PWMfrequencyChoice::PWMfrequencyChoice(Window* parent, uint8_t moduleIdx ) :
FormGroup(parent, rect_t{}) FormWindow(parent, rect_t{})
{ {
setFlexLayout(LV_FLEX_FLOW_ROW); setFlexLayout(LV_FLEX_FLOW_ROW);
lv_obj_set_width(lvobj, LV_SIZE_CONTENT); lv_obj_set_width(lvobj, LV_SIZE_CONTENT);
@@ -163,7 +161,7 @@ AFHDS3_Options::AFHDS3_Options(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP)
title += ")"; title += ")";
header.setTitle2(title); header.setTitle2(title);
auto form = new FormGroup(&body, rect_t{}); auto form = new FormWindow(&body, rect_t{});
form->setFlexLayout(); form->setFlexLayout();
form->padAll(lv_dpx(8)); form->padAll(lv_dpx(8));
@@ -183,7 +181,7 @@ AFHDS3_Options::AFHDS3_Options(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP)
temp_str += " "; temp_str += " ";
temp_str += STR_SYNC; temp_str += STR_SYNC;
new StaticText(line, rect_t{}, temp_str); new StaticText(line, rect_t{}, temp_str);
new CheckBox(line, rect_t{}, GET_SET_AND_SYNC(cfg, vCfg->PWMFrequency.Synchronized, new ToggleSwitch(line, rect_t{}, GET_SET_AND_SYNC(cfg, vCfg->PWMFrequency.Synchronized,
afhds3::DirtyConfig::DC_RX_CMD_FREQUENCY_V0)); afhds3::DirtyConfig::DC_RX_CMD_FREQUENCY_V0));
line = form->newLine(&grid); line = form->newLine(&grid);
@@ -212,7 +210,7 @@ AFHDS3_Options::AFHDS3_Options(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP)
temp_str += " "; temp_str += " ";
temp_str += STR_SYNC; temp_str += STR_SYNC;
new StaticText(line, rect_t{}, temp_str); new StaticText(line, rect_t{}, temp_str);
new CheckBox( new ToggleSwitch(
line, rect_t{}, GET_DEFAULT((vCfg->PWMFrequenciesV1.Synchronized&1<<i)>>i), line, rect_t{}, GET_DEFAULT((vCfg->PWMFrequenciesV1.Synchronized&1<<i)>>i),
[=](uint8_t newVal) { [=](uint8_t newVal) {
vCfg->PWMFrequenciesV1.Synchronized &= ~(1<<i); vCfg->PWMFrequenciesV1.Synchronized &= ~(1<<i);
+1 -1
View File
@@ -24,7 +24,7 @@
#include "page.h" #include "page.h"
#include "pulses/afhds3_config.h" #include "pulses/afhds3_config.h"
struct PWMfrequencyChoice : public FormGroup { struct PWMfrequencyChoice : public FormWindow {
PWMfrequencyChoice(Window* parent, uint8_t moduleIdx, uint8_t channelIdx); PWMfrequencyChoice(Window* parent, uint8_t moduleIdx, uint8_t channelIdx);
PWMfrequencyChoice(Window* parent, uint8_t moduleIdx); PWMfrequencyChoice(Window* parent, uint8_t moduleIdx);
void update() const; void update() const;
+1 -1
View File
@@ -317,7 +317,7 @@ struct _BuiltinIcon {
}; };
static const _BuiltinIcon _builtinIcons[] = { static const _BuiltinIcon _builtinIcons[] = {
{ICON_OPENTX, mask_edgetx}, {ICON_EDGETX, mask_edgetx},
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
{ICON_NEXT, mask_next}, {ICON_NEXT, mask_next},
{ICON_BACK, mask_back}, {ICON_BACK, mask_back},
+1 -1
View File
@@ -46,7 +46,7 @@ void cb_value_changed(lv_event_t* e) {
} }
ChannelRange::ChannelRange(Window* parent) : ChannelRange::ChannelRange(Window* parent) :
FormGroup(parent, rect_t{}) FormWindow(parent, rect_t{})
{ {
setFlexLayout(LV_FLEX_FLOW_ROW); setFlexLayout(LV_FLEX_FLOW_ROW);
lv_obj_set_width(lvobj, LV_SIZE_CONTENT); lv_obj_set_width(lvobj, LV_SIZE_CONTENT);
+1 -1
View File
@@ -24,7 +24,7 @@
#include "form.h" #include "form.h"
#include "numberedit.h" #include "numberedit.h"
class ChannelRange : public FormGroup class ChannelRange : public FormWindow
{ {
public: public:
ChannelRange(Window* parent); ChannelRange(Window* parent);
+5 -5
View File
@@ -65,7 +65,7 @@ void ColorBar::on_key(lv_event_t* e)
uint32_t key = *(uint32_t*)lv_event_get_param(e); uint32_t key = *(uint32_t*)lv_event_get_param(e);
if (key == LV_KEY_LEFT) { if (key == LV_KEY_LEFT) {
if (bar->value > 0) { if (bar->value > 0) {
auto accel = rotaryEncoderGetAccel(); uint32_t accel = rotaryEncoderGetAccel();
bar->value--; bar->value--;
if (accel > 0) { if (accel > 0) {
if (accel > bar->value) bar->value = 0; if (accel > bar->value) bar->value = 0;
@@ -75,7 +75,7 @@ void ColorBar::on_key(lv_event_t* e)
} }
} else if (key == LV_KEY_RIGHT) { } else if (key == LV_KEY_RIGHT) {
if (bar->value < bar->maxValue) { if (bar->value < bar->maxValue) {
auto accel = rotaryEncoderGetAccel(); uint32_t accel = rotaryEncoderGetAccel();
bar->value++; bar->value++;
if (accel > 0) { if (accel > 0) {
if (accel < bar->maxValue - bar->value) bar->value += accel; if (accel < bar->maxValue - bar->value) bar->value += accel;
@@ -327,7 +327,7 @@ void ThemeColorType::makeButton(Window* parent, uint32_t color)
void ThemeColorType::makeButtonsRow(Window* parent, uint32_t c1, uint32_t c2, uint32_t c3) void ThemeColorType::makeButtonsRow(Window* parent, uint32_t c1, uint32_t c2, uint32_t c3)
{ {
auto hbox = new FormGroup(parent, rect_t{}); auto hbox = new FormWindow(parent, rect_t{});
hbox->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); hbox->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND); lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND);
@@ -347,7 +347,7 @@ ThemeColorType::ThemeColorType(Window* parent, uint32_t color) :
lv_style_set_border_width(&style, 2); lv_style_set_border_width(&style, 2);
lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_GREY)); lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_GREY));
auto vbox = new FormGroup(parent, rect_t{}); auto vbox = new FormWindow(parent, rect_t{});
vbox->setFlexLayout(LV_FLEX_FLOW_COLUMN, lv_dpx(8)); vbox->setFlexLayout(LV_FLEX_FLOW_COLUMN, lv_dpx(8));
makeButtonsRow(vbox, COLOR_THEME_PRIMARY1, COLOR_THEME_PRIMARY2, COLOR_THEME_PRIMARY3); makeButtonsRow(vbox, COLOR_THEME_PRIMARY1, COLOR_THEME_PRIMARY2, COLOR_THEME_PRIMARY3);
@@ -366,7 +366,7 @@ uint32_t ThemeColorType::getRGB()
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
ColorEditor::ColorEditor(Window *parent, const rect_t& rect, uint32_t color, ColorEditor::ColorEditor(Window *parent, const rect_t& rect, uint32_t color,
std::function<void (uint32_t rgb)> setValue) : std::function<void (uint32_t rgb)> setValue) :
FormGroup(parent, rect), FormWindow(parent, rect),
_setValue(std::move(setValue)), _setValue(std::move(setValue)),
_color(color) _color(color)
{ {
+1 -1
View File
@@ -122,7 +122,7 @@ enum COLOR_EDITOR_TYPE
}; };
// the ColorEditor() control is a group of other controls // the ColorEditor() control is a group of other controls
class ColorEditor : public FormGroup class ColorEditor : public FormWindow
{ {
public: public:
ColorEditor(Window* parent, const rect_t& rect, uint32_t color, ColorEditor(Window* parent, const rect_t& rect, uint32_t color,
+5 -5
View File
@@ -71,13 +71,13 @@ class ColorEditorPopup : public Dialog
auto cedit = new ColorEditor(line, r, color, [=](uint32_t c) { updateColor(c); }); auto cedit = new ColorEditor(line, r, color, [=](uint32_t c) { updateColor(c); });
lv_obj_set_style_grid_cell_x_align(cedit->getLvObj(), LV_GRID_ALIGN_CENTER, 0); lv_obj_set_style_grid_cell_x_align(cedit->getLvObj(), LV_GRID_ALIGN_CENTER, 0);
auto vbox = new FormGroup(line, rect_t{}); auto vbox = new FormWindow(line, rect_t{});
lv_obj_set_style_grid_cell_x_align(vbox->getLvObj(), LV_GRID_ALIGN_CENTER, 0); lv_obj_set_style_grid_cell_x_align(vbox->getLvObj(), LV_GRID_ALIGN_CENTER, 0);
vbox->setFlexLayout(LV_FLEX_FLOW_COLUMN, lv_dpx(8)); vbox->setFlexLayout(LV_FLEX_FLOW_COLUMN, lv_dpx(8));
vbox->setWidth(r.w); vbox->setWidth(r.w);
vbox->setHeight(r.h); vbox->setHeight(r.h);
auto hbox = new FormGroup(vbox, rect_t{}); auto hbox = new FormWindow(vbox, rect_t{});
hbox->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); hbox->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
auto hbox_obj = hbox->getLvObj(); auto hbox_obj = hbox->getLvObj();
lv_obj_set_flex_align(hbox_obj, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_SPACE_AROUND); lv_obj_set_flex_align(hbox_obj, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_SPACE_AROUND);
@@ -92,7 +92,7 @@ class ColorEditorPopup : public Dialog
updateColor(color); updateColor(color);
hbox = new FormGroup(vbox, rect_t{}); hbox = new FormWindow(vbox, rect_t{});
hbox->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); hbox->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND); lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND);
@@ -127,7 +127,7 @@ class ColorEditorPopup : public Dialog
// color editor defaults to HSV // color editor defaults to HSV
hsvBtn->check(true); hsvBtn->check(true);
hbox = new FormGroup(vbox, rect_t{}); hbox = new FormWindow(vbox, rect_t{});
hbox->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); hbox->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_SPACE_BETWEEN); lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_SPACE_BETWEEN);
lv_obj_set_flex_grow(hbox->getLvObj(), 1); lv_obj_set_flex_grow(hbox->getLvObj(), 1);
@@ -170,7 +170,7 @@ static void color_editor_popup(lv_event_t* e)
ColorPicker::ColorPicker(Window* parent, const rect_t& rect, ColorPicker::ColorPicker(Window* parent, const rect_t& rect,
std::function<uint16_t()> getValue, std::function<uint16_t()> getValue,
std::function<void(uint16_t)> setValue) : std::function<void(uint16_t)> setValue) :
FormField(parent, rect, 0, 0, lv_btn_create), FormField(parent, rect, 0, 0, etx_button_create),
setValue(std::move(setValue)) setValue(std::move(setValue))
{ {
lv_obj_set_style_bg_opa(lvobj, LV_OPA_100, LV_PART_MAIN); lv_obj_set_style_bg_opa(lvobj, LV_OPA_100, LV_PART_MAIN);
+37
View File
@@ -46,6 +46,42 @@ enum LcdColorIndex {
LCD_COLOR_COUNT, LCD_COLOR_COUNT,
}; };
#define ARGB_SPLIT(color, a, r, g, b) \
uint16_t a = ((color) & 0xF000) >> 12; \
uint16_t r = ((color) & 0x0F00) >> 8; \
uint16_t g = ((color) & 0x00F0) >> 4; \
uint16_t b = ((color) & 0x000F)
#define RGB_SPLIT(color, r, g, b) \
uint16_t r = ((color) & 0xF800) >> 11; \
uint16_t g = ((color) & 0x07E0) >> 5; \
uint16_t b = ((color) & 0x001F)
#define ARGB_JOIN(a, r, g, b) \
(((a&0xF) << 12) + ((r&0xF) << 8) + ((g&0xF) << 4) + (b&0xF))
#define RGB_JOIN(r, g, b) \
(((r) << 11) + ((g) << 5) + (b))
#define GET_RED(color) \
(((color) & 0xF800) >> 8)
#define GET_GREEN(color) \
(((color) & 0x07E0) >> 3)
#define GET_BLUE(color) \
(((color) & 0x001F) << 3)
#define OPACITY_MAX 0x0Fu
#define OPACITY(value) ((value) & OPACITY_MAX)
#define RGB(r, g, b) (uint16_t)((((r) & 0xF8) << 8) + (((g) & 0xFC) << 3) + (((b) & 0xF8) >> 3))
#define ARGB(a, r, g, b) (uint16_t)((((a) & 0xF0) << 8) + (((r) & 0xF0) << 4) + (((g) & 0xF0) << 0) + (((b) & 0xF0) >> 4))
#define COLOR2FLAGS(color) LcdFlags(unsigned(color) << 16u)
#define COLOR_VAL(flags) ((flags) >> 16u)
#define COLOR_MASK(flags) ((flags) & 0xFFFF0000u)
// //
// Basic color definitions // Basic color definitions
// //
@@ -53,6 +89,7 @@ enum LcdColorIndex {
#define WHITE RGB(0xFF, 0xFF, 0xFF) #define WHITE RGB(0xFF, 0xFF, 0xFF)
#define BLACK RGB(0, 0, 0) #define BLACK RGB(0, 0, 0)
#define RGB_FLAG 0x8000u
#define RGB2FLAGS(r, g, b) (COLOR2FLAGS(RGB(r, g, b)) | RGB_FLAG) #define RGB2FLAGS(r, g, b) (COLOR2FLAGS(RGB(r, g, b)) | RGB_FLAG)
// //
+1 -2
View File
@@ -22,7 +22,6 @@
#include "opentx.h" #include "opentx.h"
#include "confirm_dialog.h" #include "confirm_dialog.h"
#include "static.h" #include "static.h"
#include "gridlayout.h"
ConfirmDialog::ConfirmDialog(Window* parent, const char* title, ConfirmDialog::ConfirmDialog(Window* parent, const char* title,
const char* message, const char* message,
@@ -39,7 +38,7 @@ ConfirmDialog::ConfirmDialog(Window* parent, const char* title,
lv_obj_set_style_bg_color(content->getLvObj(), lv_obj_set_style_bg_color(content->getLvObj(),
makeLvColor(COLOR_THEME_SECONDARY3), 0); makeLvColor(COLOR_THEME_SECONDARY3), 0);
auto box = new FormGroup(form, rect_t{}); auto box = new FormWindow(form, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW); box->setFlexLayout(LV_FLEX_FLOW_ROW);
lv_obj_set_style_flex_main_place(box->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0); lv_obj_set_style_flex_main_place(box->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0);
@@ -30,7 +30,7 @@
CrossfireSettings::CrossfireSettings(Window* parent, const FlexGridLayout& g, CrossfireSettings::CrossfireSettings(Window* parent, const FlexGridLayout& g,
uint8_t moduleIdx) : uint8_t moduleIdx) :
FormGroup(parent, rect_t{}), md(&g_model.moduleData[moduleIdx]) FormWindow(parent, rect_t{}), md(&g_model.moduleData[moduleIdx])
{ {
FlexGridLayout grid(g); FlexGridLayout grid(g);
setFlexLayout(); setFlexLayout();
+1 -1
View File
@@ -26,7 +26,7 @@
struct ModuleData; struct ModuleData;
class CrossfireSettings : public FormGroup, public ModuleOptions class CrossfireSettings : public FormWindow, public ModuleOptions
{ {
ModuleData* md; ModuleData* md;
+2 -2
View File
@@ -109,9 +109,9 @@ void CurveRenderer::paint(BitmapBuffer * dc, uint8_t ofst)
Curve::Curve(Window * parent, const rect_t & rect, std::function<int(int)> function, std::function<int()> position): Curve::Curve(Window * parent, const rect_t & rect, std::function<int(int)> function, std::function<int()> position):
Window(parent, rect, OPAQUE), Window(parent, rect, OPAQUE),
base(rect_t{0, 0, rect.w, rect.h}, function),
function(std::move(function)), function(std::move(function)),
position(std::move(position)), position(std::move(position))
base(rect_t{0, 0, rect.w, rect.h}, function)
{ {
} }
+1 -1
View File
@@ -75,7 +75,7 @@ CurveParam::CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
GET_DEFAULT(ref->value), setRefValue); GET_DEFAULT(ref->value), setRefValue);
// CURVE_REF_CUSTOM // CURVE_REF_CUSTOM
cust_choice = new ChoiceEx(this, rect_t{}, -MAX_CURVES, MAX_CURVES, cust_choice = new Choice(this, rect_t{}, -MAX_CURVES, MAX_CURVES,
GET_DEFAULT(ref->value), setRefValue); GET_DEFAULT(ref->value), setRefValue);
cust_choice->setTextHandler([](int value) { return getCurveString(value); }); cust_choice->setTextHandler([](int value) { return getCurveString(value); });
cust_choice->set_lv_LongPressHandler(LongPressHandler, &(ref->value)); cust_choice->set_lv_LongPressHandler(LongPressHandler, &(ref->value));
+1 -2
View File
@@ -27,7 +27,6 @@ struct CurveRef;
class GVarNumberEdit; class GVarNumberEdit;
class Choice; class Choice;
class ChoiceEx;
class CurveParam : public Window class CurveParam : public Window
{ {
@@ -38,7 +37,7 @@ class CurveParam : public Window
// Controls // Controls
GVarNumberEdit* value_edit; GVarNumberEdit* value_edit;
Choice* func_choice; Choice* func_choice;
ChoiceEx* cust_choice; Choice* cust_choice;
Window* act_field = nullptr; Window* act_field = nullptr;
+5 -140
View File
@@ -20,7 +20,6 @@
*/ */
#include "curveedit.h" #include "curveedit.h"
#include "keyboard_curve.h"
#include "opentx.h" // TODO for applyCustomCurve #include "opentx.h" // TODO for applyCustomCurve
#include "libopenui.h" #include "libopenui.h"
@@ -30,7 +29,7 @@ static const lv_coord_t default_col_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_L
static const lv_coord_t default_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; static const lv_coord_t default_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
CurveDataEdit::CurveDataEdit(Window * parent, const rect_t & rect, uint8_t index) : CurveDataEdit::CurveDataEdit(Window * parent, const rect_t & rect, uint8_t index) :
Window(parent, rect, FORM_FORWARD_FOCUS), Window(parent, rect),
index(index) index(index)
{ {
lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR_THEME_SECONDARY3), 0); lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR_THEME_SECONDARY3), 0);
@@ -43,7 +42,7 @@ CurveDataEdit::CurveDataEdit(Window * parent, const rect_t & rect, uint8_t index
#define NUM_BTN_WIDTH 48 #define NUM_BTN_WIDTH 48
#endif #endif
void CurveDataEdit::curvePointsRow(FormGroup::Line* parent, int start, int count, int curvePointsCount, bool isCustom) void CurveDataEdit::curvePointsRow(FormWindow::Line* parent, int start, int count, int curvePointsCount, bool isCustom)
{ {
static const lv_coord_t points_col_dsc[] = {11, LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; static const lv_coord_t points_col_dsc[] = {11, LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
@@ -209,138 +208,6 @@ void CurveEdit::updatePreview()
invalidate(); invalidate();
} }
// #if defined(HARDWARE_TOUCH)
// bool CurveEdit::onTouchEnd(coord_t x, coord_t y)
// {
// if (!hasFocus()) {
// setFocus(SET_FOCUS_DEFAULT);
// }
// CurveKeyboard::show(this, isCustomCurve());
// CurveHeader & curve = g_model.curves[index];
// for (int i=0; i<5 + curve.points; i++) {
// if (i != current) {
// point_t point = getPoint(index, i);
// if (abs(preview.getPointX(point.x) - x) <= 10 && abs(preview.getPointY(point.y) - y) <= 10) {
// current = i;
// updatePreview();
// break;
// }
// }
// }
// return true;
// }
// void CurveEdit::onFocusLost()
// {
// CurveKeyboard::hide();
// }
// #endif
void CurveEdit::next()
{
CurveHeader & curve = g_model.curves[index];
if (current++ == 5 + curve.points - 1) {
current = 0;
}
updatePreview();
}
void CurveEdit::previous()
{
CurveHeader & curve = g_model.curves[index];
if (current-- == 0) {
current = 5 + curve.points - 1;
}
updatePreview();
}
void CurveEdit::up()
{
int8_t & point = curveAddress(index)[current];
point = min<int8_t>(100, ++point);
storageDirty(EE_MODEL);
invalidate();
}
void CurveEdit::down()
{
int8_t & point = curveAddress(index)[current];
point = max<int8_t>(-100, --point);
storageDirty(EE_MODEL);
invalidate();
}
void CurveEdit::right()
{
CurveHeader & curve = g_model.curves[index];
if (curve.type == CURVE_TYPE_CUSTOM && current != 0 && current != curve.points + 5 - 1) {
int8_t * points = curveAddress(index);
int8_t * point = &points[5 + curve.points + current - 1];
int8_t xmax = (current == (curve.points - 2) ? +100 : *(point + 1));
*point = min<int8_t>(*point + 1, xmax-1);
storageDirty(EE_MODEL);
invalidate();
}
}
void CurveEdit::left()
{
CurveHeader & curve = g_model.curves[index];
if (curve.type == CURVE_TYPE_CUSTOM && current != 0 && current != curve.points + 5 - 1) {
int8_t * points = curveAddress(index);
int8_t * point = &points[5 + curve.points + current - 1];
int8_t xmin = (current == 1 ? -100 : *(point - 1));
*point = max<int8_t>(xmin+1, *point - 1);
storageDirty(EE_MODEL);
invalidate();
}
}
bool CurveEdit::isCustomCurve() const
{
return g_model.curves[index].type == CURVE_TYPE_CUSTOM;
}
void CurveEdit::onEvent(event_t event)
{
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
switch (event) {
#if defined(HARDWARE_TOUCH)
case EVT_VIRTUAL_KEY_LEFT:
left();
break;
case EVT_VIRTUAL_KEY_RIGHT:
right();
break;
case EVT_VIRTUAL_KEY_UP:
up();
break;
case EVT_VIRTUAL_KEY_DOWN:
down();
break;
case EVT_VIRTUAL_KEY_PREVIOUS:
previous();
break;
case EVT_VIRTUAL_KEY_NEXT:
next();
break;
#endif
default:
FormField::onEvent(event);
break;
}
}
void CurveEdit::checkEvents() void CurveEdit::checkEvents()
{ {
if (!lockSource) { if (!lockSource) {
@@ -425,14 +292,12 @@ void CurveEditWindow::buildBody(FormWindow * window)
new ModelTextEdit(iLine, rect_t{0, 0, 100, 0}, curve.name, sizeof(curve.name)); new ModelTextEdit(iLine, rect_t{0, 0, 100, 0}, curve.name, sizeof(curve.name));
// Smooth // Smooth
auto smooth = new TextButton(iLine, rect_t{}, STR_SMOOTH, [=]() { auto smooth = new TextButton(iLine, rect_t{0, 0, 70, 0}, STR_SMOOTH, [=]() {
g_model.curves[index].smooth = !g_model.curves[index].smooth; g_model.curves[index].smooth = !g_model.curves[index].smooth;
curveEdit->updatePreview(); curveEdit->updatePreview();
return g_model.curves[index].smooth; return g_model.curves[index].smooth;
}); });
smooth->check(g_model.curves[index].smooth); smooth->check(g_model.curves[index].smooth);
smooth->padAll(2);
smooth->setHeight(26);
iLine = form->newLine(&iGrid); iLine = form->newLine(&iGrid);
iLine->padAll(4); iLine->padAll(4);
@@ -463,7 +328,7 @@ void CurveEditWindow::buildBody(FormWindow * window)
}); });
// Points count // Points count
auto edit = new NumberEdit(iLine, rect_t{}, 2, 17, GET_DEFAULT(g_model.curves[index].points + 5), auto edit = new NumberEdit(iLine, rect_t{0, 0, 70, 0}, 2, 17, GET_DEFAULT(g_model.curves[index].points + 5),
[=](int32_t newValue) { [=](int32_t newValue) {
newValue -= 5; newValue -= 5;
CurveHeader &curve = g_model.curves[index]; CurveHeader &curve = g_model.curves[index];
@@ -492,7 +357,7 @@ void CurveEditWindow::buildBody(FormWindow * window)
iLine->padAll(0); iLine->padAll(0);
lv_obj_set_grid_align(iLine->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN, LV_GRID_ALIGN_SPACE_BETWEEN); lv_obj_set_grid_align(iLine->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN, LV_GRID_ALIGN_SPACE_BETWEEN);
curveDataEdit = new CurveDataEdit(iLine, rect_t{ 0, 0, box->width(), box->height() - 67 }, index); curveDataEdit = new CurveDataEdit(iLine, rect_t{ 0, 0, box->width(), box->height() - 72 }, index);
// Curve editor // Curve editor
lv_obj_set_flex_align(line->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND); lv_obj_set_flex_align(line->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND);
+1 -14
View File
@@ -45,27 +45,14 @@ class CurveEdit: public FormField
void updatePreview(); void updatePreview();
void onEvent(event_t event) override;
void checkEvents(void) override; void checkEvents(void) override;
// #if defined(HARDWARE_TOUCH)
// bool onTouchEnd(coord_t x, coord_t y) override;
// void onFocusLost() override;
// #endif
protected: protected:
Curve preview; Curve preview;
uint8_t index; uint8_t index;
uint8_t current; uint8_t current;
static mixsrc_t currentSource; static mixsrc_t currentSource;
static bool lockSource; static bool lockSource;
void next();
void previous();
void up();
void down();
void right();
void left();
bool isCustomCurve() const;
}; };
class CurveDataEdit : public Window class CurveDataEdit : public Window
@@ -86,7 +73,7 @@ class CurveDataEdit : public Window
CurveEdit * curveEdit; CurveEdit * curveEdit;
NumberEdit* numEditX[16]; NumberEdit* numEditX[16];
void curvePointsRow(FormGroup::Line* parent, int start, int count, int curvePointsCount, bool isCustom); void curvePointsRow(FormWindow::Line* parent, int start, int count, int curvePointsCount, bool isCustom);
}; };
class CurveEditWindow : public Page class CurveEditWindow : public Page
+3 -3
View File
@@ -154,13 +154,13 @@ public:
} }
}; };
class ChannelFSCombo : public FormGroup class ChannelFSCombo : public FormWindow
{ {
ChannelFailsafeEdit* edit = nullptr; ChannelFailsafeEdit* edit = nullptr;
public: public:
ChannelFSCombo(Window* parent, uint8_t ch, int vmin, int vmax) : ChannelFSCombo(Window* parent, uint8_t ch, int vmin, int vmax) :
FormGroup(parent, rect_t{}) FormWindow(parent, rect_t{})
{ {
setFlexLayout(LV_FLEX_FLOW_ROW); setFlexLayout(LV_FLEX_FLOW_ROW);
lv_obj_set_width(lvobj, LV_SIZE_CONTENT); lv_obj_set_width(lvobj, LV_SIZE_CONTENT);
@@ -211,7 +211,7 @@ FailSafePage::FailSafePage(uint8_t moduleIdx) :
{ {
header.setTitle(STR_FAILSAFESET); header.setTitle(STR_FAILSAFESET);
auto form = new FormGroup(&body, rect_t{}); auto form = new FormWindow(&body, rect_t{});
form->setFlexLayout(); form->setFlexLayout();
form->padAll(lv_dpx(8)); form->padAll(lv_dpx(8));
form->padRow(lv_dpx(8)); form->padRow(lv_dpx(8));
+2 -2
View File
@@ -102,7 +102,7 @@ void drawSleepBitmap()
lcdInitDirectDrawing(); lcdInitDirectDrawing();
lcd->clear(bgColor); lcd->clear(bgColor);
const BitmapBuffer* bitmap = OpenTxTheme::instance()->shutdown; const BitmapBuffer* bitmap = EdgeTxTheme::instance()->shutdown;
if (bitmap) { if (bitmap) {
lcd->drawMask((LCD_W - bitmap->width()) / 2, (LCD_H - bitmap->height()) / 2, lcd->drawMask((LCD_W - bitmap->width()) / 2, (LCD_H - bitmap->height()) / 2,
bitmap, fgColor); bitmap, fgColor);
@@ -134,7 +134,7 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration,
bgColor = COLOR_THEME_SECONDARY1; bgColor = COLOR_THEME_SECONDARY1;
} }
static const BitmapBuffer* shutdown = OpenTxTheme::instance()->shutdown; static const BitmapBuffer* shutdown = EdgeTxTheme::instance()->shutdown;
lcdInitDirectDrawing(); lcdInitDirectDrawing();
lcd->clear(bgColor); lcd->clear(bgColor);
+2 -3
View File
@@ -19,7 +19,6 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "libopenui_config.h"
#include "fab_button.h" #include "fab_button.h"
#include "font.h" #include "font.h"
#include "theme.h" #include "theme.h"
@@ -34,7 +33,7 @@ const uint8_t __alpha_button_off[] {
}; };
LZ4Bitmap ALPHA_BUTTON_OFF(BMP_ARGB4444, __alpha_button_off); LZ4Bitmap ALPHA_BUTTON_OFF(BMP_ARGB4444, __alpha_button_off);
FabButton::FabButton(FormGroup* parent, coord_t x, coord_t y, uint8_t icon, FabButton::FabButton(FormWindow* parent, coord_t x, coord_t y, uint8_t icon,
std::function<uint8_t(void)> pressHandler, std::function<uint8_t(void)> pressHandler,
WindowFlags windowFlags) : WindowFlags windowFlags) :
Button(parent, Button(parent,
@@ -44,7 +43,7 @@ FabButton::FabButton(FormGroup* parent, coord_t x, coord_t y, uint8_t icon,
{ {
} }
FabButton::FabButton(FormGroup* parent, uint8_t icon, FabButton::FabButton(FormWindow* parent, uint8_t icon,
std::function<uint8_t(void)> pressHandler, std::function<uint8_t(void)> pressHandler,
WindowFlags windowFlags) : WindowFlags windowFlags) :
Button(parent, {}, pressHandler, windowFlags), icon(icon) Button(parent, {}, pressHandler, windowFlags), icon(icon)
+2 -2
View File
@@ -28,11 +28,11 @@ constexpr coord_t FAB_BUTTON_SIZE = 68;
class FabButton: public Button { class FabButton: public Button {
public: public:
FabButton(FormGroup * parent, coord_t x, coord_t y, FabButton(FormWindow * parent, coord_t x, coord_t y,
uint8_t icon, std::function<uint8_t(void)> pressHandler, uint8_t icon, std::function<uint8_t(void)> pressHandler,
WindowFlags windowFlags = 0); WindowFlags windowFlags = 0);
FabButton(FormGroup * parent, uint8_t icon, FabButton(FormWindow * parent, uint8_t icon,
std::function<uint8_t(void)> pressHandler, std::function<uint8_t(void)> pressHandler,
WindowFlags windowFlags = 0); WindowFlags windowFlags = 0);
+2 -2
View File
@@ -27,7 +27,7 @@ extern inline tmr10ms_t getTicks()
FileCarosell::FileCarosell(Window *parent, const rect_t &rect, FileCarosell::FileCarosell(Window *parent, const rect_t &rect,
std::vector<std::string> fileNames) : std::vector<std::string> fileNames) :
FormGroup(parent, rect, NO_FOCUS | FORM_NO_BORDER), FormWindow(parent, rect, NO_FOCUS),
_fileNames(fileNames), _fileNames(fileNames),
fp(new FilePreview(this, {0, 0, rect.w, rect.h}, false)) fp(new FilePreview(this, {0, 0, rect.w, rect.h}, false))
{ {
@@ -65,7 +65,7 @@ void FileCarosell::setSelected(int n)
void FileCarosell::checkEvents() void FileCarosell::checkEvents()
{ {
FormGroup::checkEvents(); FormWindow::checkEvents();
uint32_t newTicks = getTicks(); uint32_t newTicks = getTicks();
+1 -1
View File
@@ -27,7 +27,7 @@
#define PAGE_INTERVAL ((1000 / 10) * 2) #define PAGE_INTERVAL ((1000 / 10) * 2)
#define SHORT_PAGE_INTERVAL ((1000 / 20)) // 500 MS #define SHORT_PAGE_INTERVAL ((1000 / 20)) // 500 MS
class FileCarosell : public FormGroup class FileCarosell : public FormWindow
{ {
public: public:
FileCarosell(Window *parent, const rect_t &rect, FileCarosell(Window *parent, const rect_t &rect,
+1 -1
View File
@@ -24,7 +24,7 @@
FilePreview::FilePreview(Window *parent, const rect_t &rect, FilePreview::FilePreview(Window *parent, const rect_t &rect,
bool drawCentered) : bool drawCentered) :
Window(parent, rect, NO_SCROLLBAR), _drawCentered(drawCentered) Window(parent, rect), _drawCentered(drawCentered)
{ {
} }
+6 -6
View File
@@ -44,7 +44,7 @@ static const char* _afhds3_phy_mode[] = {
"Lora 12ch", "Lora 12ch",
}; };
class FSProtoOpts : public FormGroup class FSProtoOpts : public FormWindow
{ {
std::function<uint8_t()> _getMode; std::function<uint8_t()> _getMode;
std::function<void(uint8_t)> _setMode; std::function<void(uint8_t)> _setMode;
@@ -56,7 +56,7 @@ public:
FSProtoOpts::FSProtoOpts(Window* parent, std::function<uint8_t()> getMode, FSProtoOpts::FSProtoOpts(Window* parent, std::function<uint8_t()> getMode,
std::function<void(uint8_t)> setMode) : std::function<void(uint8_t)> setMode) :
FormGroup(parent, rect_t{}), FormWindow(parent, rect_t{}),
_getMode(std::move(getMode)), _getMode(std::move(getMode)),
_setMode(std::move(setMode)) _setMode(std::move(setMode))
{ {
@@ -83,14 +83,14 @@ FSProtoOpts::FSProtoOpts(Window* parent, std::function<uint8_t()> getMode,
FlySkySettings::FlySkySettings(Window* parent, const FlexGridLayout& g, FlySkySettings::FlySkySettings(Window* parent, const FlexGridLayout& g,
uint8_t moduleIdx) : uint8_t moduleIdx) :
FormGroup(parent, rect_t{}), FormWindow(parent, rect_t{}),
moduleIdx(moduleIdx), moduleIdx(moduleIdx),
md(&g_model.moduleData[moduleIdx]), md(&g_model.moduleData[moduleIdx]),
grid(g) grid(g)
{ {
setFlexLayout(); setFlexLayout();
FormGroup::Line* line; FormWindow::Line* line;
#if defined(AFHDS2) #if defined(AFHDS2)
// RX options: // RX options:
@@ -132,7 +132,7 @@ FlySkySettings::FlySkySettings(Window* parent, const FlexGridLayout& g,
line = newLine(&grid); line = newLine(&grid);
afhds3TypeLabel = new StaticText(line, rect_t{}, STR_TYPE, 0, COLOR_THEME_PRIMARY1); afhds3TypeLabel = new StaticText(line, rect_t{}, STR_TYPE, 0, COLOR_THEME_PRIMARY1);
afhds3TypeForm = new FormGroup(line, rect_t{}); afhds3TypeForm = new FormWindow(line, rect_t{});
afhds3TypeForm->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP); afhds3TypeForm->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP);
lv_obj_set_style_grid_cell_x_align(afhds3TypeForm->getLvObj(), LV_GRID_ALIGN_STRETCH, 0); lv_obj_set_style_grid_cell_x_align(afhds3TypeForm->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
@@ -234,7 +234,7 @@ void FlySkySettings::checkEvents() {
if (afhds3::getConfig(moduleIdx)->others.lastUpdated > lastRefresh) { if (afhds3::getConfig(moduleIdx)->others.lastUpdated > lastRefresh) {
update(); update();
} }
FormGroup::checkEvents(); FormWindow::checkEvents();
} }
void FlySkySettings::update() void FlySkySettings::update()
+2 -2
View File
@@ -27,7 +27,7 @@
struct ModuleData; struct ModuleData;
class FlySkySettings : public FormGroup, public ModuleOptions class FlySkySettings : public FormWindow, public ModuleOptions
{ {
uint8_t moduleIdx; uint8_t moduleIdx;
ModuleData* md; ModuleData* md;
@@ -49,7 +49,7 @@ class FlySkySettings : public FormGroup, public ModuleOptions
Window* afhds3StatusLabel = nullptr; Window* afhds3StatusLabel = nullptr;
Window* afhds3StatusText = nullptr; Window* afhds3StatusText = nullptr;
Window* afhds3TypeLabel = nullptr; Window* afhds3TypeLabel = nullptr;
FormGroup* afhds3TypeForm = nullptr; FormWindow* afhds3TypeForm = nullptr;
Choice *afhds3PhyMode = nullptr; Choice *afhds3PhyMode = nullptr;
Choice *afhds3Emi = nullptr; Choice *afhds3Emi = nullptr;
Choice *afhds3RfPower = nullptr; Choice *afhds3RfPower = nullptr;
+5 -10
View File
@@ -35,8 +35,7 @@ FMMatrix<T>::FMMatrix(Window* parent, const rect_t& r, T* input) :
update(); update();
for (int i = 0; i < MAX_FLIGHT_MODES; i++) { for (int i = 0; i < MAX_FLIGHT_MODES; i++) {
lv_btnmatrix_set_btn_ctrl(lvobj, i, LV_BTNMATRIX_CTRL_RECOLOR); setTextAndState(i);
setTextWithColor(i);
} }
#if LCD_W > LCD_H #if LCD_W > LCD_H
@@ -49,20 +48,16 @@ FMMatrix<T>::FMMatrix(Window* parent, const rect_t& r, T* input) :
lv_obj_set_height(lvobj, LV_DPI_DEF); lv_obj_set_height(lvobj, LV_DPI_DEF);
#endif #endif
lv_obj_set_style_bg_opa(lvobj, LV_OPA_0, LV_PART_MAIN);
lv_obj_set_style_pad_all(lvobj, lv_dpx(4), LV_PART_MAIN); lv_obj_set_style_pad_all(lvobj, lv_dpx(4), LV_PART_MAIN);
lv_obj_set_style_pad_row(lvobj, lv_dpx(4), LV_PART_MAIN); lv_obj_set_style_pad_row(lvobj, lv_dpx(4), LV_PART_MAIN);
lv_obj_set_style_pad_column(lvobj, lv_dpx(4), LV_PART_MAIN); lv_obj_set_style_pad_column(lvobj, lv_dpx(4), LV_PART_MAIN);
lv_obj_remove_style(lvobj, nullptr, LV_PART_MAIN | LV_STATE_FOCUSED);
lv_obj_remove_style(lvobj, nullptr, LV_PART_MAIN | LV_STATE_EDITED);
} }
template<class T> template<class T>
void FMMatrix<T>::setTextWithColor(uint8_t btn_id) void FMMatrix<T>::setTextAndState(uint8_t btn_id)
{ {
setText(btn_id, makeRecolor(std::to_string(btn_id), isActive(btn_id) ? COLOR_THEME_PRIMARY1 : COLOR_THEME_SECONDARY1).c_str()); setText(btn_id, std::to_string(btn_id).c_str());
setChecked(btn_id);
} }
template<class T> template<class T>
@@ -70,7 +65,7 @@ void FMMatrix<T>::onPress(uint8_t btn_id)
{ {
if (btn_id >= MAX_FLIGHT_MODES) return; if (btn_id >= MAX_FLIGHT_MODES) return;
BFBIT_FLIP(input->flightModes, bfBit<uint32_t>(btn_id)); BFBIT_FLIP(input->flightModes, bfBit<uint32_t>(btn_id));
setTextWithColor(btn_id); setTextAndState(btn_id);
storageDirty(EE_MODEL); storageDirty(EE_MODEL);
} }
+1 -1
View File
@@ -32,7 +32,7 @@ struct FMMatrix : public ButtonMatrix {
FMMatrix(Window* parent, const rect_t& rect, T* input); FMMatrix(Window* parent, const rect_t& rect, T* input);
void onPress(uint8_t btn_id); void onPress(uint8_t btn_id);
bool isActive(uint8_t btn_id); bool isActive(uint8_t btn_id);
void setTextWithColor(uint8_t btn_id); void setTextAndState(uint8_t btn_id);
}; };
extern template struct FMMatrix<ExpoData>; extern template struct FMMatrix<ExpoData>;
+1 -1
View File
@@ -19,7 +19,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "libopenui_config.h" #include "libopenui_defines.h"
#include "font.h" #include "font.h"
#if !defined(BOOT) #if !defined(BOOT)
+4 -4
View File
@@ -110,20 +110,20 @@ void FullScreenDialog::init()
void FullScreenDialog::paint(BitmapBuffer * dc) void FullScreenDialog::paint(BitmapBuffer * dc)
{ {
OpenTxTheme::instance()->drawBackground(dc); EdgeTxTheme::instance()->drawBackground(dc);
dc->drawFilledRect(0, ALERT_FRAME_TOP, LCD_W, ALERT_FRAME_HEIGHT, SOLID, dc->drawFilledRect(0, ALERT_FRAME_TOP, LCD_W, ALERT_FRAME_HEIGHT, SOLID,
COLOR_THEME_PRIMARY2, OPACITY(8)); COLOR_THEME_PRIMARY2, OPACITY(8));
if (type == WARNING_TYPE_ALERT || type == WARNING_TYPE_ASTERISK) { if (type == WARNING_TYPE_ALERT || type == WARNING_TYPE_ASTERISK) {
dc->drawMask(ALERT_BITMAP_LEFT, ALERT_BITMAP_TOP, dc->drawMask(ALERT_BITMAP_LEFT, ALERT_BITMAP_TOP,
OpenTxTheme::instance()->error, COLOR_THEME_WARNING); EdgeTxTheme::instance()->error, COLOR_THEME_WARNING);
} else if (type == WARNING_TYPE_INFO) { } else if (type == WARNING_TYPE_INFO) {
dc->drawMask(ALERT_BITMAP_LEFT, ALERT_BITMAP_TOP, dc->drawMask(ALERT_BITMAP_LEFT, ALERT_BITMAP_TOP,
OpenTxTheme::instance()->busy, COLOR_THEME_WARNING); EdgeTxTheme::instance()->busy, COLOR_THEME_WARNING);
} else { // confirmation } else { // confirmation
dc->drawMask(ALERT_BITMAP_LEFT, ALERT_BITMAP_TOP, dc->drawMask(ALERT_BITMAP_LEFT, ALERT_BITMAP_TOP,
OpenTxTheme::instance()->error, COLOR_THEME_WARNING); EdgeTxTheme::instance()->error, COLOR_THEME_WARNING);
} }
} }
-1
View File
@@ -29,7 +29,6 @@
#include "draw_functions.h" #include "draw_functions.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "theme.h" #include "theme.h"
#include "libopenui_config.h"
#define LOAD_MODEL_BITMAP() #define LOAD_MODEL_BITMAP()
+2 -2
View File
@@ -99,7 +99,7 @@ static void bt_mode_changed(lv_event_t* e)
} }
BluetoothConfigWindow::BluetoothConfigWindow(Window *parent) : BluetoothConfigWindow::BluetoothConfigWindow(Window *parent) :
FormGroup(parent, rect_t{}) FormWindow(parent, rect_t{})
{ {
setFlexLayout(); setFlexLayout();
FlexGridLayout grid(col_dsc, row_dsc, 2); FlexGridLayout grid(col_dsc, row_dsc, 2);
@@ -107,7 +107,7 @@ BluetoothConfigWindow::BluetoothConfigWindow(Window *parent) :
auto line = newLine(&grid); auto line = newLine(&grid);
new StaticText(line, rect_t{}, STR_MODE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_MODE, 0, COLOR_THEME_PRIMARY1);
auto box = new FormGroup(line, rect_t{}); auto box = new FormWindow(line, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8)); box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8));
lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0); lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
lv_obj_set_style_flex_cross_place(box->getLvObj(), LV_FLEX_ALIGN_CENTER, 0); lv_obj_set_style_flex_cross_place(box->getLvObj(), LV_FLEX_ALIGN_CENTER, 0);
+1 -1
View File
@@ -23,7 +23,7 @@
#include "form.h" #include "form.h"
class BluetoothConfigWindow : public FormGroup class BluetoothConfigWindow : public FormWindow
{ {
public: public:
BluetoothConfigWindow(Window* parent); BluetoothConfigWindow(Window* parent);
+2 -2
View File
@@ -31,14 +31,14 @@ static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(3),
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
ExternalModuleWindow::ExternalModuleWindow(Window *parent) : ExternalModuleWindow::ExternalModuleWindow(Window *parent) :
FormGroup::Line(parent), lastModule(g_eeGeneral.internalModule) FormWindow::Line(parent), lastModule(g_eeGeneral.internalModule)
{ {
FlexGridLayout grid(col_dsc, row_dsc, 2); FlexGridLayout grid(col_dsc, row_dsc, 2);
setLayout(&grid); setLayout(&grid);
new StaticText(this, rect_t{}, STR_SAMPLE_MODE, 0, COLOR_THEME_PRIMARY1); new StaticText(this, rect_t{}, STR_SAMPLE_MODE, 0, COLOR_THEME_PRIMARY1);
auto box = new FormGroup(this, rect_t{}); auto box = new FormWindow(this, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0); lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
+1 -1
View File
@@ -23,7 +23,7 @@
#include "form.h" #include "form.h"
class ExternalModuleWindow : public FormGroup::Line class ExternalModuleWindow : public FormWindow::Line
{ {
public: public:
ExternalModuleWindow(Window* parent); ExternalModuleWindow(Window* parent);
+10 -14
View File
@@ -39,10 +39,12 @@ struct HWInputEdit : public RadioTextEdit {
static const lv_coord_t col_two_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2), static const lv_coord_t col_two_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2),
LV_GRID_TEMPLATE_LAST}; LV_GRID_TEMPLATE_LAST};
static const lv_coord_t col_three_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(2),
LV_GRID_TEMPLATE_LAST};
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
HWSticks::HWSticks(Window* parent) : FormGroup(parent, rect_t{}) HWSticks::HWSticks(Window* parent) : FormWindow(parent, rect_t{})
{ {
FlexGridLayout grid(col_two_dsc, row_dsc, 2); FlexGridLayout grid(col_two_dsc, row_dsc, 2);
setFlexLayout(); setFlexLayout();
@@ -67,9 +69,9 @@ HWSticks::HWSticks(Window* parent) : FormGroup(parent, rect_t{})
#endif #endif
} }
HWPots::HWPots(Window* parent) : FormGroup(parent, rect_t{}) HWPots::HWPots(Window* parent) : FormWindow(parent, rect_t{})
{ {
FlexGridLayout grid(col_two_dsc, row_dsc, 2); FlexGridLayout grid(col_three_dsc, row_dsc, 2);
setFlexLayout(); setFlexLayout();
auto max_pots = adcGetMaxInputs(ADC_INPUT_POT); auto max_pots = adcGetMaxInputs(ADC_INPUT_POT);
@@ -85,7 +87,7 @@ HWPots::HWPots(Window* parent) : FormGroup(parent, rect_t{})
new StaticText(line, rect_t{}, adcGetInputLabel(ADC_INPUT_POT, i), 0, new StaticText(line, rect_t{}, adcGetInputLabel(ADC_INPUT_POT, i), 0,
COLOR_THEME_PRIMARY1); COLOR_THEME_PRIMARY1);
auto box = new FormGroup(line, rect_t{}); auto box = new FormWindow(line, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(4)); box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(4));
auto box_obj = box->getLvObj(); auto box_obj = box->getLvObj();
@@ -147,24 +149,18 @@ class SwitchDynamicLabel : public StaticText
uint8_t lastpos = 0xff; uint8_t lastpos = 0xff;
}; };
HWSwitches::HWSwitches(Window* parent) : FormGroup(parent, rect_t{}) HWSwitches::HWSwitches(Window* parent) : FormWindow(parent, rect_t{})
{ {
FlexGridLayout grid(col_two_dsc, row_dsc, 2); FlexGridLayout grid(col_three_dsc, row_dsc, 2);
setFlexLayout(); setFlexLayout();
for (int i = 0; i < switchGetMaxSwitches(); i++) { for (int i = 0; i < switchGetMaxSwitches(); i++) {
auto line = newLine(&grid); auto line = newLine(&grid);
new SwitchDynamicLabel(line, i); new SwitchDynamicLabel(line, i);
auto box = new FormGroup(line, rect_t{}); new HWInputEdit(line, (char*)switchGetCustomName(i), LEN_SWITCH_NAME);
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(4));
auto box_obj = box->getLvObj();
lv_obj_set_style_flex_cross_place(box_obj, LV_FLEX_ALIGN_CENTER, 0);
new HWInputEdit(box, (char*)switchGetCustomName(i), LEN_SWITCH_NAME);
new Choice( new Choice(
box, rect_t{}, STR_SWTYPES, SWITCH_NONE, switchGetMaxType(i), line, rect_t{}, STR_SWTYPES, SWITCH_NONE, switchGetMaxType(i),
[=]() -> int { return SWITCH_CONFIG(i); }, [=]() -> int { return SWITCH_CONFIG(i); },
[=](int newValue) { [=](int newValue) {
swconfig_t mask = (swconfig_t)SWITCH_CONFIG_MASK(i); swconfig_t mask = (swconfig_t)SWITCH_CONFIG_MASK(i);
+3 -4
View File
@@ -25,16 +25,15 @@
#include "dialog.h" #include "dialog.h"
#include "button.h" #include "button.h"
struct HWSticks : public FormGroup { struct HWSticks : public FormWindow {
HWSticks(Window* parent); HWSticks(Window* parent);
}; };
struct HWPots : public FormGroup { struct HWPots : public FormWindow {
HWPots(Window* parent); HWPots(Window* parent);
}; };
struct HWSwitches : public FormWindow {
struct HWSwitches : public FormGroup {
HWSwitches(Window* parent); HWSwitches(Window* parent);
}; };
+4 -4
View File
@@ -34,7 +34,7 @@ static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(3),
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
InternalModuleWindow::InternalModuleWindow(Window *parent) : InternalModuleWindow::InternalModuleWindow(Window *parent) :
FormGroup::Line(parent), FormWindow::Line(parent),
lastModule(g_eeGeneral.internalModule) lastModule(g_eeGeneral.internalModule)
{ {
FlexGridLayout grid(col_dsc, row_dsc, 2); FlexGridLayout grid(col_dsc, row_dsc, 2);
@@ -42,7 +42,7 @@ InternalModuleWindow::InternalModuleWindow(Window *parent) :
new StaticText(this, rect_t{}, STR_TYPE, 0, COLOR_THEME_PRIMARY1); new StaticText(this, rect_t{}, STR_TYPE, 0, COLOR_THEME_PRIMARY1);
auto box = new FormGroup(this, rect_t{}); auto box = new FormWindow(this, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0); lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
@@ -55,7 +55,7 @@ InternalModuleWindow::InternalModuleWindow(Window *parent) :
[](int module) { return isInternalModuleSupported(module); }); [](int module) { return isInternalModuleSupported(module); });
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA) #if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
auto pxx1_box = new FormGroup(box, rect_t{}); auto pxx1_box = new FormWindow(box, rect_t{});
pxx1_box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); pxx1_box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
ant_box = pxx1_box->getLvObj(); ant_box = pxx1_box->getLvObj();
@@ -87,7 +87,7 @@ InternalModuleWindow::InternalModuleWindow(Window *parent) :
#endif #endif
#if defined(CROSSFIRE) #if defined(CROSSFIRE)
auto crsf_box = new FormGroup(box, rect_t{}); auto crsf_box = new FormWindow(box, rect_t{});
crsf_box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); crsf_box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
br_box = crsf_box->getLvObj(); br_box = crsf_box->getLvObj();
+1 -1
View File
@@ -23,7 +23,7 @@
#include "form.h" #include "form.h"
class InternalModuleWindow : public FormGroup::Line class InternalModuleWindow : public FormWindow::Line
{ {
public: public:
InternalModuleWindow(Window *parent); InternalModuleWindow(Window *parent);
+3 -3
View File
@@ -30,7 +30,7 @@ static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(3),
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
SerialConfigWindow::SerialConfigWindow(Window *parent, const rect_t &rect) : SerialConfigWindow::SerialConfigWindow(Window *parent, const rect_t &rect) :
FormGroup(parent, rect, FORWARD_SCROLL) FormWindow(parent, rect)
{ {
setFlexLayout(); setFlexLayout();
FlexGridLayout grid(col_dsc, row_dsc, 2); FlexGridLayout grid(col_dsc, row_dsc, 2);
@@ -45,7 +45,7 @@ SerialConfigWindow::SerialConfigWindow(Window *parent, const rect_t &rect) :
auto line = newLine(&grid); auto line = newLine(&grid);
new StaticText(line, rect_t{}, port->name, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, port->name, 0, COLOR_THEME_PRIMARY1);
auto box = new FormGroup(line, rect_t{}); auto box = new FormWindow(line, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0); lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
lv_obj_set_style_flex_cross_place(box->getLvObj(), LV_FLEX_ALIGN_CENTER, 0); lv_obj_set_style_flex_cross_place(box->getLvObj(), LV_FLEX_ALIGN_CENTER, 0);
@@ -64,7 +64,7 @@ SerialConfigWindow::SerialConfigWindow(Window *parent, const rect_t &rect) :
if (port->set_pwr != nullptr) { if (port->set_pwr != nullptr) {
new StaticText(box, rect_t{}, STR_AUX_SERIAL_PORT_POWER, 0, new StaticText(box, rect_t{}, STR_AUX_SERIAL_PORT_POWER, 0,
COLOR_THEME_PRIMARY1); COLOR_THEME_PRIMARY1);
new CheckBox( new ToggleSwitch(
box, rect_t{}, [=] { return serialGetPower(port_nr); }, box, rect_t{}, [=] { return serialGetPower(port_nr); },
[=](int8_t newValue) { [=](int8_t newValue) {
serialSetPower(port_nr, (bool)newValue); serialSetPower(port_nr, (bool)newValue);
+1 -1
View File
@@ -23,7 +23,7 @@
#include "form.h" #include "form.h"
class SerialConfigWindow : public FormGroup class SerialConfigWindow : public FormWindow
{ {
public: public:
SerialConfigWindow(Window *parent, const rect_t &rect); SerialConfigWindow(Window *parent, const rect_t &rect);
@@ -22,8 +22,6 @@
#include "input_mix_group.h" #include "input_mix_group.h"
#include "channel_bar.h" #include "channel_bar.h"
#include "lvgl_widgets/input_mix_group.h"
#include "opentx.h" #include "opentx.h"
#include <algorithm> #include <algorithm>
+1 -1
View File
@@ -102,7 +102,7 @@ InputSource::InputSource(Window* parent, ExpoData* input) :
}); });
lv_obj_add_event_cb(lvobj, InputSource::value_changed, LV_EVENT_VALUE_CHANGED, nullptr); lv_obj_add_event_cb(lvobj, InputSource::value_changed, LV_EVENT_VALUE_CHANGED, nullptr);
sensor_form = new FormGroup(this, rect_t{}); sensor_form = new FormWindow(this, rect_t{});
sensor_form->setFlexLayout(); sensor_form->setFlexLayout();
FlexGridLayout grid(col_dsc, row_dsc); FlexGridLayout grid(col_dsc, row_dsc);
+2 -2
View File
@@ -24,12 +24,12 @@
#include "window.h" #include "window.h"
struct ExpoData; struct ExpoData;
class FormGroup; class FormWindow;
class InputSource : public Window class InputSource : public Window
{ {
ExpoData* input; ExpoData* input;
FormGroup* sensor_form; FormWindow* sensor_form;
void update(); void update();
static void value_changed(lv_event_t* e); static void value_changed(lv_event_t* e);
-94
View File
@@ -1,94 +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.
*/
#include "keyboard_curve.h"
#include "button.h"
#include "translations/untranslated.h"
constexpr coord_t KEYBOARD_HEIGHT = 110;
CurveKeyboard * CurveKeyboard::_instance = nullptr;
CurveKeyboard::CurveKeyboard() :
Keyboard(KEYBOARD_HEIGHT)
{
// up
new TextButton(this, {LCD_W / 2 - 20, 5, 40, 40}, STR_CHAR_UP,
[=]() -> uint8_t {
pushEvent(EVT_VIRTUAL_KEY_UP);
return 0;
}, BUTTON_BACKGROUND | OPAQUE | NO_FOCUS);
// down
new TextButton(this, {LCD_W / 2 - 20, 65, 40, 40}, STR_CHAR_DOWN,
[=]() -> uint8_t {
pushEvent(EVT_VIRTUAL_KEY_DOWN);
return 0;
}, BUTTON_BACKGROUND | OPAQUE | NO_FOCUS);
// left
left = new TextButton(this, {LCD_W / 2 - 70, 35, 40, 40}, STR_CHAR_LEFT,
[=]() -> uint8_t {
pushEvent(EVT_VIRTUAL_KEY_LEFT);
return 0;
}, BUTTON_BACKGROUND | OPAQUE | NO_FOCUS);
// right
right = new TextButton(this, {LCD_W / 2 + 30, 35, 40, 40}, STR_CHAR_RIGHT,
[=]() -> uint8_t {
pushEvent(EVT_VIRTUAL_KEY_RIGHT);
return 0;
}, BUTTON_BACKGROUND | OPAQUE | NO_FOCUS);
// next
new TextButton(this, {LCD_W / 2 + 80, 35, 60, 40}, "Next",
[=]() -> uint8_t {
pushEvent(EVT_VIRTUAL_KEY_NEXT);
return 0;
}, BUTTON_BACKGROUND | OPAQUE | NO_FOCUS);
// previous
new TextButton(this, {LCD_W / 2 - 140, 35, 60, 40}, "Prev",
[=]() -> uint8_t {
pushEvent(EVT_VIRTUAL_KEY_PREVIOUS);
return 0;
}, BUTTON_BACKGROUND | OPAQUE | NO_FOCUS);
}
void CurveKeyboard::enableRightLeft(bool enable)
{
TRACE("STOP %d", enable);
left->enable(enable);
right->enable(enable);
}
CurveKeyboard::~CurveKeyboard()
{
_instance = nullptr;
}
void CurveKeyboard::paint(BitmapBuffer * dc)
{
lcdSetColor(RGB(0xE0, 0xE0, 0xE0));
dc->clear(CUSTOM_COLOR);
}
-60
View File
@@ -1,60 +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.
*/
#ifndef _KEYBOARD_CURVE_H_
#define _KEYBOARD_CURVE_H_
#include "keyboard_base.h"
class Button;
class CurveKeyboard : public Keyboard {
public:
CurveKeyboard();
~CurveKeyboard() override;
#if defined(DEBUG_WINDOWS)
std::string getName() const override
{
return "CurveKeyboard";
}
#endif
void enableRightLeft(bool enable);
static void show(FormField * field, bool enableRightLeft)
{
if (!_instance)
_instance = new CurveKeyboard();
_instance->setField(field);
_instance->enableRightLeft(enableRightLeft);
}
void paint(BitmapBuffer * dc) override;
protected:
static CurveKeyboard * _instance;
Button * left = nullptr;
Button * right = nullptr;
};
#endif // _KEYBOARD_CURVE_H_
@@ -88,7 +88,7 @@ void Layout::updateFromTheme()
// Hack to fix flight mode color on main view // Hack to fix flight mode color on main view
// Required because theme is loaded after the main view has been created // Required because theme is loaded after the main view has been created
if (decoration) if (decoration)
decoration->setFlightModeColor(); decoration->updateFromTheme();
} }
void Layout::adjustLayout() void Layout::adjustLayout()
+13 -47
View File
@@ -25,26 +25,9 @@
#include "hal/adc_driver.h" #include "hal/adc_driver.h"
enum slider_type { constexpr coord_t MULTIPOS_H = 18;
SLIDER_HORIZ, constexpr coord_t MULTIPOS_W_SPACING = 12;
SLIDER_6POS, constexpr coord_t MULTIPOS_W = (6+1)*MULTIPOS_W_SPACING;
};
static void slider_self_size(lv_event_t* e)
{
lv_point_t* s = (lv_point_t*)lv_event_get_param(e);
slider_type t = (slider_type)(intptr_t)lv_event_get_user_data(e);
switch(t) {
case SLIDER_HORIZ:
s->x = HORIZONTAL_SLIDERS_WIDTH;
s->y = TRIM_SQUARE_SIZE;
break;
case SLIDER_6POS:
s->x = MULTIPOS_W;
s->y = MULTIPOS_H;
break;
}
}
MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect,
uint8_t idx) : uint8_t idx) :
@@ -65,27 +48,21 @@ void MainViewSlider::checkEvents()
MainViewHorizontalSlider::MainViewHorizontalSlider(Window* parent, MainViewHorizontalSlider::MainViewHorizontalSlider(Window* parent,
uint8_t idx) : uint8_t idx) :
MainViewSlider(parent, rect_t{}, idx) MainViewSlider(parent, rect_t{0, 0, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE}, idx)
{ {
void* user_data = (void*)SLIDER_HORIZ;
lv_obj_add_event_cb(lvobj, slider_self_size, LV_EVENT_GET_SELF_SIZE,
user_data);
setWidth(HORIZONTAL_SLIDERS_WIDTH);
setHeight(TRIM_SQUARE_SIZE);
} }
void MainViewHorizontalSlider::paint(BitmapBuffer * dc) void MainViewHorizontalSlider::paint(BitmapBuffer * dc)
{ {
// The ticks // The ticks
int delta = (width() - TRIM_SQUARE_SIZE) / SLIDER_TICKS_COUNT; int sliderTicksCount = (width() - TRIM_SQUARE_SIZE) / SLIDER_TICK_SPACING;
coord_t x = TRIM_SQUARE_SIZE / 2; coord_t x = TRIM_SQUARE_SIZE / 2;
for (uint8_t i = 0; i <= SLIDER_TICKS_COUNT; i++) { for (uint8_t i = 0; i <= sliderTicksCount; i++) {
if (i == 0 || i == SLIDER_TICKS_COUNT / 2 || i == SLIDER_TICKS_COUNT) if (i == 0 || i == sliderTicksCount / 2 || i == SLIDER_TICKS_COUNT)
dc->drawSolidVerticalLine(x, 2, 13, COLOR_THEME_SECONDARY1); dc->drawSolidVerticalLine(x, 2, 13, COLOR_THEME_SECONDARY1);
else else
dc->drawSolidVerticalLine(x, 4, 9, COLOR_THEME_SECONDARY1); dc->drawSolidVerticalLine(x, 4, 9, COLOR_THEME_SECONDARY1);
x += delta; x += SLIDER_TICK_SPACING;
} }
// The square // The square
@@ -94,14 +71,8 @@ void MainViewHorizontalSlider::paint(BitmapBuffer * dc)
} }
MainView6POS::MainView6POS(Window* parent, uint8_t idx) : MainView6POS::MainView6POS(Window* parent, uint8_t idx) :
MainViewSlider(parent, rect_t{}, idx) MainViewSlider(parent, rect_t{0, 0, MULTIPOS_W, MULTIPOS_H}, idx)
{ {
void* user_data = (void*)SLIDER_6POS;
lv_obj_add_event_cb(lvobj, slider_self_size, LV_EVENT_GET_SELF_SIZE,
user_data);
setWidth(MULTIPOS_W);
setHeight(MULTIPOS_H);
} }
void MainView6POS::paint(BitmapBuffer * dc) void MainView6POS::paint(BitmapBuffer * dc)
@@ -129,27 +100,22 @@ void MainView6POS::checkEvents()
} }
} }
MainViewVerticalSlider::MainViewVerticalSlider(Window* parent, uint8_t idx) : MainViewVerticalSlider::MainViewVerticalSlider(Window* parent, const rect_t& rect, uint8_t idx) :
MainViewSlider(parent, rect_t{}, idx) MainViewSlider(parent, rect, idx)
{ {
lv_obj_set_style_max_height(lvobj, VERTICAL_SLIDERS_HEIGHT, 0);
lv_obj_set_style_min_height(lvobj, VERTICAL_SLIDERS_HEIGHT/2, 0);
lv_obj_set_style_flex_grow(lvobj, 1, 0);
setWidth(TRIM_SQUARE_SIZE);
} }
void MainViewVerticalSlider::paint(BitmapBuffer * dc) void MainViewVerticalSlider::paint(BitmapBuffer * dc)
{ {
// The ticks // The ticks
int delta = 4; int sliderTicksCount = (height() - TRIM_SQUARE_SIZE) / SLIDER_TICK_SPACING;
int sliderTicksCount = (height() - TRIM_SQUARE_SIZE) / delta;
coord_t y = TRIM_SQUARE_SIZE / 2; coord_t y = TRIM_SQUARE_SIZE / 2;
for (uint8_t i = 0; i <= sliderTicksCount; i++) { for (uint8_t i = 0; i <= sliderTicksCount; i++) {
if (i == 0 || i == sliderTicksCount / 2 || i == sliderTicksCount) if (i == 0 || i == sliderTicksCount / 2 || i == sliderTicksCount)
dc->drawSolidHorizontalLine(2, y, 13, COLOR_THEME_SECONDARY1); dc->drawSolidHorizontalLine(2, y, 13, COLOR_THEME_SECONDARY1);
else else
dc->drawSolidHorizontalLine(4, y, 9, COLOR_THEME_SECONDARY1); dc->drawSolidHorizontalLine(4, y, 9, COLOR_THEME_SECONDARY1);
y += delta; y += SLIDER_TICK_SPACING;
} }
// The square // The square
+5 -9
View File
@@ -24,17 +24,14 @@
#include "libopenui.h" #include "libopenui.h"
#include "trims.h" #include "trims.h"
#if defined(PCBNV14) #if LCD_H > LCD_W
constexpr uint8_t SLIDER_TICKS_COUNT = 30; constexpr uint8_t SLIDER_TICKS_COUNT = 30;
#else #else
constexpr uint8_t SLIDER_TICKS_COUNT = 40; constexpr uint8_t SLIDER_TICKS_COUNT = 40;
#endif #endif
constexpr coord_t HMARGIN = 5; constexpr coord_t SLIDER_TICK_SPACING = 4;
constexpr coord_t HORIZONTAL_SLIDERS_WIDTH = SLIDER_TICKS_COUNT * 4 + TRIM_SQUARE_SIZE; constexpr coord_t HORIZONTAL_SLIDERS_WIDTH = SLIDER_TICKS_COUNT * SLIDER_TICK_SPACING + TRIM_SQUARE_SIZE;
constexpr coord_t MULTIPOS_H = 18; constexpr coord_t VERTICAL_SLIDERS_HEIGHT = SLIDER_TICKS_COUNT * SLIDER_TICK_SPACING + TRIM_SQUARE_SIZE;
constexpr coord_t MULTIPOS_W_SPACING = 12;
constexpr coord_t MULTIPOS_W = (6+1)*MULTIPOS_W_SPACING;
constexpr coord_t VERTICAL_SLIDERS_HEIGHT = SLIDER_TICKS_COUNT * 4 + TRIM_SQUARE_SIZE;
class MainViewSlider : public Window class MainViewSlider : public Window
{ {
@@ -58,7 +55,6 @@ class MainViewHorizontalSlider : public MainViewSlider
class MainView6POS : public MainViewSlider class MainView6POS : public MainViewSlider
{ {
public: public:
// using MainViewSlider::MainViewSlider;
MainView6POS(Window* parent, uint8_t idx); MainView6POS(Window* parent, uint8_t idx);
void paint(BitmapBuffer * dc) override; void paint(BitmapBuffer * dc) override;
void checkEvents() override; void checkEvents() override;
@@ -67,6 +63,6 @@ class MainView6POS : public MainViewSlider
class MainViewVerticalSlider : public MainViewSlider class MainViewVerticalSlider : public MainViewSlider
{ {
public: public:
MainViewVerticalSlider(Window* parent, uint8_t idx); MainViewVerticalSlider(Window* parent, const rect_t & rect, uint8_t idx);
void paint(BitmapBuffer * dc) override; void paint(BitmapBuffer * dc) override;
}; };
@@ -139,8 +139,7 @@ coord_t TopbarImpl::getVisibleHeight(float visible) const // 0.0 -> 1.0
void TopbarImpl::paint(BitmapBuffer * dc) void TopbarImpl::paint(BitmapBuffer * dc)
{ {
dc->drawSolidFilledRect(0, 0, width(), height(), COLOR_THEME_SECONDARY1); EdgeTxTheme::instance()->drawHeaderIcon(dc, ICON_EDGETX);
OpenTxTheme::instance()->drawTopLeftBitmap(dc);
const TimerOptions timerOptions = {.options = SHOW_TIME}; const TimerOptions timerOptions = {.options = SHOW_TIME};
struct gtm t; struct gtm t;
gettime(&t); gettime(&t);
+2 -33
View File
@@ -25,27 +25,6 @@
#include "opentx.h" #include "opentx.h"
enum trim_type {
TRIM_VERT,
TRIM_HORIZ,
};
static void trim_self_size(lv_event_t* e)
{
lv_point_t* s = (lv_point_t*)lv_event_get_param(e);
trim_type t = (trim_type)(intptr_t)lv_event_get_user_data(e);
switch(t) {
case TRIM_VERT:
s->y = VERTICAL_SLIDERS_HEIGHT;
s->x = TRIM_SQUARE_SIZE;
break;
case TRIM_HORIZ:
s->x = HORIZONTAL_SLIDERS_WIDTH;
s->y = TRIM_SQUARE_SIZE;
break;
}
}
MainViewTrim::MainViewTrim(Window * parent, const rect_t & rect, uint8_t idx): MainViewTrim::MainViewTrim(Window * parent, const rect_t & rect, uint8_t idx):
Window(parent, rect), Window(parent, rect),
idx(idx) idx(idx)
@@ -109,13 +88,8 @@ void MainViewTrim::paint(BitmapBuffer * dc)
} }
MainViewHorizontalTrim::MainViewHorizontalTrim(Window* parent, uint8_t idx) : MainViewHorizontalTrim::MainViewHorizontalTrim(Window* parent, uint8_t idx) :
MainViewTrim(parent, rect_t{}, idx) MainViewTrim(parent, rect_t{0, 0, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE}, idx)
{ {
void* user_data = (void*)TRIM_HORIZ;
lv_obj_add_event_cb(lvobj, trim_self_size, LV_EVENT_GET_SELF_SIZE, user_data);
setWidth(HORIZONTAL_SLIDERS_WIDTH);
setHeight(TRIM_SQUARE_SIZE);
} }
coord_t MainViewHorizontalTrim::sx() coord_t MainViewHorizontalTrim::sx()
@@ -153,13 +127,8 @@ void MainViewHorizontalTrim::drawValue(BitmapBuffer * dc)
} }
MainViewVerticalTrim::MainViewVerticalTrim(Window* parent, uint8_t idx) : MainViewVerticalTrim::MainViewVerticalTrim(Window* parent, uint8_t idx) :
MainViewTrim(parent, rect_t{}, idx) MainViewTrim(parent, rect_t{0, 0, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT}, idx)
{ {
void* user_data = (void*)TRIM_VERT;
lv_obj_add_event_cb(lvobj, trim_self_size, LV_EVENT_GET_SELF_SIZE, user_data);
setWidth(TRIM_SQUARE_SIZE);
setHeight(VERTICAL_SLIDERS_HEIGHT);
} }
coord_t MainViewVerticalTrim::sy() coord_t MainViewVerticalTrim::sy()
+2 -5
View File
@@ -22,7 +22,7 @@
#pragma once #pragma once
#if !defined(BOOT) #if !defined(BOOT)
#include "libopenui_config.h" #include "libopenui_defines.h"
#include "libopenui_file.h" #include "libopenui_file.h"
#include "font.h" #include "font.h"
#include "window.h" #include "window.h"
@@ -30,7 +30,7 @@
#include "static.h" #include "static.h"
#include "button.h" #include "button.h"
#include "fab_button.h" #include "fab_button.h"
#include "checkbox.h" #include "toggleswitch.h"
#include "numberedit.h" #include "numberedit.h"
#include "timeedit.h" #include "timeedit.h"
#include "choice.h" #include "choice.h"
@@ -39,10 +39,8 @@
#include "filechoice.h" #include "filechoice.h"
#include "textedit.h" #include "textedit.h"
#include "slider.h" #include "slider.h"
#include "progress.h"
#include "keyboard_text.h" #include "keyboard_text.h"
#include "keyboard_number.h" #include "keyboard_number.h"
#include "keyboard_curve.h"
#include "tabsgroup.h" #include "tabsgroup.h"
#include "page.h" #include "page.h"
#include "menu.h" #include "menu.h"
@@ -51,7 +49,6 @@
#include "message_dialog.h" #include "message_dialog.h"
#include "confirm_dialog.h" #include "confirm_dialog.h"
#include "dialog.h" #include "dialog.h"
#include "gridlayout.h"
#include "getset_helpers.h" #include "getset_helpers.h"
#include "curveedit.h" #include "curveedit.h"
#include "draw_functions.h" #include "draw_functions.h"
@@ -22,8 +22,6 @@
#include "list_line_button.h" #include "list_line_button.h"
#include "opentx.h" #include "opentx.h"
#include "lvgl_widgets/input_mix_line.h"
void ListLineButton::value_changed(lv_event_t* e) void ListLineButton::value_changed(lv_event_t* e)
{ {
auto obj = lv_event_get_target(e); auto obj = lv_event_get_target(e);
@@ -1,35 +0,0 @@
/*
* Copyright (C) EdgeTX
*
* 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 "input_mix_group.h"
#define MY_CLASS &input_mix_group_class
const lv_obj_class_t input_mix_group_class = {
.width_def = LV_PCT(100),
.height_def = LV_SIZE_CONTENT,
.editable = LV_OBJ_CLASS_EDITABLE_FALSE,
.group_def = LV_OBJ_CLASS_GROUP_DEF_FALSE,
.instance_size = sizeof(lv_obj_t),
.base_class = &lv_obj_class,
};
lv_obj_t* input_mix_group_create(lv_obj_t* parent)
{
LV_LOG_INFO("begin");
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
lv_obj_class_init_obj(obj);
return obj;
}
@@ -1,32 +0,0 @@
/*
* Copyright (C) EdgeTX
*
* 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.
*/
#ifndef INPUT_MIX_GROUP_H
#define INPUT_MIX_GROUP_H
#include <lvgl/lvgl.h>
#ifdef __cplusplus
extern "C" {
#endif
extern const lv_obj_class_t input_mix_group_class;
lv_obj_t* input_mix_group_create(lv_obj_t* parent);
#ifdef __cplusplus
};
#endif
#endif
@@ -1,34 +0,0 @@
/*
* Copyright (C) EdgeTX
*
* 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 "input_mix_line.h"
#define MY_CLASS &input_mix_line_class
const lv_obj_class_t input_mix_line_class = {
.width_def = LV_PCT(100),
.height_def = LV_SIZE_CONTENT,
.group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
.instance_size = sizeof(lv_btn_t),
.base_class = &lv_btn_class,
};
lv_obj_t* input_mix_line_create(lv_obj_t* parent)
{
LV_LOG_INFO("begin");
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
lv_obj_class_init_obj(obj);
return obj;
}
@@ -1,32 +0,0 @@
/*
* Copyright (C) EdgeTX
*
* 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.
*/
#ifndef INPUT_MIX_LINE_H
#define INPUT_MIX_LINE_H
#include <lvgl/lvgl.h>
#ifdef __cplusplus
extern "C" {
#endif
extern const lv_obj_class_t input_mix_line_class;
lv_obj_t* input_mix_line_create(lv_obj_t* parent);
#ifdef __cplusplus
};
#endif
#endif
+1 -1
View File
@@ -21,7 +21,7 @@
#include "lz4_bitmaps.h" #include "lz4_bitmaps.h"
#include "libopenui/thirdparty/lz4/lz4.h" #include "libopenui/thirdparty/lz4/lz4.h"
#include "libopenui_helpers.h" #include "opentx_helpers.h"
const uint8_t* _decompressed_mask(const uint8_t* lz4_compressed, uint8_t** raw) const uint8_t* _decompressed_mask(const uint8_t* lz4_compressed, uint8_t** raw)
{ {
-200
View File
@@ -1,200 +0,0 @@
class Window
{
public:
Window(coord_t x, coord_t y, coord_t width, coord_t height):
x(x),
y(y),
width(width),
height(height),
offsetX(0),
offsetY(0),
innerWidth(width),
innerHeight(height),
focusX(-1),
focusY(-1)
{
}
coord_t x, y, width, height, offsetX, offsetY, innerWidth, innerHeight, focusX, focusY;
void scroll() {
if (touchState.Event == TE_SLIDE) {
if (innerHeight > height && touchState.startX >= this->x && touchState.startX <= this->x + this->width) {
this->offsetY = limit<coord_t>(-innerHeight + height, this->offsetY + touchState.Y - touchState.startY, 0);
touchState.startY = touchState.Y;
}
if (innerWidth > width && touchState.startY >= this->y && touchState.startY <= this->y + this->height) {
this->offsetX = limit<coord_t>(-innerWidth + width, this->offsetX + touchState.X - touchState.startX, 0);
touchState.startX = touchState.X;
}
}
}
bool touchPressed(coord_t x, coord_t y, coord_t w, coord_t h) {
return ::touchPressed(this->x + this->offsetX + x, this->y + this->offsetY + y, w, h);
}
void setHeight(coord_t height) {
this->height = height;
}
void setInnerWidth(coord_t value) {
innerWidth = value;
}
void setInnerHeight(coord_t value) {
innerHeight = value;
}
void setFocus(coord_t x, coord_t y) {
focusX = x;
focusY = y;
}
void clearFocus() {
setFocus(-1, -1);
}
bool hasFocus(coord_t x, coord_t y) {
return (x == focusX && y == focusY);
}
void drawVerticalScrollbar();
void drawSolidFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags flags)
{
setClippingRect();
lcd->drawSolidFilledRect(this->x + this->offsetX + x, this->y + this->offsetY + y, w, h, flags);
clearLcdLimits();
}
template<class T>
void drawBitmap(coord_t x, coord_t y, const T * bmp, coord_t srcx=0, coord_t srcy=0, coord_t w=0, coord_t h=0, float scale=0) {
if (this->offsetX + x >= this->width || this->offsetY + y >= this->height) {
return;
}
setClippingRect();
lcd->drawBitmap(this->x + this->offsetX + x, this->y + this->offsetY + y, bmp, srcx, srcy, w, h, scale);
clearLcdLimits();
}
inline void setClippingRect() {
lcd->setClippingRect(this->x, this->x + this->width, this->y, this->y + this->height);
}
inline void clearLcdLimits() {
lcd->clearClippingRect();
}
void drawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags flags) {
setClippingRect();
lcd->drawSizedText(this->x + this->offsetX + x, this->y + this->offsetY + y, s, len, flags);
clearLcdLimits();
}
};
template <class W>
bool Subtitle(W * window, rect_t & rect, const char * label)
{
rect.h = 14;
drawText(window, rect.x, rect.y, label, FONT(BOLD));
}
template <class W>
bool CheckBox(W * window, rect_t & rect, const char * label, uint8_t & value, LcdFlags flags=0)
{
rect.h = 30;
bool hasFocus = (flags & HAS_FOCUS) || window->hasFocus(rect.x, rect.y);
drawText(window, rect.x, rect.y+4, label);
coord_t x = rect.x + rect.w - 20;
if (hasFocus) {
window->drawSolidFilledRect(x-1, rect.y+8, 14, 14, COLOR_THEME_FOCUS);
window->drawSolidFilledRect(x+1, rect.y+10, 10, 10, COLOR_THEME_SECONDARY3);
if (value) {
window->drawSolidFilledRect(x+2, rect.y+11, 8, 8, COLOR_THEME_FOCUS);
}
}
else {
if (value) {
window->drawSolidFilledRect(x+2, rect.y+11, 8, 8, COLOR_THEME_FOCUS);
drawSolidRect(window, x, rect.y+9, 12, 12, 1, COLOR_THEME_PRIMARY3);
}
else {
drawSolidRect(window, x, rect.y+9, 12, 12, 1, COLOR_THEME_PRIMARY3);
}
}
if (window->touchPressed(rect.x, rect.y, rect.w, rect.h)) {
value ^= 1;
window->setFocus(rect.x, rect.y);
return true;
}
else {
return false;
}
}
template <class W>
void drawWidgetLabel(W * window, rect_t & rect, const char * label) {
drawText(window, rect.x, rect.y, label, TINSIZE);
}
template <class W>
void drawWidgetLine(W * window, rect_t & rect, LcdFlags color) {
window->drawSolidFilledRect(rect.x, rect.y + rect.h, rect.w, 1, color);
}
template <class W>
bool Choice(W * window, rect_t & rect, const char * label, const char * values, uint8_t & value, uint8_t vmin, uint8_t vmax, LcdFlags flags=0)
{
rect.h = 30;
bool hasFocus = (flags & HAS_FOCUS) || window->hasFocus(rect.x, rect.y);
LcdFlags textColor = 0;
LcdFlags lineColor = COLOR_THEME_DISABLED;
if (hasFocus) {
textColor = COLOR_THEME_FOCUS;
lineColor = COLOR_THEME_FOCUS;
}
drawTextAtIndex(window, rect.x, rect.y + 9, values, value, textColor);
drawWidgetLine(window, rect, lineColor);
drawWidgetLabel(window, rect, label);
if (window->touchPressed(rect.x, rect.y, rect.w, rect.h)) {
// value ^= 1;
window->setFocus(rect.x, rect.y);
return true;
}
else {
return false;
}
}
template <class W>
bool TextEdit(W * window, rect_t & rect, const char * label, char * value, uint8_t length, LcdFlags flags=0)
{
rect.h = 30;
bool hasFocus = (flags & HAS_FOCUS) || window->hasFocus(rect.x, rect.y);
LcdFlags textColor = 0;
LcdFlags lineColor = COLOR_THEME_DISABLED;
if (hasFocus) {
textColor = COLOR_THEME_FOCUS;
lineColor = COLOR_THEME_FOCUS;
}
if (!hasFocus && zlen(value, length) == 0)
menuBodyWindow.drawSizedText(rect.x, rect.y + 9, "---", length, textColor);
else
menuBodyWindow.drawSizedText(rect.x, rect.y + 9, value, length, ZCHAR | textColor);
drawWidgetLine(window, rect, lineColor);
drawWidgetLabel(window, rect, label);
if (window->touchPressed(rect.x, rect.y, rect.w, rect.h)) {
// value ^= 1;
window->setFocus(rect.x, rect.y);
return true;
}
else {
return false;
}
}
#define CHECKBOX(X, label, value) { rect.x = X; rect.w = LCD_W - (X) - 20; uint8_t _value = value; CheckBox(window, rect, label, _value); value = _value; rect.y += rect.h + 10; }
#define CHECKBOX_INVERTED(X, label, value) { rect.x = X; rect.w = LCD_W - (X) - 20; uint8_t _value = !value; CheckBox(window, rect, label, _value); value = !_value; rect.y += rect.h + 10; }
#endif
+1 -1
View File
@@ -121,7 +121,7 @@ void ModelMenu::onEvent(event_t event)
#if defined(PCBNV14) || defined(PCBPL18) #if defined(PCBNV14) || defined(PCBPL18)
void ModelMenu::addGoToMonitorsButton() void ModelMenu::addGoToMonitorsButton()
{ {
OpenTxTheme::instance()->createTextButton( new TextButton(
&header, {LCD_W / 2 + 6, MENU_TITLE_TOP + 1, LCD_W / 2 - 8, MENU_TITLE_HEIGHT - 2}, &header, {LCD_W / 2 + 6, MENU_TITLE_TOP + 1, LCD_W / 2 - 8, MENU_TITLE_HEIGHT - 2},
STR_OPEN_CHANNEL_MONITORS, [=]() { STR_OPEN_CHANNEL_MONITORS, [=]() {
pushEvent(EVT_KEY_FIRST(KEY_MODEL)); pushEvent(EVT_KEY_FIRST(KEY_MODEL));
+1 -1
View File
@@ -27,7 +27,7 @@
extern uint8_t menuCalibrationState; extern uint8_t menuCalibrationState;
enum MenuIcons { enum MenuIcons {
ICON_OPENTX, ICON_EDGETX,
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
ICON_NEXT, ICON_NEXT,
ICON_BACK, ICON_BACK,
+1 -1
View File
@@ -25,7 +25,7 @@
#include "form.h" #include "form.h"
#include "curve.h" #include "curve.h"
class FormGroup; class FormWindow;
class MixEditWindow : public Page class MixEditWindow : public Page
{ {
+8 -10
View File
@@ -77,38 +77,36 @@ void MixEditAdvanced::buildBody(FormWindow* form)
// Trim // Trim
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_TRIM, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_TRIM, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_INVERTED(mix->carryTrim)); new ToggleSwitch(line, rect_t{}, GET_SET_INVERTED(mix->carryTrim));
// Warning // Warning
new StaticText(line, rect_t{}, STR_MIXWARNING, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_MIXWARNING, 0, COLOR_THEME_PRIMARY1);
auto edit = new NumberEdit(line, rect_t{}, 0, 3, GET_SET_DEFAULT(mix->mixWarn)); auto edit = new NumberEdit(line, rect_t{0, 0, 100, 0}, 0, 3, GET_SET_DEFAULT(mix->mixWarn));
edit->setZeroText(STR_OFF); edit->setZeroText(STR_OFF);
// Delay up // Delay up
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_DELAYUP, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_DELAYUP, 0, COLOR_THEME_PRIMARY1);
edit = new NumberEdit(line, rect_t{}, 0, DELAY_MAX, GET_DEFAULT(mix->delayUp), edit = new NumberEdit(line, rect_t{0, 0, 100, 0}, 0, DELAY_MAX, GET_DEFAULT(mix->delayUp),
SET_VALUE(mix->delayUp, newValue), 0, PREC1); SET_VALUE(mix->delayUp, newValue), 0, PREC1);
edit->setSuffix("s"); edit->setSuffix("s");
// Delay down // Delay down
new StaticText(line, rect_t{}, STR_DELAYDOWN, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_DELAYDOWN, 0, COLOR_THEME_PRIMARY1);
edit = edit = new NumberEdit(line, rect_t{0, 0, 100, 0}, 0, DELAY_MAX, GET_DEFAULT(mix->delayDown),
new NumberEdit(line, rect_t{}, 0, DELAY_MAX, GET_DEFAULT(mix->delayDown), SET_VALUE(mix->delayDown, newValue), 0, PREC1);
SET_VALUE(mix->delayDown, newValue), 0, PREC1);
edit->setSuffix("s"); edit->setSuffix("s");
// Slow up // Slow up
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_SLOWUP, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_SLOWUP, 0, COLOR_THEME_PRIMARY1);
edit = new NumberEdit(line, rect_t{}, 0, DELAY_MAX, GET_DEFAULT(mix->speedUp), edit = new NumberEdit(line, rect_t{0, 0, 100, 0}, 0, DELAY_MAX, GET_DEFAULT(mix->speedUp),
SET_VALUE(mix->speedUp, newValue), 0, PREC1); SET_VALUE(mix->speedUp, newValue), 0, PREC1);
edit->setSuffix("s"); edit->setSuffix("s");
// Slow down // Slow down
new StaticText(line, rect_t{}, STR_SLOWDOWN, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_SLOWDOWN, 0, COLOR_THEME_PRIMARY1);
edit = edit = new NumberEdit(line, rect_t{0, 0, 100, 0}, 0, DELAY_MAX, GET_DEFAULT(mix->speedDown),
new NumberEdit(line, rect_t{}, 0, DELAY_MAX, GET_DEFAULT(mix->speedDown), SET_VALUE(mix->speedDown, newValue), 0, PREC1);
SET_VALUE(mix->speedDown, newValue), 0, PREC1);
edit->setSuffix("s"); edit->setSuffix("s");
} }
+1 -1
View File
@@ -25,7 +25,7 @@
#include "form.h" #include "form.h"
#include "curve.h" #include "curve.h"
class FormGroup; class FormWindow;
class MixEditAdvanced : public Page class MixEditAdvanced : public Page
{ {
+2 -7
View File
@@ -42,7 +42,7 @@ DEFINE_LZ4_BITMAP(LBM_DOT);
class CurveButton : public Button { class CurveButton : public Button {
public: public:
CurveButton(Window * parent, const rect_t &rect, uint8_t index) : CurveButton(Window * parent, const rect_t &rect, uint8_t index) :
Button(parent, rect, nullptr, 0, 0, lv_btn_create), Button(parent, rect, nullptr, 0, 0, etx_button_create),
index(index) index(index)
{ {
padAll(0); padAll(0);
@@ -207,12 +207,11 @@ void ModelCurvesPage::build(FormWindow * window)
FlexGridLayout grid(col_dsc, row_dsc); FlexGridLayout grid(col_dsc, row_dsc);
FormWindow::Line* line; FormWindow::Line* line = nullptr;
bool hasFocusButton = false; bool hasFocusButton = false;
uint8_t curveIndex = 0; uint8_t curveIndex = 0;
uint8_t firstCurveIndex;
CurveButton* firstCurveButton = nullptr; CurveButton* firstCurveButton = nullptr;
for (uint8_t index = 0; index < MAX_CURVES; index++) { for (uint8_t index = 0; index < MAX_CURVES; index++) {
@@ -222,9 +221,6 @@ void ModelCurvesPage::build(FormWindow * window)
lv_obj_set_grid_align(line->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN, LV_GRID_ALIGN_SPACE_BETWEEN); lv_obj_set_grid_align(line->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN, LV_GRID_ALIGN_SPACE_BETWEEN);
} }
CurveHeader &curve = g_model.curves[index];
int8_t * points = curveAddress(index);
// Curve drawing // Curve drawing
auto button = new CurveButton(line, rect_t{0, 0, CURVE_BTN_W, CURVE_BTH_H}, index); auto button = new CurveButton(line, rect_t{0, 0, CURVE_BTN_W, CURVE_BTH_H}, index);
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
@@ -260,7 +256,6 @@ void ModelCurvesPage::build(FormWindow * window)
}); });
if (!firstCurveButton) { if (!firstCurveButton) {
firstCurveIndex = index;
firstCurveButton = button; firstCurveButton = button;
} }
+2 -6
View File
@@ -22,8 +22,6 @@
#include "model_flightmodes.h" #include "model_flightmodes.h"
#include "opentx.h" #include "opentx.h"
#include "libopenui.h" #include "libopenui.h"
#include "lvgl_widgets/input_mix_line.h"
#include "hal/key_driver.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -68,11 +66,9 @@ class FlightModeEdit : public Page
header.setTitle(STR_MENUFLIGHTMODES); header.setTitle(STR_MENUFLIGHTMODES);
header.setTitle2(title2); header.setTitle2(title2);
body.padAll(lv_dpx(8));
lv_obj_set_scrollbar_mode(body.getLvObj(), LV_SCROLLBAR_MODE_AUTO);
FlexGridLayout grid(line_col_dsc, line_row_dsc, 2); FlexGridLayout grid(line_col_dsc, line_row_dsc, 2);
auto form = new FormWindow(&body, rect_t{}); auto form = new FormWindow(&body, rect_t{});
form->padAll(8);
form->setFlexLayout(); form->setFlexLayout();
FlightModeData* p_fm = &g_model.flightModeData[index]; FlightModeData* p_fm = &g_model.flightModeData[index];
@@ -116,7 +112,7 @@ class FlightModeEdit : public Page
line->padLeft(10); line->padLeft(10);
} }
auto trim = new FormGroup(line, rect_t{}); auto trim = new FormWindow(line, rect_t{});
trim->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); trim->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
auto trim_obj = trim->getLvObj(); auto trim_obj = trim->getLvObj();
+2 -3
View File
@@ -23,7 +23,6 @@
#include "model_gvars.h" #include "model_gvars.h"
#include "libopenui.h" #include "libopenui.h"
#include "numberedit.h" #include "numberedit.h"
#include "lvgl_widgets/input_mix_line.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -86,7 +85,7 @@ class GVarStyle
// Always update colors in case theme changes // Always update colors in case theme changes
lv_style_set_bg_color(&fmContStyle, makeLvColor(COLOR_THEME_PRIMARY2)); lv_style_set_bg_color(&fmContStyle, makeLvColor(COLOR_THEME_PRIMARY2));
lv_style_set_bg_color(&fmContStyleChecked, makeLvColor(COLOR_THEME_SECONDARY3)); lv_style_set_bg_color(&fmContStyleChecked, makeLvColor(COLOR_THEME_ACTIVE));
lv_style_set_text_color(&fmLabelStyle, makeLvColor(COLOR_THEME_SECONDARY1)); lv_style_set_text_color(&fmLabelStyle, makeLvColor(COLOR_THEME_SECONDARY1));
lv_style_set_text_color(&fmValueStyle, makeLvColor(COLOR_THEME_SECONDARY1)); lv_style_set_text_color(&fmValueStyle, makeLvColor(COLOR_THEME_SECONDARY1));
lv_style_set_text_color(&fmNameStyle, makeLvColor(COLOR_THEME_SECONDARY1)); lv_style_set_text_color(&fmNameStyle, makeLvColor(COLOR_THEME_SECONDARY1));
@@ -515,7 +514,7 @@ class GVarEditWindow : public Page
} }
if (flightMode > 0) { if (flightMode > 0) {
auto cb = new CheckBox( auto cb = new ToggleSwitch(
line, rect_t{}, [=] { return fmData->gvars[index] <= GVAR_MAX; }, line, rect_t{}, [=] { return fmData->gvars[index] <= GVAR_MAX; },
[=](uint8_t checked) { [=](uint8_t checked) {
fmData->gvars[index] = checked ? 0 : GVAR_MAX + 1; fmData->gvars[index] = checked ? 0 : GVAR_MAX + 1;
+1 -1
View File
@@ -23,7 +23,7 @@
#include "opentx.h" #include "opentx.h"
#include "gvar_numberedit.h" #include "gvar_numberedit.h"
#include "libopenui.h" #include "libopenui.h"
#include "choiceex.h" #include "choice.h"
#include "model_curves.h" #include "model_curves.h"
#include "input_edit.h" #include "input_edit.h"
#include "input_mix_group.h" #include "input_mix_group.h"
@@ -23,7 +23,6 @@
#include "opentx.h" #include "opentx.h"
#include "libopenui.h" #include "libopenui.h"
#include "switches.h" #include "switches.h"
#include "lvgl_widgets/input_mix_line.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -46,7 +45,7 @@ class LogicalSwitchEditPage : public Page
protected: protected:
uint8_t index; uint8_t index;
bool active = false; bool active = false;
FormGroup* logicalSwitchOneWindow = nullptr; FormWindow* logicalSwitchOneWindow = nullptr;
StaticText* headerSwitchName = nullptr; StaticText* headerSwitchName = nullptr;
NumberEdit* v2Edit = nullptr; NumberEdit* v2Edit = nullptr;
@@ -28,7 +28,6 @@
#include "translations.h" #include "translations.h"
#include "menus.h" #include "menus.h"
#include "libopenui.h" #include "libopenui.h"
#include "lvgl_widgets/input_mix_line.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -99,7 +98,7 @@ class ScriptEditWindow : public Page {
// File // File
auto line = form->newLine(&grid); auto line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_SCRIPT, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_SCRIPT, 0, COLOR_THEME_PRIMARY1);
auto fc = new FileChoice( new FileChoice(
line, rect_t{}, SCRIPTS_MIXES_PATH, SCRIPTS_EXT, line, rect_t{}, SCRIPTS_MIXES_PATH, SCRIPTS_EXT,
LEN_SCRIPT_FILENAME, LEN_SCRIPT_FILENAME,
[=]() { return stringFromNtString(sd->file); }, [=]() { return stringFromNtString(sd->file); },
@@ -121,7 +120,7 @@ class ScriptEditWindow : public Page {
if (sio->inputsCount > 0) { if (sio->inputsCount > 0) {
line = form->newLine(&grid); line = form->newLine(&grid);
new Subtitle(line, rect_t{}, STR_INPUTS, 0, COLOR_THEME_PRIMARY1); new Subtitle(line, STR_INPUTS);
for (int i = 0; i < sio->inputsCount; i++) { for (int i = 0; i < sio->inputsCount; i++) {
line = form->newLine(&grid); line = form->newLine(&grid);
@@ -140,7 +139,7 @@ class ScriptEditWindow : public Page {
if (sio->outputsCount > 0) { if (sio->outputsCount > 0) {
line = form->newLine(&grid); line = form->newLine(&grid);
new Subtitle(line, rect_t{}, STR_OUTPUTS, 0, COLOR_THEME_PRIMARY1); new Subtitle(line, STR_OUTPUTS);
for (int i = 0; i < sio->outputsCount; i++) { for (int i = 0; i < sio->outputsCount; i++) {
line = form->newLine(&grid); line = form->newLine(&grid);
@@ -173,9 +172,9 @@ class ScriptLineButton : public Button
const ScriptInternalData* runtimeData, const ScriptInternalData* runtimeData,
uint8_t index) : uint8_t index) :
Button(parent, rect, nullptr, 0, 0, input_mix_line_create), Button(parent, rect, nullptr, 0, 0, input_mix_line_create),
index(index),
scriptData(scriptData), scriptData(scriptData),
runtimeData(runtimeData), runtimeData(runtimeData)
index(index)
{ {
#if LCD_H > LCD_W #if LCD_H > LCD_W
padTop(5); padTop(5);
@@ -294,8 +293,6 @@ void ModelMixerScriptsPage::build(FormWindow * window, int8_t focusIdx)
FlexGridLayout grid(col_dsc, row_dsc, 2); FlexGridLayout grid(col_dsc, row_dsc, 2);
FormWindow::Line* line;
int8_t scriptIdx = 0; int8_t scriptIdx = 0;
for (int8_t idx = 0; idx < MAX_SCRIPTS; idx++) { for (int8_t idx = 0; idx < MAX_SCRIPTS; idx++) {
auto line = window->newLine(&grid); auto line = window->newLine(&grid);
+2 -2
View File
@@ -22,7 +22,7 @@
#include "model_mixes.h" #include "model_mixes.h"
#include "opentx.h" #include "opentx.h"
#include "libopenui.h" #include "libopenui.h"
#include "choiceex.h" #include "choice.h"
#include "bitfield.h" #include "bitfield.h"
#include "model_inputs.h" #include "model_inputs.h"
#include "gvar_numberedit.h" #include "gvar_numberedit.h"
@@ -532,7 +532,7 @@ void ModelMixesPage::build(FormWindow * window)
lv_obj_set_style_flex_cross_place(box_obj, LV_FLEX_ALIGN_CENTER, 0); lv_obj_set_style_flex_cross_place(box_obj, LV_FLEX_ALIGN_CENTER, 0);
new StaticText(box, rect_t{}, STR_SHOW_MIXER_MONITORS, 0, COLOR_THEME_PRIMARY1); new StaticText(box, rect_t{}, STR_SHOW_MIXER_MONITORS, 0, COLOR_THEME_PRIMARY1);
new CheckBox( new ToggleSwitch(
box, rect_t{}, [=]() { return showMonitors; }, box, rect_t{}, [=]() { return showMonitors; },
[=](uint8_t val) { enableMonitors(val); }); [=](uint8_t val) { enableMonitors(val); });
+1 -1
View File
@@ -314,7 +314,7 @@ void ModelOutputsPage::build(FormWindow *window)
lv_obj_set_style_flex_cross_place(box2->getLvObj(), LV_FLEX_ALIGN_CENTER, 0); lv_obj_set_style_flex_cross_place(box2->getLvObj(), LV_FLEX_ALIGN_CENTER, 0);
new StaticText(box2, rect_t{}, STR_ELIMITS, 0, COLOR_THEME_PRIMARY1); new StaticText(box2, rect_t{}, STR_ELIMITS, 0, COLOR_THEME_PRIMARY1);
auto cb = new CheckBox(box2, rect_t{}, GET_SET_DEFAULT(g_model.extendedLimits)); new ToggleSwitch(box2, rect_t{}, GET_SET_DEFAULT(g_model.extendedLimits));
for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) { for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) {
+13 -42
View File
@@ -78,7 +78,7 @@ constexpr coord_t MODEL_SELECT_CELL_WIDTH =
class ToolbarButton : public Button class ToolbarButton : public Button
{ {
public: public:
ToolbarButton(FormGroup *parent, const rect_t &rect, const uint8_t *bitmap, ToolbarButton(FormWindow *parent, const rect_t &rect, const uint8_t *bitmap,
std::function<uint8_t()> pressHandler = nullptr) : std::function<uint8_t()> pressHandler = nullptr) :
Button(parent, rect, pressHandler, 0), _bitmap(bitmap) Button(parent, rect, pressHandler, 0), _bitmap(bitmap)
{ {
@@ -240,7 +240,7 @@ class ButtonHolder : public FormWindow
class ModelButton : public Button class ModelButton : public Button
{ {
public: public:
ModelButton(FormGroup *parent, const rect_t &rect, ModelCell *modelCell, std::function<void()> setSelected) : ModelButton(FormWindow *parent, const rect_t &rect, ModelCell *modelCell, std::function<void()> setSelected) :
Button(parent, rect), modelCell(modelCell) Button(parent, rect), modelCell(modelCell)
{ {
m_setSelected = std::move(setSelected); m_setSelected = std::move(setSelected);
@@ -606,7 +606,7 @@ class LabelDialog : public Dialog
new TextEdit(form, rect_t{}, label, LABEL_LENGTH); new TextEdit(form, rect_t{}, label, LABEL_LENGTH);
auto box = new FormGroup(form, rect_t{}); auto box = new FormWindow(form, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW); box->setFlexLayout(LV_FLEX_FLOW_ROW);
auto box_obj = box->getLvObj(); auto box_obj = box->getLvObj();
@@ -738,7 +738,8 @@ void ModelLabelsWindow::newModel()
#if defined(LUA) #if defined(LUA)
// If there is a wizard Lua script, fire it up // If there is a wizard Lua script, fire it up
snprintf(path, LEN_BUFFER, "%s/%s%s", path, name.c_str(), SCRIPT_EXT); int len = strlen(path);
snprintf(path+len, LEN_BUFFER-len, "/%s%s", name.c_str(), SCRIPT_EXT);
if (f_stat(path, 0) == FR_OK) { if (f_stat(path, 0) == FR_OK) {
luaExec(path); luaExec(path);
StandaloneLuaWindow::instance()->attach(); StandaloneLuaWindow::instance()->attach();
@@ -898,7 +899,10 @@ void ModelLabelsWindow::buildBody(FormWindow *window)
new ProgressDialog(this, STR_RENAME_LABEL, [=]() {}); new ProgressDialog(this, STR_RENAME_LABEL, [=]() {});
modelslabels.renameLabel( modelslabels.renameLabel(
oldLabel, newLabel, [=](const char *name, int percentage) { oldLabel, newLabel, [=](const char *name, int percentage) {
rndialog->updateProgress(name, percentage); rndialog->setTitle(std::string(STR_RENAME_LABEL) + " " + name);
rndialog->updateProgress(percentage);
if (percentage >= 100)
rndialog->closeDialog();
}); });
auto labels = getLabels(); auto labels = getLabels();
lblselector->setNames(labels); lblselector->setNames(labels);
@@ -915,7 +919,10 @@ void ModelLabelsWindow::buildBody(FormWindow *window)
new ProgressDialog(this, STR_DELETE_LABEL, [=]() {}); new ProgressDialog(this, STR_DELETE_LABEL, [=]() {});
modelslabels.removeLabel( modelslabels.removeLabel(
labelToDelete, [=](const char *name, int percentage) { labelToDelete, [=](const char *name, int percentage) {
deldialog->updateProgress(name, percentage); deldialog->setTitle(std::string(STR_RENAME_LABEL) + " " + name);
deldialog->updateProgress(percentage);
if (percentage >= 100)
deldialog->closeDialog();
}); });
auto labels = getLabels(); auto labels = getLabels();
std::set<uint32_t> newset; std::set<uint32_t> newset;
@@ -989,39 +996,3 @@ void ModelLabelsWindow::setTitle()
header.setTitle(STR_MANAGE_MODELS); header.setTitle(STR_MANAGE_MODELS);
header.setTitle2(title2); header.setTitle2(title2);
} }
//-----------------------------------------------------------------------------
ProgressDialog::ProgressDialog(Window *parent, std::string title,
std::function<void()> onClose) :
Dialog(parent, title, rect_t{}),
progress(new Progress(&content->form, rect_t{})),
onClose(std::move(onClose)),
_title(title)
{
progress->setHeight(LV_DPI_DEF / 4);
content->setWidth(LCD_W * 0.8);
content->updateSize();
auto content_w = lv_obj_get_content_width(content->form.getLvObj());
progress->setWidth(content_w);
// disable canceling dialog
setCloseWhenClickOutside(false);
}
void ProgressDialog::updateProgress(const char *filename, int percentage)
{
content->setTitle(_title + " " + filename);
progress->setValue(percentage);
if (percentage >= 100) {
deleteLater();
onClose();
} else {
lv_refr_now(nullptr);
}
}
// disable keys
void ProgressDialog::onEvent(event_t) { return; }
-20
View File
@@ -106,24 +106,4 @@ class ModelLabelsWindow : public Page
void setTitle(); void setTitle();
}; };
class ProgressDialog : public Dialog
{
uint32_t lastUpdate = 0;
Progress *progress;
std::function<void()> onClose;
public:
ProgressDialog(Window *parent, std::string title,
std::function<void()> onClose);
void updateProgress(const char *filename, int percentage);
// disable keys
void onEvent(event_t) override;
protected:
std::string _title;
};
#endif // _MODEL_SELECT_H_ #endif // _MODEL_SELECT_H_
+6 -6
View File
@@ -110,7 +110,7 @@ SubScreenButton::SubScreenButton(Window* parent, const char* text,
Button(parent, rect_t{}, [=]() -> uint8_t { Button(parent, rect_t{}, [=]() -> uint8_t {
pressHandler(); pressHandler();
return 0; return 0;
}, 0, 0, lv_btn_create), }, 0, 0, etx_vbutton_create),
text(text) text(text)
{ {
lv_obj_add_event_cb(lvobj, SubScreenButton::event_cb, LV_EVENT_ALL, nullptr); lv_obj_add_event_cb(lvobj, SubScreenButton::event_cb, LV_EVENT_ALL, nullptr);
@@ -404,12 +404,12 @@ void ModelSetupPage::build(FormWindow * window)
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
auto oform = new FormGroup(window, rect_t{}); auto oform = new FormWindow(window, rect_t{});
oform->setFlexLayout(LV_FLEX_FLOW_COLUMN, lv_dpx(PAGE_PADDING)); oform->setFlexLayout(LV_FLEX_FLOW_COLUMN, lv_dpx(PAGE_PADDING));
oform->padAll(PAGE_PADDING); oform->padAll(PAGE_PADDING);
// Modules // Modules
auto form = new FormGroup(oform, rect_t{}); auto form = new FormWindow(oform, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING)); form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING));
lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc); lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc);
@@ -423,7 +423,7 @@ void ModelSetupPage::build(FormWindow * window)
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1); lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1);
// Timer buttons // Timer buttons
form = new FormGroup(oform, rect_t{}); form = new FormWindow(oform, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING)); form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING));
lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc); lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc);
@@ -436,7 +436,7 @@ void ModelSetupPage::build(FormWindow * window)
btn = new SubScreenButton(form, TR_TIMER "3", []() { new TimerWindow(2); }); btn = new SubScreenButton(form, TR_TIMER "3", []() { new TimerWindow(2); });
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1); lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1);
form = new FormGroup(oform, rect_t{}); form = new FormWindow(oform, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING)); form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING));
lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc); lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc);
@@ -449,7 +449,7 @@ void ModelSetupPage::build(FormWindow * window)
btn = new SubScreenButton(form, STR_THROTTLE_LABEL, []() { new ThrottleParams(); }); btn = new SubScreenButton(form, STR_THROTTLE_LABEL, []() { new ThrottleParams(); });
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1); lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1);
form = new FormGroup(oform, rect_t{}); form = new FormWindow(oform, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING)); form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING));
lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc); lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc);
+24 -19
View File
@@ -24,7 +24,6 @@
#include "model_telemetry.h" #include "model_telemetry.h"
#include "opentx.h" #include "opentx.h"
#include "libopenui.h" #include "libopenui.h"
#include "lvgl_widgets/input_mix_line.h"
#define SET_DIRTY() storageDirty(EE_MODEL) #define SET_DIRTY() storageDirty(EE_MODEL)
@@ -696,19 +695,19 @@ class SensorEditWindow : public Page {
paramLines[P_AUTOOFFSET] = form->newLine(&grid); paramLines[P_AUTOOFFSET] = form->newLine(&grid);
new StaticText(paramLines[P_AUTOOFFSET], rect_t{}, STR_AUTOOFFSET, 0, COLOR_THEME_PRIMARY1); new StaticText(paramLines[P_AUTOOFFSET], rect_t{}, STR_AUTOOFFSET, 0, COLOR_THEME_PRIMARY1);
new CheckBox(paramLines[P_AUTOOFFSET], rect_t{}, GET_SET_DEFAULT(sensor->autoOffset)); new ToggleSwitch(paramLines[P_AUTOOFFSET], rect_t{}, GET_SET_DEFAULT(sensor->autoOffset));
paramLines[P_ONLYPOS] = form->newLine(&grid); paramLines[P_ONLYPOS] = form->newLine(&grid);
new StaticText(paramLines[P_ONLYPOS], rect_t{}, STR_ONLYPOSITIVE, 0, COLOR_THEME_PRIMARY1); new StaticText(paramLines[P_ONLYPOS], rect_t{}, STR_ONLYPOSITIVE, 0, COLOR_THEME_PRIMARY1);
new CheckBox(paramLines[P_ONLYPOS], rect_t{}, GET_SET_DEFAULT(sensor->onlyPositive)); new ToggleSwitch(paramLines[P_ONLYPOS], rect_t{}, GET_SET_DEFAULT(sensor->onlyPositive));
paramLines[P_FILTER] = form->newLine(&grid); paramLines[P_FILTER] = form->newLine(&grid);
new StaticText(paramLines[P_FILTER], rect_t{}, STR_FILTER, 0, COLOR_THEME_PRIMARY1); new StaticText(paramLines[P_FILTER], rect_t{}, STR_FILTER, 0, COLOR_THEME_PRIMARY1);
new CheckBox(paramLines[P_FILTER], rect_t{}, GET_SET_DEFAULT(sensor->filter)); new ToggleSwitch(paramLines[P_FILTER], rect_t{}, GET_SET_DEFAULT(sensor->filter));
paramLines[P_PERSISTENT] = form->newLine(&grid); paramLines[P_PERSISTENT] = form->newLine(&grid);
new StaticText(paramLines[P_PERSISTENT], rect_t{}, STR_PERSISTENT, 0, COLOR_THEME_PRIMARY1); new StaticText(paramLines[P_PERSISTENT], rect_t{}, STR_PERSISTENT, 0, COLOR_THEME_PRIMARY1);
new CheckBox(paramLines[P_PERSISTENT], rect_t{}, GET_DEFAULT(sensor->persistent), [=](int32_t newValue) { new ToggleSwitch(paramLines[P_PERSISTENT], rect_t{}, GET_DEFAULT(sensor->persistent), [=](int32_t newValue) {
sensor->persistent = newValue; sensor->persistent = newValue;
if (!sensor->persistent) if (!sensor->persistent)
sensor->persistentValue = 0; sensor->persistentValue = 0;
@@ -718,7 +717,7 @@ class SensorEditWindow : public Page {
// Logs // Logs
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_LOGS, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_LOGS, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_DEFAULT(sensor->logs), [=](int32_t newValue) { new ToggleSwitch(line, rect_t{}, GET_DEFAULT(sensor->logs), [=](int32_t newValue) {
sensor->logs = newValue; sensor->logs = newValue;
logsClose(); logsClose();
SET_DIRTY(); SET_DIRTY();
@@ -804,7 +803,7 @@ void ModelTelemetryPage::buildSensorList(int8_t focusSensorIndex)
return; return;
} }
} }
for (uint8_t i = idx - 1; i >= 0; i -= 1) { for (int8_t i = idx - 1; i >= 0; i -= 1) {
if (g_model.telemetrySensors[i].isAvailable()) { if (g_model.telemetrySensors[i].isAvailable()) {
rebuild(window, i); rebuild(window, i);
return; return;
@@ -836,6 +835,12 @@ void ModelTelemetryPage::buildSensorList(int8_t focusSensorIndex)
} }
} }
#if LCD_W > LCD_H
#define NUM_EDIT_W 100
#else
#define NUM_EDIT_W 65
#endif
void ModelTelemetryPage::build(FormWindow * window) void ModelTelemetryPage::build(FormWindow * window)
{ {
window->padAll(4); window->padAll(4);
@@ -844,7 +849,7 @@ void ModelTelemetryPage::build(FormWindow * window)
this->window = window; this->window = window;
// Sensors // Sensors
new Subtitle(window, rect_t{}, STR_TELEMETRY_SENSORS, 0, COLOR_THEME_PRIMARY1); new Subtitle(window, STR_TELEMETRY_SENSORS);
sensorWindow = new FormWindow(window, rect_t{}); sensorWindow = new FormWindow(window, rect_t{});
sensorWindow->padAll(0); sensorWindow->padAll(0);
@@ -906,34 +911,34 @@ void ModelTelemetryPage::build(FormWindow * window)
line = window->newLine(&grid); line = window->newLine(&grid);
line->padLeft(10); line->padLeft(10);
new StaticText(line, rect_t{}, STR_SHOW_INSTANCE_ID, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_SHOW_INSTANCE_ID, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_DEFAULT(g_model.showInstanceIds)); new ToggleSwitch(line, rect_t{}, GET_SET_DEFAULT(g_model.showInstanceIds));
// Ignore instance button // Ignore instance button
line = window->newLine(&grid); line = window->newLine(&grid);
line->padLeft(10); line->padLeft(10);
new StaticText(line, rect_t{}, STR_IGNORE_INSTANCE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_IGNORE_INSTANCE, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_DEFAULT(g_model.ignoreSensorIds)); new ToggleSwitch(line, rect_t{}, GET_SET_DEFAULT(g_model.ignoreSensorIds));
// RX stat // RX stat
new Subtitle(window, rect_t{}, getRxStatLabels()->label, 0, COLOR_THEME_PRIMARY1); new Subtitle(window, getRxStatLabels()->label);
line = window->newLine(&grid); line = window->newLine(&grid);
line->padLeft(10); line->padLeft(10);
new StaticText(line, rect_t{}, STR_LOWALARM, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_LOWALARM, 0, COLOR_THEME_PRIMARY1);
new NumberEdit(line, rect_t{}, 0, 100, GET_SET_DEFAULT(g_model.rfAlarms.warning)); new NumberEdit(line, rect_t{0, 0, NUM_EDIT_W, 0}, 0, 100, GET_SET_DEFAULT(g_model.rfAlarms.warning));
line = window->newLine(&grid); line = window->newLine(&grid);
line->padLeft(10); line->padLeft(10);
new StaticText(line, rect_t{}, STR_CRITICALALARM, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_CRITICALALARM, 0, COLOR_THEME_PRIMARY1);
new NumberEdit(line, rect_t{}, 0, 100, GET_SET_DEFAULT(g_model.rfAlarms.critical)); new NumberEdit(line, rect_t{0, 0, NUM_EDIT_W, 0}, 0, 100, GET_SET_DEFAULT(g_model.rfAlarms.critical));
line = window->newLine(&grid); line = window->newLine(&grid);
line->padLeft(10); line->padLeft(10);
new StaticText(line, rect_t{}, STR_DISABLE_ALARM, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_DISABLE_ALARM, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_DEFAULT(g_model.disableTelemetryWarning)); new ToggleSwitch(line, rect_t{}, GET_SET_DEFAULT(g_model.disableTelemetryWarning));
// Vario // Vario
new Subtitle(window, rect_t{}, STR_VARIO, 0, COLOR_THEME_PRIMARY1); new Subtitle(window, STR_VARIO);
FlexGridLayout grid5(col_dsc5, row_dsc, 4); FlexGridLayout grid5(col_dsc5, row_dsc, 4);
@@ -956,20 +961,20 @@ void ModelTelemetryPage::build(FormWindow * window)
line->padLeft(10); line->padLeft(10);
new StaticText(line, rect_t{}, STR_RANGE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_RANGE, 0, COLOR_THEME_PRIMARY1);
auto vMin = new NumberEdit(line, rect_t{}, -17, 17, GET_SET_WITH_OFFSET(g_model.varioData.min, -10)); auto vMin = new NumberEdit(line, rect_t{0, 0, NUM_EDIT_W, 0}, -17, 17, GET_SET_WITH_OFFSET(g_model.varioData.min, -10));
vMin->setAvailableHandler([](int val) { return val < g_model.varioData.max + 10; }); vMin->setAvailableHandler([](int val) { return val < g_model.varioData.max + 10; });
auto vMax = new NumberEdit(line, rect_t{}, -17, 17, GET_SET_WITH_OFFSET(g_model.varioData.max, 10)); auto vMax = new NumberEdit(line, rect_t{0, 0, NUM_EDIT_W, 0}, -17, 17, GET_SET_WITH_OFFSET(g_model.varioData.max, 10));
vMax->setAvailableHandler([](int val) { return g_model.varioData.min - 10 < val; }); vMax->setAvailableHandler([](int val) { return g_model.varioData.min - 10 < val; });
line = window->newLine(&grid5); line = window->newLine(&grid5);
line->padLeft(10); line->padLeft(10);
new StaticText(line, rect_t{}, STR_CENTER, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_CENTER, 0, COLOR_THEME_PRIMARY1);
auto cMin = new NumberEdit(line, rect_t{}, -15, 15, GET_SET_WITH_OFFSET(g_model.varioData.centerMin, -5), 0, PREC1); auto cMin = new NumberEdit(line, rect_t{0, 0, NUM_EDIT_W, 0}, -15, 15, GET_SET_WITH_OFFSET(g_model.varioData.centerMin, -5), 0, PREC1);
cMin->setAvailableHandler([](int val) { return val < g_model.varioData.centerMax + 5; }); cMin->setAvailableHandler([](int val) { return val < g_model.varioData.centerMax + 5; });
auto cMax = new NumberEdit(line, rect_t{}, -15, 15, GET_SET_WITH_OFFSET(g_model.varioData.centerMax, 5), 0, PREC1); auto cMax = new NumberEdit(line, rect_t{0, 0, NUM_EDIT_W, 0}, -15, 15, GET_SET_WITH_OFFSET(g_model.varioData.centerMax, 5), 0, PREC1);
cMax->setAvailableHandler([](int val) { return g_model.varioData.centerMin - 5 < val; }); cMax->setAvailableHandler([](int val) { return g_model.varioData.centerMin - 5 < val; });
new Choice(line, rect_t{}, STR_VVARIOCENTER, 0, 1, GET_SET_DEFAULT(g_model.varioData.centerSilent)); new Choice(line, rect_t{}, STR_VVARIOCENTER, 0, 1, GET_SET_DEFAULT(g_model.varioData.centerSilent));
@@ -30,8 +30,6 @@ static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
TemplatePage::TemplatePage() : Page(ICON_MODEL_SELECT) TemplatePage::TemplatePage() : Page(ICON_MODEL_SELECT)
{ {
body.padAll(0);
auto form = new FormWindow(&body, rect_t{}); auto form = new FormWindow(&body, rect_t{});
form->setFlexLayout(); form->setFlexLayout();
form->padAll(4); form->padAll(4);
+40 -40
View File
@@ -23,7 +23,6 @@
#include "usb_joystick.h" #include "usb_joystick.h"
#include "channel_bar.h" #include "channel_bar.h"
#include "button_matrix.h" #include "button_matrix.h"
#include "lvgl_widgets/input_mix_line.h"
#include "opentx.h" #include "opentx.h"
@@ -111,6 +110,15 @@ class USBChannelButtonSel : public ButtonMatrix
m_channel(channel), m_channel(channel),
m_setValue(std::move(_setValue)) m_setValue(std::move(_setValue))
{ {
bg_color[0] = makeLvColor(COLOR_THEME_PRIMARY2); // Unused
fg_color[0] = makeLvColor(COLOR_THEME_SECONDARY1);
bg_color[1] = makeLvColor(COLOR_THEME_DISABLED); // Used by other channel_bar
fg_color[1] = makeLvColor(COLOR_THEME_PRIMARY1);
bg_color[2] = makeLvColor(COLOR_THEME_ACTIVE); // Used by this channel
fg_color[2] = makeLvColor(COLOR_THEME_PRIMARY1);
bg_color[3] = makeLvColor(COLOR_THEME_WARNING); // Collision
fg_color[3] = makeLvColor(COLOR_THEME_PRIMARY2);
initBtnMap(USBCH_BTNMX_COL, USBJ_BUTTON_SIZE); initBtnMap(USBCH_BTNMX_COL, USBJ_BUTTON_SIZE);
char snum[5]; char snum[5];
for (uint8_t btn = 0; btn < USBJ_BUTTON_SIZE; btn++) { for (uint8_t btn = 0; btn < USBJ_BUTTON_SIZE; btn++) {
@@ -119,6 +127,8 @@ class USBChannelButtonSel : public ButtonMatrix
} }
update(); update();
lv_obj_set_style_radius(lvobj, LV_RADIUS_CIRCLE, LV_PART_ITEMS);
lv_obj_add_event_cb(lvobj, btnsel_event_cb, LV_EVENT_DRAW_PART_BEGIN, this); lv_obj_add_event_cb(lvobj, btnsel_event_cb, LV_EVENT_DRAW_PART_BEGIN, this);
memset(m_btns, 0, USBJ_BUTTON_SIZE); memset(m_btns, 0, USBJ_BUTTON_SIZE);
@@ -137,16 +147,11 @@ class USBChannelButtonSel : public ButtonMatrix
updateState(); updateState();
} }
void setValue(int val)
{
if (m_setValue) {
m_setValue(val);
}
}
void onPress(uint8_t btn_id) override void onPress(uint8_t btn_id) override
{ {
setValue(btn_id); if (m_setValue) {
m_setValue(btn_id);
}
updateState(); updateState();
} }
@@ -161,16 +166,29 @@ class USBChannelButtonSel : public ButtonMatrix
void updateState() void updateState()
{ {
USBJoystickChData * cch = usbJChAddress(m_channel); USBJoystickChData * cch = usbJChAddress(m_channel);
for(uint8_t i = 0; i < USBJ_BUTTON_SIZE; i++) m_btns[i] &= 1;
uint8_t last = cch->lastBtnNum(); uint8_t last = cch->lastBtnNum();
for(uint8_t b = cch->btn_num; b <= last; b++) m_btns[b] |= 2; uint8_t i;
for (i = 0; i < USBJ_BUTTON_SIZE; i++)
m_btns[i] &= 1;
for(i = cch->btn_num; i <= last; i++)
m_btns[i] |= 2;
}
void setColor(lv_obj_draw_part_dsc_t* dsc)
{
uint8_t state = getBtnState((uint8_t)dsc->id);
dsc->rect_dsc->bg_color = bg_color[state];
dsc->label_dsc->color = fg_color[state];
} }
protected: protected:
uint8_t m_channel = 0; uint8_t m_channel = 0;
std::function<void(int)> m_setValue; std::function<void(int)> m_setValue;
uint8_t m_btns[USBJ_BUTTON_SIZE]; uint8_t m_btns[USBJ_BUTTON_SIZE];
lv_color_t bg_color[4];
lv_color_t fg_color[4];
}; };
static void btnsel_event_cb(lv_event_t* e) static void btnsel_event_cb(lv_event_t* e)
@@ -181,26 +199,8 @@ static void btnsel_event_cb(lv_event_t* e)
lv_obj_draw_part_dsc_t* dsc = lv_event_get_draw_part_dsc(e); lv_obj_draw_part_dsc_t* dsc = lv_event_get_draw_part_dsc(e);
if(dsc->class_p == &lv_btnmatrix_class && dsc->type == LV_BTNMATRIX_DRAW_PART_BTN) { if(dsc->class_p == &lv_btnmatrix_class && dsc->type == LV_BTNMATRIX_DRAW_PART_BTN) {
dsc->rect_dsc->radius = LV_RADIUS_CIRCLE;
auto btsel = (USBChannelButtonSel*)lv_event_get_user_data(e); auto btsel = (USBChannelButtonSel*)lv_event_get_user_data(e);
btsel->setColor(dsc);
uint8_t state = btsel->getBtnState((uint8_t)dsc->id);
if (state == 1) {
dsc->rect_dsc->bg_color = makeLvColor(COLOR_THEME_DISABLED);
dsc->label_dsc->color = makeLvColor(COLOR_THEME_PRIMARY1);
}
else if (state == 2) {
dsc->rect_dsc->bg_color = makeLvColor(COLOR_THEME_EDIT);
dsc->label_dsc->color = makeLvColor(COLOR_THEME_PRIMARY2);
}
else if (state == 3) {
dsc->rect_dsc->bg_color = makeLvColor(COLOR_THEME_WARNING);
dsc->label_dsc->color = makeLvColor(COLOR_THEME_PRIMARY2);
}
else {
dsc->rect_dsc->bg_color = makeLvColor(COLOR_THEME_PRIMARY2);
dsc->label_dsc->color = makeLvColor(COLOR_THEME_SECONDARY1);
}
} }
} }
} }
@@ -298,13 +298,6 @@ class USBChannelEditWindow : public Page
auto line = form->newLine(&grid); auto line = form->newLine(&grid);
line->padTop(0);
line->padBottom(0);
collisionText = new StaticText(line, rect_t{}, "", OPAQUE, FONT(BOLD) | COLOR_THEME_PRIMARY2 | CENTERED);
collisionText->setBackgroundColor(COLOR_THEME_WARNING);
lv_obj_set_grid_cell(collisionText->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, USBCH_COLS, LV_GRID_ALIGN_CENTER, 0, 1);
line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_USBJOYSTICK_CH_MODE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_USBJOYSTICK_CH_MODE, 0, COLOR_THEME_PRIMARY1);
new Choice(line, rect_t{}, STR_VUSBJOYSTICK_CH_MODE, 0, USBJOYS_CH_LAST, new Choice(line, rect_t{}, STR_VUSBJOYSTICK_CH_MODE, 0, USBJOYS_CH_LAST,
GET_DEFAULT(cch->mode), SET_VALUE_WUPDATE(cch->mode)); GET_DEFAULT(cch->mode), SET_VALUE_WUPDATE(cch->mode));
@@ -314,7 +307,7 @@ class USBChannelEditWindow : public Page
#endif #endif
new StaticText(line, rect_t{}, STR_USBJOYSTICK_CH_INVERSION, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_USBJOYSTICK_CH_INVERSION, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_DEFAULT(cch->inversion)); new ToggleSwitch(line, rect_t{}, GET_SET_DEFAULT(cch->inversion));
line = form->newLine(&grid); line = form->newLine(&grid);
m_btnModeFrame = new FormWindow(line, rect_t{}); m_btnModeFrame = new FormWindow(line, rect_t{});
@@ -359,6 +352,13 @@ class USBChannelEditWindow : public Page
new Choice(m_simModeLine, rect_t{}, STR_VUSBJOYSTICK_CH_SIM, 0, USBJOYS_SIM_LAST, new Choice(m_simModeLine, rect_t{}, STR_VUSBJOYSTICK_CH_SIM, 0, USBJOYS_SIM_LAST,
GET_DEFAULT(cch->param), SET_VALUE_WUPDATE(cch->param)); GET_DEFAULT(cch->param), SET_VALUE_WUPDATE(cch->param));
line = form->newLine(&grid);
line->padTop(0);
line->padBottom(0);
collisionText = new StaticText(line, rect_t{}, "", OPAQUE, FONT(BOLD) | COLOR_THEME_PRIMARY2 | CENTERED);
collisionText->setBackgroundColor(COLOR_THEME_WARNING);
lv_obj_set_grid_cell(collisionText->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, USBCH_COLS, LV_GRID_ALIGN_CENTER, 0, 1);
update(); update();
} }
}; };
@@ -546,7 +546,7 @@ ModelUSBJoystickPage::ModelUSBJoystickPage() :
_ApplyBtn = new TextButton(line, rect_t{}, STR_USBJOYSTICK_APPLY_CHANGES, _ApplyBtn = new TextButton(line, rect_t{}, STR_USBJOYSTICK_APPLY_CHANGES,
[=]() { onUSBJoystickModelChanged(); this->update(); return 0; }); [=]() { onUSBJoystickModelChanged(); this->update(); return 0; });
auto btngrp = new FormGroup(form, rect_t{}); auto btngrp = new FormWindow(form, rect_t{});
_ChannelsGroup = btngrp; _ChannelsGroup = btngrp;
btngrp->setFlexLayout(); btngrp->setFlexLayout();
btngrp->padRow(lv_dpx(4)); btngrp->padRow(lv_dpx(4));
+1 -1
View File
@@ -23,7 +23,7 @@
#include "page.h" #include "page.h"
class FormGroup; class FormWindow;
class USBChannelLineButton; class USBChannelLineButton;
class ModelUSBJoystickPage : public Page class ModelUSBJoystickPage : public Page
+11 -14
View File
@@ -69,7 +69,7 @@ static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT,
struct FailsafeChoice; struct FailsafeChoice;
class ModuleWindow : public FormGroup class ModuleWindow : public FormWindow
{ {
public: public:
ModuleWindow(Window* parent, uint8_t moduleIdx); ModuleWindow(Window* parent, uint8_t moduleIdx);
@@ -99,7 +99,7 @@ class ModuleWindow : public FormGroup
void updateIDStaticText(int mdIdx); void updateIDStaticText(int mdIdx);
}; };
struct FailsafeChoice : public FormGroup { struct FailsafeChoice : public FormWindow {
FailsafeChoice(Window* parent, uint8_t moduleIdx); FailsafeChoice(Window* parent, uint8_t moduleIdx);
void update() const; void update() const;
@@ -124,7 +124,7 @@ static void fs_changed(lv_event_t* e)
} }
FailsafeChoice::FailsafeChoice(Window* parent, uint8_t moduleIdx) : FailsafeChoice::FailsafeChoice(Window* parent, uint8_t moduleIdx) :
FormGroup(parent, rect_t{}) FormWindow(parent, rect_t{})
{ {
setFlexLayout(LV_FLEX_FLOW_ROW); setFlexLayout(LV_FLEX_FLOW_ROW);
lv_obj_set_width(lvobj, LV_SIZE_CONTENT); lv_obj_set_width(lvobj, LV_SIZE_CONTENT);
@@ -163,7 +163,7 @@ static void mw_refresh_cb(lv_event_t* e)
} }
ModuleWindow::ModuleWindow(Window* parent, uint8_t moduleIdx) : ModuleWindow::ModuleWindow(Window* parent, uint8_t moduleIdx) :
FormGroup(parent, rect_t{}), FormWindow(parent, rect_t{}),
moduleIdx(moduleIdx) moduleIdx(moduleIdx)
{ {
setFlexLayout(); setFlexLayout();
@@ -260,7 +260,7 @@ void ModuleWindow::updateModule()
if(isModuleModelIndexAvailable(moduleIdx)) { if(isModuleModelIndexAvailable(moduleIdx)) {
auto line = newLine(&grid); auto line = newLine(&grid);
new StaticText(line, rect_t{},""); new StaticText(line, rect_t{},"");
auto box = new FormGroup(line, rect_t{}); auto box = new FormWindow(line, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
lv_obj_set_width(box->getLvObj(), LV_SIZE_CONTENT); lv_obj_set_width(box->getLvObj(), LV_SIZE_CONTENT);
idUnique = new StaticText(box, rect_t{}, "", 0, 0); idUnique = new StaticText(box, rect_t{}, "", 0, 0);
@@ -270,7 +270,7 @@ void ModuleWindow::updateModule()
auto line = newLine(&grid); auto line = newLine(&grid);
new StaticText(line, rect_t{}, STR_RECEIVER, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_RECEIVER, 0, COLOR_THEME_PRIMARY1);
auto box = new FormGroup(line, rect_t{}); auto box = new FormWindow(line, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
lv_obj_set_width(box->getLvObj(), LV_SIZE_CONTENT); lv_obj_set_width(box->getLvObj(), LV_SIZE_CONTENT);
@@ -397,7 +397,7 @@ void ModuleWindow::updateModule()
auto line = newLine(&grid); auto line = newLine(&grid);
new StaticText(line, rect_t{}, STR_MODULE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_MODULE, 0, COLOR_THEME_PRIMARY1);
auto box = new FormGroup(line, rect_t{}); auto box = new FormWindow(line, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8)); box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
registerButton = new TextButton(box, rect_t{}, STR_REGISTER); registerButton = new TextButton(box, rect_t{}, STR_REGISTER);
@@ -460,7 +460,7 @@ void ModuleWindow::updateModule()
auto line = newLine(&grid); auto line = newLine(&grid);
new StaticText(line, rect_t{}, STR_REFRESHRATE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_REFRESHRATE, 0, COLOR_THEME_PRIMARY1);
auto box = new FormGroup(line, rect_t{}); auto box = new FormWindow(line, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW); box->setFlexLayout(LV_FLEX_FLOW_ROW);
auto edit = new NumberEdit( auto edit = new NumberEdit(
@@ -483,7 +483,7 @@ void ModuleWindow::updateModule()
if (isModuleGhost(moduleIdx)) { if (isModuleGhost(moduleIdx)) {
auto line = newLine(&grid); auto line = newLine(&grid);
new StaticText(line, rect_t{}, "Raw 12 bits", 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, "Raw 12 bits", 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_DEFAULT(md->ghost.raw12bits)); new ToggleSwitch(line, rect_t{}, GET_SET_DEFAULT(md->ghost.raw12bits));
} }
updateSubType(); updateSubType();
@@ -746,10 +746,7 @@ ModulePage::ModulePage(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP)
header.setTitle(STR_MENU_MODEL_SETUP); header.setTitle(STR_MENU_MODEL_SETUP);
header.setTitle2(title2); header.setTitle2(title2);
body.padAll(0); auto form = new FormWindow(&body, rect_t{});
lv_obj_set_scrollbar_mode(body.getLvObj(), LV_SCROLLBAR_MODE_AUTO);
auto form = new FormGroup(&body, rect_t{});
form->setFlexLayout(); form->setFlexLayout();
form->padAll(lv_dpx(8)); form->padAll(lv_dpx(8));
@@ -759,7 +756,7 @@ ModulePage::ModulePage(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP)
auto line = form->newLine(&grid); auto line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_MODE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_MODE, 0, COLOR_THEME_PRIMARY1);
auto box = new FormGroup(line, rect_t{}); auto box = new FormWindow(line, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW); box->setFlexLayout(LV_FLEX_FLOW_ROW);
lv_obj_set_width(box->getLvObj(), LV_SIZE_CONTENT); lv_obj_set_width(box->getLvObj(), LV_SIZE_CONTENT);
+29 -29
View File
@@ -36,20 +36,20 @@ static void update_mpm_settings(lv_event_t* e)
lv_event_send(ms->getParent()->getLvObj(), LV_EVENT_REFRESH, nullptr); lv_event_send(ms->getParent()->getLvObj(), LV_EVENT_REFRESH, nullptr);
} }
struct MPMProtoOption : public FormGroup::Line struct MPMProtoOption : public FormWindow::Line
{ {
StaticText* label; StaticText* label;
Choice* choice; Choice* choice;
NumberEdit* edit; NumberEdit* edit;
CheckBox* cb; ToggleSwitch* cb;
DynamicNumber<uint16_t>* rssi; DynamicNumber<uint16_t>* rssi;
MPMProtoOption(FormGroup* form, FlexGridLayout *layout); MPMProtoOption(FormWindow* form, FlexGridLayout *layout);
void update(const MultiRfProtocols::RfProto* rfProto, ModuleData* md, uint8_t moduleIdx); void update(const MultiRfProtocols::RfProto* rfProto, ModuleData* md, uint8_t moduleIdx);
}; };
MPMProtoOption::MPMProtoOption(FormGroup* form, FlexGridLayout *layout) : MPMProtoOption::MPMProtoOption(FormWindow* form, FlexGridLayout *layout) :
FormGroup::Line(form, layout) FormWindow::Line(form, layout)
{ {
if (layout) layout->resetPos(); if (layout) layout->resetPos();
label = new StaticText(this, rect_t{}, "", 0, COLOR_THEME_PRIMARY1); label = new StaticText(this, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
@@ -60,7 +60,7 @@ MPMProtoOption::MPMProtoOption(FormGroup* form, FlexGridLayout *layout) :
choice = new Choice(box, rect_t{}, 0, 0, nullptr); choice = new Choice(box, rect_t{}, 0, 0, nullptr);
edit = new NumberEdit(box, rect_t{}, 0, 0, nullptr); edit = new NumberEdit(box, rect_t{}, 0, 0, nullptr);
cb = new CheckBox(box, rect_t{}, nullptr, nullptr); cb = new ToggleSwitch(box, rect_t{}, nullptr, nullptr);
rssi = new DynamicNumber<uint16_t>( rssi = new DynamicNumber<uint16_t>(
box, rect_t{}, [] { return (uint16_t)TELEMETRY_RSSI(); }, 0, getRxStatLabels()->label, getRxStatLabels()->unit); box, rect_t{}, [] { return (uint16_t)TELEMETRY_RSSI(); }, 0, getRxStatLabels()->label, getRxStatLabels()->unit);
rssi->padTop(5); rssi->padTop(5);
@@ -148,11 +148,11 @@ void MPMProtoOption::update(const MultiRfProtocols::RfProto* rfProto, ModuleData
} }
} }
struct MPMSubtype : public FormGroup::Line struct MPMSubtype : public FormWindow::Line
{ {
Choice* choice; Choice* choice;
MPMSubtype(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx); MPMSubtype(FormWindow* form, FlexGridLayout *layout, uint8_t moduleIdx);
void update(const MultiRfProtocols::RfProto* rfProto, uint8_t moduleIdx); void update(const MultiRfProtocols::RfProto* rfProto, uint8_t moduleIdx);
void checkEvents(); void checkEvents();
@@ -187,8 +187,8 @@ static void subtype_event_cb(lv_event_t* e)
if (obj) lv_event_send(obj, LV_EVENT_VALUE_CHANGED, nullptr); if (obj) lv_event_send(obj, LV_EVENT_VALUE_CHANGED, nullptr);
} }
MPMSubtype::MPMSubtype(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx) : MPMSubtype::MPMSubtype(FormWindow* form, FlexGridLayout *layout, uint8_t moduleIdx) :
FormGroup::Line(form, layout) FormWindow::Line(form, layout)
{ {
this->moduleIdx = moduleIdx; this->moduleIdx = moduleIdx;
this->DSM2lastSubType = g_model.moduleData[this->moduleIdx].subType; this->DSM2lastSubType = g_model.moduleData[this->moduleIdx].subType;
@@ -227,16 +227,16 @@ void MPMSubtype::update(const MultiRfProtocols::RfProto* rfProto, uint8_t module
lv_event_send(choice->getLvObj(), LV_EVENT_VALUE_CHANGED, &stop); lv_event_send(choice->getLvObj(), LV_EVENT_VALUE_CHANGED, &stop);
} }
struct MPMServoRate : public FormGroup::Line { struct MPMServoRate : public FormWindow::Line {
MPMServoRate(FormGroup* form, FlexGridLayout* layout, uint8_t moduleIdx); MPMServoRate(FormWindow* form, FlexGridLayout* layout, uint8_t moduleIdx);
void update() const { lv_event_send(choice->getLvObj(), LV_EVENT_VALUE_CHANGED, nullptr); } void update() const { lv_event_send(choice->getLvObj(), LV_EVENT_VALUE_CHANGED, nullptr); }
private: private:
Choice* choice; Choice* choice;
}; };
MPMServoRate::MPMServoRate(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx) : MPMServoRate::MPMServoRate(FormWindow* form, FlexGridLayout *layout, uint8_t moduleIdx) :
FormGroup::Line(form, layout) FormWindow::Line(form, layout)
{ {
if (layout) layout->resetPos(); if (layout) layout->resetPos();
new StaticText(this, rect_t{}, STR_MULTI_SERVOFREQ, 0, COLOR_THEME_PRIMARY1); new StaticText(this, rect_t{}, STR_MULTI_SERVOFREQ, 0, COLOR_THEME_PRIMARY1);
@@ -249,40 +249,40 @@ MPMServoRate::MPMServoRate(FormGroup* form, FlexGridLayout *layout, uint8_t modu
md->multi.optionValue, (md->multi.optionValue & 0xFD) + (newValue << 1))); md->multi.optionValue, (md->multi.optionValue & 0xFD) + (newValue << 1)));
} }
struct MPMAutobind : public FormGroup::Line { struct MPMAutobind : public FormWindow::Line {
MPMAutobind(FormGroup* form, FlexGridLayout* layout, uint8_t moduleIdx); MPMAutobind(FormWindow* form, FlexGridLayout* layout, uint8_t moduleIdx);
void update() const { cb->update(); } void update() const { cb->update(); }
private: private:
CheckBox* cb; ToggleSwitch* cb;
}; };
MPMAutobind::MPMAutobind(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx) : MPMAutobind::MPMAutobind(FormWindow* form, FlexGridLayout *layout, uint8_t moduleIdx) :
FormGroup::Line(form, layout) FormWindow::Line(form, layout)
{ {
if (layout) layout->resetPos(); if (layout) layout->resetPos();
new StaticText(this, rect_t{}, STR_MULTI_AUTOBIND, 0, COLOR_THEME_PRIMARY1); new StaticText(this, rect_t{}, STR_MULTI_AUTOBIND, 0, COLOR_THEME_PRIMARY1);
auto md = &g_model.moduleData[moduleIdx]; auto md = &g_model.moduleData[moduleIdx];
cb = new CheckBox(this, rect_t{}, GET_SET_DEFAULT(md->multi.autoBindMode)); cb = new ToggleSwitch(this, rect_t{}, GET_SET_DEFAULT(md->multi.autoBindMode));
} }
struct MPMChannelMap : public FormGroup::Line struct MPMChannelMap : public FormWindow::Line
{ {
MPMChannelMap(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx); MPMChannelMap(FormWindow* form, FlexGridLayout *layout, uint8_t moduleIdx);
void update(const MultiRfProtocols::RfProto* rfProto); void update(const MultiRfProtocols::RfProto* rfProto);
private: private:
CheckBox* cb; ToggleSwitch* cb;
}; };
MPMChannelMap::MPMChannelMap(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx) : MPMChannelMap::MPMChannelMap(FormWindow* form, FlexGridLayout *layout, uint8_t moduleIdx) :
FormGroup::Line(form, layout) FormWindow::Line(form, layout)
{ {
if (layout) layout->resetPos(); if (layout) layout->resetPos();
new StaticText(this, rect_t{}, STR_DISABLE_CH_MAP, 0, COLOR_THEME_PRIMARY1); new StaticText(this, rect_t{}, STR_DISABLE_CH_MAP, 0, COLOR_THEME_PRIMARY1);
auto md = &g_model.moduleData[moduleIdx]; auto md = &g_model.moduleData[moduleIdx];
cb = new CheckBox(this, rect_t{}, GET_SET_DEFAULT(md->multi.disableMapping)); cb = new ToggleSwitch(this, rect_t{}, GET_SET_DEFAULT(md->multi.disableMapping));
} }
void MPMChannelMap::update(const MultiRfProtocols::RfProto* rfProto) void MPMChannelMap::update(const MultiRfProtocols::RfProto* rfProto)
@@ -298,7 +298,7 @@ void MPMChannelMap::update(const MultiRfProtocols::RfProto* rfProto)
MultimoduleSettings::MultimoduleSettings(Window *parent, MultimoduleSettings::MultimoduleSettings(Window *parent,
const FlexGridLayout &g, const FlexGridLayout &g,
uint8_t moduleIdx) : uint8_t moduleIdx) :
FormGroup(parent, rect_t{}), md(&g_model.moduleData[moduleIdx]), FormWindow(parent, rect_t{}), md(&g_model.moduleData[moduleIdx]),
moduleIdx(moduleIdx) moduleIdx(moduleIdx)
{ {
FlexGridLayout grid(g); FlexGridLayout grid(g);
@@ -336,13 +336,13 @@ MultimoduleSettings::MultimoduleSettings(Window *parent,
// Low power mode // Low power mode
line = newLine(&grid); line = newLine(&grid);
new StaticText(line, rect_t{}, STR_MULTI_LOWPOWER, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_MULTI_LOWPOWER, 0, COLOR_THEME_PRIMARY1);
lp_mode = new CheckBox(line, rect_t{}, GET_SET_DEFAULT(md->multi.lowPowerMode)); lp_mode = new ToggleSwitch(line, rect_t{}, GET_SET_DEFAULT(md->multi.lowPowerMode));
#if defined(MANUFACTURER_FRSKY) #if defined(MANUFACTURER_FRSKY)
// Disable telemetry // Disable telemetry
line = newLine(&grid); line = newLine(&grid);
new StaticText(line, rect_t{}, STR_DISABLE_TELEM, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_DISABLE_TELEM, 0, COLOR_THEME_PRIMARY1);
disable_telem = new CheckBox(line, rect_t{}, GET_SET_DEFAULT(md->multi.disableTelemetry)); disable_telem = new ToggleSwitch(line, rect_t{}, GET_SET_DEFAULT(md->multi.disableTelemetry));
#endif #endif
cm_line = new MPMChannelMap(this, &grid, moduleIdx); cm_line = new MPMChannelMap(this, &grid, moduleIdx);
+5 -4
View File
@@ -22,9 +22,10 @@
#pragma once #pragma once
#include "form.h" #include "form.h"
#include "checkbox.h"
#include "module_setup.h" #include "module_setup.h"
class ToggleSwitch;
struct ModuleData; struct ModuleData;
struct MPMProtoOption; struct MPMProtoOption;
struct MPMSubtype; struct MPMSubtype;
@@ -32,7 +33,7 @@ struct MPMServoRate;
struct MPMAutobind; struct MPMAutobind;
struct MPMChannelMap; struct MPMChannelMap;
class MultimoduleSettings : public FormGroup, public ModuleOptions class MultimoduleSettings : public FormWindow, public ModuleOptions
{ {
ModuleData* md; ModuleData* md;
uint8_t moduleIdx; uint8_t moduleIdx;
@@ -41,9 +42,9 @@ class MultimoduleSettings : public FormGroup, public ModuleOptions
MPMProtoOption* opt_line; MPMProtoOption* opt_line;
MPMServoRate* sr_line; MPMServoRate* sr_line;
MPMAutobind* ab_line; MPMAutobind* ab_line;
CheckBox* lp_mode; ToggleSwitch* lp_mode;
#if defined(MANUFACTURER_FRSKY) #if defined(MANUFACTURER_FRSKY)
CheckBox* disable_telem; ToggleSwitch* disable_telem;
#endif #endif
MPMChannelMap* cm_line; MPMChannelMap* cm_line;
+4 -23
View File
@@ -23,8 +23,6 @@
#include "multi_rfprotos.h" #include "multi_rfprotos.h"
#include "strhelpers.h" #include "strhelpers.h"
#include "progress.h"
// TODO: format for LCD_WIDTH > LCD_HEIGHT // TODO: format for LCD_WIDTH > LCD_HEIGHT
// TODO: translation // TODO: translation
@@ -32,37 +30,20 @@ const char* RFSCAN_TITLE = "MPM: Scanning protocols...";
RfScanDialog::RfScanDialog(Window* parent, MultiRfProtocols* protos, RfScanDialog::RfScanDialog(Window* parent, MultiRfProtocols* protos,
std::function<void()> onClose) : std::function<void()> onClose) :
Dialog(parent, RFSCAN_TITLE, rect_t{}), ProgressDialog(parent, RFSCAN_TITLE, onClose),
protos(protos), protos(protos)
progress(new Progress(&content->form, rect_t{})),
onClose(std::move(onClose))
{ {
progress->setHeight(LV_DPI_DEF / 4);
content->setWidth(LCD_W * 0.8);
content->updateSize();
auto content_w = lv_obj_get_content_width(content->form.getLvObj());
progress->setWidth(content_w);
// disable canceling dialog
setCloseWhenClickOutside(false);
// setFocus();
} }
void RfScanDialog::showProgress() void RfScanDialog::showProgress()
{ {
progress->setValue((int)(protos->getProgress() * 100.0)); updateProgress((int)(protos->getProgress() * 100.0));
} }
// disable keys
void RfScanDialog::onEvent(event_t) { return; }
void RfScanDialog::checkEvents() void RfScanDialog::checkEvents()
{ {
if (!protos->isScanning()) { if (!protos->isScanning()) {
deleteLater(); closeDialog();
onClose();
} else if (RTOS_GET_MS() - lastUpdate >= 200) { } else if (RTOS_GET_MS() - lastUpdate >= 200) {
showProgress(); showProgress();
lastUpdate = RTOS_GET_MS(); lastUpdate = RTOS_GET_MS();
+1 -7
View File
@@ -24,23 +24,17 @@
class MultiRfProtocols; class MultiRfProtocols;
class RfScanDialog : public Dialog class RfScanDialog : public ProgressDialog
{ {
MultiRfProtocols* protos; MultiRfProtocols* protos;
uint32_t lastUpdate = 0; uint32_t lastUpdate = 0;
Progress* progress;
std::function<void()> onClose;
public: public:
RfScanDialog(Window* parent, MultiRfProtocols* protos, RfScanDialog(Window* parent, MultiRfProtocols* protos,
std::function<void()> onClose); std::function<void()> onClose);
void showProgress(); void showProgress();
// disable keys
void onEvent(event_t) override;
void checkEvents() override; void checkEvents() override;
}; };
+1 -1
View File
@@ -182,7 +182,7 @@ void OutputEditWindow::buildBody(FormWindow* form)
// Direction // Direction
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_INVERTED, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_INVERTED, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_DEFAULT(output->revert), new ToggleSwitch(line, rect_t{}, GET_DEFAULT(output->revert),
[output, this](uint8_t newValue) { [output, this](uint8_t newValue) {
output->revert = newValue; output->revert = newValue;
SET_DIRTY(); SET_DIRTY();
+7 -4
View File
@@ -25,7 +25,7 @@
#include "opentx.h" #include "opentx.h"
PageHeader::PageHeader(Page * parent, uint8_t icon): PageHeader::PageHeader(Page * parent, uint8_t icon):
FormGroup(parent, { 0, 0, LCD_W, MENU_HEADER_HEIGHT }, OPAQUE), FormWindow(parent, { 0, 0, LCD_W, MENU_HEADER_HEIGHT }, OPAQUE),
icon(icon) icon(icon)
{ {
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
@@ -33,7 +33,7 @@ PageHeader::PageHeader(Page * parent, uint8_t icon):
[=]() -> uint8_t { [=]() -> uint8_t {
parent->onCancel(); parent->onCancel();
return 0; return 0;
}, NO_FOCUS | FORM_NO_BORDER); }, NO_FOCUS);
#endif #endif
title = new StaticText(this, title = new StaticText(this,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP,
@@ -55,7 +55,7 @@ StaticText* PageHeader::setTitle2(std::string txt)
void PageHeader::paint(BitmapBuffer * dc) void PageHeader::paint(BitmapBuffer * dc)
{ {
OpenTxTheme::instance()->drawPageHeaderBackground(dc, getIcon(), ""); EdgeTxTheme::instance()->drawPageHeaderBackground(dc, getIcon(), nullptr);
dc->drawSolidFilledRect(MENU_HEADER_HEIGHT, 0, LCD_W - MENU_HEADER_HEIGHT, dc->drawSolidFilledRect(MENU_HEADER_HEIGHT, 0, LCD_W - MENU_HEADER_HEIGHT,
MENU_HEADER_HEIGHT, COLOR_THEME_SECONDARY1); MENU_HEADER_HEIGHT, COLOR_THEME_SECONDARY1);
} }
@@ -68,11 +68,14 @@ static constexpr rect_t _get_body_rect()
Page::Page(unsigned icon): Page::Page(unsigned icon):
Window(Layer::back(), {0, 0, LCD_W, LCD_H}, OPAQUE), Window(Layer::back(), {0, 0, LCD_W, LCD_H}, OPAQUE),
header(this, icon), header(this, icon),
body(this, _get_body_rect(), FORM_FORWARD_FOCUS) body(this, _get_body_rect())
{ {
Layer::push(this); Layer::push(this);
lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR_THEME_SECONDARY3), 0); lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR_THEME_SECONDARY3), 0);
body.padAll(0);
lv_obj_set_scrollbar_mode(body.getLvObj(), LV_SCROLLBAR_MODE_AUTO);
} }
void Page::deleteLater(bool detach, bool trash) void Page::deleteLater(bool detach, bool trash)
+1 -1
View File
@@ -28,7 +28,7 @@
class Page; class Page;
class PageHeader : public FormGroup class PageHeader : public FormWindow
{ {
public: public:
PageHeader(Page* parent, uint8_t icon); PageHeader(Page* parent, uint8_t icon);
+1 -1
View File
@@ -26,7 +26,7 @@
template <typename T> template <typename T>
PpmFrameSettings<T>::PpmFrameSettings(Window* parent, T* ppm) : PpmFrameSettings<T>::PpmFrameSettings(Window* parent, T* ppm) :
FormGroup(parent, rect_t{}) FormWindow(parent, rect_t{})
{ {
setFlexLayout(LV_FLEX_FLOW_ROW); setFlexLayout(LV_FLEX_FLOW_ROW);
+1 -1
View File
@@ -25,7 +25,7 @@
#include "numberedit.h" #include "numberedit.h"
template <typename T> template <typename T>
struct PpmFrameSettings : public FormGroup { struct PpmFrameSettings : public FormWindow {
private: private:
NumberEdit* ppmFrameLenEditObject = nullptr; NumberEdit* ppmFrameLenEditObject = nullptr;
+30 -54
View File
@@ -46,7 +46,7 @@ static void cb_changed(lv_event_t* e)
} }
} }
static void make_conditional(Window* w, CheckBox* cb) static void make_conditional(Window* w, ToggleSwitch* cb)
{ {
lv_obj_t* w_obj = w->getLvObj(); lv_obj_t* w_obj = w->getLvObj();
if (!cb->getValue()) { lv_obj_add_flag(w_obj, LV_OBJ_FLAG_HIDDEN); } if (!cb->getValue()) { lv_obj_add_flag(w_obj, LV_OBJ_FLAG_HIDDEN); }
@@ -81,7 +81,7 @@ struct SwitchWarnMatrix : public ButtonMatrix {
SwitchWarnMatrix(Window* parent, const rect_t& rect); SwitchWarnMatrix(Window* parent, const rect_t& rect);
void onPress(uint8_t btn_id); void onPress(uint8_t btn_id);
bool isActive(uint8_t btn_id); bool isActive(uint8_t btn_id);
void setTextWithColor(uint8_t btn_id); void setTextAndState(uint8_t btn_id);
private: private:
uint8_t sw_idx[MAX_SWITCHES]; uint8_t sw_idx[MAX_SWITCHES];
}; };
@@ -90,7 +90,7 @@ struct PotWarnMatrix : public ButtonMatrix {
PotWarnMatrix(Window* parent, const rect_t& rect); PotWarnMatrix(Window* parent, const rect_t& rect);
void onPress(uint8_t btn_id); void onPress(uint8_t btn_id);
bool isActive(uint8_t btn_id); bool isActive(uint8_t btn_id);
void setTextWithColor(uint8_t btn_id); void setTextAndState(uint8_t btn_id);
private: private:
uint8_t pot_idx[MAX_POTS]; uint8_t pot_idx[MAX_POTS];
}; };
@@ -99,7 +99,7 @@ struct CenterBeepsMatrix : public ButtonMatrix {
CenterBeepsMatrix(Window* parent, const rect_t& rect); CenterBeepsMatrix(Window* parent, const rect_t& rect);
void onPress(uint8_t btn_id); void onPress(uint8_t btn_id);
bool isActive(uint8_t btn_id); bool isActive(uint8_t btn_id);
void setTextWithColor(uint8_t btn_id); void setTextAndState(uint8_t btn_id);
private: private:
uint8_t max_analogs; uint8_t max_analogs;
uint8_t ana_idx[MAX_ANALOG_INPUTS]; uint8_t ana_idx[MAX_ANALOG_INPUTS];
@@ -110,33 +110,31 @@ PreflightChecks::PreflightChecks() : Page(ICON_MODEL_SETUP)
header.setTitle(STR_MENU_MODEL_SETUP); header.setTitle(STR_MENU_MODEL_SETUP);
header.setTitle2(STR_PREFLIGHT); header.setTitle2(STR_PREFLIGHT);
body.padAll(8);
auto form = new FormWindow(&body, rect_t{}); auto form = new FormWindow(&body, rect_t{});
form->setFlexLayout(); form->setFlexLayout();
form->padAll(4); form->padAll(8);
FlexGridLayout grid(line_col_dsc, line_row_dsc, 2); FlexGridLayout grid(line_col_dsc, line_row_dsc, 2);
// Display checklist // Display checklist
auto line = form->newLine(&grid); auto line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_CHECKLIST, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_CHECKLIST, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_DEFAULT(g_model.displayChecklist)); new ToggleSwitch(line, rect_t{}, GET_SET_DEFAULT(g_model.displayChecklist));
// Throttle warning // Throttle warning
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_THROTTLE_WARNING, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_THROTTLE_WARNING, 0, COLOR_THEME_PRIMARY1);
auto tw = new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_model.disableThrottleWarning)); auto tw = new ToggleSwitch(line, rect_t{}, GET_SET_INVERTED(g_model.disableThrottleWarning));
// Custom Throttle warning (conditional on previous field) // Custom Throttle warning (conditional on previous field)
line = form->newLine(&grid); line = form->newLine(&grid);
make_conditional(line, tw); make_conditional(line, tw);
new StaticText(line, rect_t{}, STR_CUSTOM_THROTTLE_WARNING, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_CUSTOM_THROTTLE_WARNING, 0, COLOR_THEME_PRIMARY1);
auto box = new FormGroup::Line(line, window_create(line->getLvObj())); auto box = new FormWindow::Line(line, window_create(line->getLvObj()));
lv_obj_set_layout(box->getLvObj(), LV_LAYOUT_FLEX); lv_obj_set_layout(box->getLvObj(), LV_LAYOUT_FLEX);
box->setWidth(LCD_W /2 - 15); box->setWidth(LCD_W /2 - 15);
auto cst_tw = new CheckBox( auto cst_tw = new ToggleSwitch(
box, rect_t{}, GET_SET_DEFAULT(g_model.enableCustomThrottleWarning)); box, rect_t{}, GET_SET_DEFAULT(g_model.enableCustomThrottleWarning));
// Custom Throttle warning value // Custom Throttle warning value
@@ -147,7 +145,10 @@ PreflightChecks::PreflightChecks() : Page(ICON_MODEL_SETUP)
// Switch warnings (TODO: add display switch?) // Switch warnings (TODO: add display switch?)
line = form->newLine(&grid); line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_SWITCHES, 0, COLOR_THEME_PRIMARY1);
line = form->newLine(&grid);
line->padTop(0); line->padTop(0);
line->padLeft(4);
new SwitchWarnMatrix(line, rect_t{}); new SwitchWarnMatrix(line, rect_t{});
// Pots and sliders warning // Pots and sliders warning
@@ -160,6 +161,7 @@ PreflightChecks::PreflightChecks() : Page(ICON_MODEL_SETUP)
// Pot warnings // Pot warnings
line = form->newLine(&grid); line = form->newLine(&grid);
line->padTop(0); line->padTop(0);
line->padLeft(4);
auto pwm = new PotWarnMatrix(line, rect_t{}); auto pwm = new PotWarnMatrix(line, rect_t{});
make_conditional(pwm, pots_wm); make_conditional(pwm, pots_wm);
} }
@@ -169,6 +171,7 @@ PreflightChecks::PreflightChecks() : Page(ICON_MODEL_SETUP)
line->padTop(0); line->padTop(0);
new StaticText(line, rect_t{}, STR_BEEPCTR, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_BEEPCTR, 0, COLOR_THEME_PRIMARY1);
line = form->newLine(&grid); line = form->newLine(&grid);
line->padLeft(4);
new CenterBeepsMatrix(line, rect_t{}); new CenterBeepsMatrix(line, rect_t{});
} }
@@ -204,8 +207,7 @@ SwitchWarnMatrix::SwitchWarnMatrix(Window* parent, const rect_t& r) :
uint8_t btn_id = 0; uint8_t btn_id = 0;
for (uint8_t i = 0; i < MAX_SWITCHES; i++) { for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
if (SWITCH_EXISTS(i)) { if (SWITCH_EXISTS(i)) {
lv_btnmatrix_set_btn_ctrl(lvobj, btn_id, LV_BTNMATRIX_CTRL_RECOLOR); setTextAndState(i);
setTextWithColor(i);
btn_id++; btn_id++;
} }
} }
@@ -215,22 +217,16 @@ SwitchWarnMatrix::SwitchWarnMatrix(Window* parent, const rect_t& r) :
uint8_t rows = ((btn_cnt - 1) / SW_BTNS) + 1; uint8_t rows = ((btn_cnt - 1) / SW_BTNS) + 1;
lv_obj_set_height(lvobj, (rows * LV_DPI_DEF) / 3); lv_obj_set_height(lvobj, (rows * LV_DPI_DEF) / 3);
lv_obj_set_style_bg_opa(lvobj, LV_OPA_0, LV_PART_MAIN);
lv_obj_set_style_pad_all(lvobj, 4, LV_PART_MAIN); lv_obj_set_style_pad_all(lvobj, 4, LV_PART_MAIN);
lv_obj_set_style_pad_left(lvobj, LV_DPI_DEF / 10, LV_PART_MAIN);
lv_obj_set_style_pad_row(lvobj, 4, LV_PART_MAIN); lv_obj_set_style_pad_row(lvobj, 4, LV_PART_MAIN);
lv_obj_set_style_pad_column(lvobj, 4, LV_PART_MAIN); lv_obj_set_style_pad_column(lvobj, 4, LV_PART_MAIN);
lv_obj_remove_style(lvobj, nullptr, LV_PART_MAIN | LV_STATE_FOCUSED);
lv_obj_remove_style(lvobj, nullptr, LV_PART_MAIN | LV_STATE_EDITED);
} }
void SwitchWarnMatrix::setTextWithColor(uint8_t btn_id) void SwitchWarnMatrix::setTextAndState(uint8_t btn_id)
{ {
auto color = isActive(btn_id) ? COLOR_THEME_PRIMARY1 : COLOR_THEME_SECONDARY1; setText(btn_id, switchWarninglabel(sw_idx[btn_id]).c_str());
setText(btn_id, makeRecolor(switchWarninglabel(sw_idx[btn_id]), color).c_str()); setChecked(btn_id);
} }
void SwitchWarnMatrix::onPress(uint8_t btn_id) void SwitchWarnMatrix::onPress(uint8_t btn_id)
@@ -249,7 +245,7 @@ void SwitchWarnMatrix::onPress(uint8_t btn_id)
SET_DIRTY(); SET_DIRTY();
// TODO: save state in object // TODO: save state in object
setTextWithColor(sw); setTextAndState(sw);
} }
bool SwitchWarnMatrix::isActive(uint8_t btn_id) bool SwitchWarnMatrix::isActive(uint8_t btn_id)
@@ -276,8 +272,7 @@ PotWarnMatrix::PotWarnMatrix(Window* parent, const rect_t& r) :
uint8_t btn_id = 0; uint8_t btn_id = 0;
for (uint16_t i = 0; i < MAX_POTS; i++) { for (uint16_t i = 0; i < MAX_POTS; i++) {
if (IS_POT_AVAILABLE(i)) { if (IS_POT_AVAILABLE(i)) {
lv_btnmatrix_set_btn_ctrl(lvobj, btn_id, LV_BTNMATRIX_CTRL_RECOLOR); setTextAndState(btn_id);
setTextWithColor(btn_id);
btn_id++; btn_id++;
} }
} }
@@ -287,23 +282,16 @@ PotWarnMatrix::PotWarnMatrix(Window* parent, const rect_t& r) :
uint8_t rows = ((btn_cnt - 1) / SW_BTNS) + 1; uint8_t rows = ((btn_cnt - 1) / SW_BTNS) + 1;
lv_obj_set_height(lvobj, (rows * LV_DPI_DEF) / 3); lv_obj_set_height(lvobj, (rows * LV_DPI_DEF) / 3);
lv_obj_set_style_bg_opa(lvobj, LV_OPA_0, LV_PART_MAIN);
lv_obj_set_style_pad_all(lvobj, 4, LV_PART_MAIN); lv_obj_set_style_pad_all(lvobj, 4, LV_PART_MAIN);
lv_obj_set_style_pad_left(lvobj, LV_DPI_DEF / 10, LV_PART_MAIN);
lv_obj_set_style_pad_row(lvobj, 4, LV_PART_MAIN); lv_obj_set_style_pad_row(lvobj, 4, LV_PART_MAIN);
lv_obj_set_style_pad_column(lvobj, 4, LV_PART_MAIN); lv_obj_set_style_pad_column(lvobj, 4, LV_PART_MAIN);
lv_obj_remove_style(lvobj, nullptr, LV_PART_MAIN | LV_STATE_FOCUSED);
lv_obj_remove_style(lvobj, nullptr, LV_PART_MAIN | LV_STATE_EDITED);
} }
void PotWarnMatrix::setTextWithColor(uint8_t btn_id) void PotWarnMatrix::setTextAndState(uint8_t btn_id)
{ {
auto idx = pot_idx[btn_id]; setText(btn_id, getPotLabel(pot_idx[btn_id]));
auto color = isActive(btn_id) ? COLOR_THEME_PRIMARY1 : COLOR_THEME_SECONDARY1; setChecked(btn_id);
setText(btn_id, makeRecolor(getPotLabel(idx), color).c_str());
} }
void PotWarnMatrix::onPress(uint8_t btn_id) void PotWarnMatrix::onPress(uint8_t btn_id)
@@ -316,7 +304,7 @@ void PotWarnMatrix::onPress(uint8_t btn_id)
(g_model.potsWarnEnabled & (1 << pot))) { (g_model.potsWarnEnabled & (1 << pot))) {
SAVE_POT_POSITION(pot); SAVE_POT_POSITION(pot);
} }
setTextWithColor(btn_id); setTextAndState(btn_id);
SET_DIRTY(); SET_DIRTY();
} }
@@ -352,8 +340,7 @@ CenterBeepsMatrix::CenterBeepsMatrix(Window* parent, const rect_t& r) :
for (uint8_t i = 0; i < max_analogs; i++) { for (uint8_t i = 0; i < max_analogs; i++) {
if (i < max_sticks || (IS_POT_SLIDER_AVAILABLE(i - max_sticks) && if (i < max_sticks || (IS_POT_SLIDER_AVAILABLE(i - max_sticks) &&
!IS_POT_MULTIPOS(i - max_sticks))) { !IS_POT_MULTIPOS(i - max_sticks))) {
lv_btnmatrix_set_btn_ctrl(lvobj, btn_id, LV_BTNMATRIX_CTRL_RECOLOR); setTextAndState(btn_id);
setTextWithColor(btn_id);
btn_id++; btn_id++;
} }
} }
@@ -363,31 +350,20 @@ CenterBeepsMatrix::CenterBeepsMatrix(Window* parent, const rect_t& r) :
uint8_t rows = ((btn_cnt - 1) / SW_BTNS) + 1; uint8_t rows = ((btn_cnt - 1) / SW_BTNS) + 1;
lv_obj_set_height(lvobj, (rows * LV_DPI_DEF) / 3); lv_obj_set_height(lvobj, (rows * LV_DPI_DEF) / 3);
lv_obj_set_style_bg_opa(lvobj, LV_OPA_0, LV_PART_MAIN);
lv_obj_set_style_pad_all(lvobj, 4, LV_PART_MAIN); lv_obj_set_style_pad_all(lvobj, 4, LV_PART_MAIN);
lv_obj_set_style_pad_left(lvobj, LV_DPI_DEF / 10, LV_PART_MAIN);
lv_obj_set_style_pad_row(lvobj, 4, LV_PART_MAIN); lv_obj_set_style_pad_row(lvobj, 4, LV_PART_MAIN);
lv_obj_set_style_pad_column(lvobj, 4, LV_PART_MAIN); lv_obj_set_style_pad_column(lvobj, 4, LV_PART_MAIN);
lv_obj_remove_style(lvobj, nullptr, LV_PART_MAIN | LV_STATE_FOCUSED);
lv_obj_remove_style(lvobj, nullptr, LV_PART_MAIN | LV_STATE_EDITED);
} }
void CenterBeepsMatrix::setTextWithColor(uint8_t btn_id) void CenterBeepsMatrix::setTextAndState(uint8_t btn_id)
{ {
auto max_sticks = adcGetMaxInputs(ADC_INPUT_MAIN); auto max_sticks = adcGetMaxInputs(ADC_INPUT_MAIN);
if (ana_idx[btn_id] < max_sticks) if (ana_idx[btn_id] < max_sticks)
setText(btn_id, makeRecolor(getAnalogShortLabel(ana_idx[btn_id]), setText(btn_id, getAnalogShortLabel(ana_idx[btn_id]));
isActive(btn_id) ? COLOR_THEME_PRIMARY1
: COLOR_THEME_SECONDARY1)
.c_str());
else else
setText(btn_id, makeRecolor(getAnalogLabel(ADC_INPUT_POT, ana_idx[btn_id] - max_sticks), setText(btn_id, getAnalogLabel(ADC_INPUT_POT, ana_idx[btn_id] - max_sticks));
isActive(btn_id) ? COLOR_THEME_PRIMARY1 setChecked(btn_id);
: COLOR_THEME_SECONDARY1)
.c_str());
} }
void CenterBeepsMatrix::onPress(uint8_t btn_id) void CenterBeepsMatrix::onPress(uint8_t btn_id)
@@ -395,7 +371,7 @@ void CenterBeepsMatrix::onPress(uint8_t btn_id)
if (btn_id >= max_analogs) return; if (btn_id >= max_analogs) return;
uint8_t i = ana_idx[btn_id]; uint8_t i = ana_idx[btn_id];
BFBIT_FLIP(g_model.beepANACenter, bfBit<BeepANACenter>(i)); BFBIT_FLIP(g_model.beepANACenter, bfBit<BeepANACenter>(i));
setTextWithColor(btn_id); setTextAndState(btn_id);
SET_DIRTY(); SET_DIRTY();
} }
+19 -19
View File
@@ -72,7 +72,7 @@ extern ColorMaintainer colorMaintainer;
class ThemedStaticText : public StaticText class ThemedStaticText : public StaticText
{ {
public: public:
ThemedStaticText(FormGroup *window, const rect_t &rect, std::string text, LcdColorIndex colorIndex) : ThemedStaticText(FormWindow *window, const rect_t &rect, std::string text, LcdColorIndex colorIndex) :
StaticText(window, rect, text, 0, COLOR(colorIndex)), StaticText(window, rect, text, 0, COLOR(colorIndex)),
_colorIndex(colorIndex) _colorIndex(colorIndex)
{ {
@@ -90,11 +90,11 @@ class ThemedStaticText : public StaticText
LcdColorIndex _colorIndex; LcdColorIndex _colorIndex;
}; };
class ThemedCheckBox : public CheckBox class ThemedCheckBox : public ToggleSwitch
{ {
public: public:
ThemedCheckBox(Window *parent, rect_t rect, bool checked) : ThemedCheckBox(Window *parent, rect_t rect, bool checked) :
CheckBox(parent, rect, [=]() { return checked; }, [](uint8_t value) {}, NO_FOCUS), ToggleSwitch(parent, rect, [=]() { return checked; }, [](uint8_t value) {}, NO_FOCUS),
checked(checked) checked(checked)
{ {
enable(false); enable(false);
@@ -112,7 +112,7 @@ class ThemedCheckBox : public CheckBox
void paint(BitmapBuffer *dc) override void paint(BitmapBuffer *dc) override
{ {
colorMaintainer.applyColorValues(); colorMaintainer.applyColorValues();
CheckBox::paint(dc); ToggleSwitch::paint(dc);
colorMaintainer.restoreColorValues(); colorMaintainer.restoreColorValues();
} }
@@ -147,7 +147,7 @@ class ThemedMainViewHorizontalSlider : public MainViewHorizontalSlider
class ThemedButton : public TextButton class ThemedButton : public TextButton
{ {
public: public:
ThemedButton(FormGroup *window, const rect_t &rect, std::string text, bool isChecked, WindowFlags windowFlags, ThemedButton(FormWindow *window, const rect_t &rect, std::string text, bool isChecked, WindowFlags windowFlags,
LcdColorIndex colorIndex) : LcdColorIndex colorIndex) :
TextButton(window, rect, text, nullptr, windowFlags | NO_FOCUS), TextButton(window, rect, text, nullptr, windowFlags | NO_FOCUS),
_colorIndex(colorIndex), _colorIndex(colorIndex),
@@ -219,31 +219,31 @@ class ThemedTextEdit : public TextEdit
}; };
// display controls using the appropriate theme. // display controls using the appropriate theme.
class PreviewWindow : public FormGroup class PreviewWindow : public FormWindow
{ {
public: public:
PreviewWindow(Window *window, rect_t rect, PreviewWindow(Window *window, rect_t rect,
std::vector<ColorEntry> colorList) : std::vector<ColorEntry> colorList) :
FormGroup(window, rect, NO_FOCUS), _colorList(colorList) FormWindow(window, rect, NO_FOCUS), _colorList(colorList)
{ {
// reset default group to avoid focus // reset default group to avoid focus
lv_group_t* def_group = lv_group_get_default(); lv_group_t* def_group = lv_group_get_default();
lv_group_set_default(nullptr); lv_group_set_default(nullptr);
new ThemedStaticText(this, {5, 40, 100, LINE_HEIGHT}, STR_THEME_CHECKBOX, COLOR_THEME_PRIMARY1_INDEX); new ThemedStaticText(this, {5, 44, 100, PAGE_LINE_HEIGHT}, STR_THEME_CHECKBOX, COLOR_THEME_PRIMARY1_INDEX);
new ThemedCheckBox(this, {100 + 15, 40, 20, LINE_HEIGHT}, true); new ThemedCheckBox(this, {100, 40, 40, 28}, true);
new ThemedCheckBox(this, {140 + 15, 40, 20, LINE_HEIGHT}, false); new ThemedCheckBox(this, {150, 40, 40, 28}, false);
new ThemedButton(this, {190, 40, 100, LINE_HEIGHT + 10}, STR_THEME_ACTIVE, true, BUTTON_CHECKED, COLOR_THEME_PRIMARY1_INDEX); new ThemedButton(this, {210, 40, 100, PAGE_LINE_HEIGHT + 10}, STR_THEME_ACTIVE, true, BUTTON_CHECKED, COLOR_THEME_PRIMARY1_INDEX);
new ThemedButton(this, {190, 75, 100, LINE_HEIGHT + 10}, STR_THEME_REGULAR, false, 0, COLOR_THEME_PRIMARY1_INDEX); new ThemedButton(this, {210, 75, 100, PAGE_LINE_HEIGHT + 10}, STR_THEME_REGULAR, false, 0, COLOR_THEME_PRIMARY1_INDEX);
new ThemedMainViewHorizontalTrim(this, {5, 65, HORIZONTAL_SLIDERS_WIDTH, 20}, 0); new ThemedMainViewHorizontalTrim(this, {5, 75, HORIZONTAL_SLIDERS_WIDTH, 20}, 0);
new ThemedMainViewHorizontalSlider(this, {5, 87, HORIZONTAL_SLIDERS_WIDTH, 20}, 0); new ThemedMainViewHorizontalSlider(this, {5, 97, HORIZONTAL_SLIDERS_WIDTH, 20}, 0);
new ThemedStaticText(this, {5, 115, 100, LINE_HEIGHT}, STR_THEME_WARNING, COLOR_THEME_WARNING_INDEX); new ThemedStaticText(this, {5, 122, 100, PAGE_LINE_HEIGHT}, STR_THEME_WARNING, COLOR_THEME_WARNING_INDEX);
new ThemedStaticText(this, {5, 140, 100, LINE_HEIGHT}, STR_THEME_DISABLED, COLOR_THEME_DISABLED_INDEX); new ThemedStaticText(this, {5, 144, 100, PAGE_LINE_HEIGHT}, STR_THEME_DISABLED, COLOR_THEME_DISABLED_INDEX);
new ThemedTextEdit(this, {5, 160, 100, LINE_HEIGHT + 1}, STR_THEME_EDIT, new ThemedTextEdit(this, {5, 170, 100, 32}, STR_THEME_EDIT,
COLOR_THEME_EDIT_INDEX, COLOR_THEME_PRIMARY2_INDEX); COLOR_THEME_EDIT_INDEX, COLOR_THEME_PRIMARY2_INDEX);
new ThemedTextEdit(this, {110, 160, 100, LINE_HEIGHT + 1}, STR_THEME_FOCUS, new ThemedTextEdit(this, {110, 170, 100, 32}, STR_THEME_FOCUS,
COLOR_THEME_FOCUS_INDEX, COLOR_THEME_PRIMARY2_INDEX); COLOR_THEME_FOCUS_INDEX, COLOR_THEME_PRIMARY2_INDEX);
ticks = 0; ticks = 0;
@@ -336,7 +336,7 @@ class PreviewWindow : public FormGroup
protected: protected:
std::vector<ColorEntry> _colorList; std::vector<ColorEntry> _colorList;
CheckBox *checkBox; ToggleSwitch *checkBox;
tmr10ms_t ticks; tmr10ms_t ticks;
}; };
+1 -1
View File
@@ -29,7 +29,7 @@
PXX1AntennaSettings::PXX1AntennaSettings(Window* parent, PXX1AntennaSettings::PXX1AntennaSettings(Window* parent,
const FlexGridLayout& g, const FlexGridLayout& g,
uint8_t moduleIdx) : uint8_t moduleIdx) :
FormGroup(parent, rect_t{}), md(&g_model.moduleData[moduleIdx]) FormWindow(parent, rect_t{}), md(&g_model.moduleData[moduleIdx])
{ {
FlexGridLayout grid(g); FlexGridLayout grid(g);
setFlexLayout(); setFlexLayout();

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