From ddbd8386d2b9b77aa9474ede5abee0393ba60a00 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 24 Feb 2019 06:41:00 +0100 Subject: [PATCH] lv_page: fixes when child is added --- lv_objx/lv_cont.h | 8 ++++---- lv_objx/lv_page.c | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lv_objx/lv_cont.h b/lv_objx/lv_cont.h index 7fa5370c2..cf78574b5 100644 --- a/lv_objx/lv_cont.h +++ b/lv_objx/lv_cont.h @@ -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 diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 26d517cf6..46b9a2c33 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -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);