style refresh optimizations

This commit is contained in:
Gabor Kiss-Vamosi
2020-03-10 10:41:39 +01:00
parent 498f050262
commit dc4e643f62
29 changed files with 166 additions and 115 deletions

View File

@@ -151,7 +151,8 @@ uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp)
uint32_t t = UINT32_MAX; uint32_t t = UINT32_MAX;
d = lv_disp_get_next(NULL); d = lv_disp_get_next(NULL);
while(d) { while(d) {
t = LV_MATH_MIN(t, lv_tick_elaps(d->last_activity_time)); uint32_t elaps = lv_tick_elaps(d->last_activity_time);
t = LV_MATH_MIN(t, elaps);
d = lv_disp_get_next(d); d = lv_disp_get_next(d);
} }

View File

@@ -1154,7 +1154,7 @@ void lv_obj_add_style(lv_obj_t * obj, uint8_t part, lv_style_t * style)
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
trans_del(obj, part, 0xFF, NULL); trans_del(obj, part, 0xFF, NULL);
#endif #endif
lv_obj_refresh_style(obj); lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
} }
/** /**
@@ -1191,7 +1191,7 @@ void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part)
{ {
lv_obj_clean_style_list(obj, part); lv_obj_clean_style_list(obj, part);
lv_obj_refresh_style(obj); lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
} }
/** /**
@@ -1213,7 +1213,7 @@ void _lv_obj_set_style_local_int(lv_obj_t * obj, uint8_t part, lv_style_property
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
trans_del(obj, part, prop, NULL); trans_del(obj, part, prop, NULL);
#endif #endif
lv_obj_refresh_style(obj); lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK));
} }
/** /**
@@ -1235,7 +1235,7 @@ void _lv_obj_set_style_local_color(lv_obj_t * obj, uint8_t part, lv_style_proper
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
trans_del(obj, part, prop, NULL); trans_del(obj, part, prop, NULL);
#endif #endif
lv_obj_refresh_style(obj); lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK));
} }
/** /**
@@ -1257,7 +1257,7 @@ void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t part, lv_style_property
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
trans_del(obj, part, prop, NULL); trans_del(obj, part, prop, NULL);
#endif #endif
lv_obj_refresh_style(obj); lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK));
} }
/** /**
@@ -1279,7 +1279,7 @@ void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t part, lv_style_property
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
trans_del(obj, part, prop, NULL); trans_del(obj, part, prop, NULL);
#endif #endif
lv_obj_refresh_style(obj); lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK));
} }
/** /**
@@ -1304,17 +1304,59 @@ bool _lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_prop
/** /**
* Notify an object (and its children) about its style is modified * Notify an object (and its children) about its style is modified
* @param obj pointer to an object * @param obj pointer to an object
* @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used the optimize what needs to be refreshed.
*/ */
void lv_obj_refresh_style(lv_obj_t * obj) void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop)
{ {
LV_ASSERT_OBJ(obj, LV_OBJX_NAME); LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
/*If a real style refresh is required*/
bool real_refr = false;
switch(prop) {
case LV_STYLE_PROP_ALL:
case LV_STYLE_CLIP_CORNER:
case LV_STYLE_SIZE:
case LV_STYLE_TRANSFORM_WIDTH:
case LV_STYLE_TRANSFORM_HEIGHT:
case LV_STYLE_PAD_TOP:
case LV_STYLE_PAD_BOTTOM:
case LV_STYLE_PAD_LEFT:
case LV_STYLE_PAD_RIGHT:
case LV_STYLE_PAD_INNER:
case LV_STYLE_OUTLINE_WIDTH:
case LV_STYLE_OUTLINE_PAD:
case LV_STYLE_SHADOW_WIDTH:
case LV_STYLE_SHADOW_OFS_X:
case LV_STYLE_SHADOW_OFS_Y:
case LV_STYLE_SHADOW_SPREAD:
case LV_STYLE_VALUE_LETTER_SPACE:
case LV_STYLE_VALUE_LINE_SPACE:
case LV_STYLE_VALUE_OFS_X:
case LV_STYLE_VALUE_OFS_Y:
case LV_STYLE_VALUE_ALIGN:
case LV_STYLE_VALUE_STR:
case LV_STYLE_VALUE_FONT:
case LV_STYLE_TEXT_LETTER_SPACE:
case LV_STYLE_TEXT_LINE_SPACE:
case LV_STYLE_TEXT_FONT:
case LV_STYLE_LINE_WIDTH:
real_refr = true;
break;
default:
real_refr = false;
}
if(real_refr) {
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
obj->signal_cb(obj, LV_SIGNAL_STYLE_CHG, NULL); obj->signal_cb(obj, LV_SIGNAL_STYLE_CHG, NULL);
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
if(prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_INHERIT_MASK))
/*Send style change signals*/ /*Send style change signals*/
refresh_children_style(obj); refresh_children_style(obj);
} else {
lv_obj_invalidate(obj);
}
} }
/** /**
@@ -1586,7 +1628,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
} }
#endif #endif
lv_obj_refresh_style(obj); lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
} }
@@ -3134,8 +3176,9 @@ lv_coord_t lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
sh_width = sh_width / 2; /*THe blur adds only half width*/ sh_width = sh_width / 2; /*THe blur adds only half width*/
sh_width++; sh_width++;
sh_width += lv_obj_get_style_shadow_spread(obj, part); sh_width += lv_obj_get_style_shadow_spread(obj, part);
sh_width += LV_MATH_MAX(LV_MATH_ABS(lv_obj_get_style_shadow_ofs_x(obj, part)), lv_style_int_t sh_ofs_x = lv_obj_get_style_shadow_ofs_x(obj, part);
LV_MATH_ABS(lv_obj_get_style_shadow_ofs_y(obj, part))); lv_style_int_t sh_ofs_y = lv_obj_get_style_shadow_ofs_y(obj, part);
sh_width += LV_MATH_MAX(LV_MATH_ABS(sh_ofs_x), LV_MATH_ABS(sh_ofs_y));
s = LV_MATH_MAX(s, sh_width); s = LV_MATH_MAX(s, sh_width);
} }
} }
@@ -3375,7 +3418,8 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) res = LV_RES_INV; if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) res = LV_RES_INV;
} }
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
obj->ext_draw_pad = LV_MATH_MAX(obj->ext_draw_pad, lv_obj_get_draw_rect_ext_pad_size(obj, LV_OBJ_PART_MAIN)); lv_coord_t d = lv_obj_get_draw_rect_ext_pad_size(obj, LV_OBJ_PART_MAIN);
obj->ext_draw_pad = LV_MATH_MAX(obj->ext_draw_pad, d);
} }
#if LV_USE_OBJ_REALIGN #if LV_USE_OBJ_REALIGN
else if(sign == LV_SIGNAL_PARENT_SIZE_CHG) { else if(sign == LV_SIGNAL_PARENT_SIZE_CHG) {
@@ -3451,7 +3495,7 @@ static void report_style_mod_core(void * style, lv_obj_t * obj)
for(ci = 0; ci < dsc->style_cnt; ci++) { for(ci = 0; ci < dsc->style_cnt; ci++) {
lv_style_t * class = lv_style_list_get_style(dsc, ci); lv_style_t * class = lv_style_list_get_style(dsc, ci);
if(class == style) { if(class == style) {
lv_obj_refresh_style(obj); lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
/*It's enough to handle once (if duplicated)*/ /*It's enough to handle once (if duplicated)*/
break; break;
} }
@@ -3746,7 +3790,7 @@ static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v)
else x = tr->end_value._ptr; else x = tr->end_value._ptr;
_lv_style_set_ptr(style, tr->prop, x); _lv_style_set_ptr(style, tr->prop, x);
} }
lv_obj_refresh_style(tr->obj); lv_obj_refresh_style(tr->obj, tr->prop);
} }

