Skip to content

Commit

Permalink
fix(color): Fix inputs and mixes scroll order (EdgeTX#3785)
Browse files Browse the repository at this point in the history
* Fix scroll order when adding new inputs and mixes.

* Set focus to first input/mix line, if one exists. Otherwise set focus to '+' button.
  • Loading branch information
philmoz authored and MRC3742 committed Dec 22, 2023
1 parent 30d5157 commit f22acbd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 29 deletions.
22 changes: 14 additions & 8 deletions radio/src/gui/colorlcd/model_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,18 @@ void ModelInputsPage::build(FormWindow *window)
form = new FormWindow(window, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);

auto btn = new TextButton(window, rect_t{}, LV_SYMBOL_PLUS, [=]() {
newInput();
return 0;
});
auto btn_obj = btn->getLvObj();
lv_obj_set_width(btn_obj, lv_pct(100));
lv_group_focus_obj(btn_obj);

groups.clear();
lines.clear();

bool focusSet = false;
uint8_t index = 0;
ExpoData* line = g_model.expoData;
for (uint8_t input = 0; input < MAX_INPUTS; input++) {
Expand All @@ -462,7 +471,11 @@ void ModelInputsPage::build(FormWindow *window)
groups.emplace_back(group);
while (index < MAX_EXPOS && line->chn == input && EXPO_VALID(line)) {
// one button per input line
createLineButton(group, index);
auto btn = createLineButton(group, index);
if (!focusSet) {
focusSet = true;
lv_group_focus_obj(btn->getLvObj());
}
++index;
++line;
}
Expand All @@ -473,12 +486,5 @@ void ModelInputsPage::build(FormWindow *window)
break;
}
}

auto btn = new TextButton(window, rect_t{}, LV_SYMBOL_PLUS, [=]() {
newInput();
return 0;
});
auto btn_obj = btn->getLvObj();
lv_obj_set_width(btn_obj, lv_pct(100));
}

48 changes: 27 additions & 21 deletions radio/src/gui/colorlcd/model_mixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,31 @@ void ModelMixesPage::build(FormWindow * window)
form = new FormWindow(window, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);

auto box = new FormWindow(window, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
box->padLeft(lv_dpx(8));

auto box_obj = box->getLvObj();
lv_obj_set_width(box_obj, lv_pct(100));
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 CheckBox(
box, rect_t{}, [=]() { return showMonitors; },
[=](uint8_t val) { enableMonitors(val); });

auto btn = new TextButton(window, rect_t{}, LV_SYMBOL_PLUS, [=]() {
newMix();
return 0;
});
auto btn_obj = btn->getLvObj();
lv_obj_set_width(btn_obj, lv_pct(100));
lv_group_focus_obj(btn_obj);

groups.clear();
lines.clear();

bool focusSet = false;
uint8_t index = 0;
MixData* line = g_model.mixData;
for (uint8_t ch = 0; (ch < MAX_OUTPUT_CHANNELS) && (index < MAX_MIXERS); ch++) {
Expand All @@ -423,32 +445,16 @@ void ModelMixesPage::build(FormWindow * window)
groups.emplace_back(group);
while (index < MAX_MIXERS && (line->destCh == ch)) {
// one button per input line
createLineButton(group, index);
auto btn = createLineButton(group, index);
if (!focusSet) {
focusSet = true;
lv_group_focus_obj(btn->getLvObj());
}
++index;
++line;
}
}
}

auto box = new FormGroup(window, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
box->padLeft(lv_dpx(8));

auto box_obj = box->getLvObj();
lv_obj_set_width(box_obj, lv_pct(100));
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 CheckBox(
box, rect_t{}, [=]() { return showMonitors; },
[=](uint8_t val) { enableMonitors(val); });

auto btn = new TextButton(window, rect_t{}, LV_SYMBOL_PLUS, [=]() {
newMix();
return 0;
});
auto btn_obj = btn->getLvObj();
lv_obj_set_width(btn_obj, lv_pct(100));
}

void ModelMixesPage::enableMonitors(bool enabled)
Expand Down

0 comments on commit f22acbd

Please sign in to comment.