From 06746dfd63a3267f08314860b08189921e50147f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 15 Oct 2019 10:32:15 +0200 Subject: [PATCH] fix page overflow when object created on the right due to RTL base dir --- src/lv_objx/lv_ddlist.c | 20 +++++++++++++++++--- src/lv_objx/lv_page.c | 4 ++-- src/lv_objx/lv_tabview.c | 14 ++++++++++---- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/lv_objx/lv_ddlist.c b/src/lv_objx/lv_ddlist.c index 82b5f5309..b26c6a933 100644 --- a/src/lv_objx/lv_ddlist.c +++ b/src/lv_objx/lv_ddlist.c @@ -113,6 +113,10 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_set_drag(scrl, false); lv_page_set_scrl_fit2(new_ddlist, LV_FIT_FILL, LV_FIT_TIGHT); + lv_coord_t x; + if(lv_obj_get_base_dir(new_ddlist) == LV_BIDI_DIR_RTL) x = lv_obj_get_x(new_ddlist) + lv_obj_get_width(new_ddlist); + else x = lv_obj_get_x(new_ddlist); + ext->label = lv_label_create(new_ddlist, NULL); lv_cont_set_fit2(new_ddlist, LV_FIT_TIGHT, LV_FIT_NONE); lv_page_set_sb_mode(new_ddlist, LV_SB_MODE_HIDE); @@ -120,6 +124,10 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) lv_ddlist_set_options(new_ddlist, "Option 1\nOption 2\nOption 3"); + + if(lv_obj_get_base_dir(new_ddlist) == LV_BIDI_DIR_RTL) lv_obj_set_x(new_ddlist, x - lv_obj_get_width(new_ddlist)); + else lv_obj_set_x(new_ddlist, x); + /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { @@ -132,9 +140,6 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SB, &lv_style_pretty_color); } - if(lv_obj_get_base_dir(new_ddlist) == LV_BIDI_DIR_RTL) { - lv_obj_set_x(new_ddlist, lv_obj_get_width(par) - lv_obj_get_width(new_ddlist)); - } } /*Copy an existing drop down list*/ @@ -995,11 +1000,20 @@ static void lv_ddlist_pos_current_option(lv_obj_t * ddlist) */ static void lv_ddlist_refr_width(lv_obj_t * ddlist) { + + /*Save the current x coordinate because it should be kept after the refrsh*/ + lv_coord_t x; + if(lv_obj_get_base_dir(ddlist) == LV_BIDI_DIR_RTL) x = lv_obj_get_x(ddlist) + lv_obj_get_width(ddlist); + else x = lv_obj_get_x(ddlist); + /*Set the TIGHT fit horizontally the set the width to the content*/ lv_page_set_scrl_fit2(ddlist, LV_FIT_TIGHT, lv_page_get_scrl_fit_bottom(ddlist)); /*Revert FILL fit to fill the parent with the options area. It allows to RIGHT/CENTER align the text*/ lv_page_set_scrl_fit2(ddlist, LV_FIT_FILL, lv_page_get_scrl_fit_bottom(ddlist)); + + if(lv_obj_get_base_dir(ddlist) == LV_BIDI_DIR_RTL) lv_obj_set_x(ddlist, x - lv_obj_get_width(ddlist)); + else lv_obj_set_x(ddlist, x); } #endif diff --git a/src/lv_objx/lv_page.c b/src/lv_objx/lv_page.c index 8e37f7321..b0d308d65 100644 --- a/src/lv_objx/lv_page.c +++ b/src/lv_objx/lv_page.c @@ -846,8 +846,8 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) 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; + tmp->coords.x1 -= style_scrl->body.padding.right + style_bg->body.padding.right; + tmp->coords.x2 -= style_scrl->body.padding.right + 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_scrl->body.padding.top; diff --git a/src/lv_objx/lv_tabview.c b/src/lv_objx/lv_tabview.c index da48aad11..ac6e08d90 100644 --- a/src/lv_objx/lv_tabview.c +++ b/src/lv_objx/lv_tabview.c @@ -147,7 +147,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, th->style.tabview.btn.tgl_pr); } else { lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, &lv_style_plain); - lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, &lv_style_transp); + lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, &lv_style_pretty);//transp); lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, &lv_style_plain_color); } } @@ -222,8 +222,8 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name) lv_obj_t * h = lv_page_create(ext->content, NULL); lv_obj_set_size(h, lv_obj_get_width(tabview), lv_obj_get_height(ext->content)); lv_page_set_sb_mode(h, LV_SB_MODE_AUTO); - lv_page_set_style(h, LV_PAGE_STYLE_BG, &lv_style_transp); - lv_page_set_style(h, LV_PAGE_STYLE_SCRL, &lv_style_transp); + lv_page_set_style(h, LV_PAGE_STYLE_BG, &lv_style_transp_tight); + lv_page_set_style(h, LV_PAGE_STYLE_SCRL, &lv_style_transp);//plain_color); if(page_signal == NULL) page_signal = lv_obj_get_signal_cb(h); if(page_scrl_signal == NULL) page_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(h)); @@ -400,7 +400,13 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an case LV_TABVIEW_BTNS_POS_TOP: case LV_TABVIEW_BTNS_POS_BOTTOM: indic_size = lv_obj_get_width(ext->indic); - indic_pos = indic_size * id + tabs_style->body.padding.inner * id + tabs_style->body.padding.left; + if(lv_obj_get_base_dir(tabview) == LV_BIDI_DIR_RTL) { + uint16_t id_rtl = (ext->tab_cnt - (id + 1)); + printf("id:%d, id_Rtl:%d\n", id, id_rtl); + indic_pos = indic_size * id_rtl + tabs_style->body.padding.inner * id_rtl + tabs_style->body.padding.left; + } else { + indic_pos = indic_size * id + tabs_style->body.padding.inner * id + tabs_style->body.padding.left; + } break; case LV_TABVIEW_BTNS_POS_LEFT: case LV_TABVIEW_BTNS_POS_RIGHT: