Skip to content

Commit

Permalink
For pages display via TabsGroup class. move the scroll bar setting to…
Browse files Browse the repository at this point in the history
… the 'body' window.
  • Loading branch information
Phil Mitchell committed Mar 16, 2023
1 parent 2b6fbcf commit 42b4d91
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 169 deletions.
12 changes: 4 additions & 8 deletions radio/src/gui/colorlcd/model_curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,8 @@ void ModelCurvesPage::build(FormWindow * window)
#endif
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};

window->padAll(0);
lv_obj_set_scrollbar_mode(window->getLvObj(), LV_SCROLLBAR_MODE_AUTO);

auto form = new FormWindow(window, rect_t{});
form->setFlexLayout();
form->padAll(6);
window->padAll(6);
window->setFlexLayout();

FlexGridLayout grid(col_dsc, row_dsc);

Expand All @@ -222,7 +218,7 @@ void ModelCurvesPage::build(FormWindow * window)
for (uint8_t index = 0; index < MAX_CURVES; index++) {
if (isCurveUsed(index)) {
if ((curveIndex % PER_ROW) == 0) {
line = form->newLine(&grid);
line = window->newLine(&grid);
lv_obj_set_grid_align(line->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN, LV_GRID_ALIGN_SPACE_BETWEEN);
}

Expand Down Expand Up @@ -285,7 +281,7 @@ void ModelCurvesPage::build(FormWindow * window)

if (curveIndex < MAX_CURVES) {
if ((curveIndex % PER_ROW) == 0) {
line = form->newLine(&grid);
line = window->newLine(&grid);
lv_obj_set_grid_align(line->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN,
LV_GRID_ALIGN_SPACE_BETWEEN);
}
Expand Down
13 changes: 3 additions & 10 deletions radio/src/gui/colorlcd/model_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void ModelInputsPage::removeLine(InputMixButton* l)
}
}

InputMixGroup* ModelInputsPage::createGroup(FormGroup* form, mixsrc_t src)
InputMixGroup* ModelInputsPage::createGroup(FormWindow* form, mixsrc_t src)
{
return new InputMixGroup(form, src);
}
Expand Down Expand Up @@ -442,16 +442,9 @@ void ModelInputsPage::pasteInputAfter(uint8_t dst_idx)

void ModelInputsPage::build(FormWindow *window)
{
window->padAll(0);
lv_obj_set_scrollbar_mode(window->getLvObj(), LV_SCROLLBAR_MODE_AUTO);
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);

form = new FormGroup(window, rect_t{});
form->setFlexLayout();
form->padAll(lv_dpx(8));
form->padRow(lv_dpx(4));

auto form_obj = form->getLvObj();
lv_obj_set_width(form_obj, lv_pct(100));
form = window;

groups.clear();
lines.clear();
Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/colorlcd/model_inputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ModelInputsPage : public PageTab
void build(FormWindow *window) override;

protected:
FormGroup* form = nullptr;
FormWindow* form = nullptr;
std::list<InputMixGroup*> groups;
std::list<InputMixButton*> lines;
InputMixButton* _copySrc = nullptr;
Expand All @@ -49,7 +49,7 @@ class ModelInputsPage : public PageTab

virtual void addLineButton(uint8_t index);
virtual void addLineButton(mixsrc_t src, uint8_t index);
virtual InputMixGroup* createGroup(FormGroup* form, mixsrc_t src);
virtual InputMixGroup* createGroup(FormWindow* form, mixsrc_t src);
virtual InputMixButton* createLineButton(InputMixGroup *group, uint8_t index);

void newInput();
Expand Down
12 changes: 4 additions & 8 deletions radio/src/gui/colorlcd/model_logical_switches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,8 @@ void ModelLogicalSwitchesPage::build(FormWindow* window)
LV_GRID_TEMPLATE_LAST};
#endif

window->padAll(0);
lv_obj_set_scrollbar_mode(window->getLvObj(), LV_SCROLLBAR_MODE_AUTO);

auto form = new FormWindow(window, rect_t{});
form->setFlexLayout();
form->padAll(4);
window->padAll(4);
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 0);

FlexGridLayout grid(l_col_dsc, row_dsc, 2);

Expand All @@ -598,7 +594,7 @@ void ModelLogicalSwitchesPage::build(FormWindow* window)
bool isActive = (ls->func != LS_FUNC_NONE);

