fix(ui): Adjust model setup button layout to better fit portrait screen (#2956)
* Adjust model setup layout to better fix on portrait LCD screen. * Set buttons to fixed width and allow to grow vertically to fit text. * Cleanup layout logic - buttons stretched horizontally, centered vertically.
This commit is contained in:
@@ -282,56 +282,53 @@ void ModelSetupPage::build(FormWindow * window)
|
|||||||
new Choice(line, rect_t{}, STR_ADCFILTERVALUES, 0, 2,
|
new Choice(line, rect_t{}, STR_ADCFILTERVALUES, 0, 2,
|
||||||
GET_SET_DEFAULT(g_model.jitterFilter));
|
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(window, rect_t{});
|
||||||
|
oform->setFlexLayout(LV_FLEX_FLOW_COLUMN, lv_dpx(PAGE_PADDING));
|
||||||
|
oform->padAll(PAGE_PADDING);
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
auto form = new FormGroup(window, rect_t{});
|
auto form = new FormGroup(oform, rect_t{});
|
||||||
form->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8));
|
form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING));
|
||||||
lv_obj_set_style_flex_main_place(form->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0);
|
lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc);
|
||||||
form->padAll(lv_dpx(8));
|
|
||||||
|
|
||||||
Window* btn = new IntmoduleButton(form);
|
Window* btn = new IntmoduleButton(form);
|
||||||
lv_obj_set_style_min_width(btn->getLvObj(), LV_DPI_DEF, 0);
|
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||||
|
|
||||||
btn = new ExtmoduleButton(form);
|
btn = new ExtmoduleButton(form);
|
||||||
lv_obj_set_style_min_width(btn->getLvObj(), LV_DPI_DEF, 0);
|
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||||
|
|
||||||
btn = new TrainerModuleButton(form);
|
btn = new TrainerModuleButton(form);
|
||||||
lv_obj_set_style_min_width(btn->getLvObj(), LV_DPI_DEF, 0);
|
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(window, rect_t{});
|
form = new FormGroup(oform, rect_t{});
|
||||||
form->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8));
|
form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING));
|
||||||
lv_obj_set_style_flex_main_place(form->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0);
|
lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc);
|
||||||
form->padAll(lv_dpx(8));
|
|
||||||
|
|
||||||
btn = new SubScreenButton(form, TR_TIMER "1",
|
btn = new SubScreenButton(form, TR_TIMER "1", []() { new TimerWindow(0); });
|
||||||
[]() { new TimerWindow(0); });
|
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||||
lv_obj_set_style_min_width(btn->getLvObj(), LV_DPI_DEF, 0);
|
|
||||||
|
|
||||||
btn = new SubScreenButton(form, TR_TIMER "2",
|
btn = new SubScreenButton(form, TR_TIMER "2", []() { new TimerWindow(1); });
|
||||||
[]() { new TimerWindow(1); });
|
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||||
lv_obj_set_style_min_width(btn->getLvObj(), LV_DPI_DEF, 0);
|
|
||||||
|
|
||||||
btn = new SubScreenButton(form, TR_TIMER "3",
|
btn = new SubScreenButton(form, TR_TIMER "3", []() { new TimerWindow(2); });
|
||||||
[]() { 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_style_min_width(btn->getLvObj(), LV_DPI_DEF, 0);
|
|
||||||
|
|
||||||
|
form = new FormGroup(oform, rect_t{});
|
||||||
|
form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING));
|
||||||
|
lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc);
|
||||||
|
|
||||||
form = new FormGroup(window, rect_t{});
|
btn = new SubScreenButton(form, STR_PREFLIGHT, []() { new PreflightChecks(); });
|
||||||
form->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8));
|
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||||
lv_obj_set_style_flex_main_place(form->getLvObj(), LV_FLEX_ALIGN_SPACE_EVENLY, 0);
|
|
||||||
form->padAll(lv_dpx(8));
|
|
||||||
|
|
||||||
btn = new SubScreenButton(form, STR_PREFLIGHT,
|
btn = new SubScreenButton(form, STR_TRIMS, []() { new TrimsSetup(); });
|
||||||
[]() { new PreflightChecks(); });
|
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||||
lv_obj_set_style_min_width(btn->getLvObj(), LV_DPI_DEF, 0);
|
|
||||||
|
|
||||||
btn = new SubScreenButton(form, STR_TRIMS,
|
btn = new SubScreenButton(form, STR_THROTTLE_LABEL, []() { new ThrottleParams(); });
|
||||||
[]() { new TrimsSetup(); });
|
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||||
lv_obj_set_style_min_width(btn->getLvObj(), LV_DPI_DEF, 0);
|
|
||||||
|
|
||||||
btn = new SubScreenButton(form, STR_THROTTLE_LABEL,
|
|
||||||
[]() { new ThrottleParams(); });
|
|
||||||
lv_obj_set_style_min_width(btn->getLvObj(), LV_DPI_DEF, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_SUBSCREEN_BTNS 9
|
#define MAX_SUBSCREEN_BTNS 9
|
||||||
|
|||||||
Reference in New Issue
Block a user