View File

@@ -507,7 +507,7 @@ void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part);
* Notify an object about its style is modified * Notify an object about its style is modified
* @param obj pointer to an object * @param obj pointer to an object
*/ */
void lv_obj_refresh_style(lv_obj_t * obj); void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop);
/** /**
* Notify all object if a style is modified * Notify all object if a style is modified

View File

@@ -42,6 +42,8 @@ LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
#define LV_STYLE_TRANS_NUM_MAX 6 #define LV_STYLE_TRANS_NUM_MAX 6
#define LV_STYLE_PROP_ALL 0xFF
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
@@ -198,6 +200,7 @@ typedef uint16_t lv_style_property_t;
#define LV_STYLE_STATE_POS 8 #define LV_STYLE_STATE_POS 8
#define LV_STYLE_STATE_MASK 0x7F00 #define LV_STYLE_STATE_MASK 0x7F00
#define LV_STYLE_INHERIT_MASK 0x8000
typedef uint16_t lv_style_state_t; typedef uint16_t lv_style_state_t;

View File

@@ -260,8 +260,9 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
/*Fill the first line. Use `memcpy` because it's faster then simple value assignment*/ /*Fill the first line. Use `memcpy` because it's faster then simple value assignment*/
/*Set the first pixels manually*/ /*Set the first pixels manually*/
int32_t fill_end = draw_area->x1 + FILL_DIRECT_LEN + (draw_area_w & FILL_DIRECT_MASK) - 1;
int32_t direct_fill_end = LV_MATH_MIN(draw_area->x2, int32_t direct_fill_end = LV_MATH_MIN(draw_area->x2,
draw_area->x1 + FILL_DIRECT_LEN + (draw_area_w & FILL_DIRECT_MASK) - 1); fill_end);
for(x = draw_area->x1; x <= direct_fill_end ; x++) { for(x = draw_area->x1; x <= direct_fill_end ; x++) {
disp_buf_tmp[x].full = color.full; disp_buf_tmp[x].full = color.full;
} }

View File

@@ -412,9 +412,8 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
/* The real draw area is around the line. /* The real draw area is around the line.
* It's easy to calculate with steep lines, but the area can be very wide with very flat lines. * It's easy to calculate with steep lines, but the area can be very wide with very flat lines.
* So deal with it only with steep lines. */ * So deal with it only with steep lines. */
int32_t draw_area_w; int32_t draw_area_w = lv_area_get_width(&draw_area);
if(flat) draw_area_w = lv_area_get_width(&draw_area); if(!flat) draw_area_w = LV_MATH_MIN(draw_area_w, dsc->width * 2 + 2);
else draw_area_w = LV_MATH_MIN(lv_area_get_width(&draw_area), dsc->width * 2 + 2);
/*Draw the background line by line*/ /*Draw the background line by line*/
int32_t h; int32_t h;

View File

@@ -361,8 +361,9 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert
*/ */
void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area_t * rect, lv_coord_t radius, bool inv) void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area_t * rect, lv_coord_t radius, bool inv)
{ {
lv_coord_t w = lv_area_get_width(rect);
int32_t short_side = LV_MATH_MIN(lv_area_get_width(rect), lv_area_get_height(rect)); lv_coord_t h = lv_area_get_height(rect);
int32_t short_side = LV_MATH_MIN(w, h);
if(radius > short_side >> 1) radius = short_side >> 1; if(radius > short_side >> 1) radius = short_side >> 1;
lv_area_copy(&param->cfg.rect, rect); lv_area_copy(&param->cfg.rect, rect);

View File

@@ -161,7 +161,9 @@ bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, lv_coord
/*No radius, it is within the rectangle*/ /*No radius, it is within the rectangle*/
return true; return true;
} }
lv_coord_t max_radius = LV_MATH_MIN(lv_area_get_width(a_p) / 2, lv_area_get_height(a_p) / 2); lv_coord_t w = lv_area_get_width(a_p) / 2;
lv_coord_t h = lv_area_get_height(a_p) / 2;
lv_coord_t max_radius = LV_MATH_MIN(w, h);
if(radius > max_radius) if(radius > max_radius)
radius = max_radius; radius = max_radius;

View File

@@ -100,7 +100,7 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
lv_style_list_copy(&ext->style_arc, &copy_ext->style_arc); lv_style_list_copy(&ext->style_arc, &copy_ext->style_arc);
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(arc); lv_obj_refresh_style(arc, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("arc created"); LV_LOG_INFO("arc created");

View File

@@ -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); lv_style_list_copy(&ext->style_indic, &ext_copy->style_indic);
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(bar); lv_obj_refresh_style(bar, LV_STYLE_PROP_ALL);
lv_bar_set_value(bar, ext->cur_value, LV_ANIM_OFF); lv_bar_set_value(bar, ext->cur_value, LV_ANIM_OFF);
} }

View File