if (isActive) {
line = form->newLine(&grid);
line = window->newLine(&grid);

button = new LogicalSwitchButton(
line, rect_t{0, 0, window->width() - 12, LS_BUTTON_H}, i);
Expand Down Expand Up @@ -665,7 +661,7 @@ void ModelLogicalSwitchesPage::build(FormWindow* window)
}

if (hasEmptySwitch) {
line = form->newLine(&grid);
line = window->newLine(&grid);
addButton =
new TextButton(line, rect_t{0, 0, window->width() - 12, LS_BUTTON_H},
LV_SYMBOL_PLUS, [=]() {
Expand Down
10 changes: 3 additions & 7 deletions radio/src/gui/colorlcd/model_mixer_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +289,16 @@ void ModelMixerScriptsPage::rebuild(FormWindow * window, int8_t focusIdx)

void ModelMixerScriptsPage::build(FormWindow * window, int8_t focusIdx)
{
window->padAll(0);
lv_obj_set_scrollbar_mode(window->getLvObj(), LV_SCROLLBAR_MODE_AUTO);

auto form = new FormWindow(window, rect_t{});
form->setFlexLayout();
form->padAll(4);
window->padAll(4);
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 0);

FlexGridLayout grid(col_dsc, row_dsc, 2);

FormWindow::Line* line;

int8_t scriptIdx = 0;
for (int8_t idx = 0; idx < MAX_SCRIPTS; idx++) {
auto line = form->newLine(&grid);
auto line = window->newLine(&grid);

ScriptInternalData* runtimeData = nullptr;
ScriptData* const sd = &(g_model.scriptsData[idx]);
Expand Down
12 changes: 3 additions & 9 deletions radio/src/gui/colorlcd/model_mixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ InputMixGroup* ModelMixesPage::getGroupByIndex(uint8_t index)
return getGroupBySrc(MIXSRC_CH1 + ch);
}

InputMixGroup* ModelMixesPage::createGroup(FormGroup* form, mixsrc_t src)
InputMixGroup* ModelMixesPage::createGroup(FormWindow* form, mixsrc_t src)
{
auto group = new InputMixGroup(form, src);
if (showMonitors) group->enableMixerMonitor(src - MIXSRC_CH1);
Expand Down Expand Up @@ -512,16 +512,10 @@ void ModelMixesPage::pasteMixAfter(uint8_t dst_idx)
void ModelMixesPage::build(FormWindow * window)
{
scroll_win = window->getParent();
window->padAll(0);
lv_obj_set_scrollbar_mode(window->getLvObj(), LV_SCROLLBAR_MODE_AUTO);

form = new FormGroup(window, rect_t{});
form->setFlexLayout();
form->padAll(lv_dpx(8));
form->padRow(lv_dpx(4));
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);

auto form_obj = form->getLvObj();
lv_obj_set_width(form_obj, lv_pct(100));
form = window;

groups.clear();
lines.clear();
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/model_mixes.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ModelMixesPage : public ModelInputsPage

void addLineButton(uint8_t index) override;
void addLineButton(mixsrc_t src, uint8_t index) override;
InputMixGroup* createGroup(FormGroup* form, mixsrc_t src) override;
InputMixGroup* createGroup(FormWindow* form, mixsrc_t src) override;
InputMixButton* createLineButton(InputMixGroup* group,
uint8_t index) override;

Expand Down
36 changes: 16 additions & 20 deletions radio/src/gui/colorlcd/model_outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,45 +291,41 @@ ModelOutputsPage::ModelOutputsPage() :

void ModelOutputsPage::build(FormWindow *window)
{
window->padAll(0);
lv_obj_set_scrollbar_mode(window->getLvObj(), LV_SCROLLBAR_MODE_AUTO);
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);

auto form = new FormGroup(window, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(16));
form->padAll(lv_dpx(8));
form->padRow(lv_dpx(4));
lv_obj_set_style_flex_cross_place(window->getLvObj(), LV_FLEX_ALIGN_START, 0);

auto form_obj = form->getLvObj();
lv_obj_set_style_flex_cross_place(form_obj, LV_FLEX_ALIGN_CENTER, 0);
auto box = new FormWindow(window, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8));
box->padRow(4);
lv_obj_set_style_flex_cross_place(box->getLvObj(), LV_FLEX_ALIGN_CENTER, 0);

new TextButton(form, rect_t{}, STR_ADD_ALL_TRIMS_TO_SUBTRIMS, [=]() {
new TextButton(box, rect_t{}, STR_ADD_ALL_TRIMS_TO_SUBTRIMS, [=]() {
moveTrimsToOffsets();
form->invalidate();
window->invalidate();
return 0;
});

auto box = new FormGroup(form, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
auto box2 = new FormWindow(box, rect_t{});
box2->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
box2->setWidth(LV_SIZE_CONTENT);
lv_obj_set_style_flex_cross_place(box2->getLvObj(), LV_FLEX_ALIGN_CENTER, 0);

auto box_obj = box->getLvObj();
lv_obj_set_width(box_obj, LV_SIZE_CONTENT);
lv_obj_set_style_flex_cross_place(box_obj, LV_FLEX_ALIGN_CENTER, 0);

new StaticText(box, rect_t{}, STR_ELIMITS, 0, COLOR_THEME_PRIMARY1);
new CheckBox(box, rect_t{}, GET_SET_DEFAULT(g_model.extendedLimits));
new StaticText(box2, rect_t{}, STR_ELIMITS, 0, COLOR_THEME_PRIMARY1);
auto cb = new CheckBox(box2, rect_t{}, GET_SET_DEFAULT(g_model.extendedLimits));

for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) {

// Channel settings
auto btn = new OutputLineButton(form, ch);
auto btn = new OutputLineButton(window, ch);
#if LCD_W > LCD_H
// Initial scroll height is incorrect without this??? (Issue #3186)
btn->setHeight(35);
#endif

LimitData* output = limitAddress(ch);
btn->setPressHandler([=]() -> uint8_t {
Menu *menu = new Menu(form);
Menu *menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() {
editOutput(ch, btn);
});
Expand Down
21 changes: 8 additions & 13 deletions radio/src/gui/colorlcd/model_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,27 +223,22 @@ static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT,

void ModelSetupPage::build(FormWindow * window)
{
window->padAll(0);
lv_obj_set_scrollbar_mode(window->getLvObj(), LV_SCROLLBAR_MODE_AUTO);

auto wform = new FormWindow(window, rect_t{});
wform->setFlexLayout();
wform->padAll(4);
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 0);

FlexGridLayout grid(line_col_dsc, line_row_dsc, 2);

// Model name
auto line = wform->newLine(&grid);
auto line = window->newLine(&grid);
new StaticText(line, rect_t{}, STR_MODELNAME, 0, COLOR_THEME_PRIMARY1);
new ModelNameEdit(line, rect_t{});

// Model labels
line = wform->newLine(&grid);
line = window->newLine(&grid);
new StaticText(line, rect_t{}, STR_LABELS, 0, COLOR_THEME_PRIMARY1);
auto curmod = modelslist.getCurrentModel();
labelTextButton =
new TextButton(line, rect_t{}, modelslabels.getBulletLabelString(curmod ,STR_UNLABELEDMODEL), [=] () {
Menu *menu = new Menu(wform, true);
Menu *menu = new Menu(window, true);
menu->setTitle(STR_LABELS);
for (auto &label: modelslabels.getLabels()) {
menu->addLineBuffered(label,
Expand All @@ -265,26 +260,26 @@ void ModelSetupPage::build(FormWindow * window)
});

// Bitmap
line = wform->newLine(&grid);
line = window->newLine(&grid);
new StaticText(line, rect_t{}, STR_BITMAP, 0, COLOR_THEME_PRIMARY1);
// TODO: show bitmap thumbnail instead?
new ModelBitmapEdit(line, rect_t{});

// Global functions
line = wform->newLine(&grid);
line = window->newLine(&grid);
new StaticText(line, rect_t{}, STR_USE_GLOBAL_FUNCS, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_model.noGlobalFunctions));

// Model ADC jitter filter
line = wform->newLine(&grid);
line = window->newLine(&grid);
new StaticText(line, rect_t{}, STR_JITTER_FILTER, 0, COLOR_THEME_PRIMARY1);
new Choice(line, rect_t{}, STR_ADCFILTERVALUES, 0, 2,
GET_SET_DEFAULT(g_model.jitterFilter));

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};

auto oform = new FormGroup(wform, rect_t{});
auto oform = new FormGroup(window, rect_t{});
oform->setFlexLayout(LV_FLEX_FLOW_COLUMN, lv_dpx(PAGE_PADDING));
oform->padAll(PAGE_PADDING);

Expand Down
Loading

0 comments on commit 42b4d91

Please sign in to comment.