From ded47f705a3e9a9083b77976d061a7f7e70ef607 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 31 Oct 2019 07:07:22 +0100 Subject: [PATCH] tabview fix missing indicator --- src/lv_objx/lv_tabview.c | 16 ++++++---------- src/lv_themes/lv_theme_material.c | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/lv_objx/lv_tabview.c b/src/lv_objx/lv_tabview.c index 6c1aba058..4b6a2dcfa 100644 --- a/src/lv_objx/lv_tabview.c +++ b/src/lv_objx/lv_tabview.c @@ -468,14 +468,6 @@ void lv_tabview_set_style(lv_obj_t * tabview, lv_tabview_style_t type, const lv_ case LV_TABVIEW_STYLE_BTN_TGL_PR: lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_PR, style); break; case LV_TABVIEW_STYLE_INDIC: lv_obj_set_style(ext->indic, style); - - switch(ext->btns_pos) { - case LV_TABVIEW_BTNS_POS_TOP: - case LV_TABVIEW_BTNS_POS_BOTTOM: lv_obj_set_height(ext->indic, style->body.padding.inner); break; - case LV_TABVIEW_BTNS_POS_LEFT: - case LV_TABVIEW_BTNS_POS_RIGHT: lv_obj_set_width(ext->indic, style->body.padding.inner); break; - } - tabview_realign(tabview); break; } @@ -803,6 +795,10 @@ static void refr_indic_size(lv_obj_t * tabview) lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview); const lv_style_t * style_btn_bg = lv_tabview_get_style(tabview, LV_TABVIEW_STYLE_BTN_BG); + const lv_style_t * style_indic = lv_tabview_get_style(tabview, LV_TABVIEW_STYLE_INDIC); + + if(style_indic == NULL) style_indic = &lv_style_plain_color; + /*Set the indicator width/height*/ lv_coord_t indic_w; @@ -817,7 +813,7 @@ static void refr_indic_size(lv_obj_t * tabview) case LV_TABVIEW_BTNS_POS_BOTTOM: lv_obj_set_hidden(ext->indic, false); if(ext->tab_cnt) { - indic_h = style_btn_bg->body.padding.inner; + indic_h = style_indic->body.padding.inner; indic_w = (lv_obj_get_width(tabview) - style_btn_bg->body.padding.inner * (ext->tab_cnt - 1) - style_btn_bg->body.padding.left - style_btn_bg->body.padding.right) / ext->tab_cnt; @@ -830,7 +826,7 @@ static void refr_indic_size(lv_obj_t * tabview) case LV_TABVIEW_BTNS_POS_RIGHT: lv_obj_set_hidden(ext->indic, false); if(ext->tab_cnt) { - indic_w = style_btn_bg->body.padding.inner; + indic_w = style_indic->body.padding.inner; max_h = lv_obj_get_height(ext->btns) - style_btn_bg->body.padding.top - style_btn_bg->body.padding.bottom; indic_h= max_h - ((ext->tab_cnt - 1) * style_btn_bg->body.padding.inner); indic_h = indic_h / ext->tab_cnt; diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index d46128392..7f792965d 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -676,6 +676,7 @@ static void tabview_init(void) indic.body.radius = 0; indic.body.border.width = 0; indic.body.padding.inner = LV_DPI / 20; + indic.body.padding.inner = LV_DPI / 20; lv_style_copy(&btn_bg, &def); btn_bg.body.main_color = lv_color_hex3(0xccc);