@@ -97,7 +97,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
ext->checkable = copy_ext->checkable; ext->checkable = copy_ext->checkable;
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(btn); lv_obj_refresh_style(btn, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("button created"); LV_LOG_INFO("button created");

View File

@@ -152,7 +152,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t)); memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t));
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(chart); lv_obj_refresh_style(chart, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("chart created"); LV_LOG_INFO("chart created");

View File

@@ -113,7 +113,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
ext->layout = copy_ext->layout; ext->layout = copy_ext->layout;
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(cont); lv_obj_refresh_style(cont, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("container created"); LV_LOG_INFO("container created");
@@ -243,7 +243,7 @@ lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont)
/********************** /**********************
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/
extern uint32_t cont_sign;
/** /**
* Signal function of the container * Signal function of the container
* @param cont pointer to a container object * @param cont pointer to a container object
@@ -282,7 +282,7 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
} }
} }
else if(sign == LV_SIGNAL_PARENT_SIZE_CHG) { else if(sign == LV_SIGNAL_PARENT_SIZE_CHG) {
/*FLOOD and FILL fit needs to be refreshed if the parent's size has changed*/ /*MAX and EDGE fit needs to be refreshed if the parent's size has changed*/
lv_cont_refr_autofit(cont); lv_cont_refr_autofit(cont);
} }
@@ -523,7 +523,8 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
break; break;
} }
w_row += lv_obj_get_width(child_rc) + inner; /*Add the object width + opad*/ w_row += lv_obj_get_width(child_rc) + inner; /*Add the object width + opad*/
h_row = LV_MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/ lv_coord_t child_h = lv_obj_get_height(child_rc);
h_row = LV_MATH_MAX(h_row, child_h); /*Search the highest object*/
obj_num++; obj_num++;
if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW)) if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW))
break; /*If can not be followed by an other object then break here*/ break; /*If can not be followed by an other object then break here*/

View File

@@ -144,7 +144,7 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy)
lv_style_list_copy(&ext->indic.style_list, &copy_ext->indic.style_list); lv_style_list_copy(&ext->indic.style_list, &copy_ext->indic.style_list);
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(cpicker); lv_obj_refresh_style(cpicker, LV_STYLE_PROP_ALL);
} }
refr_indic_pos(cpicker); refr_indic_pos(cpicker);

View File

