1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

lv_page: fixes when child is added

This commit is contained in:
Gabor Kiss-Vamosi 2019-02-24 06:41:00 +01:00
parent 285ff7d3b4
commit ddbd8386d2
2 changed files with 13 additions and 5 deletions

View File

@ -49,10 +49,10 @@ typedef uint8_t lv_layout_t;
typedef enum {
LV_FIT_NONE,
LV_FIT_TIGHT,
LV_FIT_FLOOD,
LV_FIT_FILL,
LV_FIT_NONE, /*Do not change the size automatically*/
LV_FIT_TIGHT, /*Involve the children*/
LV_FIT_FLOOD, /*Align the size to the parent's edge*/
LV_FIT_FILL, /*Align the size to the parent's edge first but if there is an object out of it then involve it*/
}lv_fit_t;
typedef struct

View File

@ -103,7 +103,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_drag(ext->scrl, true);
lv_obj_set_drag_throw(ext->scrl, true);
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
lv_cont_set_fit4(ext->scrl, LV_FIT_NONE, LV_FIT_FILL, LV_FIT_NONE, LV_FIT_FILL);
lv_cont_set_fit4(ext->scrl, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL);
/* Add the signal function only if 'scrolling' is created
* because everything has to be ready before any signal is received*/
@ -772,6 +772,14 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
lv_obj_t * tmp = child;
child = lv_obj_get_child(page, child); /*Get the next child before move this*/
/*Reposition the child to take padding into account*/
lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
child->coords.x1 += style->body.padding.hor;
child->coords.x2 += style->body.padding.hor;
child->coords.y1 += style->body.padding.ver;
child->coords.y2 += style->body.padding.ver;
lv_obj_set_parent(tmp, ext->scrl);
} else {
child = lv_obj_get_child(page, child);