flex layout: add fields switches automatically to next row

This commit is contained in:
Raphael Coeffic
2022-06-11 15:13:11 +02:00
committed by Raphael Coeffic
parent 9529151bea
commit 2caea0eb53
3 changed files with 15 additions and 6 deletions
+12 -3
View File
@@ -61,11 +61,20 @@ class FlexGridLayout
}
}
void nextColumn() { col_pos++; }
void nextRow() { row_pos++; }
void resetPos() { col_pos = 0; row_pos = 0; }
void nextColumn() { col_pos += col_span; }
void nextRow() { row_pos += row_span; }
void nextCell()
{
nextColumn();
if (col_dsc[col_pos] == LV_GRID_TEMPLATE_LAST) {
nextRow();
col_pos = 0;
}
}
void setColSpan(uint8_t span) { col_span = span; }
void setRowSpan(uint8_t span) { row_span = span; }
};
+2 -2
View File
@@ -141,7 +141,7 @@ void FormGroup::Line::addChild(Window* window, bool front)
Window::addChild(window, front);
if (layout) {
layout->add(window->getLvObj());
layout->nextColumn();
layout->nextCell();
}
}
@@ -205,7 +205,7 @@ void FormGroup::setFlexLayout(lv_flex_flow_t flow, lv_coord_t padding)
FormGroup::Line* FormGroup::newLine(FlexGridLayout* layout)
{
layout->resetPos();
if (layout) layout->resetPos();
auto lv_line = lv_obj_create(lvobj);
return new Line(this, lv_line, layout);
}
+1 -1
View File
@@ -152,7 +152,7 @@ class FormGroup : public FormField, public FieldContainer
void clear();
void setFlexLayout(lv_flex_flow_t flow = LV_FLEX_FLOW_COLUMN, lv_coord_t padding = 0);
Line* newLine(FlexGridLayout* layout);
Line* newLine(FlexGridLayout* layout = nullptr);
void setFocus(uint8_t flag = SET_FOCUS_DEFAULT,
Window *from = nullptr) override;