diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index dad90f0620..64c22fe4cc 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -466,39 +466,40 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig } /*Post draw when the children are drawn*/ else if(mode == LV_DESIGN_DRAW_POST) { - ancestor_design(ddlist, mask, mode); - /*Redraw the text on the selected area with a different color*/ lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist); lv_opa_t opa_scale = lv_obj_get_opa_scale(ddlist); /*Redraw only in opened state*/ - if(ext->opened == 0) return true; + if(ext->opened) { + lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG); + const lv_font_t * font = style->text.font; + lv_coord_t font_h = lv_font_get_height(font); - lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG); - const lv_font_t * font = style->text.font; - lv_coord_t font_h = lv_font_get_height(font); + lv_area_t area_sel; + area_sel.y1 = ext->label->coords.y1; + area_sel.y1 += ext->sel_opt_id * (font_h + style->text.line_space); + area_sel.y1 -= style->text.line_space / 2; - lv_area_t area_sel; - area_sel.y1 = ext->label->coords.y1; - area_sel.y1 += ext->sel_opt_id * (font_h + style->text.line_space); - area_sel.y1 -= style->text.line_space / 2; - - area_sel.y2 = area_sel.y1 + font_h + style->text.line_space - 1; - area_sel.x1 = ddlist->coords.x1; - area_sel.x2 = ddlist->coords.x2; - lv_area_t mask_sel; - bool area_ok; - area_ok = lv_area_intersect(&mask_sel, mask, &area_sel); - if(area_ok) { - lv_style_t * sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_SEL); - lv_style_t new_style; - lv_style_copy(&new_style, style); - new_style.text.color = sel_style->text.color; - new_style.text.opa = sel_style->text.opa; - lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale, - lv_label_get_text(ext->label), LV_TXT_FLAG_NONE, NULL); + area_sel.y2 = area_sel.y1 + font_h + style->text.line_space - 1; + area_sel.x1 = ddlist->coords.x1; + area_sel.x2 = ddlist->coords.x2; + lv_area_t mask_sel; + bool area_ok; + area_ok = lv_area_intersect(&mask_sel, mask, &area_sel); + if(area_ok) { + lv_style_t * sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_SEL); + lv_style_t new_style; + lv_style_copy(&new_style, style); + new_style.text.color = sel_style->text.color; + new_style.text.opa = sel_style->text.opa; + lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale, + lv_label_get_text(ext->label), LV_TXT_FLAG_NONE, NULL); + } } + + /*Draw the scrollbar in the ancestor page design function*/ + ancestor_design(ddlist, mask, mode); } return true; diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 81e7fb8d62..9ac9eac1c4 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -195,7 +195,10 @@ void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode) if(sb_mode == LV_SB_MODE_HIDE) ext->sb.mode |= LV_SB_MODE_HIDE; /*Set the hidden flag*/ else if (sb_mode == LV_SB_MODE_UNHIDE) ext->sb.mode &= (~LV_SB_MODE_HIDE); /*Clear the hidden flag*/ - else ext->sb.mode = sb_mode; + else { + if(ext->sb.mode & LV_SB_MODE_HIDE) sb_mode |= LV_SB_MODE_HIDE; + ext->sb.mode = sb_mode; + } ext->sb.hor_draw = 0; ext->sb.ver_draw = 0; @@ -488,7 +491,6 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo style->body.shadow.width = shadow_width_tmp; style->body.empty = empty_tmp; - lv_page_ext_t * ext = lv_obj_get_ext_attr(page); /*Draw the scrollbars*/