Choice can now accept an array of const char * as values argument

This commit is contained in:
Bertrand Songis
2020-03-31 15:52:12 +02:00
parent 44e3e34602
commit dc1848843d
7 changed files with 12 additions and 10 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ class GVarNumberEdit: public FormGroup
// The main field
int32_t value = getValue();
if (GV_IS_GV_VALUE(value, vmin, vmax)) {
auto result = new Choice(this, {0, 0, width() - GVAR_BUTTON_WIDTH, height()}, nullptr, -MAX_GVARS, MAX_GVARS - 1,
auto result = new Choice(this, {0, 0, width() - GVAR_BUTTON_WIDTH, height()}, -MAX_GVARS, MAX_GVARS - 1,
[=]() {
uint16_t gvar1 = GV_GET_GV1_VALUE(vmin, vmax);
return GV_INDEX_CALC_DELTA(getValue(), gvar1);
+1 -1
View File
@@ -156,7 +156,7 @@ class InputEditWindow: public Page {
case CURVE_REF_CUSTOM:
{
auto choice = new Choice(curveParamField, rect, nullptr, -MAX_CURVES, MAX_CURVES, GET_SET_DEFAULT(line->curve.value));
auto choice = new Choice(curveParamField, rect, -MAX_CURVES, MAX_CURVES, GET_SET_DEFAULT(line->curve.value));
choice->setTextHandler([](int value) {
return getCurveString(value);
});
+1 -1
View File
@@ -216,7 +216,7 @@ class MixEditWindow : public Page {
case CURVE_REF_CUSTOM:
{
auto choice = new Choice(curveParamField, rect, nullptr, -MAX_CURVES, MAX_CURVES, GET_SET_DEFAULT(line->curve.value));
auto choice = new Choice(curveParamField, rect, -MAX_CURVES, MAX_CURVES, GET_SET_DEFAULT(line->curve.value));
choice->setTextHandler([](int value) {
return getCurveString(value);
});
+3 -1
View File
@@ -932,6 +932,8 @@ void onBindMenu(const char * result)
moduleState[moduleIdx].mode = MODULE_MODE_BIND;
}
const char * STR_TIMER_MODES[] = {"OFF", "ON", "Start", "Throttle", "Throttle %", "Throttle Start"};
void ModelSetupPage::build(FormWindow * window)
{
FormGridLayout grid;
@@ -983,7 +985,7 @@ void ModelSetupPage::build(FormWindow * window)
// Timer mode
new StaticText(window, grid.getLabelSlot(true), STR_MODE);
grid.nextLine();
new Choice(group, timerGrid.getSlot(2, 0), "\011""OFF\0 ""ON\0 ""Start\0 ""Thr\0 ""Thr%\0 ""Thr Start", 0, TMRMODE_MAX, GET_SET_DEFAULT(timer->mode));
new Choice(group, timerGrid.getSlot(2, 0), STR_TIMER_MODES, 0, TMRMODE_MAX, GET_SET_DEFAULT(timer->mode));
new SwitchChoice(group, timerGrid.getSlot(2, 1), SWSRC_FIRST, SWSRC_LAST, GET_SET_DEFAULT(timer->swtch));
timerGrid.nextLine();
+3 -3
View File
@@ -410,7 +410,7 @@ void RadioSetupPage::build(FormWindow * window)
// Audio language
new StaticText(window, grid.getLabelSlot(), STR_VOICE_LANGUAGE);
auto choice = new Choice(window, grid.getFieldSlot(), nullptr, 0, DIM(languagePacks) - 2, GET_VALUE(currentLanguagePackIdx),
auto choice = new Choice(window, grid.getFieldSlot(), 0, DIM(languagePacks) - 2, GET_VALUE(currentLanguagePackIdx),
[](uint8_t newValue) {
currentLanguagePackIdx = newValue;
currentLanguagePack = languagePacks[currentLanguagePackIdx];
@@ -455,7 +455,7 @@ void RadioSetupPage::build(FormWindow * window)
// RX channel order
new StaticText(window, grid.getLabelSlot(), STR_RXCHANNELORD); // RAET->AETR
choice = new Choice(window, grid.getFieldSlot(), nullptr, 0, 4*3*2 - 1, GET_SET_DEFAULT(g_eeGeneral.templateSetup));
choice = new Choice(window, grid.getFieldSlot(), 0, 4*3*2 - 1, GET_SET_DEFAULT(g_eeGeneral.templateSetup));
choice->setTextHandler([](uint8_t value) {
char s[5];
for (uint8_t i=0; i<4; i++) {
@@ -468,7 +468,7 @@ void RadioSetupPage::build(FormWindow * window)
// Stick mode
new StaticText(window, grid.getLabelSlot(), STR_MODE);
choice = new Choice(window, grid.getFieldSlot(), nullptr, 0, 3, GET_DEFAULT(g_eeGeneral.stickMode),
choice = new Choice(window, grid.getFieldSlot(), 0, 3, GET_DEFAULT(g_eeGeneral.stickMode),
[=](uint8_t newValue) {
pausePulses();
g_eeGeneral.stickMode = newValue;
+2 -2
View File
@@ -91,7 +91,7 @@ class SpecialFunctionEditPage : public Page {
case FUNC_RESET:
if (CFN_PARAM(cfn) < FUNC_RESET_PARAM_FIRST_TELEM) {
new StaticText(specialFunctionOneWindow, grid.getLabelSlot(), STR_RESET);
auto choice = new Choice(specialFunctionOneWindow, grid.getFieldSlot(), nullptr, 0,
auto choice = new Choice(specialFunctionOneWindow, grid.getFieldSlot(), 0,
FUNC_RESET_PARAM_FIRST_TELEM + lastUsedTelemetryIndex(),
GET_SET_DEFAULT(CFN_PARAM(cfn)));
choice->setAvailableHandler(isSourceAvailableInResetSpecialFunction);
@@ -139,7 +139,7 @@ class SpecialFunctionEditPage : public Page {
case FUNC_SET_TIMER: {
new StaticText(specialFunctionOneWindow, grid.getLabelSlot(), STR_TIMER);
auto timerchoice = new Choice(specialFunctionOneWindow, grid.getFieldSlot(), nullptr, 0, TIMERS - 1, GET_SET_DEFAULT(CFN_TIMER_INDEX(cfn)));
auto timerchoice = new Choice(specialFunctionOneWindow, grid.getFieldSlot(), 0, TIMERS - 1, GET_SET_DEFAULT(CFN_TIMER_INDEX(cfn)));
timerchoice->setTextHandler([](int32_t value) {
return std::string(STR_TIMER) + std::to_string(value + 1);
});