@@ -580,7 +580,7 @@ void lv_dropdown_open(lv_obj_t * ddlist, lv_anim_enable_t anim)
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_BG), &ext->style_page);
lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCRLBAR), &ext->style_scrlbar); lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCRLBAR), &ext->style_scrlbar);
lv_obj_clean_style_list(ext->page, LV_PAGE_PART_SCRL); lv_obj_clean_style_list(ext->page, LV_PAGE_PART_SCRL);
lv_obj_refresh_style(ext->page); lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL);
lv_page_set_scrl_fit(ext->page, LV_FIT_TIGHT); lv_page_set_scrl_fit(ext->page, LV_FIT_TIGHT);
@@ -924,7 +924,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); 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)); lv_obj_set_height(ddlist, top + bottom + lv_font_get_line_height(font));
if(ext->page) lv_obj_refresh_style(ext->page); if(ext->page) lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL);
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
char c = *((char *)param); char c = *((char *)param);
@@ -986,7 +986,7 @@ static lv_res_t lv_dropdown_page_signal(lv_obj_t * page, lv_signal_t sign, void
lv_style_int_t left = lv_obj_get_style_pad_left(ddlist, LV_DROPDOWN_PART_LIST); lv_style_int_t left = lv_obj_get_style_pad_left(ddlist, LV_DROPDOWN_PART_LIST);
lv_style_int_t right = lv_obj_get_style_pad_right(ddlist, LV_DROPDOWN_PART_LIST); lv_style_int_t right = lv_obj_get_style_pad_right(ddlist, LV_DROPDOWN_PART_LIST);
lv_obj_t * scrl = lv_page_get_scrl(page); lv_obj_t * scrl = lv_page_get_scrl(page);
scrl->ext_draw_pad = LV_MATH_MAX(scrl->ext_draw_pad, LV_MATH_MAX(left, right)); scrl->ext_draw_pad = LV_MATH_MAX3(scrl->ext_draw_pad, left, right);
} }
else if(sign == LV_SIGNAL_RELEASED) { else if(sign == LV_SIGNAL_RELEASED) {
if(lv_indev_is_dragging(lv_indev_get_act()) == false) { if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
@@ -1043,7 +1043,7 @@ static lv_res_t lv_dropdown_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign,
* (The scrollabel is scrolled the "select rectangle" is drawn on the bg too)*/ * (The scrollabel is scrolled the "select rectangle" is drawn on the bg too)*/
lv_style_int_t left = lv_obj_get_style_pad_left(ddlist, LV_DROPDOWN_PART_LIST); lv_style_int_t left = lv_obj_get_style_pad_left(ddlist, LV_DROPDOWN_PART_LIST);
lv_style_int_t right = lv_obj_get_style_pad_right(ddlist, LV_DROPDOWN_PART_LIST); lv_style_int_t right = lv_obj_get_style_pad_right(ddlist, LV_DROPDOWN_PART_LIST);
scrl->ext_draw_pad = LV_MATH_MAX(scrl->ext_draw_pad, LV_MATH_MAX(left, right)); scrl->ext_draw_pad = LV_MATH_MAX3(scrl->ext_draw_pad, left, right);
} }
return res; return res;

View File

@@ -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); lv_img_set_src(img, copy_ext->src);
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(img); lv_obj_refresh_style(img, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("image created"); LV_LOG_INFO("image created");

View File

@@ -100,7 +100,7 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
#endif #endif
ext->tiled = copy_ext->tiled; ext->tiled = copy_ext->tiled;
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(imgbtn); lv_obj_refresh_style(imgbtn, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("image button created"); LV_LOG_INFO("image button created");

View File

@@ -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; ext->dot_end = copy_ext->dot_end;
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(new_label); lv_obj_refresh_style(new_label, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("label created"); LV_LOG_INFO("label created");
@@ -1153,7 +1153,6 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
else if(sign == LV_SIGNAL_STYLE_CHG) { else if(sign == LV_SIGNAL_STYLE_CHG) {
/*Revert dots for proper refresh*/ /*Revert dots for proper refresh*/
lv_label_revert_dots(label); lv_label_revert_dots(label);
lv_label_refr_text(label); lv_label_refr_text(label);
} }
else if(sign == LV_SIGNAL_COORD_CHG) { else if(sign == LV_SIGNAL_COORD_CHG) {

View File

@@ -88,7 +88,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
ext->bright = copy_ext->bright; ext->bright = copy_ext->bright;
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(led); lv_obj_refresh_style(led, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("led created"); LV_LOG_INFO("led created");

View File

@@ -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); lv_line_set_points(line, copy_ext->point_array, copy_ext->point_num);
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(line); lv_obj_refresh_style(line, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("line created"); LV_LOG_INFO("line created");

View File

@@ -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*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(list); lv_obj_refresh_style(list, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("list created"); LV_LOG_INFO("list created");

View File

@@ -105,7 +105,7 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(spinbox); lv_obj_refresh_style(spinbox, LV_STYLE_PROP_ALL);
} }
lv_spinbox_updatevalue(spinbox); lv_spinbox_updatevalue(spinbox);

View File

@@ -1,5 +1,5 @@
/** /**
* @file lv_preload.c * @file lv_spinner.c
* *
*/ */
@@ -39,7 +39,7 @@
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static lv_res_t lv_spinner_signal(lv_obj_t * preload, lv_signal_t sign, void * param); static lv_res_t lv_spinner_signal(lv_obj_t * spinner, lv_signal_t sign, void * param);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@@ -64,23 +64,23 @@ static lv_design_cb_t ancestor_design;
*/ */
lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy)
{ {
LV_LOG_TRACE("preload create started"); LV_LOG_TRACE("spinner create started");
/*Create the ancestor of pre loader*/ /*Create the ancestor of pre loader*/
lv_obj_t * preload = lv_arc_create(par, copy); lv_obj_t * spinner = lv_arc_create(par, copy);
LV_ASSERT_MEM(preload); LV_ASSERT_MEM(spinner);
if(preload == NULL) return NULL; if(spinner == NULL) return NULL;
/*Allocate the pre loader type specific extended data*/ /*Allocate the pre loader type specific extended data*/
lv_spinner_ext_t * ext = lv_obj_allocate_ext_attr(preload, sizeof(lv_spinner_ext_t)); lv_spinner_ext_t * ext = lv_obj_allocate_ext_attr(spinner, sizeof(lv_spinner_ext_t));
LV_ASSERT_MEM(ext); LV_ASSERT_MEM(ext);
if(ext == NULL) { if(ext == NULL) {
lv_obj_del(preload); lv_obj_del(spinner);
return NULL; return NULL;
} }
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(preload); if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(spinner);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(preload); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(spinner);
/*Initialize the allocated 'ext' */ /*Initialize the allocated 'ext' */
ext->arc_length = LV_SPINNER_DEF_ARC_LENGTH; ext->arc_length = LV_SPINNER_DEF_ARC_LENGTH;
@@ -89,14 +89,14 @@ lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy)
ext->time = LV_SPINNER_DEF_SPIN_TIME; ext->time = LV_SPINNER_DEF_SPIN_TIME;
/*The signal and design functions are not copied so set them here*/ /*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(preload, lv_spinner_signal); lv_obj_set_signal_cb(spinner, lv_spinner_signal);
/*Init the new spinner spinner*/ /*Init the new spinner spinner*/
if(copy == NULL) { if(copy == NULL) {
ext->arc.bg_angle_start = 0; ext->arc.bg_angle_start = 0;
ext->arc.bg_angle_end = 360; ext->arc.bg_angle_end = 360;
lv_obj_set_size(preload, LV_DPI, LV_DPI); lv_obj_set_size(spinner, LV_DPI, LV_DPI);
lv_theme_apply(preload, LV_THEME_SPINNER); lv_theme_apply(spinner, LV_THEME_SPINNER);
} }
/*Copy an existing spinner*/ /*Copy an existing spinner*/
@@ -106,14 +106,14 @@ lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy)
ext->time = copy_ext->time; ext->time = copy_ext->time;
ext->anim_dir = copy_ext->anim_dir; ext->anim_dir = copy_ext->anim_dir;
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(preload); lv_obj_refresh_style(spinner, LV_STYLE_PROP_ALL);
} }
lv_spinner_set_type(preload, ext->anim_type); lv_spinner_set_type(spinner, ext->anim_type);
LV_LOG_INFO("preload created"); LV_LOG_INFO("spinner created");
return preload; return spinner;
} }
/*====================== /*======================
@@ -122,55 +122,55 @@ lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy)
/** /**
* Set the length of the spinning arc in degrees * Set the length of the spinning arc in degrees
* @param preload pointer to a preload object * @param spinner pointer to a spinner object
* @param deg length of the arc * @param deg length of the arc
*/ */
void lv_spinner_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg) void lv_spinner_set_arc_length(lv_obj_t * spinner, lv_anim_value_t deg)
{ {
LV_ASSERT_OBJ(preload, LV_OBJX_NAME); LV_ASSERT_OBJ(spinner, LV_OBJX_NAME);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload); lv_spinner_ext_t * ext = lv_obj_get_ext_attr(spinner);
ext->arc_length = deg; ext->arc_length = deg;
} }
/** /**
* Set the spin time of the arc * Set the spin time of the arc
* @param preload pointer to a preload object * @param spinner pointer to a spinner object
* @param time time of one round in milliseconds * @param time time of one round in milliseconds
*/ */
void lv_spinner_set_spin_time(lv_obj_t * preload, uint16_t time) void lv_spinner_set_spin_time(lv_obj_t * spinner, uint16_t time)
{ {
LV_ASSERT_OBJ(preload, LV_OBJX_NAME); LV_ASSERT_OBJ(spinner, LV_OBJX_NAME);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload); lv_spinner_ext_t * ext = lv_obj_get_ext_attr(spinner);
ext->time = time; ext->time = time;
lv_spinner_set_type(preload, ext->anim_type); lv_spinner_set_type(spinner, ext->anim_type);
} }
/*===================== /*=====================
* Setter functions * Setter functions
*====================*/ *====================*/
/** /**
* Set the animation type of a preloadeer. * Set the animation type of a spinnereer.
* @param preload pointer to pre loader object * @param spinner pointer to pre loader object
* @param type animation type of the preload * @param type animation type of the spinner
* */ * */
void lv_spinner_set_type(lv_obj_t * preload, lv_spinner_type_t type) void lv_spinner_set_type(lv_obj_t * spinner, lv_spinner_type_t type)
{ {
LV_ASSERT_OBJ(preload, LV_OBJX_NAME); LV_ASSERT_OBJ(spinner, LV_OBJX_NAME);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload); lv_spinner_ext_t * ext = lv_obj_get_ext_attr(spinner);
/*delete previous animation*/ /*delete previous animation*/
lv_anim_del(preload, NULL); lv_anim_del(spinner, NULL);
switch(type) { switch(type) {
case LV_SPINNER_TYPE_FILLSPIN_ARC: { case LV_SPINNER_TYPE_FILLSPIN_ARC: {
ext->anim_type = LV_SPINNER_TYPE_FILLSPIN_ARC; ext->anim_type = LV_SPINNER_TYPE_FILLSPIN_ARC;
lv_anim_t a; lv_anim_t a;
lv_anim_init(&a); lv_anim_init(&a);
lv_anim_set_var(&a, preload); lv_anim_set_var(&a, spinner);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_anim_cb); lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_anim_cb);
lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out); lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT); lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
@@ -193,7 +193,7 @@ void lv_spinner_set_type(lv_obj_t * preload, lv_spinner_type_t type)
ext->anim_type = type; ext->anim_type = type;
lv_anim_t a; lv_anim_t a;
lv_anim_init(&a); lv_anim_init(&a);
lv_anim_set_var(&a, preload); lv_anim_set_var(&a, spinner);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_anim_cb); lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_anim_cb);
lv_anim_set_time(&a, ext->time); lv_anim_set_time(&a, ext->time);
lv_anim_set_path_cb(&a, (LV_SPINNER_TYPE_CONSTANT_ARC == type ? lv_anim_path_linear : lv_anim_path_ease_in_out)); lv_anim_set_path_cb(&a, (LV_SPINNER_TYPE_CONSTANT_ARC == type ? lv_anim_path_linear : lv_anim_path_ease_in_out));
@@ -206,14 +206,14 @@ void lv_spinner_set_type(lv_obj_t * preload, lv_spinner_type_t type)
} }
} }
void lv_spinner_set_dir(lv_obj_t * preload, lv_spinner_dir_t dir) void lv_spinner_set_dir(lv_obj_t * spinner, lv_spinner_dir_t dir)
{ {
LV_ASSERT_OBJ(preload, LV_OBJX_NAME); LV_ASSERT_OBJ(spinner, LV_OBJX_NAME);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload); lv_spinner_ext_t * ext = lv_obj_get_ext_attr(spinner);
ext->anim_dir = dir; ext->anim_dir = dir;
lv_spinner_set_type(preload, ext->anim_type); lv_spinner_set_type(spinner, ext->anim_type);
} }
/*===================== /*=====================
@@ -222,44 +222,44 @@ void lv_spinner_set_dir(lv_obj_t * preload, lv_spinner_dir_t dir)
/** /**
* Get the arc length [degree] of the a pre loader * Get the arc length [degree] of the a pre loader
* @param preload pointer to a pre loader object * @param spinner pointer to a pre loader object
*/ */
lv_anim_value_t lv_spinner_get_arc_length(const lv_obj_t * preload) lv_anim_value_t lv_spinner_get_arc_length(const lv_obj_t * spinner)
{ {
LV_ASSERT_OBJ(preload, LV_OBJX_NAME); LV_ASSERT_OBJ(spinner, LV_OBJX_NAME);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload); lv_spinner_ext_t * ext = lv_obj_get_ext_attr(spinner);
return ext->arc_length; return ext->arc_length;
} }
/** /**
* Get the spin time of the arc * Get the spin time of the arc
* @param preload pointer to a pre loader object [milliseconds] * @param spinner pointer to a pre loader object [milliseconds]
*/ */
uint16_t lv_spinner_get_spin_time(const lv_obj_t * preload) uint16_t lv_spinner_get_spin_time(const lv_obj_t * spinner)
{ {
LV_ASSERT_OBJ(preload, LV_OBJX_NAME); LV_ASSERT_OBJ(spinner, LV_OBJX_NAME);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload); lv_spinner_ext_t * ext = lv_obj_get_ext_attr(spinner);
return ext->time; return ext->time;
} }
/** /**
* Get the animation type of a preloadeer. * Get the animation type of a spinnereer.
* @param preload pointer to pre loader object * @param spinner pointer to pre loader object
* @return animation type * @return animation type
* */ * */
lv_spinner_type_t lv_spinner_get_type(lv_obj_t * preload) lv_spinner_type_t lv_spinner_get_type(lv_obj_t * spinner)
{ {
LV_ASSERT_OBJ(preload, LV_OBJX_NAME); LV_ASSERT_OBJ(spinner, LV_OBJX_NAME);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload); lv_spinner_ext_t * ext = lv_obj_get_ext_attr(spinner);
return ext->anim_type; return ext->anim_type;
} }
lv_spinner_dir_t lv_spinner_get_dir(lv_obj_t * preload) lv_spinner_dir_t lv_spinner_get_dir(lv_obj_t * spinner)
{ {
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload); lv_spinner_ext_t * ext = lv_obj_get_ext_attr(spinner);
return ext->anim_dir; return ext->anim_dir;
} }
@@ -274,8 +274,8 @@ lv_spinner_dir_t lv_spinner_get_dir(lv_obj_t * preload)
*/ */
void lv_spinner_anim_cb(void * ptr, lv_anim_value_t val) void lv_spinner_anim_cb(void * ptr, lv_anim_value_t val)
{ {
lv_obj_t * preload = ptr; lv_obj_t * spinner = ptr;
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload); lv_spinner_ext_t * ext = lv_obj_get_ext_attr(spinner);
int16_t angle_start = val - ext->arc_length / 2 - 90; int16_t angle_start = val - ext->arc_length / 2 - 90;
if(angle_start < 0) angle_start += 360; if(angle_start < 0) angle_start += 360;
@@ -284,7 +284,7 @@ void lv_spinner_anim_cb(void * ptr, lv_anim_value_t val)
angle_start = angle_start % 360; angle_start = angle_start % 360;
angle_end = angle_end % 360; angle_end = angle_end % 360;
lv_arc_set_angles(preload, angle_start, angle_end); lv_arc_set_angles(spinner, angle_start, angle_end);
} }
/********************** /**********************
@@ -293,17 +293,17 @@ void lv_spinner_anim_cb(void * ptr, lv_anim_value_t val)
/** /**
* Signal function of the pre loader * Signal function of the pre loader
* @param preload pointer to a pre loader object * @param spinner pointer to a pre loader object
* @param sign a signal type from lv_signal_t enum * @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable * @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted * @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/ */
static lv_res_t lv_spinner_signal(lv_obj_t * preload, lv_signal_t sign, void * param) static lv_res_t lv_spinner_signal(lv_obj_t * spinner, lv_signal_t sign, void * param)
{ {
lv_res_t res; lv_res_t res;
/* Include the ancient signal function */ /* Include the ancient signal function */
res = ancestor_signal(preload, sign, param); res = ancestor_signal(spinner, sign, param);
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

View File

@@ -99,7 +99,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_switch_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_style_list_copy(&ext->style_knob, &copy_ext->style_knob); lv_style_list_copy(&ext->style_knob, &copy_ext->style_knob);
lv_obj_refresh_style(sw); lv_obj_refresh_style(sw, LV_STYLE_PROP_ALL);
} }
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/

