diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index ec443efd3..88474cd0b 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -103,7 +103,9 @@ static void lv_event_mark_deleted(lv_obj_t * obj); static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find); static void lv_obj_del_async_cb(void * obj); static void obj_del_core(lv_obj_t * obj); - +static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop); +static void update_style_cache_children(lv_obj_t * obj); +static void invalidate_style_cache(lv_obj_t * obj, uint8_t part); /********************** * STATIC VARIABLES **********************/ @@ -1120,7 +1122,7 @@ void lv_obj_add_style(lv_obj_t * obj, uint8_t part, lv_style_t * style) #if LV_USE_ANIMATION trans_del(obj, part, 0xFF, NULL); #endif - lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); } /** @@ -1144,7 +1146,7 @@ void lv_obj_remove_style(lv_obj_t * obj, uint8_t part, lv_style_t * style) #if LV_USE_ANIMATION trans_del(obj, part, 0xFF, NULL); #endif - lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); } /** @@ -1181,7 +1183,7 @@ void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part) { lv_obj_clean_style_list(obj, part); - lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); } /** @@ -1203,7 +1205,7 @@ void _lv_obj_set_style_local_int(lv_obj_t * obj, uint8_t part, lv_style_property #if LV_USE_ANIMATION trans_del(obj, part, prop, NULL); #endif - lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK)); + lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK)); } /** @@ -1225,7 +1227,7 @@ void _lv_obj_set_style_local_color(lv_obj_t * obj, uint8_t part, lv_style_proper #if LV_USE_ANIMATION trans_del(obj, part, prop, NULL); #endif - lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK)); + lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK)); } /** @@ -1247,7 +1249,7 @@ void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t part, lv_style_property #if LV_USE_ANIMATION trans_del(obj, part, prop, NULL); #endif - lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK)); + lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK)); } /** @@ -1269,7 +1271,7 @@ void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t part, lv_style_property #if LV_USE_ANIMATION trans_del(obj, part, prop, NULL); #endif - lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK)); + lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK)); } /** @@ -1296,11 +1298,11 @@ bool lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_prope * @param obj pointer to an object * @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used to optimize what needs to be refreshed. */ -void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop) +void lv_obj_refresh_style(lv_obj_t * obj, uint8_t part, lv_style_property_t prop) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - _lv_obj_invalidate_style_cache(obj); + invalidate_style_cache(obj, part); /*If a real style refresh is required*/ bool real_refr = false; @@ -1390,63 +1392,6 @@ void lv_obj_report_style_mod(lv_style_t * style) } -/** - * Update the cache of style list - * @param obj pointer to an obejct - * @param part the part of the object - */ -void _lv_obj_update_style_cache(lv_obj_t * obj, uint8_t part) -{ - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list->valid_cache) return; - - bool ignore_cache_ori = list->ignore_cache; - list->ignore_cache = 1; - list->bg_grad_dir_none = lv_obj_get_style_bg_grad_dir(obj, part) == LV_GRAD_DIR_NONE ? 1 : 0; - list->bg_opa_transp = lv_obj_get_style_bg_opa(obj, part) == LV_OPA_TRANSP ? 1 : 0; - list->border_width_zero = lv_obj_get_style_border_width(obj, part) == LV_OPA_TRANSP ? 1 : 0; - list->clip_corner_off = lv_obj_get_style_clip_corner(obj, part) == false ? 1 : 0; - list->img_recolor_opa_transp = lv_obj_get_style_image_recolor_opa(obj, part) == LV_OPA_TRANSP ? 1 : 0; - list->line_width_zerop = lv_obj_get_style_line_width(obj, part) == 0 ? 1 : 0; - list->opa_scale_transp = lv_obj_get_style_opa_scale(obj, part) == LV_OPA_TRANSP ? 1 : 0; - list->outline_width_zero = lv_obj_get_style_outline_width(obj, part) == 0 ? 1 : 0; - list->pattern_img_null = lv_obj_get_style_pattern_image(obj, part) == NULL ? 1 : 0; - list->shadow_width_zero = lv_obj_get_style_shadow_width(obj, part) == 0 ? 1 : 0; - list->text_decor_none = lv_obj_get_style_text_decor(obj, part) == LV_TEXT_DECOR_NONE ? 1 : 0; - list->text_letter_space_zero = lv_obj_get_style_text_letter_space(obj, part) == 0 ? 1 : 0; - list->text_line_space_zero = lv_obj_get_style_text_line_space(obj, part) == 0 ? 1 : 0; - list->transform_angle_zero = lv_obj_get_style_transform_angle(obj, part) == 0 ? 1 : 0; - list->transform_height_zero = lv_obj_get_style_transform_width(obj, part) == 0 ? 1 : 0; - list->transform_width_zero = lv_obj_get_style_transform_height(obj, part) == 0 ? 1 : 0; - list->transform_zoom_zero = lv_obj_get_style_transform_zoom(obj, part) == LV_IMG_ZOOM_NONE ? 1 : 0; - list->value_txt_str = lv_obj_get_style_value_str(obj, part) == NULL ? 1 : 0; - - list->ignore_cache = ignore_cache_ori; - list->valid_cache = 1; -} - -/** - * Mark the object and all of it's children's style lists as invalid. - * The cache will be updated when a cached property asked nest time - * @param obj pointer to an object - */ -void _lv_obj_invalidate_style_cache(lv_obj_t * obj) -{ - uint8_t part; - for(part = 0; part != _LV_OBJ_PART_REAL_LAST; part++) { - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) break; - list->valid_cache = 0; - - } - - lv_obj_t * child = lv_obj_get_child(obj, NULL); - while(child) { - _lv_obj_invalidate_style_cache(child); - child = lv_obj_get_child(obj, child); - } -} - /*----------------- * Attribute set *----------------*/ @@ -1720,10 +1665,10 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) } } + lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); } #endif - lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); } @@ -2511,7 +2456,8 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl lv_style_list_t * list = lv_obj_get_style_list(parent, part); if(!list->ignore_cache) { - _lv_obj_update_style_cache((lv_obj_t*)parent, part); + if(!list->valid_cache) update_style_cache((lv_obj_t*)parent, part, prop & (~LV_STYLE_STATE_MASK)); + bool def = false; switch(prop & (~LV_STYLE_STATE_MASK)) { case LV_STYLE_BG_GRAD_DIR: @@ -2555,7 +2501,6 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl if(def) break; } - lv_state_t state = lv_obj_get_state(parent, part); prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS); @@ -2675,9 +2620,8 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop while(parent) { lv_style_list_t * list = lv_obj_get_style_list(parent, part); - if(!list->ignore_cache) { - _lv_obj_update_style_cache((lv_obj_t*)parent, part); + if(!list->valid_cache) update_style_cache((lv_obj_t*)parent, part, prop & (~LV_STYLE_STATE_MASK)); bool def = false; switch(prop & (~LV_STYLE_STATE_MASK)) { case LV_STYLE_OPA_SCALE: @@ -2752,8 +2696,8 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_ lv_style_list_t * list = lv_obj_get_style_list(parent, part); if(!list->ignore_cache) { + if(!list->valid_cache) update_style_cache((lv_obj_t*)parent, part, prop & (~LV_STYLE_STATE_MASK)); bool def = false; - _lv_obj_update_style_cache((lv_obj_t*)parent, part); switch(prop & (~LV_STYLE_STATE_MASK)) { case LV_STYLE_VALUE_STR: if(list->opa_scale_transp) def = true; @@ -3958,7 +3902,7 @@ static void report_style_mod_core(void * style, lv_obj_t * obj) for(ci = 0; ci < list->style_cnt; ci++) { lv_style_t * class = lv_style_list_get_style(list, ci); if(class == style || style == NULL) { - lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); break; } } @@ -4339,7 +4283,7 @@ static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v) else x = tr->end_value._ptr; _lv_style_set_ptr(style, tr->prop, x); } - lv_obj_refresh_style(tr->obj, tr->prop); + lv_obj_refresh_style(tr->obj, tr->part, tr->prop); } @@ -4434,3 +4378,127 @@ static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_fin return false; } + +/** + * Update the cache of style list + * @param obj pointer to an obejct + * @param part the part of the object + * @param prop the property which triggered the update + */ +static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop) +{ + + bool cachable; + switch(prop) { + case LV_STYLE_BG_GRAD_DIR: + case LV_STYLE_CLIP_CORNER: + case LV_STYLE_TEXT_LETTER_SPACE: + case LV_STYLE_TEXT_LINE_SPACE: + case LV_STYLE_TRANSFORM_ANGLE: + case LV_STYLE_TRANSFORM_WIDTH: + case LV_STYLE_TRANSFORM_HEIGHT: + case LV_STYLE_TRANSFORM_ZOOM: + case LV_STYLE_BORDER_WIDTH: + case LV_STYLE_LINE_WIDTH: + case LV_STYLE_OUTLINE_WIDTH: + case LV_STYLE_SHADOW_WIDTH: + case LV_STYLE_OPA_SCALE: + case LV_STYLE_BG_OPA: + case LV_STYLE_IMAGE_RECOLOR_OPA: + case LV_STYLE_VALUE_STR: + case LV_STYLE_PATTERN_IMAGE: + cachable = true; + break; + default: + cachable = false; + } + + if(!cachable) return; + + lv_style_list_t * list = lv_obj_get_style_list(obj, part); + + bool ignore_cache_ori = list->ignore_cache; + list->ignore_cache = 1; + + list->opa_scale_transp = lv_obj_get_style_opa_scale(obj, part) == LV_OPA_TRANSP ? 1 : 0; + list->text_decor_none = lv_obj_get_style_text_decor(obj, part) == LV_TEXT_DECOR_NONE ? 1 : 0; + list->text_letter_space_zero = lv_obj_get_style_text_letter_space(obj, part) == 0 ? 1 : 0; + list->text_line_space_zero = lv_obj_get_style_text_line_space(obj, part) == 0 ? 1 : 0; + + list->bg_grad_dir_none = lv_obj_get_style_bg_grad_dir(obj, part) == LV_GRAD_DIR_NONE ? 1 : 0; + list->bg_opa_transp = lv_obj_get_style_bg_opa(obj, part) == LV_OPA_TRANSP ? 1 : 0; + list->border_width_zero = lv_obj_get_style_border_width(obj, part) == LV_OPA_TRANSP ? 1 : 0; + list->clip_corner_off = lv_obj_get_style_clip_corner(obj, part) == false ? 1 : 0; + list->img_recolor_opa_transp = lv_obj_get_style_image_recolor_opa(obj, part) == LV_OPA_TRANSP ? 1 : 0; + list->line_width_zerop = lv_obj_get_style_line_width(obj, part) == 0 ? 1 : 0; + list->outline_width_zero = lv_obj_get_style_outline_width(obj, part) == 0 ? 1 : 0; + list->pattern_img_null = lv_obj_get_style_pattern_image(obj, part) == NULL ? 1 : 0; + list->shadow_width_zero = lv_obj_get_style_shadow_width(obj, part) == 0 ? 1 : 0; + list->transform_angle_zero = lv_obj_get_style_transform_angle(obj, part) == 0 ? 1 : 0; + list->transform_height_zero = lv_obj_get_style_transform_width(obj, part) == 0 ? 1 : 0; + list->transform_width_zero = lv_obj_get_style_transform_height(obj, part) == 0 ? 1 : 0; + list->transform_zoom_zero = lv_obj_get_style_transform_zoom(obj, part) == LV_IMG_ZOOM_NONE ? 1 : 0; + list->value_txt_str = lv_obj_get_style_value_str(obj, part) == NULL ? 1 : 0; + + list->ignore_cache = ignore_cache_ori; + list->valid_cache = 1; +} + +void _lv_obj_disable_style_cahcing(lv_obj_t * obj, bool dis) +{ + uint8_t part; + for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) { + lv_style_list_t * list = lv_obj_get_style_list(obj, part); + if(list == NULL) break; + list->ignore_cache = dis; + } + for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) { + lv_style_list_t * list = lv_obj_get_style_list(obj, part); + if(list == NULL) break; + list->ignore_cache = dis; + } +} + +/** + * Update the cache of style list + * @param obj pointer to an object + * @param part the part of the object + */ +static void update_style_cache_children(lv_obj_t * obj) +{ + uint8_t part; + for(part = 0; part != _LV_OBJ_PART_REAL_LAST; part++) { + lv_style_list_t * list = lv_obj_get_style_list(obj, part); + if(list == NULL) break; + + bool ignore_cache_ori = list->ignore_cache; + list->ignore_cache = 1; + + list->opa_scale_transp = lv_obj_get_style_opa_scale(obj, part) == LV_OPA_TRANSP ? 1 : 0; + list->text_decor_none = lv_obj_get_style_text_decor(obj, part) == LV_TEXT_DECOR_NONE ? 1 : 0; + list->text_letter_space_zero = lv_obj_get_style_text_letter_space(obj, part) == 0 ? 1 : 0; + list->text_line_space_zero = lv_obj_get_style_text_line_space(obj, part) == 0 ? 1 : 0; + list->img_recolor_opa_transp = lv_obj_get_style_image_recolor_opa(obj, part) == LV_OPA_TRANSP ? 1 : 0; + + list->ignore_cache = ignore_cache_ori; + } +} + +/** + * Mark the object and all of it's children's style lists as invalid. + * The cache will be updated when a cached property asked nest time + * @param obj pointer to an object + */ +static void invalidate_style_cache(lv_obj_t * obj, uint8_t part) +{ + lv_style_list_t * list = lv_obj_get_style_list(obj, part); + if(list == NULL) return; + list->valid_cache = 0; + + lv_obj_t * child = lv_obj_get_child(obj, NULL); + while(child) { + update_style_cache_children(child); + child = lv_obj_get_child(obj, child); + } +} + diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 06d2bc070..c5f9b0cd4 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -586,7 +586,7 @@ void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part); * @param obj pointer to an object * @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used to optimize what needs to be refreshed. */ -void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop); +void lv_obj_refresh_style(lv_obj_t * obj, uint8_t part, lv_style_property_t prop); /** * Notify all object if a style is modified @@ -595,20 +595,6 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop); */ void lv_obj_report_style_mod(lv_style_t * style); -/** - * Update the cache of style list - * @param obj pointer to an obejct - * @param part the part of the object - */ -void _lv_obj_update_style_cache(lv_obj_t * obj, uint8_t part); - -/** - * Mark the object and all of it's children's style lists as invalid. - * The cache will be updated when a cached property asked nest time - * @param obj pointer to an object - */ -void _lv_obj_invalidate_style_cache(lv_obj_t * obj); - /** * Set a local style property of a part of an object in a given state. * @param obj pointer to an object diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 391c17459..0db481ec8 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -226,8 +226,8 @@ typedef struct { uint32_t has_trans :1; uint32_t skip_trans :1; /*1: Temporally skip the transition style if any*/ uint32_t ignore_trans :1; /*1: Mark that this style list shouldn't receive transitions at all*/ - uint32_t ignore_cache :1; /*1: Ignore cache while getting value of properties*/ - uint32_t valid_cache :1; /*1: The cache is invalid and needs to be updated*/ + uint32_t valid_cache :1; /*1: The cache is invalid and needs to be updated*/ + uint8_t ignore_cache :1; /**1: Ignore style cache while getting value of properties*/ uint32_t opa_scale_transp :1; uint32_t clip_corner_off :1; diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 1aa9fe580..031cd2a06 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -1366,7 +1366,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; } - lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } /********************** diff --git a/src/lv_themes/lv_theme_mono.c b/src/lv_themes/lv_theme_mono.c index ba5357088..e9f0f9015 100644 --- a/src/lv_themes/lv_theme_mono.c +++ b/src/lv_themes/lv_theme_mono.c @@ -1023,7 +1023,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) } - lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } diff --git a/src/lv_themes/lv_theme_template.c b/src/lv_themes/lv_theme_template.c index 2a22fad4e..722e72e07 100644 --- a/src/lv_themes/lv_theme_template.c +++ b/src/lv_themes/lv_theme_template.c @@ -855,7 +855,7 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; } - lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } /********************** diff --git a/src/lv_widgets/lv_arc.c b/src/lv_widgets/lv_arc.c index 4dd7d9f45..f7cf087f1 100644 --- a/src/lv_widgets/lv_arc.c +++ b/src/lv_widgets/lv_arc.c @@ -101,7 +101,7 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy) lv_style_list_copy(&ext->style_arc, ©_ext->style_arc); /*Refresh the style with new signal function*/ - lv_obj_refresh_style(arc, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(arc, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("arc created"); diff --git a/src/lv_widgets/lv_bar.c b/src/lv_widgets/lv_bar.c index f76a2e13f..f787e2680 100644 --- a/src/lv_widgets/lv_bar.c +++ b/src/lv_widgets/lv_bar.c @@ -130,7 +130,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy) lv_style_list_copy(&ext->style_indic, &ext_copy->style_indic); /*Refresh the style with new signal function*/ - lv_obj_refresh_style(bar, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(bar, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); lv_bar_set_value(bar, ext->cur_value, LV_ANIM_OFF); } diff --git a/src/lv_widgets/lv_btn.c b/src/lv_widgets/lv_btn.c index fa327bd6e..3d5556083 100644 --- a/src/lv_widgets/lv_btn.c +++ b/src/lv_widgets/lv_btn.c @@ -100,7 +100,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy) ext->checkable = copy_ext->checkable; /*Refresh the style with new signal function*/ - lv_obj_refresh_style(btn, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(btn, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("button created"); diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 5501fcfa6..f604cb10f 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -660,6 +660,7 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl /*The state changes without re-caching the styles, disable the use of cache*/ lv_state_t state_ori = btnm->state; + _lv_obj_disable_style_cahcing(btnm, true); btnm->state = LV_STATE_DEFAULT; lv_draw_rect_dsc_init(&draw_rect_rel_dsc); lv_draw_label_dsc_init(&draw_label_rel_dsc); @@ -667,6 +668,7 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_rel_dsc); draw_label_rel_dsc.flag = txt_flag; btnm->state = state_ori; + _lv_obj_disable_style_cahcing(btnm, false); bool chk_inited = false; bool disabled_inited = false; @@ -700,12 +702,14 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl if(tgl_state) { if(!chk_inited) { btnm->state = LV_STATE_CHECKED; + _lv_obj_disable_style_cahcing(btnm, true); lv_draw_rect_dsc_init(&draw_rect_chk_dsc); lv_draw_label_dsc_init(&draw_label_chk_dsc); lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_chk_dsc); lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_chk_dsc); draw_label_chk_dsc.flag = txt_flag; btnm->state = state_ori; + _lv_obj_disable_style_cahcing(btnm, false); chk_inited = true; } } @@ -713,12 +717,14 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl if(button_is_inactive(ext->ctrl_bits[btn_i])) { if(!disabled_inited) { btnm->state = LV_STATE_DISABLED; + _lv_obj_disable_style_cahcing(btnm, true); lv_draw_rect_dsc_init(&draw_rect_ina_dsc); lv_draw_label_dsc_init(&draw_label_ina_dsc); lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_ina_dsc); lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_ina_dsc); draw_label_ina_dsc.flag = txt_flag; btnm->state = state_ori; + _lv_obj_disable_style_cahcing(btnm, false); disabled_inited = true; } draw_rect_dsc_act = &draw_rect_ina_dsc; diff --git a/src/lv_widgets/lv_calendar.c b/src/lv_widgets/lv_calendar.c index 9936b624b..ab9835007 100644 --- a/src/lv_widgets/lv_calendar.c +++ b/src/lv_widgets/lv_calendar.c @@ -705,6 +705,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month)); calendar->state = LV_STATE_DEFAULT; + _lv_obj_disable_style_cahcing(calendar, true); lv_draw_label_dsc_t label_dsc; lv_draw_label_dsc_init(&label_dsc); @@ -738,6 +739,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) lv_draw_label(&header_area, mask, &label_dsc, LV_SYMBOL_RIGHT, NULL); calendar->state = state_ori; /*Restore the state*/ + _lv_obj_disable_style_cahcing(calendar, false); } /** @@ -810,6 +812,7 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area) /*The state changes without re-caching the styles, disable the use of cache*/ lv_state_t state_ori = calendar->state; calendar->state = LV_STATE_DEFAULT; + _lv_obj_disable_style_cahcing(calendar, true); lv_state_t month_state = LV_STATE_DISABLED; @@ -856,6 +859,7 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area) if(box_area.y1 > clip_area->y2) { calendar->state = state_ori; + _lv_obj_disable_style_cahcing(calendar, false); return; } @@ -926,6 +930,7 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area) } } calendar->state = state_ori; + _lv_obj_disable_style_cahcing(calendar, false); } diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index d7308cf88..75d0a146c 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -152,7 +152,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) _lv_memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t)); /*Refresh the style with new signal function*/ - lv_obj_refresh_style(chart, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(chart, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("chart created"); diff --git a/src/lv_widgets/lv_cont.c b/src/lv_widgets/lv_cont.c index ffb716832..04a81343e 100644 --- a/src/lv_widgets/lv_cont.c +++ b/src/lv_widgets/lv_cont.c @@ -112,7 +112,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy) ext->layout = copy_ext->layout; /*Refresh the style with new signal function*/ - lv_obj_refresh_style(cont, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(cont, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("container created"); diff --git a/src/lv_widgets/lv_cpicker.c b/src/lv_widgets/lv_cpicker.c index d80c9a56c..bc46ffcc4 100644 --- a/src/lv_widgets/lv_cpicker.c +++ b/src/lv_widgets/lv_cpicker.c @@ -144,7 +144,7 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy) lv_style_list_copy(&ext->knob.style_list, ©_ext->knob.style_list); /*Refresh the style with new signal function*/ - lv_obj_refresh_style(cpicker, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(cpicker, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } refr_knob_pos(cpicker); diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index c7bbd8746..09c073318 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -609,7 +609,7 @@ void lv_dropdown_open(lv_obj_t * ddlist) lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_BG), &ext->style_page); lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCROLLBAR), &ext->style_scrlbar); lv_obj_clean_style_list(ext->page, LV_PAGE_PART_SCROLLABLE); - lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(ext->page, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); lv_obj_t * label = lv_label_create(ext->page, NULL); lv_label_set_text_static(label, ext->options); @@ -965,7 +965,7 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p const lv_font_t * font = lv_obj_get_style_text_font(ddlist, LV_DROPDOWN_PART_MAIN); lv_obj_set_height(ddlist, top + bottom + lv_font_get_line_height(font)); - if(ext->page) lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL); + if(ext->page) lv_obj_refresh_style(ext->page, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } else if(sign == LV_SIGNAL_CONTROL) { #if LV_USE_GROUP @@ -1134,8 +1134,10 @@ static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id lv_obj_t * page = ext->page; lv_state_t state_orig = page->state; - page->state = LV_STATE_DEFAULT; - page->state |= state; + if(state != page->state) { + _lv_obj_disable_style_cahcing(ddlist, true); + page->state = state; + } /*Draw a rectangle under the selected item*/ const lv_font_t * font = lv_obj_get_style_text_font(ddlist, LV_DROPDOWN_PART_LIST); @@ -1159,6 +1161,7 @@ static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id lv_draw_rect(&rect_area, clip_area, &sel_rect); page->state = state_orig; + _lv_obj_disable_style_cahcing(ddlist, false); } @@ -1169,8 +1172,10 @@ static void draw_box_label(lv_obj_t * ddlist, const lv_area_t * clip_area, uint1 lv_obj_t * page = ext->page; lv_state_t state_orig = page->state; - page->state = LV_STATE_DEFAULT; - page->state |= state; + if(state != page->state) { + page->state = state; + _lv_obj_disable_style_cahcing(ddlist, true); + } lv_draw_label_dsc_t label_dsc; lv_draw_label_dsc_init(&label_dsc); @@ -1204,6 +1209,7 @@ static void draw_box_label(lv_obj_t * ddlist, const lv_area_t * clip_area, uint1 lv_draw_label(&label->coords, &mask_sel, &label_dsc, lv_label_get_text(label), NULL); } page->state = state_orig; + _lv_obj_disable_style_cahcing(ddlist, false); } /** diff --git a/src/lv_widgets/lv_gauge.c b/src/lv_widgets/lv_gauge.c index ad7cb32e1..4457c9ba5 100644 --- a/src/lv_widgets/lv_gauge.c +++ b/src/lv_widgets/lv_gauge.c @@ -124,7 +124,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy) ext->format_cb = copy_ext->format_cb; /*Refresh the style with new signal function*/ - lv_obj_refresh_style(gauge, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(gauge, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("gauge created"); diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 6c6f65791..d92dcc2d8 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -121,7 +121,7 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy) lv_img_set_src(img, copy_ext->src); /*Refresh the style with new signal function*/ - lv_obj_refresh_style(img, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(img, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("image created"); diff --git a/src/lv_widgets/lv_imgbtn.c b/src/lv_widgets/lv_imgbtn.c index 1c37d92a9..43bf7e37b 100644 --- a/src/lv_widgets/lv_imgbtn.c +++ b/src/lv_widgets/lv_imgbtn.c @@ -100,7 +100,7 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy) #endif ext->tiled = copy_ext->tiled; /*Refresh the style with new signal function*/ - lv_obj_refresh_style(imgbtn, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(imgbtn, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("image button created"); diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index 1113a6b10..65e6397f6 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -161,7 +161,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) ext->dot_end = copy_ext->dot_end; /*Refresh the style with new signal function*/ - lv_obj_refresh_style(new_label, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(new_label, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("label created"); diff --git a/src/lv_widgets/lv_led.c b/src/lv_widgets/lv_led.c index 53c679c2f..dea778d7d 100644 --- a/src/lv_widgets/lv_led.c +++ b/src/lv_widgets/lv_led.c @@ -88,7 +88,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy) ext->bright = copy_ext->bright; /*Refresh the style with new signal function*/ - lv_obj_refresh_style(led, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(led, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("led created"); diff --git a/src/lv_widgets/lv_line.c b/src/lv_widgets/lv_line.c index e2c53e925..c54a0ecf5 100644 --- a/src/lv_widgets/lv_line.c +++ b/src/lv_widgets/lv_line.c @@ -95,7 +95,7 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy) lv_line_set_points(line, copy_ext->point_array, copy_ext->point_num); /*Refresh the style with new signal function*/ - lv_obj_refresh_style(line, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(line, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("line created"); diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index c8e7ae724..5b643058f 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -96,7 +96,7 @@ lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy) ext->cur_value = copy_ext->cur_value; /*Refresh the style with new signal function*/ - lv_obj_refresh_style(linemeter, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(linemeter, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("line meter created"); diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index dfd2b32af..526e53adf 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -115,7 +115,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy) } /*Refresh the style with new signal function*/ - lv_obj_refresh_style(list, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(list, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("list created"); diff --git a/src/lv_widgets/lv_msgbox.c b/src/lv_widgets/lv_msgbox.c index 60f4cdc9c..9448bec58 100644 --- a/src/lv_widgets/lv_msgbox.c +++ b/src/lv_widgets/lv_msgbox.c @@ -127,7 +127,7 @@ lv_obj_t * lv_msgbox_create(lv_obj_t * par, const lv_obj_t * copy) if(copy_ext->btnm) ext->btnm = lv_btnmatrix_create(mbox, copy_ext->btnm); /*Refresh the style with new signal function*/ - lv_obj_refresh_style(mbox, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(mbox, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("message box created"); diff --git a/src/lv_widgets/lv_objmask.c b/src/lv_widgets/lv_objmask.c index 2c817fb17..ed22bb30b 100644 --- a/src/lv_widgets/lv_objmask.c +++ b/src/lv_widgets/lv_objmask.c @@ -86,7 +86,7 @@ lv_obj_t * lv_objmask_create(lv_obj_t * par, const lv_obj_t * copy) /* lv_objmask_ext_t * copy_ext = lv_obj_get_ext_attr(copy); */ /*Refresh the style with new signal function*/ - lv_obj_refresh_style(objmask, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(objmask, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("object mask created"); diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 7c67fcb68..8b6818edc 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -135,7 +135,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_set_signal_cb(scrl, lv_roller_scrl_signal); lv_style_list_copy(&ext->style_sel, ©_ext->style_sel); - lv_obj_refresh_style(roller, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(roller, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("roller created"); diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index bb83f9298..7e658226d 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -103,7 +103,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy) lv_area_copy(&ext->left_knob_area, ©_ext->left_knob_area); lv_area_copy(&ext->right_knob_area, ©_ext->right_knob_area); - lv_obj_refresh_style(slider, LV_OBJ_PART_ALL); + lv_obj_refresh_style(slider, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("slider created"); diff --git a/src/lv_widgets/lv_spinbox.c b/src/lv_widgets/lv_spinbox.c index 669c72d38..1fac9de80 100644 --- a/src/lv_widgets/lv_spinbox.c +++ b/src/lv_widgets/lv_spinbox.c @@ -106,7 +106,7 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy) lv_spinbox_set_rollover(spinbox, copy_ext->rollover); /*Refresh the style with new signal function*/ - lv_obj_refresh_style(spinbox, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(spinbox, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } lv_spinbox_updatevalue(spinbox); diff --git a/src/lv_widgets/lv_spinner.c b/src/lv_widgets/lv_spinner.c index 16c0e570b..8e0e2dcd0 100644 --- a/src/lv_widgets/lv_spinner.c +++ b/src/lv_widgets/lv_spinner.c @@ -106,7 +106,7 @@ lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy) ext->time = copy_ext->time; ext->anim_dir = copy_ext->anim_dir; /*Refresh the style with new signal function*/ - lv_obj_refresh_style(spinner, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(spinner, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } lv_spinner_set_type(spinner, ext->anim_type); diff --git a/src/lv_widgets/lv_switch.c b/src/lv_widgets/lv_switch.c index dfc1aa964..9340f1efa 100644 --- a/src/lv_widgets/lv_switch.c +++ b/src/lv_widgets/lv_switch.c @@ -100,7 +100,7 @@ lv_obj_t * lv_switch_create(lv_obj_t * par, const lv_obj_t * copy) lv_switch_ext_t * copy_ext = lv_obj_get_ext_attr(copy); lv_style_list_copy(&ext->style_knob, ©_ext->style_knob); - lv_obj_refresh_style(sw, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(sw, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } /*Refresh the style with new signal function*/ diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index 0e44d1e5c..b35484e9a 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -110,7 +110,7 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy) } /*Refresh the style with new signal function*/ - lv_obj_refresh_style(table, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(table, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("table created"); diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index f68d69a36..3f4efb3e8 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -180,11 +180,11 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) LV_PAGE_PART_SCROLLABLE)); lv_style_list_copy(lv_obj_get_style_list(new_tab, LV_PAGE_PART_SCROLLBAR), lv_obj_get_style_list(copy_tab, LV_PAGE_PART_SCROLLBAR)); - lv_obj_refresh_style(new_tab, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(new_tab, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } /*Refresh the style with new signal function*/ - lv_obj_refresh_style(tabview, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(tabview, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } tabview_realign(tabview); diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 9cf859f82..e8a332c9e 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -187,7 +187,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy) if(copy_ext->one_line) lv_textarea_set_one_line(ta, true); /*Refresh the style with new signal function*/ - lv_obj_refresh_style(ta, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(ta, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } #if LV_USE_ANIMATION diff --git a/src/lv_widgets/lv_tileview.c b/src/lv_widgets/lv_tileview.c index 0ea0f8133..3fa01503c 100644 --- a/src/lv_widgets/lv_tileview.c +++ b/src/lv_widgets/lv_tileview.c @@ -133,7 +133,7 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy) #endif /*Refresh the style with new signal function*/ - lv_obj_refresh_style(new_tileview, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(new_tileview, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("tileview created"); diff --git a/src/lv_widgets/lv_win.c b/src/lv_widgets/lv_win.c index 20fbb7426..0e122976d 100644 --- a/src/lv_widgets/lv_win.c +++ b/src/lv_widgets/lv_win.c @@ -156,7 +156,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) } /*Refresh the style with new signal function*/ - lv_obj_refresh_style(new_win, LV_STYLE_PROP_ALL); + lv_obj_refresh_style(new_win, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); lv_win_realign(new_win);