From fe35307d9fa23b7eb817caf78b32c66d28404bf7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 11 Oct 2019 14:15:38 +0200 Subject: [PATCH] fix page oveflow with right aligned object (due to RTL base dir) --- src/lv_objx/lv_page.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lv_objx/lv_page.c b/src/lv_objx/lv_page.c index 64f6ba923..8e37f7321 100644 --- a/src/lv_objx/lv_page.c +++ b/src/lv_objx/lv_page.c @@ -828,8 +828,10 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) lv_page_ext_t * ext = lv_obj_get_ext_attr(page); lv_obj_t * child; if(sign == LV_SIGNAL_CHILD_CHG) { /*Automatically move children to the scrollable object*/ - const lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL); + const lv_style_t * style_bg = lv_page_get_style(page, LV_PAGE_STYLE_BG); + const lv_style_t * style_scrl = lv_page_get_style(page, LV_PAGE_STYLE_SCRL); lv_fit_t fit_left = lv_page_get_scrl_fit_left(page); + lv_fit_t fit_right = lv_page_get_scrl_fit_right(page); lv_fit_t fit_top = lv_page_get_scrl_fit_top(page); child = lv_obj_get_child(page, NULL); while(child != NULL) { @@ -837,15 +839,19 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) 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 (Only if it's on (0;0) now) + /* Reposition the child to take padding into account (Only if it's on (0;0) or (widht;height) coordinates now) * It's required to keep new the object on the same coordinate if FIT is enabled.*/ if((tmp->coords.x1 == page->coords.x1) && (fit_left == LV_FIT_TIGHT || fit_left == LV_FIT_FILL)) { - tmp->coords.x1 += style->body.padding.left; - tmp->coords.x2 += style->body.padding.left; + tmp->coords.x1 += style_scrl->body.padding.left; + tmp->coords.x2 += style_scrl->body.padding.left; + } + else if((tmp->coords.x2 == page->coords.x2) && (fit_right == LV_FIT_TIGHT || fit_right == LV_FIT_FILL)) { + tmp->coords.x1 -= style_scrl->body.padding.right * 2 + style_bg->body.padding.right; + tmp->coords.x2 -= style_scrl->body.padding.right * 2 + style_bg->body.padding.right; } if((tmp->coords.y1 == page->coords.y1) && (fit_top == LV_FIT_TIGHT || fit_top == LV_FIT_FILL)) { - tmp->coords.y1 += style->body.padding.top; - tmp->coords.y2 += style->body.padding.top; + tmp->coords.y1 += style_scrl->body.padding.top; + tmp->coords.y2 += style_scrl->body.padding.top; } lv_obj_set_parent(tmp, ext->scrl); } else {