View File

@@ -108,7 +108,7 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
} }
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(table); lv_obj_refresh_style(table, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("table created"); LV_LOG_INFO("table created");

View File

@@ -180,11 +180,11 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
LV_PAGE_PART_SCRL)); LV_PAGE_PART_SCRL));
lv_style_list_copy(lv_obj_get_style_list(new_tab, LV_PAGE_PART_SCRLBAR), lv_obj_get_style_list(copy_tab, lv_style_list_copy(lv_obj_get_style_list(new_tab, LV_PAGE_PART_SCRLBAR), lv_obj_get_style_list(copy_tab,
LV_PAGE_PART_SCRLBAR)); LV_PAGE_PART_SCRLBAR));
lv_obj_refresh_style(new_tab); lv_obj_refresh_style(new_tab, LV_STYLE_PROP_ALL);
} }
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(tabview); lv_obj_refresh_style(tabview, LV_STYLE_PROP_ALL);
} }
tabview_realign(tabview); tabview_realign(tabview);

View File

@@ -188,7 +188,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); if(copy_ext->one_line) lv_textarea_set_one_line(ta, true);
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(ta); lv_obj_refresh_style(ta, LV_STYLE_PROP_ALL);
} }
#if LV_USE_ANIMATION #if LV_USE_ANIMATION

View File

@@ -133,7 +133,7 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
#endif #endif
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(new_tileview); lv_obj_refresh_style(new_tileview, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("tileview created"); LV_LOG_INFO("tileview created");

View File

@@ -134,7 +134,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
} }
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(new_win); lv_obj_refresh_style(new_win, LV_STYLE_PROP_ALL);
lv_win_realign(new_win); lv_win_realign(new_win);