fix(color): Multiple fixes and improvements to switch and source popup menus (#4055)

* Fixes for switch and source select popup menus.
- Fix missing GV filter in source select
- Ensure all options are included in one of the filters
- Add misc filter to switch select (for TELE and ACT options)
- Show inverted and no-selection options when filter selected
- Make menu line height consistent.

* Fix selected item in list when filter applied.
This commit is contained in:
philmoz
2023-09-23 11:21:12 +10:00
committed by GitHub
parent c783f16b20
commit 55217dc303
8 changed files with 60 additions and 18 deletions
+22 -3
View File
@@ -40,20 +40,39 @@ class SourceChoiceMenuToolbar : public MenuToolbar
if (modelCustomScriptsEnabled())
addButton(STR_CHAR_LUA, MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA);
#endif
addButton(STR_CHAR_STICK, MIXSRC_FIRST_STICK, MIXSRC_LAST_STICK);
#if defined(PCBHORUS)
auto lastSource = MIXSRC_LAST_SPACEMOUSE;
#elif defined(IMU)
auto lastSource = MIXSRC_TILT_Y;
#else
auto lastSource = MIXSRC_LAST_STICK;
#endif
addButton(STR_CHAR_STICK, MIXSRC_FIRST_STICK, lastSource, [=](int16_t index) {
if (index >= MIXSRC_FIRST_POT && index <= MIXSRC_LAST_POT)
return false;
#if MAX_AXIS > 0
if (index >= MIXSRC_FIRST_AXIS && index <= MIXSRC_LAST_AXIS)
return false;
#endif
return index >= MIXSRC_FIRST_STICK && index <= lastSource;
});
addButton(STR_CHAR_POT, MIXSRC_FIRST_POT, MIXSRC_LAST_POT);
addButton(STR_CHAR_FUNCTION, MIXSRC_MIN, MIXSRC_MAX);
addButton(STR_CHAR_FUNCTION, MIXSRC_MIN, MIXSRC_LAST_TIMER, [=](int16_t index) {
return (index >= MIXSRC_MIN && index <= MIXSRC_MAX) || (index >= MIXSRC_TX_VOLTAGE && index <= MIXSRC_LAST_TIMER);
});
#if defined(HELI)
if (modelHeliEnabled())
addButton(STR_CHAR_CYC, MIXSRC_FIRST_HELI, MIXSRC_LAST_HELI);
#endif
addButton(STR_CHAR_TRIM, MIXSRC_FIRST_TRIM, MIXSRC_LAST_TRIM);
addButton(STR_CHAR_SWITCH, MIXSRC_FIRST_SWITCH, MIXSRC_LAST_SWITCH);
if (modelLSEnabled())
addButton(STR_CHAR_SWITCH, MIXSRC_FIRST_LOGICAL_SWITCH, MIXSRC_LAST_LOGICAL_SWITCH);
addButton(STR_CHAR_TRAINER, MIXSRC_FIRST_TRAINER, MIXSRC_LAST_TRAINER);
addButton(STR_CHAR_CHANNEL, MIXSRC_FIRST_CH, MIXSRC_LAST_CH);
#if defined(GVARS)
if (modelGVEnabled())
addButton(STR_CHAR_SLIDER, MIXSRC_LAST_GVAR, MIXSRC_FIRST_GVAR);
addButton(STR_CHAR_SLIDER, MIXSRC_FIRST_GVAR, MIXSRC_LAST_GVAR);
#endif
if (modelTelemetryEnabled())
addButton(STR_CHAR_TELEMETRY, MIXSRC_FIRST_TELEM, MIXSRC_LAST_TELEM);
+12 -3
View File
@@ -34,10 +34,19 @@ class SwitchChoiceMenuToolbar : public MenuToolbar
SwitchChoiceMenuToolbar(SwitchChoice* choice, Menu* menu) :
MenuToolbar(choice, menu)
{
addButton(STR_CHAR_SWITCH, SWSRC_FIRST_SWITCH, SWSRC_LAST_SWITCH);
addButton(STR_CHAR_SWITCH, SWSRC_FIRST_SWITCH, SWSRC_LAST_MULTIPOS_SWITCH);
addButton(STR_CHAR_TRIM, SWSRC_FIRST_TRIM, SWSRC_LAST_TRIM);
addButton(STR_CHAR_SWITCH, SWSRC_FIRST_LOGICAL_SWITCH,
SWSRC_LAST_LOGICAL_SWITCH);
addButton(STR_CHAR_SWITCH, SWSRC_FIRST_LOGICAL_SWITCH, SWSRC_LAST_LOGICAL_SWITCH);
addButton(STR_CHAR_TELEMETRY, SWSRC_FIRST_SENSOR, SWSRC_LAST_SENSOR);
#if defined(DEBUG_LATENCY)
auto lastSource = SWSRC_LATENCY_TOGGLE;
#else
auto lastSource = SWSRC_RADIO_ACTIVITY;
#endif
addButton(STR_CHAR_FUNCTION, SWSRC_TELEMETRY_STREAMING, lastSource, [=](int16_t index) {
index = abs(index);
return index == 0 || (index >= SWSRC_TELEMETRY_STREAMING && index <= lastSource && !(index >= SWSRC_FIRST_SENSOR && index <= SWSRC_LAST_SENSOR));
});
}
};
@@ -511,6 +511,7 @@ void table_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
lv_obj_add_style(obj, &styles.pad_small, LV_PART_ITEMS);
lv_obj_add_style(obj, &styles.pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
lv_obj_add_style(obj, &styles.bg_color_focus, LV_PART_ITEMS | LV_STATE_EDITED);
lv_obj_set_style_pad_ver(obj, 7, LV_PART_ITEMS);
}
void etx_keyboard_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)