FormGroup::Line: split parent and form group

This commit is contained in:
Raphael Coeffic
2022-06-11 15:13:11 +02:00
committed by Raphael Coeffic
parent 40268f8e52
commit 96d8022384
2 changed files with 26 additions and 11 deletions
+21 -10
View File
@@ -111,13 +111,25 @@ void FormField::setFocus(uint8_t flag, Window * from)
FormGroup::Line::Line(FormGroup* parent, lv_obj_t* obj,
FlexGridLayout* layout) :
Window(parent, obj), layout(layout)
Window(parent, obj), layout(layout), group(parent)
{
construct();
}
FormGroup::Line::Line(Window* parent, lv_obj_t* obj, FlexGridLayout* layout,
FormGroup* group) :
Window(parent, obj), layout(layout), group(group)
{
construct();
}
void FormGroup::Line::construct()
{
// forward scroll and focus
windowFlags |= FORWARD_SCROLL | FORM_FORWARD_FOCUS;
if (layout) {
layout->apply(obj);
layout->apply(lvobj);
}
lv_obj_set_height(lvobj, LV_SIZE_CONTENT);
@@ -135,8 +147,7 @@ void FormGroup::Line::addChild(Window* window, bool front)
void FormGroup::Line::addField(FormField *field, bool front)
{
auto form = static_cast<FormGroup*>(parent);
form->addField(field, front);
group->addField(field, front);
}
void FormGroup::Line::removeField(FormField *field)
@@ -257,12 +268,12 @@ void FormGroup::addField(FormField * field, bool front)
}
}
if (!focusWindow && !(field->getWindowFlags() & FORM_FORWARD_FOCUS)) {
field->setFocus(SET_FOCUS_DEFAULT);
}
else if (focusWindow == this && (windowFlags & FORM_FORWARD_FOCUS)) {
field->setFocus(SET_FOCUS_DEFAULT);
}
// if (!focusWindow && !(field->getWindowFlags() & FORM_FORWARD_FOCUS)) {
// field->setFocus(SET_FOCUS_DEFAULT);
// }
// else if (focusWindow == this && (windowFlags & FORM_FORWARD_FOCUS)) {
// field->setFocus(SET_FOCUS_DEFAULT);
// }
}
void FormGroup::setFocus(uint8_t flag, Window * from)
+5 -1
View File
@@ -128,9 +128,13 @@ class FormGroup : public FormField, public FieldContainer
class Line : public Window, public FieldContainer
{
FlexGridLayout* layout;
FormGroup* group;
void construct();
public:
Line(FormGroup *parent, lv_obj_t *lvobj, FlexGridLayout* layout);
Line(FormGroup *parent, lv_obj_t *obj, FlexGridLayout* layout);
Line(Window *parent, lv_obj_t *obj, FlexGridLayout* layout, FormGroup* group);
protected:
void addChild(Window* window, bool front = false) override;