From 74d19b109cea8418a88e3658c1014b58bf25344b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 16 Dec 2020 10:22:13 +0100 Subject: [PATCH] experiements with improving styles --- src/lv_core/lv_disp.c | 8 +- src/lv_core/lv_flex.c | 313 +++--- src/lv_core/lv_grid.c | 178 +-- src/lv_core/lv_obj.c | 84 +- src/lv_core/lv_obj.h | 21 +- src/lv_core/lv_obj_draw.c | 696 ++++++------ src/lv_core/lv_obj_pos.c | 48 +- src/lv_core/lv_obj_scroll.c | 26 +- src/lv_core/lv_obj_style.c | 1505 ++++++++----------------- src/lv_core/lv_obj_style.h | 736 +++++------- src/lv_core/lv_refr.c | 6 +- src/lv_core/lv_style.c | 1914 ++++++++++++++------------------ src/lv_core/lv_style.h | 971 ++++++++-------- src/lv_draw/lv_draw_arc.c | 2 +- src/lv_draw/lv_draw_label.h | 4 +- src/lv_draw/lv_draw_line.c | 8 +- src/lv_draw/lv_draw_line.h | 6 +- src/lv_draw/lv_draw_rect.c | 29 +- src/lv_draw/lv_draw_rect.h | 38 +- src/lv_hal/lv_hal_disp.c | 4 +- src/lv_misc/lv_mem.c | 2 - src/lv_themes/lv_theme.c | 155 +-- src/lv_themes/lv_theme_empty.c | 5 +- src/lv_widgets/lv_arc.h | 2 - src/lv_widgets/lv_bar.c | 8 +- 25 files changed, 2804 insertions(+), 3965 deletions(-) diff --git a/src/lv_core/lv_disp.c b/src/lv_core/lv_disp.c index abb67f04c..1157032a3 100644 --- a/src/lv_core/lv_disp.c +++ b/src/lv_core/lv_disp.c @@ -210,8 +210,8 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t /*Be sure both screens are in a normal position*/ lv_obj_set_pos(new_scr, 0, 0); lv_obj_set_pos(lv_scr_act(), 0, 0); - lv_style_remove_prop(_lv_obj_get_local_style(new_scr, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); - lv_style_remove_prop(_lv_obj_get_local_style(lv_scr_act(), LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); +// lv_style_remove_prop(_lv_obj_get_local_style(new_scr, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); +// lv_style_remove_prop(_lv_obj_get_local_style(lv_scr_act(), LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); lv_anim_t a_new; lv_anim_init(&a_new); @@ -374,7 +374,7 @@ static void scr_load_anim_start(lv_anim_t * a) static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v) { - lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v); +// lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v); } @@ -384,6 +384,6 @@ static void scr_anim_ready(lv_anim_t * a) if(d->prev_scr && d->del_prev) lv_obj_del(d->prev_scr); d->prev_scr = NULL; - lv_style_remove_prop(_lv_obj_get_local_style(a->var, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); +// lv_style_remove_prop(_lv_obj_get_local_style(a->var, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); } #endif diff --git a/src/lv_core/lv_flex.c b/src/lv_core/lv_flex.c index d558d5107..dc76597b0 100644 --- a/src/lv_core/lv_flex.c +++ b/src/lv_core/lv_flex.c @@ -146,77 +146,77 @@ lv_flex_place_t lv_obj_get_flex_self_place(lv_obj_t * obj) void _lv_flex_refresh(lv_obj_t * cont) { lv_flex_dir_t dir = get_dir(cont); - - if(dir == LV_FLEX_DIR_NONE) return; - - bool rtl = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false; - bool row = dir == LV_FLEX_DIR_ROW ? true : false; - /*Count the grow units and free space*/ - lv_coord_t max_main_size = (row ? lv_obj_get_width_fit(cont) : lv_obj_get_height_fit(cont)); - lv_coord_t abs_y = cont->coords.y1 + lv_obj_get_style_pad_top(cont, LV_OBJ_PART_MAIN) - lv_obj_get_scroll_y(cont); - lv_coord_t abs_x = cont->coords.x1 + lv_obj_get_style_pad_left(cont, LV_OBJ_PART_MAIN) - lv_obj_get_scroll_x(cont); - - lv_flex_place_t cross_place = lv_obj_get_flex_track_place(cont); - lv_flex_place_t main_place = cont->spec_attr->flex_cont.main_place; - lv_coord_t * cross_pos = (row ? &abs_y : &abs_x); - - if((row && cont->h_set == LV_SIZE_AUTO) || - (!row && cont->w_set == LV_SIZE_AUTO)) - { - cross_place = LV_FLEX_PLACE_START; - } - - if(rtl && !row) { - if(cross_place == LV_FLEX_PLACE_START) cross_place = LV_FLEX_PLACE_END; - else if(cross_place == LV_FLEX_PLACE_END) cross_place = LV_FLEX_PLACE_START; - } - - lv_coord_t total_track_cross_size = 0; - lv_coord_t gap = 0; - uint32_t track_cnt = 0; - uint32_t track_first_item; - uint32_t next_track_first_item; - bool rev = get_rev(cont); - - if(cross_place != LV_FLEX_PLACE_START) { - track_first_item = rev ? cont->spec_attr->child_cnt - 1 : 0; - track_t t; - while(track_first_item ) { - /*Search the first item of the next row */ - next_track_first_item = find_track_end(cont, track_first_item, max_main_size, &t); - total_track_cross_size += t.track_cross_size; - track_cnt++; - track_first_item = next_track_first_item; - } - - lv_coord_t max_cross_size = (row ? lv_obj_get_height_fit(cont) : lv_obj_get_width_fit(cont)); - place_content(cross_place, max_cross_size, total_track_cross_size, track_cnt, cross_pos, &gap); - } - - track_first_item = rev ? cont->spec_attr->child_cnt - 1 : 0; - - if(rtl && !row) { - *cross_pos += total_track_cross_size; - } - - while(track_first_item) { - track_t t; - /*Search the first item of the next row */ - next_track_first_item = find_track_end(cont, track_first_item, max_main_size, &t); - - if(rtl && !row) { - *cross_pos -= t.track_cross_size; - } - children_repos(cont, track_first_item, next_track_first_item, abs_x, abs_y, max_main_size, main_place, &t); - track_first_item = next_track_first_item; - - if(rtl && !row) { - *cross_pos -= gap; - } else { - *cross_pos += t.track_cross_size + gap; - } - } - LV_ASSERT_MEM_INTEGRITY(); +// +// if(dir == LV_FLEX_DIR_NONE) return; +// +// bool rtl = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false; +// bool row = dir == LV_FLEX_DIR_ROW ? true : false; +// /*Count the grow units and free space*/ +// lv_coord_t max_main_size = (row ? lv_obj_get_width_fit(cont) : lv_obj_get_height_fit(cont)); +// lv_coord_t abs_y = cont->coords.y1 + lv_obj_get_style_pad_top(cont, LV_OBJ_PART_MAIN) - lv_obj_get_scroll_y(cont); +// lv_coord_t abs_x = cont->coords.x1 + lv_obj_get_style_pad_left(cont, LV_OBJ_PART_MAIN) - lv_obj_get_scroll_x(cont); +// +// lv_flex_place_t cross_place = lv_obj_get_flex_track_place(cont); +// lv_flex_place_t main_place = cont->spec_attr->flex_cont.main_place; +// lv_coord_t * cross_pos = (row ? &abs_y : &abs_x); +// +// if((row && cont->h_set == LV_SIZE_AUTO) || +// (!row && cont->w_set == LV_SIZE_AUTO)) +// { +// cross_place = LV_FLEX_PLACE_START; +// } +// +// if(rtl && !row) { +// if(cross_place == LV_FLEX_PLACE_START) cross_place = LV_FLEX_PLACE_END; +// else if(cross_place == LV_FLEX_PLACE_END) cross_place = LV_FLEX_PLACE_START; +// } +// +// lv_coord_t total_track_cross_size = 0; +// lv_coord_t gap = 0; +// uint32_t track_cnt = 0; +// uint32_t track_first_item; +// uint32_t next_track_first_item; +// bool rev = get_rev(cont); +// +// if(cross_place != LV_FLEX_PLACE_START) { +// track_first_item = rev ? cont->spec_attr->child_cnt - 1 : 0; +// track_t t; +// while(track_first_item ) { +// /*Search the first item of the next row */ +// next_track_first_item = find_track_end(cont, track_first_item, max_main_size, &t); +// total_track_cross_size += t.track_cross_size; +// track_cnt++; +// track_first_item = next_track_first_item; +// } +// +// lv_coord_t max_cross_size = (row ? lv_obj_get_height_fit(cont) : lv_obj_get_width_fit(cont)); +// place_content(cross_place, max_cross_size, total_track_cross_size, track_cnt, cross_pos, &gap); +// } +// +// track_first_item = rev ? cont->spec_attr->child_cnt - 1 : 0; +// +// if(rtl && !row) { +// *cross_pos += total_track_cross_size; +// } +// +// while(track_first_item) { +// track_t t; +// /*Search the first item of the next row */ +// next_track_first_item = find_track_end(cont, track_first_item, max_main_size, &t); +// +// if(rtl && !row) { +// *cross_pos -= t.track_cross_size; +// } +// children_repos(cont, track_first_item, next_track_first_item, abs_x, abs_y, max_main_size, main_place, &t); +// track_first_item = next_track_first_item; +// +// if(rtl && !row) { +// *cross_pos -= gap; +// } else { +// *cross_pos += t.track_cross_size + gap; +// } +// } +// LV_ASSERT_MEM_INTEGRITY(); } /********************** @@ -293,91 +293,92 @@ static uint32_t find_track_end(lv_obj_t * cont, uint32_t item_start_id, lv_coord static void children_repos(lv_obj_t * cont, uint32_t item_first_id, uint32_t item_last_id, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t max_main_size, lv_flex_place_t main_place, track_t * t) { - bool rev = get_rev(cont); - lv_coord_t gap = lv_obj_get_flex_gap(cont); - bool row = get_dir(cont) == LV_FLEX_DIR_ROW ? true : false; - - lv_coord_t(*obj_get_main_size)(const lv_obj_t *) = (row ? lv_obj_get_width_margin : lv_obj_get_height_margin); - lv_coord_t(*obj_get_cross_size)(const lv_obj_t *) = (!row ? lv_obj_get_width_margin : lv_obj_get_height_margin); - void (*area_set_main_size)(lv_area_t *, lv_coord_t) = (row ? lv_area_set_width : lv_area_set_height); - void (*area_set_cross_size)(lv_area_t *, lv_coord_t) = (!row ? lv_area_set_width : lv_area_set_height); - lv_coord_t (*area_get_main_size)(const lv_area_t *) = (!row ? lv_area_get_width : lv_area_get_height); - lv_style_int_t (*get_margin_start)(const lv_obj_t *, uint8_t part) = (row ? lv_obj_get_style_margin_left : lv_obj_get_style_margin_top); - lv_style_int_t (*get_margin_end)(const lv_obj_t *, uint8_t part) = (row ? lv_obj_get_style_margin_right : lv_obj_get_style_margin_bottom); - - bool rtl = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false; - - if(row && rtl) abs_x += lv_obj_get_width_fit(cont); - - lv_coord_t main_pos = 0; - - lv_coord_t place_gap = 0; - place_content(main_place, max_main_size, t->track_main_size, t->item_cnt, &main_pos, &place_gap); - - lv_obj_t * item = get_next_item(cont, rev, &item_first_id); - /*Reposition the children*/ - while(item && item_first_id != item_last_id) { - /*Ignore non-flex items*/ - lv_coord_t main_set = (row ? item->x_set : item->y_set); - if(LV_COORD_IS_FLEX(main_set) == false) { - item = get_next_item(cont, rev, &item_first_id); - continue; - } - - lv_coord_t main_size = (row ? item->w_set : item->h_set); - if(_LV_FLEX_GET_GROW(main_size) || LV_COORD_GET_FLEX(main_set) == LV_FLEX_PLACE_STRETCH) { - lv_area_t old_coords; - lv_area_copy(&old_coords, &item->coords); - - if(_LV_FLEX_GET_GROW(main_size)) { - lv_coord_t s = _LV_FLEX_GET_GROW(main_size) * t->grow_unit; - s -= get_margin_start(item, LV_OBJ_PART_MAIN) + get_margin_end(item, LV_OBJ_PART_MAIN); - area_set_main_size(&item->coords, s); - } - if(LV_COORD_GET_FLEX(main_set) == LV_FLEX_PLACE_STRETCH) { - area_set_cross_size(&item->coords, t->track_cross_size); - } - - if(lv_area_get_height(&old_coords) != area_get_main_size(&item->coords)) { - lv_obj_invalidate(item); - lv_signal_send(item, LV_SIGNAL_COORD_CHG, &old_coords); - lv_obj_invalidate(item); - } - } - - lv_coord_t cross_pos = 0; - lv_coord_t cross_set = (row ? item->y_set : item->x_set); - switch(LV_COORD_GET_FLEX(cross_set)) { - case LV_FLEX_PLACE_CENTER: - cross_pos = (t->track_cross_size - obj_get_cross_size(item)) / 2; - break; - case LV_FLEX_PLACE_END: - cross_pos = t->track_cross_size - obj_get_cross_size(item); - break; - } - - if(row && rtl) { - main_pos -= obj_get_main_size(item) + gap + place_gap; - } - - lv_coord_t diff_x = abs_x - item->coords.x1 + lv_obj_get_style_margin_left(item, LV_OBJ_PART_MAIN); - lv_coord_t diff_y = abs_y - item->coords.y1 + lv_obj_get_style_margin_top(item, LV_OBJ_PART_MAIN); - diff_x += row ? main_pos : cross_pos; - diff_y += row ? cross_pos : main_pos; - - if(diff_x || diff_y) { - item->coords.x1 += diff_x; - item->coords.x2 += diff_x; - item->coords.y1 += diff_y; - item->coords.y2 += diff_y; - _lv_obj_move_children_by(item, diff_x, diff_y); - } - - if(!(row && rtl)) { - main_pos += obj_get_main_size(item) + gap + place_gap; - } - item = get_next_item(cont, rev, &item_first_id); - } + return; +// bool rev = get_rev(cont); +// lv_coord_t gap = lv_obj_get_flex_gap(cont); +// bool row = get_dir(cont) == LV_FLEX_DIR_ROW ? true : false; +// +// lv_coord_t(*obj_get_main_size)(const lv_obj_t *) = (row ? lv_obj_get_width_margin : lv_obj_get_height_margin); +// lv_coord_t(*obj_get_cross_size)(const lv_obj_t *) = (!row ? lv_obj_get_width_margin : lv_obj_get_height_margin); +// void (*area_set_main_size)(lv_area_t *, lv_coord_t) = (row ? lv_area_set_width : lv_area_set_height); +// void (*area_set_cross_size)(lv_area_t *, lv_coord_t) = (!row ? lv_area_set_width : lv_area_set_height); +// lv_coord_t (*area_get_main_size)(const lv_area_t *) = (!row ? lv_area_get_width : lv_area_get_height); +// lv_coord_t (*get_margin_start)(const lv_obj_t *, uint8_t part) = (row ? lv_obj_get_style_margin_left : lv_obj_get_style_margin_top); +// lv_coord_t (*get_margin_end)(const lv_obj_t *, uint8_t part) = (row ? lv_obj_get_style_margin_right : lv_obj_get_style_margin_bottom); +// +// bool rtl = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false; +// +// if(row && rtl) abs_x += lv_obj_get_width_fit(cont); +// +// lv_coord_t main_pos = 0; +// +// lv_coord_t place_gap = 0; +// place_content(main_place, max_main_size, t->track_main_size, t->item_cnt, &main_pos, &place_gap); +// +// lv_obj_t * item = get_next_item(cont, rev, &item_first_id); +// /*Reposition the children*/ +// while(item && item_first_id != item_last_id) { +// /*Ignore non-flex items*/ +// lv_coord_t main_set = (row ? item->x_set : item->y_set); +// if(LV_COORD_IS_FLEX(main_set) == false) { +// item = get_next_item(cont, rev, &item_first_id); +// continue; +// } +// +// lv_coord_t main_size = (row ? item->w_set : item->h_set); +// if(_LV_FLEX_GET_GROW(main_size) || LV_COORD_GET_FLEX(main_set) == LV_FLEX_PLACE_STRETCH) { +// lv_area_t old_coords; +// lv_area_copy(&old_coords, &item->coords); +// +// if(_LV_FLEX_GET_GROW(main_size)) { +// lv_coord_t s = _LV_FLEX_GET_GROW(main_size) * t->grow_unit; +// s -= get_margin_start(item, LV_OBJ_PART_MAIN) + get_margin_end(item, LV_OBJ_PART_MAIN); +// area_set_main_size(&item->coords, s); +// } +// if(LV_COORD_GET_FLEX(main_set) == LV_FLEX_PLACE_STRETCH) { +// area_set_cross_size(&item->coords, t->track_cross_size); +// } +// +// if(lv_area_get_height(&old_coords) != area_get_main_size(&item->coords)) { +// lv_obj_invalidate(item); +// lv_signal_send(item, LV_SIGNAL_COORD_CHG, &old_coords); +// lv_obj_invalidate(item); +// } +// } +// +// lv_coord_t cross_pos = 0; +// lv_coord_t cross_set = (row ? item->y_set : item->x_set); +// switch(LV_COORD_GET_FLEX(cross_set)) { +// case LV_FLEX_PLACE_CENTER: +// cross_pos = (t->track_cross_size - obj_get_cross_size(item)) / 2; +// break; +// case LV_FLEX_PLACE_END: +// cross_pos = t->track_cross_size - obj_get_cross_size(item); +// break; +// } +// +// if(row && rtl) { +// main_pos -= obj_get_main_size(item) + gap + place_gap; +// } +// +// lv_coord_t diff_x = abs_x - item->coords.x1 + lv_obj_get_style_margin_left(item, LV_OBJ_PART_MAIN); +// lv_coord_t diff_y = abs_y - item->coords.y1 + lv_obj_get_style_margin_top(item, LV_OBJ_PART_MAIN); +// diff_x += row ? main_pos : cross_pos; +// diff_y += row ? cross_pos : main_pos; +// +// if(diff_x || diff_y) { +// item->coords.x1 += diff_x; +// item->coords.x2 += diff_x; +// item->coords.y1 += diff_y; +// item->coords.y2 += diff_y; +// _lv_obj_move_children_by(item, diff_x, diff_y); +// } +// +// if(!(row && rtl)) { +// main_pos += obj_get_main_size(item) + gap + place_gap; +// } +// item = get_next_item(cont, rev, &item_first_id); +// } } static void place_content(lv_coord_t place, lv_coord_t max_size, lv_coord_t track_size, lv_coord_t item_cnt, lv_coord_t * start_pos, lv_coord_t * gap) diff --git a/src/lv_core/lv_grid.c b/src/lv_core/lv_grid.c index 18d381257..7de278ff2 100644 --- a/src/lv_core/lv_grid.c +++ b/src/lv_core/lv_grid.c @@ -222,8 +222,8 @@ void _lv_grid_full_refresh(lv_obj_t * cont) /* Calculate the grids absolute x and y coordinates. * It will be used as helper during item repositioning to avoid calculating this value for every children*/ - lv_coord_t pad_left = lv_obj_get_style_pad_left(cont, LV_OBJ_PART_MAIN); - lv_coord_t pad_top = lv_obj_get_style_pad_top(cont, LV_OBJ_PART_MAIN); + lv_coord_t pad_left = lv_obj_get_style_pad_left(cont, LV_PART_MAIN); + lv_coord_t pad_top = lv_obj_get_style_pad_top(cont, LV_PART_MAIN); hint.grid_abs.x = pad_left + cont->coords.x1 - lv_obj_get_scroll_x(cont); hint.grid_abs.y = pad_top + cont->coords.y1 - lv_obj_get_scroll_y(cont); @@ -351,93 +351,93 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * calc) */ static void item_repos(lv_obj_t * item, _lv_grid_calc_t * calc, item_repos_hint_t * hint) { - if(_lv_obj_is_grid_item(item) == false) return; - - uint32_t col_pos = LV_GRID_GET_CELL_POS(item->x_set); - uint32_t col_span = LV_GRID_GET_CELL_SPAN(item->x_set); - uint32_t row_pos = LV_GRID_GET_CELL_POS(item->y_set); - uint32_t row_span = LV_GRID_GET_CELL_SPAN(item->y_set); - - lv_coord_t col_x1 = calc->x[col_pos]; - lv_coord_t col_x2 = calc->x[col_pos + col_span - 1] + calc->w[col_pos + col_span - 1]; - lv_coord_t col_w = col_x2 - col_x1; - - lv_coord_t row_y1 = calc->y[row_pos]; - lv_coord_t row_y2 = calc->y[row_pos + row_span - 1] + calc->h[row_pos + row_span - 1]; - lv_coord_t row_h = row_y2 - row_y1; - - uint8_t x_flag = LV_GRID_GET_CELL_PLACE(item->x_set); - uint8_t y_flag = LV_GRID_GET_CELL_PLACE(item->y_set); - - /*If the item has RTL base dir switch start and end*/ - if(lv_obj_get_base_dir(item) == LV_BIDI_DIR_RTL) { - if(x_flag == LV_GRID_START) x_flag = LV_GRID_END; - else if(x_flag == LV_GRID_END) x_flag = LV_GRID_START; - } - - lv_coord_t x; - lv_coord_t y; - lv_coord_t item_w = lv_obj_get_width(item); - lv_coord_t item_h = lv_obj_get_height(item); - - lv_coord_t margin_top = lv_obj_get_style_margin_top(item, LV_OBJ_PART_MAIN); - lv_coord_t margin_bottom = lv_obj_get_style_margin_bottom(item, LV_OBJ_PART_MAIN); - lv_coord_t margin_left = lv_obj_get_style_margin_left(item, LV_OBJ_PART_MAIN); - lv_coord_t margin_right = lv_obj_get_style_margin_right(item, LV_OBJ_PART_MAIN); - - switch(x_flag) { - default: - case LV_GRID_START: - x = calc->x[col_pos] + margin_left; - break; - case LV_GRID_STRETCH: - x = calc->x[col_pos] + margin_left; - item_w = col_w - margin_left - margin_right; - item->w_set = LV_SIZE_STRETCH; - break; - case LV_GRID_CENTER: - x = calc->x[col_pos] + (col_w - (item_w + margin_left - margin_right)) / 2; - break; - case LV_GRID_END: - x = calc->x[col_pos] + col_w - lv_obj_get_width(item) - margin_right; - break; - } - - switch(y_flag) { - default: - case LV_GRID_START: - y = calc->y[row_pos] + margin_top; - break; - case LV_GRID_STRETCH: - y = calc->y[row_pos] + margin_top; - item_h = row_h - margin_top - margin_bottom; - item->h_set = LV_SIZE_STRETCH; - break; - case LV_GRID_CENTER: - y = calc->y[row_pos] + (row_h - (item_h + margin_top + margin_bottom)) / 2; - break; - case LV_GRID_END: - y = calc->y[row_pos] + row_h - lv_obj_get_height(item) - margin_bottom; - break; - } - - /*Set a new size if required*/ - if(lv_obj_get_width(item) != item_w || lv_obj_get_height(item) != item_h) { - lv_area_t old_coords; - lv_area_copy(&old_coords, &item->coords); - lv_obj_invalidate(item); - lv_area_set_width(&item->coords, item_w); - lv_area_set_height(&item->coords, item_h); - lv_obj_invalidate(item); - lv_signal_send(item, LV_SIGNAL_COORD_CHG, &old_coords); - - } - bool moved = true; - if(hint) { - if(hint->grid_abs.x + x == item->coords.x1 && hint->grid_abs.y + y == item->coords.y1) moved = false; - } - - if(moved) _lv_obj_move_to(item, x, y, false); +// if(_lv_obj_is_grid_item(item) == false) return; +// +// uint32_t col_pos = LV_GRID_GET_CELL_POS(item->x_set); +// uint32_t col_span = LV_GRID_GET_CELL_SPAN(item->x_set); +// uint32_t row_pos = LV_GRID_GET_CELL_POS(item->y_set); +// uint32_t row_span = LV_GRID_GET_CELL_SPAN(item->y_set); +// +// lv_coord_t col_x1 = calc->x[col_pos]; +// lv_coord_t col_x2 = calc->x[col_pos + col_span - 1] + calc->w[col_pos + col_span - 1]; +// lv_coord_t col_w = col_x2 - col_x1; +// +// lv_coord_t row_y1 = calc->y[row_pos]; +// lv_coord_t row_y2 = calc->y[row_pos + row_span - 1] + calc->h[row_pos + row_span - 1]; +// lv_coord_t row_h = row_y2 - row_y1; +// +// uint8_t x_flag = LV_GRID_GET_CELL_PLACE(item->x_set); +// uint8_t y_flag = LV_GRID_GET_CELL_PLACE(item->y_set); +// +// /*If the item has RTL base dir switch start and end*/ +// if(lv_obj_get_base_dir(item) == LV_BIDI_DIR_RTL) { +// if(x_flag == LV_GRID_START) x_flag = LV_GRID_END; +// else if(x_flag == LV_GRID_END) x_flag = LV_GRID_START; +// } +// +// lv_coord_t x; +// lv_coord_t y; +// lv_coord_t item_w = lv_obj_get_width(item); +// lv_coord_t item_h = lv_obj_get_height(item); +// +// lv_coord_t margin_top = lv_obj_get_style_margin_top(item, LV_OBJ_PART_MAIN); +// lv_coord_t margin_bottom = lv_obj_get_style_margin_bottom(item, LV_OBJ_PART_MAIN); +// lv_coord_t margin_left = lv_obj_get_style_margin_left(item, LV_OBJ_PART_MAIN); +// lv_coord_t margin_right = lv_obj_get_style_margin_right(item, LV_OBJ_PART_MAIN); +// +// switch(x_flag) { +// default: +// case LV_GRID_START: +// x = calc->x[col_pos] + margin_left; +// break; +// case LV_GRID_STRETCH: +// x = calc->x[col_pos] + margin_left; +// item_w = col_w - margin_left - margin_right; +// item->w_set = LV_SIZE_STRETCH; +// break; +// case LV_GRID_CENTER: +// x = calc->x[col_pos] + (col_w - (item_w + margin_left - margin_right)) / 2; +// break; +// case LV_GRID_END: +// x = calc->x[col_pos] + col_w - lv_obj_get_width(item) - margin_right; +// break; +// } +// +// switch(y_flag) { +// default: +// case LV_GRID_START: +// y = calc->y[row_pos] + margin_top; +// break; +// case LV_GRID_STRETCH: +// y = calc->y[row_pos] + margin_top; +// item_h = row_h - margin_top - margin_bottom; +// item->h_set = LV_SIZE_STRETCH; +// break; +// case LV_GRID_CENTER: +// y = calc->y[row_pos] + (row_h - (item_h + margin_top + margin_bottom)) / 2; +// break; +// case LV_GRID_END: +// y = calc->y[row_pos] + row_h - lv_obj_get_height(item) - margin_bottom; +// break; +// } +// +// /*Set a new size if required*/ +// if(lv_obj_get_width(item) != item_w || lv_obj_get_height(item) != item_h) { +// lv_area_t old_coords; +// lv_area_copy(&old_coords, &item->coords); +// lv_obj_invalidate(item); +// lv_area_set_width(&item->coords, item_w); +// lv_area_set_height(&item->coords, item_h); +// lv_obj_invalidate(item); +// lv_signal_send(item, LV_SIGNAL_COORD_CHG, &old_coords); +// +// } +// bool moved = true; +// if(hint) { +// if(hint->grid_abs.x + x == item->coords.x1 && hint->grid_abs.y + y == item->coords.y1) moved = false; +// } +// +// if(moved) _lv_obj_move_to(item, x, y, false); } /** diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 230449058..97ef88776 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -202,7 +202,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) else lv_theme_apply(obj, LV_THEME_SCR); } else { - lv_style_list_copy(&obj->style_list, ©->style_list); +// lv_style_list_copy(&obj->style_list, ©->style_list); } return obj; } @@ -627,14 +627,10 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) uint8_t part; for(part = 0; part < _LV_OBJ_PART_MAX; part++) { - lv_style_list_t * style_list = _lv_obj_get_style_list(obj, part); - if(style_list == NULL) break; /*No more style lists*/ - if(style_list->ignore_trans) continue; - - lv_style_int_t time = lv_obj_get_style_transition_time(obj, part); - lv_style_property_t props[LV_STYLE_TRANS_NUM_MAX]; - lv_style_int_t delay = lv_obj_get_style_transition_delay(obj, part); - lv_anim_path_t * path = lv_obj_get_style_transition_path(obj, part); + uint16_t time = lv_obj_get_style_transition_time(obj, part); + lv_style_prop_t props[LV_STYLE_TRANS_NUM_MAX]; + uint16_t delay = lv_obj_get_style_transition_delay(obj, part); + const lv_anim_path_t * path = lv_obj_get_style_transition_path(obj, part); props[0] = lv_obj_get_style_transition_prop_1(obj, part); props[1] = lv_obj_get_style_transition_prop_2(obj, part); props[2] = lv_obj_get_style_transition_prop_3(obj, part); @@ -644,26 +640,14 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) uint8_t i; for(i = 0; i < LV_STYLE_TRANS_NUM_MAX; i++) { - if(props[i] != 0) { - _lv_style_list_add_trans_style(style_list); - + if(props[i] != _LV_STYLE_PROP_INV) { _lv_obj_create_style_transition(obj, props[i], part, prev_state, new_state, time, delay, path); - } } - if(cmp_res == _LV_STYLE_STATE_CMP_VISUAL_DIFF) { -#if LV_STYLE_CACHE_LEVEL > 0 - _lv_obj_invalidate_style_cache(obj, part, LV_STYLE_PROP_ALL); -#endif - } - } - if(cmp_res == _LV_STYLE_STATE_CMP_DIFF) _lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); + if(cmp_res == _LV_STYLE_STATE_CMP_DIFF) _lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); else if(cmp_res == _LV_STYLE_STATE_CMP_VISUAL_DIFF) lv_obj_invalidate(obj); - #endif - - } @@ -1434,8 +1418,6 @@ static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t if(parent) obj->flags |= LV_OBJ_FLAG_GESTURE_BUBBLE; obj->state = LV_STATE_DEFAULT; - lv_style_list_init(&obj->style_list); - /*Copy the attributes if required*/ if(copy != NULL) { lv_area_copy(&obj->coords, ©->coords); @@ -1479,7 +1461,7 @@ static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t static void lv_obj_destructor(void * p) { lv_obj_t * obj = p; - _lv_obj_reset_style_list_no_refr(obj, LV_OBJ_PART_MAIN); + lv_obj_remove_all_styles(obj); if(obj->spec_attr) lv_mem_free(obj->spec_attr); lv_class_destroy(obj); @@ -1497,12 +1479,12 @@ static void lv_obj_destructor(void * p) static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area, lv_design_mode_t mode) { if(mode == LV_DESIGN_COVER_CHK) { - if(lv_obj_get_style_clip_corner(obj, LV_OBJ_PART_MAIN)) return LV_DESIGN_RES_MASKED; + if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) return LV_DESIGN_RES_MASKED; /*Most trivial test. Is the mask fully IN the object? If no it surely doesn't cover it*/ - lv_coord_t r = lv_obj_get_style_radius(obj, LV_OBJ_PART_MAIN); - lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_OBJ_PART_MAIN); - lv_coord_t h = lv_obj_get_style_transform_height(obj, LV_OBJ_PART_MAIN); + lv_coord_t r = lv_obj_get_style_radius(obj, LV_PART_MAIN); + lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN); + lv_coord_t h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN); lv_area_t coords; lv_area_copy(&coords, &obj->coords); coords.x1 -= w; @@ -1512,11 +1494,11 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area if(_lv_area_is_in(clip_area, &coords, r) == false) return LV_DESIGN_RES_NOT_COVER; - if(lv_obj_get_style_bg_opa(obj, LV_OBJ_PART_MAIN) < LV_OPA_MAX) return LV_DESIGN_RES_NOT_COVER; + if(lv_obj_get_style_bg_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DESIGN_RES_NOT_COVER; - if(lv_obj_get_style_bg_blend_mode(obj, LV_OBJ_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER; - if(lv_obj_get_style_border_blend_mode(obj, LV_OBJ_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER; - if(lv_obj_get_style_opa_scale(obj, LV_OBJ_PART_MAIN) < LV_OPA_MAX) return LV_DESIGN_RES_NOT_COVER; + if(lv_obj_get_style_bg_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER; + if(lv_obj_get_style_border_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER; + if(lv_obj_get_style_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DESIGN_RES_NOT_COVER; return LV_DESIGN_RES_COVER; @@ -1525,14 +1507,14 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area lv_draw_rect_dsc_t draw_dsc; lv_draw_rect_dsc_init(&draw_dsc); /*If the border is drawn later disable loading its properties*/ - if(lv_obj_get_style_border_post(obj, LV_OBJ_PART_MAIN)) { + if(lv_obj_get_style_border_post(obj, LV_PART_MAIN)) { draw_dsc.border_post = 1; } - lv_obj_init_draw_rect_dsc(obj, LV_OBJ_PART_MAIN, &draw_dsc); + lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc); - lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_OBJ_PART_MAIN); - lv_coord_t h = lv_obj_get_style_transform_height(obj, LV_OBJ_PART_MAIN); + lv_coord_t w = 0;//lv_obj_get_style_transform_width(obj, LV_OBJ_PART_MAIN); + lv_coord_t h = 0;//lv_obj_get_style_transform_height(obj, LV_OBJ_PART_MAIN); lv_area_t coords; lv_area_copy(&coords, &obj->coords); coords.x1 -= w; @@ -1542,10 +1524,10 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area lv_draw_rect(&coords, clip_area, &draw_dsc); - if(lv_obj_get_style_clip_corner(obj, LV_OBJ_PART_MAIN)) { + if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) { lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); - lv_coord_t r = lv_obj_get_style_radius(obj, LV_OBJ_PART_MAIN); + lv_coord_t r = lv_obj_get_style_radius(obj, LV_PART_MAIN); lv_draw_mask_radius_init(mp, &obj->coords, r, false); /*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/ @@ -1555,23 +1537,23 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area else if(mode == LV_DESIGN_DRAW_POST) { _lv_obj_draw_scrollbar(obj, clip_area); - if(lv_obj_get_style_clip_corner(obj, LV_OBJ_PART_MAIN)) { + if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) { lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(obj + 8); _lv_mem_buf_release(param); } /*If the border is drawn later disable loading other properties*/ - if(lv_obj_get_style_border_post(obj, LV_OBJ_PART_MAIN)) { + if(lv_obj_get_style_border_post(obj, LV_PART_MAIN)) { lv_draw_rect_dsc_t draw_dsc; lv_draw_rect_dsc_init(&draw_dsc); draw_dsc.bg_opa = LV_OPA_TRANSP; - draw_dsc.pattern_opa = LV_OPA_TRANSP; +// draw_dsc.pattern_opa = LV_OPA_TRANSP; draw_dsc.shadow_opa = LV_OPA_TRANSP; draw_dsc.value_opa = LV_OPA_TRANSP; - lv_obj_init_draw_rect_dsc(obj, LV_OBJ_PART_MAIN, &draw_dsc); + lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc); - lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_OBJ_PART_MAIN); - lv_coord_t h = lv_obj_get_style_transform_height(obj, LV_OBJ_PART_MAIN); + lv_coord_t w = 0;//lv_obj_get_style_transform_width(obj, LV_OBJ_PART_MAIN); + lv_coord_t h = 0;//lv_obj_get_style_transform_height(obj, LV_OBJ_PART_MAIN); lv_area_t coords; lv_area_copy(&coords, &obj->coords); coords.x1 -= w; @@ -1651,13 +1633,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) { lv_res_t res = LV_RES_OK; - if(sign == LV_SIGNAL_GET_STYLE) { - lv_get_style_info_t * info = param; - if(info->part == LV_OBJ_PART_MAIN) info->result = &obj->style_list; - else info->result = NULL; - return LV_RES_OK; - } - else if(sign == LV_SIGNAL_PRESSED) { + if(sign == LV_SIGNAL_PRESSED) { lv_obj_add_state(obj, LV_STATE_PRESSED); } else if(sign == LV_SIGNAL_RELEASED) { @@ -1779,7 +1755,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) } else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { lv_coord_t * s = param; - lv_coord_t d = _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_PART_MAIN); *s = LV_MATH_MAX(*s, d); } else if(sign == LV_SIGNAL_STYLE_CHG) { diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index c70bc13ac..5804bcddd 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -45,7 +45,7 @@ extern "C" { #endif #define LV_MAX_ANCESTOR_NUM 8 -#define _LV_OBJ_PART_MAX 128 +#define _LV_OBJ_PART_MAX 32 #define LV_EXT_CLICK_AREA_OFF 0 #define LV_EXT_CLICK_AREA_TINY 1 @@ -126,7 +126,6 @@ enum { LV_SIGNAL_STYLE_CHG, /**< Object's style has changed */ LV_SIGNAL_BASE_DIR_CHG, /**< The base dir has changed*/ LV_SIGNAL_REFR_EXT_DRAW_PAD, /**< Object's extra padding has changed */ - LV_SIGNAL_GET_STYLE, /**< Get the style of an object*/ LV_SIGNAL_GET_SELF_SIZE, /**< Get the internal size of a widget*/ /*Input device related*/ @@ -230,7 +229,7 @@ LV_CLASS_DECLARE_START(lv_obj, lv_base) _lv_base_data \ struct _lv_obj_t * parent; \ lv_obj_spec_attr_t * spec_attr; \ - lv_style_list_t style_list; \ + lv_obj_style_list_t style_list; \ lv_area_t coords; \ lv_coord_t x_set; \ lv_coord_t y_set; \ @@ -248,12 +247,15 @@ LV_CLASS_DECLARE_END(lv_obj, lv_base) extern lv_obj_class_t lv_obj; enum { - LV_OBJ_PART_MAIN, - LV_OBJ_PART_ALL = 0xFF, + LV_PART_MAIN, + LV_PART_SCROLLBAR, + LV_PART_CONTENT, + LV_PART_INDICATOR, + LV_PART_KNOB, + LV_PART_PLACEHOLDER, + LV_PART_HIGHLIGHT, }; -typedef uint8_t lv_obj_part_t; - /** Used by `lv_obj_get_type()`. The object's and its ancestor types are stored here*/ typedef struct { const char * type[LV_MAX_ANCESTOR_NUM]; /**< [0]: the actual type, [1]: ancestor, [2] #1's ancestor @@ -265,11 +267,6 @@ typedef struct { bool result; } lv_hit_test_info_t; -typedef struct { - uint8_t part; - lv_style_list_t * result; -} lv_get_style_info_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/src/lv_core/lv_obj_draw.c b/src/lv_core/lv_obj_draw.c index 40fd6dd90..3aa40731c 100644 --- a/src/lv_core/lv_obj_draw.c +++ b/src/lv_core/lv_obj_draw.c @@ -54,12 +54,12 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t draw_dsc->radius = lv_obj_get_style_radius(obj, part); #if LV_USE_OPA_SCALE - lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part); - if(opa_scale <= LV_OPA_MIN) { + lv_opa_t opa = lv_obj_get_style_opa(obj, part); + if(opa <= LV_OPA_MIN) { draw_dsc->bg_opa = LV_OPA_TRANSP; draw_dsc->border_opa = LV_OPA_TRANSP; draw_dsc->shadow_opa = LV_OPA_TRANSP; - draw_dsc->pattern_opa = LV_OPA_TRANSP; + draw_dsc->bg_img_opa = LV_OPA_TRANSP; draw_dsc->value_opa = LV_OPA_TRANSP; return; } @@ -113,26 +113,26 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t #endif #if LV_USE_PATTERN - draw_dsc->pattern_image = lv_obj_get_style_pattern_image(obj, part); - if(draw_dsc->pattern_image) { - if(draw_dsc->pattern_opa != LV_OPA_TRANSP) { - draw_dsc->pattern_opa = lv_obj_get_style_pattern_opa(obj, part); - if(draw_dsc->pattern_opa > LV_OPA_MIN) { - draw_dsc->pattern_recolor_opa = lv_obj_get_style_pattern_recolor_opa(obj, part); - draw_dsc->pattern_repeat = lv_obj_get_style_pattern_repeat(obj, part); - if(lv_img_src_get_type(draw_dsc->pattern_image) == LV_IMG_SRC_SYMBOL) { - draw_dsc->pattern_recolor = lv_obj_get_style_pattern_recolor(obj, part); - draw_dsc->pattern_font = lv_obj_get_style_text_font(obj, part); - } - else if(draw_dsc->pattern_recolor_opa > LV_OPA_MIN) { - draw_dsc->pattern_recolor = lv_obj_get_style_pattern_recolor(obj, part); - } -#if LV_USE_BLEND_MODES - draw_dsc->pattern_blend_mode = lv_obj_get_style_pattern_blend_mode(obj, part); -#endif - } - } - } +// if(draw_dsc->bg_img_opa != LV_OPA_TRANSP) { +// draw_dsc->bg_img_src = lv_obj_get_style_pattern_image(obj, part); +// if(draw_dsc->bg_img_src) { +// draw_dsc->bg_img_opa = lv_obj_get_style_pattern_opa(obj, part); +// if(draw_dsc->bg_img_opa > LV_OPA_MIN) { +//// draw_dsc->pattern_recolor_opa = lv_obj_get_style_pattern_recolor_opa(obj, part); +//// draw_dsc->bg_img_mosaic = lv_obj_get_style_pattern_repeat(obj, part); +// if(lv_img_src_get_type(draw_dsc->bg_img_src) == LV_IMG_SRC_SYMBOL) { +//// draw_dsc->pattern_recolor = lv_obj_get_style_pattern_recolor(obj, part); +// draw_dsc->pattern_font = lv_obj_get_style_text_font(obj, part); +// } +// else if(draw_dsc->pattern_recolor_opa > LV_OPA_MIN) { +// draw_dsc->pattern_recolor = lv_obj_get_style_pattern_recolor(obj, part); +// } +//#if LV_USE_BLEND_MODES +// draw_dsc->pattern_blend_mode = lv_obj_get_style_pattern_blend_mode(obj, part); +//#endif +// } +// } +// } #endif #if LV_USE_SHADOW @@ -153,34 +153,12 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } #endif -#if LV_USE_VALUE_STR - draw_dsc->value_str = lv_obj_get_style_value_str(obj, part); - if(draw_dsc->value_str) { - if(draw_dsc->value_opa > LV_OPA_MIN) { - draw_dsc->value_opa = lv_obj_get_style_value_opa(obj, part); - if(draw_dsc->value_opa > LV_OPA_MIN) { - draw_dsc->value_ofs_x = lv_obj_get_style_value_ofs_x(obj, part); - draw_dsc->value_ofs_y = lv_obj_get_style_value_ofs_y(obj, part); - draw_dsc->value_color = lv_obj_get_style_value_color(obj, part); - draw_dsc->value_font = lv_obj_get_style_value_font(obj, part); - draw_dsc->value_letter_space = lv_obj_get_style_value_letter_space(obj, part); - draw_dsc->value_line_space = lv_obj_get_style_value_line_space(obj, part); - draw_dsc->value_align = lv_obj_get_style_value_align(obj, part); -#if LV_USE_BLEND_MODES - draw_dsc->value_blend_mode = lv_obj_get_style_value_blend_mode(obj, part); -#endif - } - } - } -#endif - #if LV_USE_OPA_SCALE - if(opa_scale < LV_OPA_MAX) { - draw_dsc->bg_opa = (uint16_t)((uint16_t)draw_dsc->bg_opa * opa_scale) >> 8; - draw_dsc->border_opa = (uint16_t)((uint16_t)draw_dsc->border_opa * opa_scale) >> 8; - draw_dsc->shadow_opa = (uint16_t)((uint16_t)draw_dsc->shadow_opa * opa_scale) >> 8; - draw_dsc->pattern_opa = (uint16_t)((uint16_t)draw_dsc->pattern_opa * opa_scale) >> 8; - draw_dsc->value_opa = (uint16_t)((uint16_t)draw_dsc->value_opa * opa_scale) >> 8; + if(opa < LV_OPA_MAX) { + draw_dsc->bg_opa = (uint16_t)((uint16_t)draw_dsc->bg_opa * opa) >> 8; + draw_dsc->border_opa = (uint16_t)((uint16_t)draw_dsc->border_opa * opa) >> 8; + draw_dsc->shadow_opa = (uint16_t)((uint16_t)draw_dsc->shadow_opa * opa) >> 8; + draw_dsc->value_opa = (uint16_t)((uint16_t)draw_dsc->value_opa * opa) >> 8; } #endif } @@ -195,34 +173,34 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t */ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_t * draw_dsc) { - draw_dsc->opa = lv_obj_get_style_text_opa(obj, part); - if(draw_dsc->opa <= LV_OPA_MIN) return; - -#if LV_USE_OPA_SCALE - lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part); - if(opa_scale < LV_OPA_MAX) { - draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8; - } - if(draw_dsc->opa <= LV_OPA_MIN) return; -#endif - - draw_dsc->color = lv_obj_get_style_text_color(obj, part); - draw_dsc->letter_space = lv_obj_get_style_text_letter_space(obj, part); - draw_dsc->line_space = lv_obj_get_style_text_line_space(obj, part); - draw_dsc->decor = lv_obj_get_style_text_decor(obj, part); -#if LV_USE_BLEND_MODES - draw_dsc->blend_mode = lv_obj_get_style_text_blend_mode(obj, part); -#endif - - draw_dsc->font = lv_obj_get_style_text_font(obj, part); - - if(draw_dsc->sel_start != LV_DRAW_LABEL_NO_TXT_SEL && draw_dsc->sel_end != LV_DRAW_LABEL_NO_TXT_SEL) { - draw_dsc->color = lv_obj_get_style_text_sel_color(obj, part); - } - -#if LV_USE_BIDI - draw_dsc->bidi_dir = lv_obj_get_base_dir(obj); -#endif +// draw_dsc->opa = lv_obj_get_style_text_opa(obj, part); +// if(draw_dsc->opa <= LV_OPA_MIN) return; +// +//#if LV_USE_OPA_SCALE +// lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part); +// if(opa_scale < LV_OPA_MAX) { +// draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8; +// } +// if(draw_dsc->opa <= LV_OPA_MIN) return; +//#endif +// +// draw_dsc->color = lv_obj_get_style_text_color(obj, part); +// draw_dsc->letter_space = lv_obj_get_style_text_letter_space(obj, part); +// draw_dsc->line_space = lv_obj_get_style_text_line_space(obj, part); +// draw_dsc->decor = lv_obj_get_style_text_decor(obj, part); +//#if LV_USE_BLEND_MODES +// draw_dsc->blend_mode = lv_obj_get_style_text_blend_mode(obj, part); +//#endif +// +// draw_dsc->font = lv_obj_get_style_text_font(obj, part); +// +// if(draw_dsc->sel_start != LV_DRAW_LABEL_NO_TXT_SEL && draw_dsc->sel_end != LV_DRAW_LABEL_NO_TXT_SEL) { +// draw_dsc->color = lv_obj_get_style_text_sel_color(obj, part); +// } +// +//#if LV_USE_BIDI +// draw_dsc->bidi_dir = lv_obj_get_base_dir(obj); +//#endif } /** @@ -235,29 +213,29 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_ */ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t * draw_dsc) { - draw_dsc->opa = lv_obj_get_style_image_opa(obj, part); - if(draw_dsc->opa <= LV_OPA_MIN) return; - -#if LV_USE_OPA_SCALE - lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part); - if(opa_scale < LV_OPA_MAX) { - draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8; - } - if(draw_dsc->opa <= LV_OPA_MIN) return; -#endif - - draw_dsc->angle = 0; - draw_dsc->zoom = LV_IMG_ZOOM_NONE; - draw_dsc->pivot.x = lv_area_get_width(&obj->coords) / 2; - draw_dsc->pivot.y = lv_area_get_height(&obj->coords) / 2; - - draw_dsc->recolor_opa = lv_obj_get_style_image_recolor_opa(obj, part); - if(draw_dsc->recolor_opa > 0) { - draw_dsc->recolor = lv_obj_get_style_image_recolor(obj, part); - } -#if LV_USE_BLEND_MODES - draw_dsc->blend_mode = lv_obj_get_style_image_blend_mode(obj, part); -#endif +// draw_dsc->opa = lv_obj_get_style_image_opa(obj, part); +// if(draw_dsc->opa <= LV_OPA_MIN) return; +// +//#if LV_USE_OPA_SCALE +// lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part); +// if(opa_scale < LV_OPA_MAX) { +// draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8; +// } +// if(draw_dsc->opa <= LV_OPA_MIN) return; +//#endif +// +// draw_dsc->angle = 0; +// draw_dsc->zoom = LV_IMG_ZOOM_NONE; +// draw_dsc->pivot.x = lv_area_get_width(&obj->coords) / 2; +// draw_dsc->pivot.y = lv_area_get_height(&obj->coords) / 2; +// +// draw_dsc->recolor_opa = lv_obj_get_style_image_recolor_opa(obj, part); +// if(draw_dsc->recolor_opa > 0) { +// draw_dsc->recolor = lv_obj_get_style_image_recolor(obj, part); +// } +//#if LV_USE_BLEND_MODES +// draw_dsc->blend_mode = lv_obj_get_style_image_blend_mode(obj, part); +//#endif } @@ -271,33 +249,33 @@ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t * */ void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t * draw_dsc) { - draw_dsc->width = lv_obj_get_style_line_width(obj, part); - if(draw_dsc->width == 0) return; - - draw_dsc->opa = lv_obj_get_style_line_opa(obj, part); - if(draw_dsc->opa <= LV_OPA_MIN) return; - -#if LV_USE_OPA_SCALE - lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part); - if(opa_scale < LV_OPA_MAX) { - draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8; - } - if(draw_dsc->opa <= LV_OPA_MIN) return; -#endif - - draw_dsc->color = lv_obj_get_style_line_color(obj, part); - - draw_dsc->dash_width = lv_obj_get_style_line_dash_width(obj, part); - if(draw_dsc->dash_width) { - draw_dsc->dash_gap = lv_obj_get_style_line_dash_gap(obj, part); - } - - draw_dsc->round_start = lv_obj_get_style_line_rounded(obj, part); - draw_dsc->round_end = draw_dsc->round_start; - -#if LV_USE_BLEND_MODES - draw_dsc->blend_mode = lv_obj_get_style_line_blend_mode(obj, part); -#endif +// draw_dsc->width = lv_obj_get_style_line_width(obj, part); +// if(draw_dsc->width == 0) return; +// +// draw_dsc->opa = lv_obj_get_style_line_opa(obj, part); +// if(draw_dsc->opa <= LV_OPA_MIN) return; +// +//#if LV_USE_OPA_SCALE +// lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part); +// if(opa_scale < LV_OPA_MAX) { +// draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8; +// } +// if(draw_dsc->opa <= LV_OPA_MIN) return; +//#endif +// +// draw_dsc->color = lv_obj_get_style_line_color(obj, part); +// +// draw_dsc->dash_width = lv_obj_get_style_line_dash_width(obj, part); +// if(draw_dsc->dash_width) { +// draw_dsc->dash_gap = lv_obj_get_style_line_dash_gap(obj, part); +// } +// +// draw_dsc->round_start = lv_obj_get_style_line_rounded(obj, part); +// draw_dsc->round_end = draw_dsc->round_start; +// +//#if LV_USE_BLEND_MODES +// draw_dsc->blend_mode = lv_obj_get_style_line_blend_mode(obj, part); +//#endif } /** @@ -310,68 +288,68 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) { lv_coord_t s = 0; - lv_coord_t sh_width = lv_obj_get_style_shadow_width(obj, part); - if(sh_width) { - lv_opa_t sh_opa = lv_obj_get_style_shadow_opa(obj, part); - if(sh_opa > LV_OPA_MIN) { - sh_width = sh_width / 2; /*THe blur adds only half width*/ - sh_width++; - sh_width += lv_obj_get_style_shadow_spread(obj, part); - lv_style_int_t sh_ofs_x = lv_obj_get_style_shadow_ofs_x(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); - } - } - - const char * value_str = lv_obj_get_style_value_str(obj, part); - if(value_str) { - lv_opa_t value_opa = lv_obj_get_style_value_opa(obj, part); - if(value_opa > LV_OPA_MIN) { - lv_style_int_t letter_space = lv_obj_get_style_value_letter_space(obj, part); - lv_style_int_t line_space = lv_obj_get_style_value_letter_space(obj, part); - const lv_font_t * font = lv_obj_get_style_value_font(obj, part); - - lv_point_t txt_size; - _lv_txt_get_size(&txt_size, value_str, font, letter_space, line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE); - - lv_area_t value_area; - value_area.x1 = 0; - value_area.y1 = 0; - value_area.x2 = txt_size.x - 1; - value_area.y2 = txt_size.y - 1; - - lv_style_int_t align = lv_obj_get_style_value_align(obj, part); - lv_style_int_t xofs = lv_obj_get_style_value_ofs_x(obj, part); - lv_style_int_t yofs = lv_obj_get_style_value_ofs_y(obj, part); - lv_point_t p_align; - _lv_area_align(&obj->coords, &value_area, align, &p_align); - - value_area.x1 += p_align.x + xofs; - value_area.y1 += p_align.y + yofs; - value_area.x2 += p_align.x + xofs; - value_area.y2 += p_align.y + yofs; - - s = LV_MATH_MAX(s, obj->coords.x1 - value_area.x1); - s = LV_MATH_MAX(s, obj->coords.y1 - value_area.y1); - s = LV_MATH_MAX(s, value_area.x2 - obj->coords.x2); - s = LV_MATH_MAX(s, value_area.y2 - obj->coords.y2); - } - } - - lv_style_int_t outline_width = lv_obj_get_style_outline_width(obj, part); - if(outline_width) { - lv_opa_t outline_opa = lv_obj_get_style_outline_opa(obj, part); - if(outline_opa > LV_OPA_MIN) { - lv_style_int_t outline_pad = lv_obj_get_style_outline_pad(obj, part); - s = LV_MATH_MAX(s, outline_pad + outline_width); - } - } - - lv_coord_t w = lv_obj_get_style_transform_width(obj, part); - lv_coord_t h = lv_obj_get_style_transform_height(obj, part); - lv_coord_t wh = LV_MATH_MAX(w, h); - if(wh > 0) s += wh; +// lv_coord_t sh_width = lv_obj_get_style_shadow_width(obj, part); +// if(sh_width) { +// lv_opa_t sh_opa = lv_obj_get_style_shadow_opa(obj, part); +// if(sh_opa > LV_OPA_MIN) { +// sh_width = sh_width / 2; /*THe blur adds only half width*/ +// sh_width++; +// sh_width += lv_obj_get_style_shadow_spread(obj, part); +// lv_style_int_t sh_ofs_x = lv_obj_get_style_shadow_ofs_x(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); +// } +// } +// +// const char * value_str = lv_obj_get_style_value_str(obj, part); +// if(value_str) { +// lv_opa_t value_opa = lv_obj_get_style_value_opa(obj, part); +// if(value_opa > LV_OPA_MIN) { +// lv_style_int_t letter_space = lv_obj_get_style_value_letter_space(obj, part); +// lv_style_int_t line_space = lv_obj_get_style_value_letter_space(obj, part); +// const lv_font_t * font = lv_obj_get_style_value_font(obj, part); +// +// lv_point_t txt_size; +// _lv_txt_get_size(&txt_size, value_str, font, letter_space, line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE); +// +// lv_area_t value_area; +// value_area.x1 = 0; +// value_area.y1 = 0; +// value_area.x2 = txt_size.x - 1; +// value_area.y2 = txt_size.y - 1; +// +// lv_style_int_t align = lv_obj_get_style_value_align(obj, part); +// lv_style_int_t xofs = lv_obj_get_style_value_ofs_x(obj, part); +// lv_style_int_t yofs = lv_obj_get_style_value_ofs_y(obj, part); +// lv_point_t p_align; +// _lv_area_align(&obj->coords, &value_area, align, &p_align); +// +// value_area.x1 += p_align.x + xofs; +// value_area.y1 += p_align.y + yofs; +// value_area.x2 += p_align.x + xofs; +// value_area.y2 += p_align.y + yofs; +// +// s = LV_MATH_MAX(s, obj->coords.x1 - value_area.x1); +// s = LV_MATH_MAX(s, obj->coords.y1 - value_area.y1); +// s = LV_MATH_MAX(s, value_area.x2 - obj->coords.x2); +// s = LV_MATH_MAX(s, value_area.y2 - obj->coords.y2); +// } +// } +// +// lv_style_int_t outline_width = lv_obj_get_style_outline_width(obj, part); +// if(outline_width) { +// lv_opa_t outline_opa = lv_obj_get_style_outline_opa(obj, part); +// if(outline_opa > LV_OPA_MIN) { +// lv_style_int_t outline_pad = lv_obj_get_style_outline_pad(obj, part); +// s = LV_MATH_MAX(s, outline_pad + outline_width); +// } +// } +// +// lv_coord_t w = lv_obj_get_style_transform_width(obj, part); +// lv_coord_t h = lv_obj_get_style_transform_height(obj, part); +// lv_coord_t wh = LV_MATH_MAX(w, h); +// if(wh > 0) s += wh; return s; } @@ -407,147 +385,147 @@ void _lv_obj_refresh_ext_draw_pad(lv_obj_t * obj) */ void _lv_obj_draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area) { - if(lv_obj_has_flag(obj, LV_OBJ_FLAG_SCROLLABLE) == false) return; - - lv_scroll_dir_t sm = lv_obj_get_scrollbar_mode(obj); - if(sm == LV_SCROLLBAR_MODE_OFF) { - return; - } - - /*If there is no indev scrolling this object but the moe is active return*/ - lv_indev_t * indev = lv_indev_get_next(NULL); - if(sm == LV_SCROLLBAR_MODE_ACTIVE) { - bool found = false; - while(indev) { - if(lv_indev_get_scroll_obj(indev) == obj) { - found = true; - break; - } - indev = lv_indev_get_next(indev); - } - if(!found) { - return; - } - } - - lv_coord_t st = lv_obj_get_scroll_top(obj); - lv_coord_t sb = lv_obj_get_scroll_bottom(obj); - lv_coord_t sl = lv_obj_get_scroll_left(obj); - lv_coord_t sr = lv_obj_get_scroll_right(obj); - - /*Return if too small content to scroll*/ - if(sm == LV_SCROLLBAR_MODE_AUTO && st <= 0 && sb <= 0 && sl <= 0 && sr <= 0) { - return; - } - - lv_coord_t end_space = lv_obj_get_style_scrollbar_space_end(obj, LV_OBJ_PART_MAIN); - lv_coord_t side_space = lv_obj_get_style_scrollbar_space_side(obj, LV_OBJ_PART_MAIN); - lv_coord_t tickness = lv_obj_get_style_scrollbar_tickness(obj, LV_OBJ_PART_MAIN); - - lv_coord_t obj_h = lv_obj_get_height(obj); - lv_coord_t obj_w = lv_obj_get_width(obj); - - lv_scroll_dir_t dir = lv_obj_get_scroll_dir(obj); - - bool ver_draw = false; - if((dir & LV_DIR_VER) && - ((sm == LV_SCROLLBAR_MODE_ON) || - (sm == LV_SCROLLBAR_MODE_AUTO && (st > 0 || sb > 0)) || - (sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_SCROLL_DIR_VER))) { - ver_draw = true; - } - - - bool hor_draw = false; - if((dir & LV_DIR_HOR) && - ((sm == LV_SCROLLBAR_MODE_ON) || - (sm == LV_SCROLLBAR_MODE_AUTO && (sl > 0 || sr > 0)) || - (sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_SCROLL_DIR_HOR))) { - hor_draw = true; - } - - - lv_coord_t ver_reg_space = ver_draw ? tickness + side_space : 0; - lv_coord_t hor_req_space = hor_draw ? tickness + side_space : 0; - lv_coord_t rem; - - lv_draw_rect_dsc_t draw_dsc; - lv_res_t sb_res = scrollbar_init_draw_dsc(obj, &draw_dsc); - if(sb_res != LV_RES_OK) return; - - lv_area_t area; - area.y1 = obj->coords.y1; - area.y2 = obj->coords.y2; - area.x2 = obj->coords.x2 - side_space; - area.x1 = area.x2 - tickness; - - /*Draw horizontal scrollbar if the mode is ON or can be scrolled in this direction*/ - if(ver_draw && _lv_area_is_on(&area, clip_area)) { - lv_coord_t content_h = obj_h + st + sb; - lv_coord_t sb_h = ((obj_h - end_space * 2 - hor_req_space) * obj_h) / content_h; - sb_h = LV_MATH_MAX(sb_h, SCROLLBAR_MIN_SIZE); - rem = (obj_h - end_space * 2 - hor_req_space) - sb_h; /*Remaining size from the scrollbar track that is not the scrollbar itself*/ - lv_coord_t scroll_h = content_h - obj_h; /*The size of the content which can be really scrolled*/ - if(scroll_h <= 0) { - area.y1 = obj->coords.y1 + end_space; - area.y2 = obj->coords.y2 - end_space - hor_req_space - 1; - area.x2 = obj->coords.x2 - side_space; - area.x1 = area.x2 - tickness + 1; - } else { - lv_coord_t sb_y = (rem * sb) / scroll_h; - sb_y = rem - sb_y; - - area.y1 = obj->coords.y1 + sb_y + end_space; - area.y2 = area.y1 + sb_h - 1; - area.x2 = obj->coords.x2 - side_space; - area.x1 = area.x2 - tickness; - if(area.y1 < obj->coords.y1 + end_space) { - area.y1 = obj->coords.y1 + end_space; - if(area.y1 + SCROLLBAR_MIN_SIZE > area.y2) area.y2 = area.y1 + SCROLLBAR_MIN_SIZE; - } - if(area.y2 > obj->coords.y2 - hor_req_space - end_space) { - area.y2 = obj->coords.y2 - hor_req_space - end_space; - if(area.y2 - SCROLLBAR_MIN_SIZE < area.y1) area.y1 = area.y2 - SCROLLBAR_MIN_SIZE; - } - } - lv_draw_rect(&area, clip_area, &draw_dsc); - } - - area.y2 = obj->coords.y2 - side_space; - area.y1 =area.y2 - tickness; - area.x1 = obj->coords.x1; - area.x2 = obj->coords.x2; - /*Draw horizontal scrollbar if the mode is ON or can be scrolled in this direction*/ - if(hor_draw && _lv_area_is_on(&area, clip_area)) { - lv_coord_t content_w = obj_w + sl + sr; - lv_coord_t sb_w = ((obj_w - end_space * 2 - ver_reg_space) * obj_w) / content_w; - sb_w = LV_MATH_MAX(sb_w, SCROLLBAR_MIN_SIZE); - rem = (obj_w - end_space * 2 - ver_reg_space) - sb_w; /*Remaining size from the scrollbar track that is not the scrollbar itself*/ - lv_coord_t scroll_w = content_w - obj_w; /*The size of the content which can be really scrolled*/ - if(scroll_w <= 0) { - area.y2 = obj->coords.y2 - side_space; - area.y1 = area.y2 - tickness + 1; - area.x1 = obj->coords.x1 + end_space; - area.x2 = obj->coords.x2 - end_space - ver_reg_space - 1; - } else { - lv_coord_t sb_x = (rem * sr) / scroll_w; - sb_x = rem - sb_x; - - area.x1 = obj->coords.x1 + sb_x + end_space; - area.x2 = area.x1 + sb_w - 1; - area.y2 = obj->coords.y2 - side_space; - area.y1 = area.y2 - tickness; - if(area.x1 < obj->coords.x1 + end_space) { - area.x1 = obj->coords.x1 + end_space; - if(area.x1 + SCROLLBAR_MIN_SIZE > area.x2) area.x2 = area.x1 + SCROLLBAR_MIN_SIZE; - } - if(area.x2 > obj->coords.x2 - ver_reg_space - end_space) { - area.x2 = obj->coords.x2 - ver_reg_space - end_space; - if(area.x2 - SCROLLBAR_MIN_SIZE < area.x1) area.x1 = area.x2 - SCROLLBAR_MIN_SIZE; - } - } - lv_draw_rect(&area, clip_area, &draw_dsc); - } +// if(lv_obj_has_flag(obj, LV_OBJ_FLAG_SCROLLABLE) == false) return; +// +// lv_scroll_dir_t sm = lv_obj_get_scrollbar_mode(obj); +// if(sm == LV_SCROLLBAR_MODE_OFF) { +// return; +// } +// +// /*If there is no indev scrolling this object but the moe is active return*/ +// lv_indev_t * indev = lv_indev_get_next(NULL); +// if(sm == LV_SCROLLBAR_MODE_ACTIVE) { +// bool found = false; +// while(indev) { +// if(lv_indev_get_scroll_obj(indev) == obj) { +// found = true; +// break; +// } +// indev = lv_indev_get_next(indev); +// } +// if(!found) { +// return; +// } +// } +// +// lv_coord_t st = lv_obj_get_scroll_top(obj); +// lv_coord_t sb = lv_obj_get_scroll_bottom(obj); +// lv_coord_t sl = lv_obj_get_scroll_left(obj); +// lv_coord_t sr = lv_obj_get_scroll_right(obj); +// +// /*Return if too small content to scroll*/ +// if(sm == LV_SCROLLBAR_MODE_AUTO && st <= 0 && sb <= 0 && sl <= 0 && sr <= 0) { +// return; +// } +// +// lv_coord_t end_space = lv_obj_get_style_scrollbar_space_end(obj, LV_OBJ_PART_MAIN); +// lv_coord_t side_space = lv_obj_get_style_scrollbar_space_side(obj, LV_OBJ_PART_MAIN); +// lv_coord_t tickness = lv_obj_get_style_scrollbar_tickness(obj, LV_OBJ_PART_MAIN); +// +// lv_coord_t obj_h = lv_obj_get_height(obj); +// lv_coord_t obj_w = lv_obj_get_width(obj); +// +// lv_scroll_dir_t dir = lv_obj_get_scroll_dir(obj); +// +// bool ver_draw = false; +// if((dir & LV_DIR_VER) && +// ((sm == LV_SCROLLBAR_MODE_ON) || +// (sm == LV_SCROLLBAR_MODE_AUTO && (st > 0 || sb > 0)) || +// (sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_SCROLL_DIR_VER))) { +// ver_draw = true; +// } +// +// +// bool hor_draw = false; +// if((dir & LV_DIR_HOR) && +// ((sm == LV_SCROLLBAR_MODE_ON) || +// (sm == LV_SCROLLBAR_MODE_AUTO && (sl > 0 || sr > 0)) || +// (sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_SCROLL_DIR_HOR))) { +// hor_draw = true; +// } +// +// +// lv_coord_t ver_reg_space = ver_draw ? tickness + side_space : 0; +// lv_coord_t hor_req_space = hor_draw ? tickness + side_space : 0; +// lv_coord_t rem; +// +// lv_draw_rect_dsc_t draw_dsc; +// lv_res_t sb_res = scrollbar_init_draw_dsc(obj, &draw_dsc); +// if(sb_res != LV_RES_OK) return; +// +// lv_area_t area; +// area.y1 = obj->coords.y1; +// area.y2 = obj->coords.y2; +// area.x2 = obj->coords.x2 - side_space; +// area.x1 = area.x2 - tickness; +// +// /*Draw horizontal scrollbar if the mode is ON or can be scrolled in this direction*/ +// if(ver_draw && _lv_area_is_on(&area, clip_area)) { +// lv_coord_t content_h = obj_h + st + sb; +// lv_coord_t sb_h = ((obj_h - end_space * 2 - hor_req_space) * obj_h) / content_h; +// sb_h = LV_MATH_MAX(sb_h, SCROLLBAR_MIN_SIZE); +// rem = (obj_h - end_space * 2 - hor_req_space) - sb_h; /*Remaining size from the scrollbar track that is not the scrollbar itself*/ +// lv_coord_t scroll_h = content_h - obj_h; /*The size of the content which can be really scrolled*/ +// if(scroll_h <= 0) { +// area.y1 = obj->coords.y1 + end_space; +// area.y2 = obj->coords.y2 - end_space - hor_req_space - 1; +// area.x2 = obj->coords.x2 - side_space; +// area.x1 = area.x2 - tickness + 1; +// } else { +// lv_coord_t sb_y = (rem * sb) / scroll_h; +// sb_y = rem - sb_y; +// +// area.y1 = obj->coords.y1 + sb_y + end_space; +// area.y2 = area.y1 + sb_h - 1; +// area.x2 = obj->coords.x2 - side_space; +// area.x1 = area.x2 - tickness; +// if(area.y1 < obj->coords.y1 + end_space) { +// area.y1 = obj->coords.y1 + end_space; +// if(area.y1 + SCROLLBAR_MIN_SIZE > area.y2) area.y2 = area.y1 + SCROLLBAR_MIN_SIZE; +// } +// if(area.y2 > obj->coords.y2 - hor_req_space - end_space) { +// area.y2 = obj->coords.y2 - hor_req_space - end_space; +// if(area.y2 - SCROLLBAR_MIN_SIZE < area.y1) area.y1 = area.y2 - SCROLLBAR_MIN_SIZE; +// } +// } +// lv_draw_rect(&area, clip_area, &draw_dsc); +// } +// +// area.y2 = obj->coords.y2 - side_space; +// area.y1 =area.y2 - tickness; +// area.x1 = obj->coords.x1; +// area.x2 = obj->coords.x2; +// /*Draw horizontal scrollbar if the mode is ON or can be scrolled in this direction*/ +// if(hor_draw && _lv_area_is_on(&area, clip_area)) { +// lv_coord_t content_w = obj_w + sl + sr; +// lv_coord_t sb_w = ((obj_w - end_space * 2 - ver_reg_space) * obj_w) / content_w; +// sb_w = LV_MATH_MAX(sb_w, SCROLLBAR_MIN_SIZE); +// rem = (obj_w - end_space * 2 - ver_reg_space) - sb_w; /*Remaining size from the scrollbar track that is not the scrollbar itself*/ +// lv_coord_t scroll_w = content_w - obj_w; /*The size of the content which can be really scrolled*/ +// if(scroll_w <= 0) { +// area.y2 = obj->coords.y2 - side_space; +// area.y1 = area.y2 - tickness + 1; +// area.x1 = obj->coords.x1 + end_space; +// area.x2 = obj->coords.x2 - end_space - ver_reg_space - 1; +// } else { +// lv_coord_t sb_x = (rem * sr) / scroll_w; +// sb_x = rem - sb_x; +// +// area.x1 = obj->coords.x1 + sb_x + end_space; +// area.x2 = area.x1 + sb_w - 1; +// area.y2 = obj->coords.y2 - side_space; +// area.y1 = area.y2 - tickness; +// if(area.x1 < obj->coords.x1 + end_space) { +// area.x1 = obj->coords.x1 + end_space; +// if(area.x1 + SCROLLBAR_MIN_SIZE > area.x2) area.x2 = area.x1 + SCROLLBAR_MIN_SIZE; +// } +// if(area.x2 > obj->coords.x2 - ver_reg_space - end_space) { +// area.x2 = obj->coords.x2 - ver_reg_space - end_space; +// if(area.x2 - SCROLLBAR_MIN_SIZE < area.x1) area.x1 = area.x2 - SCROLLBAR_MIN_SIZE; +// } +// } +// lv_draw_rect(&area, clip_area, &draw_dsc); +// } } /********************** @@ -562,33 +540,33 @@ void _lv_obj_draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area) */ static lv_res_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc) { - lv_draw_rect_dsc_init(dsc); - dsc->bg_opa = lv_obj_get_style_scrollbar_bg_opa(obj, LV_OBJ_PART_MAIN); - if(dsc->bg_opa > LV_OPA_MIN) { - dsc->bg_color = lv_obj_get_style_scrollbar_bg_color(obj, LV_OBJ_PART_MAIN); - } - - dsc->border_opa = lv_obj_get_style_scrollbar_border_opa(obj, LV_OBJ_PART_MAIN); - if(dsc->border_opa > LV_OPA_MIN) { - dsc->border_width = lv_obj_get_style_scrollbar_border_width(obj, LV_OBJ_PART_MAIN); - if(dsc->border_width > 0) { - dsc->border_color = lv_obj_get_style_scrollbar_border_color(obj, LV_OBJ_PART_MAIN); - } else { - dsc->border_opa = LV_OPA_TRANSP; - } - } - - lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, LV_OBJ_PART_MAIN); - if(opa_scale < LV_OPA_MAX) { - dsc->bg_opa = (dsc->bg_opa * opa_scale) >> 8; - dsc->border_opa = (dsc->bg_opa * opa_scale) >> 8; - } - - if(dsc->bg_opa != LV_OPA_TRANSP || dsc->border_opa != LV_OPA_TRANSP) { - dsc->radius = lv_obj_get_style_scrollbar_radius(obj, LV_OBJ_PART_MAIN); - return LV_RES_OK; - } else { - return LV_RES_INV; - } +// lv_draw_rect_dsc_init(dsc); +// dsc->bg_opa = lv_obj_get_style_scrollbar_bg_opa(obj, LV_OBJ_PART_MAIN); +// if(dsc->bg_opa > LV_OPA_MIN) { +// dsc->bg_color = lv_obj_get_style_scrollbar_bg_color(obj, LV_OBJ_PART_MAIN); +// } +// +// dsc->border_opa = lv_obj_get_style_scrollbar_border_opa(obj, LV_OBJ_PART_MAIN); +// if(dsc->border_opa > LV_OPA_MIN) { +// dsc->border_width = lv_obj_get_style_scrollbar_border_width(obj, LV_OBJ_PART_MAIN); +// if(dsc->border_width > 0) { +// dsc->border_color = lv_obj_get_style_scrollbar_border_color(obj, LV_OBJ_PART_MAIN); +// } else { +// dsc->border_opa = LV_OPA_TRANSP; +// } +// } +// +// lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, LV_OBJ_PART_MAIN); +// if(opa_scale < LV_OPA_MAX) { +// dsc->bg_opa = (dsc->bg_opa * opa_scale) >> 8; +// dsc->border_opa = (dsc->bg_opa * opa_scale) >> 8; +// } +// +// if(dsc->bg_opa != LV_OPA_TRANSP || dsc->border_opa != LV_OPA_TRANSP) { +// dsc->radius = lv_obj_get_style_scrollbar_radius(obj, LV_OBJ_PART_MAIN); +// return LV_RES_OK; +// } else { +// return LV_RES_INV; +// } } diff --git a/src/lv_core/lv_obj_pos.c b/src/lv_core/lv_obj_pos.c index 51b89921a..a4170eb12 100644 --- a/src/lv_core/lv_obj_pos.c +++ b/src/lv_core/lv_obj_pos.c @@ -203,8 +203,8 @@ void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h) */ void lv_obj_set_content_width(lv_obj_t * obj, lv_coord_t w) { - lv_style_int_t pleft = lv_obj_get_style_pad_left(obj, LV_OBJ_PART_MAIN); - lv_style_int_t pright = lv_obj_get_style_pad_right(obj, LV_OBJ_PART_MAIN); + lv_coord_t pleft = lv_obj_get_style_pad_left(obj, LV_PART_MAIN); + lv_coord_t pright = lv_obj_get_style_pad_right(obj, LV_PART_MAIN); lv_obj_set_width(obj, w + pleft + pright); } @@ -216,8 +216,8 @@ void lv_obj_set_content_width(lv_obj_t * obj, lv_coord_t w) */ void lv_obj_set_content_height(lv_obj_t * obj, lv_coord_t h) { - lv_style_int_t ptop = lv_obj_get_style_pad_top(obj, LV_OBJ_PART_MAIN); - lv_style_int_t pbottom = lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN); + lv_coord_t ptop = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); + lv_coord_t pbottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN); lv_obj_set_height(obj, h + ptop + pbottom); } @@ -230,8 +230,8 @@ void lv_obj_set_content_height(lv_obj_t * obj, lv_coord_t h) */ void lv_obj_set_width_margin(lv_obj_t * obj, lv_coord_t w) { - lv_style_int_t mleft = lv_obj_get_style_margin_left(obj, LV_OBJ_PART_MAIN); - lv_style_int_t mright = lv_obj_get_style_margin_right(obj, LV_OBJ_PART_MAIN); + lv_coord_t mleft = 0;//lv_obj_get_style_margin_left(obj, LV_PART_MAIN); + lv_coord_t mright = 0;//lv_obj_get_style_margin_right(obj, LV_PART_MAIN); lv_obj_set_width(obj, w - mleft - mright); } @@ -244,8 +244,8 @@ void lv_obj_set_width_margin(lv_obj_t * obj, lv_coord_t w) */ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h) { - lv_style_int_t mtop = lv_obj_get_style_margin_top(obj, LV_OBJ_PART_MAIN); - lv_style_int_t mbottom = lv_obj_get_style_margin_bottom(obj, LV_OBJ_PART_MAIN); + lv_coord_t mtop = 0;//lv_obj_get_style_margin_top(obj, LV_PART_MAIN); + lv_coord_t mbottom = 0;//lv_obj_get_style_margin_bottom(obj, LV_PART_MAIN); lv_obj_set_height(obj, h - mtop - mbottom); } @@ -269,8 +269,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co lv_coord_t x = 0; lv_coord_t y = 0; lv_obj_t * parent = lv_obj_get_parent(obj); - lv_coord_t pleft = lv_obj_get_style_pad_left(parent, LV_OBJ_PART_MAIN); - lv_coord_t ptop = lv_obj_get_style_pad_top(parent, LV_OBJ_PART_MAIN); + lv_coord_t pleft = lv_obj_get_style_pad_left(parent, LV_PART_MAIN); + lv_coord_t ptop = lv_obj_get_style_pad_top(parent, LV_PART_MAIN); switch(align) { case LV_ALIGN_CENTER: x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width(obj) / 2; @@ -403,8 +403,8 @@ void lv_obj_get_inner_coords(const lv_obj_t * obj, lv_area_t * coords_out) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - lv_border_side_t part = lv_obj_get_style_border_side(obj, LV_OBJ_PART_MAIN); - lv_coord_t w = lv_obj_get_style_border_width(obj, LV_OBJ_PART_MAIN); + lv_border_side_t part = lv_obj_get_style_border_side(obj, LV_PART_MAIN); + lv_coord_t w = lv_obj_get_style_border_width(obj, LV_PART_MAIN); if(part & LV_BORDER_SIDE_LEFT) coords_out->x1 += w; if(part & LV_BORDER_SIDE_RIGHT) coords_out->x2 -= w; @@ -429,7 +429,7 @@ lv_coord_t lv_obj_get_x(const lv_obj_t * obj) if(parent) { rel_x = obj->coords.x1 - parent->coords.x1; rel_x += lv_obj_get_scroll_x(parent); - rel_x -= lv_obj_get_style_pad_left(parent, LV_OBJ_PART_MAIN); + rel_x -= lv_obj_get_style_pad_left(parent, LV_PART_MAIN); } else { rel_x = obj->coords.x1; @@ -454,7 +454,7 @@ lv_coord_t lv_obj_get_y(const lv_obj_t * obj) if(parent) { rel_y = obj->coords.y1 - parent->coords.y1; rel_y += lv_obj_get_scroll_y(parent); - rel_y -= lv_obj_get_style_pad_top(parent, LV_OBJ_PART_MAIN); + rel_y -= lv_obj_get_style_pad_top(parent, LV_PART_MAIN); } else { rel_y = obj->coords.y1; @@ -497,8 +497,8 @@ lv_coord_t lv_obj_get_width_fit(const lv_obj_t * obj) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - lv_style_int_t left = lv_obj_get_style_pad_left(obj, LV_OBJ_PART_MAIN); - lv_style_int_t right = lv_obj_get_style_pad_right(obj, LV_OBJ_PART_MAIN); + lv_coord_t left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN); + lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN); return lv_obj_get_width(obj) - left - right; } @@ -512,8 +512,8 @@ lv_coord_t lv_obj_get_height_fit(const lv_obj_t * obj) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - lv_style_int_t top = lv_obj_get_style_pad_top((lv_obj_t *)obj, LV_OBJ_PART_MAIN); - lv_style_int_t bottom = lv_obj_get_style_pad_bottom((lv_obj_t *)obj, LV_OBJ_PART_MAIN); + lv_coord_t top = lv_obj_get_style_pad_top((lv_obj_t *)obj, LV_PART_MAIN); + lv_coord_t bottom = lv_obj_get_style_pad_bottom((lv_obj_t *)obj, LV_PART_MAIN); return lv_obj_get_height(obj) - top - bottom; } @@ -526,8 +526,8 @@ lv_coord_t lv_obj_get_height_fit(const lv_obj_t * obj) */ lv_coord_t lv_obj_get_height_margin(const lv_obj_t * obj) { - lv_style_int_t mtop = lv_obj_get_style_margin_top(obj, LV_OBJ_PART_MAIN); - lv_style_int_t mbottom = lv_obj_get_style_margin_bottom(obj, LV_OBJ_PART_MAIN); + lv_coord_t mtop = lv_obj_get_style_margin_top(obj, LV_PART_MAIN); + lv_coord_t mbottom = lv_obj_get_style_margin_bottom(obj, LV_PART_MAIN); return lv_obj_get_height(obj) + mtop + mbottom; } @@ -540,8 +540,8 @@ lv_coord_t lv_obj_get_height_margin(const lv_obj_t * obj) */ lv_coord_t lv_obj_get_width_margin(const lv_obj_t * obj) { - lv_style_int_t mleft = lv_obj_get_style_margin_left(obj, LV_OBJ_PART_MAIN); - lv_style_int_t mright = lv_obj_get_style_margin_right(obj, LV_OBJ_PART_MAIN); + lv_coord_t mleft = lv_obj_get_style_margin_left(obj, LV_PART_MAIN); + lv_coord_t mright = lv_obj_get_style_margin_right(obj, LV_PART_MAIN); return lv_obj_get_width(obj) + mleft + mright; } @@ -620,8 +620,8 @@ void _lv_obj_move_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, bool notify_par lv_obj_t * parent = obj->parent; if(parent) { - lv_coord_t pad_left = lv_obj_get_style_pad_left(parent, LV_OBJ_PART_MAIN); - lv_coord_t pad_top = lv_obj_get_style_pad_top(parent, LV_OBJ_PART_MAIN); + lv_coord_t pad_left = lv_obj_get_style_pad_left(parent, LV_PART_MAIN); + lv_coord_t pad_top = lv_obj_get_style_pad_top(parent, LV_PART_MAIN); x += pad_left + parent->coords.x1 - lv_obj_get_scroll_x(parent); y += pad_top + parent->coords.y1 - lv_obj_get_scroll_y(parent); diff --git a/src/lv_core/lv_obj_scroll.c b/src/lv_core/lv_obj_scroll.c index a04f078fa..d49e05d55 100644 --- a/src/lv_core/lv_obj_scroll.c +++ b/src/lv_core/lv_obj_scroll.c @@ -130,11 +130,11 @@ lv_coord_t lv_obj_get_scroll_bottom(lv_obj_t * obj) uint32_t i; for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { lv_obj_t * child = lv_obj_get_child(obj, i); - child_res = LV_MATH_MAX(child_res, child->coords.y2 + lv_obj_get_style_margin_bottom(child, LV_OBJ_PART_MAIN)); + child_res = LV_MATH_MAX(child_res, child->coords.y2 + lv_obj_get_style_margin_bottom(child, LV_PART_MAIN)); } - lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_OBJ_PART_MAIN); - lv_coord_t pad_bottom = lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN); + lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); + lv_coord_t pad_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN); child_res -= (obj->coords.y2 - pad_bottom); @@ -156,8 +156,8 @@ lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj) } /*With RTL base direction scrolling the left is normal so find the left most coordinate*/ - lv_coord_t pad_right = lv_obj_get_style_pad_right(obj, LV_OBJ_PART_MAIN); - lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_OBJ_PART_MAIN); + lv_coord_t pad_right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN); + lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN); lv_coord_t child_res = 0; @@ -165,7 +165,7 @@ lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj) lv_coord_t x1 = LV_COORD_MAX; for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { lv_obj_t * child = lv_obj_get_child(obj, i); - x1 = LV_MATH_MIN(x1, child->coords.x1 - lv_obj_get_style_margin_left(child, LV_OBJ_PART_MAIN)); + x1 = LV_MATH_MIN(x1, child->coords.x1 - lv_obj_get_style_margin_left(child, LV_PART_MAIN)); } @@ -197,11 +197,11 @@ lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj) uint32_t i; for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { lv_obj_t * child = lv_obj_get_child(obj, i); - child_res = LV_MATH_MAX(child_res, child->coords.x2 + lv_obj_get_style_margin_right(child, LV_OBJ_PART_MAIN)); + child_res = LV_MATH_MAX(child_res, child->coords.x2 + lv_obj_get_style_margin_right(child, LV_PART_MAIN)); } - lv_coord_t pad_right = lv_obj_get_style_pad_right(obj, LV_OBJ_PART_MAIN); - lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_OBJ_PART_MAIN); + lv_coord_t pad_right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN); + lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN); child_res -= (obj->coords.x2 - pad_right); @@ -324,10 +324,10 @@ void lv_obj_scroll_to_view(lv_obj_t * obj, lv_anim_enable_t anim_en) { lv_obj_t * parent = lv_obj_get_parent(obj); - lv_coord_t pleft = lv_obj_get_style_pad_left(parent, LV_OBJ_PART_MAIN); - lv_coord_t pright = lv_obj_get_style_pad_right(parent, LV_OBJ_PART_MAIN); - lv_coord_t ptop = lv_obj_get_style_pad_top(parent, LV_OBJ_PART_MAIN); - lv_coord_t pbottom = lv_obj_get_style_pad_bottom(parent, LV_OBJ_PART_MAIN); + lv_coord_t pleft = lv_obj_get_style_pad_left(parent, LV_PART_MAIN); + lv_coord_t pright = lv_obj_get_style_pad_right(parent, LV_PART_MAIN); + lv_coord_t ptop = lv_obj_get_style_pad_top(parent, LV_PART_MAIN); + lv_coord_t pbottom = lv_obj_get_style_pad_bottom(parent, LV_PART_MAIN); lv_coord_t left_diff = parent->coords.x1 + pleft - obj->coords.x1; lv_coord_t right_diff = -(parent->coords.x2 - pright - obj->coords.x2); diff --git a/src/lv_core/lv_obj_style.c b/src/lv_core/lv_obj_style.c index 643c6f1db..39b1ee58c 100644 --- a/src/lv_core/lv_obj_style.c +++ b/src/lv_core/lv_obj_style.c @@ -26,51 +26,41 @@ typedef struct { lv_obj_t * obj; - lv_style_property_t prop; + lv_style_prop_t prop; uint8_t part; - union { - lv_color_t _color; - lv_style_int_t _int; - lv_opa_t _opa; - const void * _ptr; - } start_value; - union { - lv_color_t _color; - lv_style_int_t _int; - lv_opa_t _opa; - const void * _ptr; - } end_value; + lv_style_value_t start_value; + lv_style_value_t end_value; } lv_style_trans_t; typedef struct { lv_draw_rect_dsc_t rect; - lv_draw_label_dsc_t label; - lv_draw_line_dsc_t line; - lv_draw_img_dsc_t img; - lv_style_int_t pad_top; - lv_style_int_t pad_bottom; - lv_style_int_t pad_right; - lv_style_int_t pad_left; - lv_style_int_t pad_inner; - lv_style_int_t margin_top; - lv_style_int_t margin_bottom; - lv_style_int_t margin_left; - lv_style_int_t margin_right; - lv_style_int_t size; - lv_style_int_t transform_width; - lv_style_int_t transform_height; - lv_style_int_t transform_angle; - lv_style_int_t transform_zoom; - lv_style_int_t scale_width; - lv_style_int_t scale_border_width; - lv_style_int_t scale_end_border_width; - lv_style_int_t scale_end_line_width; - lv_color_t scale_grad_color; - lv_color_t scale_end_color; - lv_opa_t opa_scale; - uint32_t clip_corder :1; - uint32_t border_post :1; +// lv_draw_label_dsc_t label; +// lv_draw_line_dsc_t line; +// lv_draw_img_dsc_t img; +// lv_style_int_t pad_top; +// lv_style_int_t pad_bottom; +// lv_style_int_t pad_right; +// lv_style_int_t pad_left; +// lv_style_int_t pad_inner; +// lv_style_int_t margin_top; +// lv_style_int_t margin_bottom; +// lv_style_int_t margin_left; +// lv_style_int_t margin_right; +// lv_style_int_t size; +// lv_style_int_t transform_width; +// lv_style_int_t transform_height; +// lv_style_int_t transform_angle; +// lv_style_int_t transform_zoom; +// lv_style_int_t scale_width; +// lv_style_int_t scale_border_width; +// lv_style_int_t scale_end_border_width; +// lv_style_int_t scale_end_line_width; +// lv_color_t scale_grad_color; +// lv_color_t scale_end_color; +// lv_opa_t opa_scale; +// uint32_t clip_corder :1; +// uint32_t border_post :1; }style_snapshot_t; @@ -80,7 +70,7 @@ typedef struct { static void report_style_change_core(void * style, lv_obj_t * obj); static void refresh_children_style(lv_obj_t * obj); #if LV_USE_ANIMATION -static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_style_trans_t * tr_limit); +static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, lv_style_trans_t * tr_limit); static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v); static void trans_anim_start_cb(lv_anim_t * a); static void trans_anim_ready_cb(lv_anim_t * a); @@ -124,21 +114,38 @@ void _lv_obj_style_init(void) * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` * @param style pointer to a style to add (Only its pointer will be saved) */ -void lv_obj_add_style(lv_obj_t * obj, uint8_t part, lv_style_t * style) +void lv_obj_add_style(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_t * style) { if(style == NULL) return; - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - if(list == NULL) { - LV_LOG_WARN("Can't find style with part: %d", part); - return; - } - - _lv_style_list_add_style(list, style); #if LV_USE_ANIMATION trans_del(obj, part, 0xFF, NULL); #endif - _lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); + + uint32_t i; + /*Go after the transition and local styles*/ + for(i = 0; i < obj->style_list.style_cnt; i++) { + if(obj->style_list.styles[i].is_trans) continue; + if(obj->style_list.styles[i].is_local) continue; + break; + } + + /*Now `i` is at the first normal style. Insert the new style before this */ + + /*Allocate space for the new style and shift the rest of the style to the end*/ + obj->style_list.style_cnt++; + obj->style_list.styles = lv_mem_realloc(obj->style_list.styles, obj->style_list.style_cnt * sizeof(lv_obj_style_t)); + + uint32_t j; + for(j = obj->style_list.style_cnt - 1; j > i ; j--) { + obj->style_list.styles[j] = obj->style_list.styles[j - 1]; + } + + obj->style_list.styles[i].style = style; + obj->style_list.styles[i].part = part; + obj->style_list.styles[i].state = state; + + _lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); } /** @@ -148,21 +155,37 @@ void lv_obj_add_style(lv_obj_t * obj, uint8_t part, lv_style_t * style) * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` * @param style pointer to a style to remove */ -void lv_obj_remove_style(lv_obj_t * obj, uint8_t part, lv_style_t * style) +void lv_obj_remove_style(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_t * style) { if(style == NULL) return; - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - if(list == NULL) { - LV_LOG_WARN("Can't find style with part: %d", part); - return; + uint32_t i; + /*Find the style*/ + for(i = 0; i < obj->style_list.style_cnt; i++) { + if(obj->style_list.styles[i].state == state && + obj->style_list.styles[i].part == part) { + break; + } } - _lv_style_list_remove_style(list, style); + /*The style is not found*/ + if(i == obj->style_list.style_cnt) return; + + /*Shift the styles after `i` by one*/ + uint32_t j; + for(j = i; j > obj->style_list.style_cnt - 2 ; j--) { + obj->style_list.styles[j] = obj->style_list.styles[j + 1]; + } + + + obj->style_list.style_cnt--; + obj->style_list.styles = lv_mem_realloc(obj->style_list.styles, obj->style_list.style_cnt * sizeof(lv_style_t)); + + #if LV_USE_ANIMATION trans_del(obj, part, 0xFF, NULL); #endif - _lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); + _lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); } /** @@ -173,11 +196,17 @@ void lv_obj_remove_style(lv_obj_t * obj, uint8_t part, lv_style_t * style) * @param part the part of the object which style list should be reseted. * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` */ -void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part) +void lv_obj_remove_all_styles(lv_obj_t * obj) { - _lv_obj_reset_style_list_no_refr(obj, part); +#if LV_USE_ANIMATION + trans_del(obj, 0xFF, 0xFF, NULL); +#endif - _lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); + lv_mem_free(obj->style_list.styles); + obj->style_list.styles = NULL; + obj->style_list.style_cnt = 0; + + _lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); } /** @@ -207,13 +236,24 @@ void lv_obj_report_style_change(lv_style_t * style) * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` * @return true: the property was found and removed; false: the property was not found */ -bool lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_property_t prop) +bool lv_obj_remove_style_prop(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_prop_t prop) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - lv_style_t * style = _lv_obj_get_local_style(obj, part); - if(style) return lv_style_remove_prop(style, prop); - else return false; + uint32_t i; + /*Find the style*/ + for(i = 0; i < obj->style_list.style_cnt; i++) { + if(obj->style_list.styles[i].is_local && + obj->style_list.styles[i].state == state && + obj->style_list.styles[i].part == part) { + break; + } + } + + /*The style is not found*/ + if(i == obj->style_list.style_cnt) return false; + + return lv_style_remove_prop(obj->style_list.styles[i].style, prop); } @@ -257,274 +297,6 @@ void lv_obj_fade_out(lv_obj_t * obj, uint32_t time, uint32_t delay) #endif -/** - * Get the style list of part of an object - * @param obj pointer to an object - * @param part the part of the object. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @return pointer to the style list - */ -lv_style_list_t * _lv_obj_get_style_list(const lv_obj_t * obj, uint8_t part) -{ - if(part == LV_OBJ_PART_MAIN) return &((lv_obj_t *)obj)->style_list; - - lv_get_style_info_t info; - info.part = part; - info.result = NULL; - - lv_res_t res; - res = lv_signal_send((lv_obj_t *)obj, LV_SIGNAL_GET_STYLE, &info); - - if(res != LV_RES_OK) return NULL; - - return info.result; -} - -/** - * Enable/disable the use of style cache for an object - * @param obj pointer to an object - * @param dis true: disable; false: enable (re-enable) - */ -void _lv_obj_disable_style_caching(lv_obj_t * obj, bool dis) -{ -#if LV_STYLE_CACHE_LEVEL >= 1 - uint8_t part; - for(part = 0; part < _LV_OBJ_PART_MAX; part++) { - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - if(list == NULL) break; - list->ignore_cache = dis; - } -#else - LV_UNUSED(obj); - LV_UNUSED(dis); -#endif -} - - -#if LV_STYLE_CACHE_LEVEL > 0 - -/** - * 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, lv_style_property_t prop) -{ - if(style_prop_is_cacheable(prop) == false) return; - - for(part = 0; part < _LV_OBJ_PART_MAX; part++) { - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - if(list == NULL) break; - list->valid_cache = 0; - } - - uint32_t i; - for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { - lv_obj_t * child = lv_obj_get_child(obj, i); - update_style_cache_children(child); - } -} -#endif /*LV_STYLE_CACHE_LEVEL >= 1*/ - -/** - * Get a style property of a part of an object in the object's current state. - * If there is a running transitions it is taken into account - * @param obj pointer to an object - * @param part the part of the object which style property should be get. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop the property to get. E.g. `LV_STYLE_BORDER_WIDTH`. - * The state of the object will be added internally - * @return the value of the property of the given part in the current state. - * If the property is not found a default value will be returned. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_width()` - * @note for performance reasons it's not checked if the property really has integer type - */ -lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop) -{ - lv_style_property_t prop_ori = prop; - - lv_style_attr_t attr; - attr = prop_ori >> 8; - - lv_style_int_t value_act; - lv_res_t res = LV_RES_INV; - const lv_obj_t * parent = obj; - while(parent) { - lv_style_list_t * list = _lv_obj_get_style_list(parent, part); -#if LV_STYLE_CACHE_LEVEL >= 1 - if(!list->ignore_cache && list->style_cnt > 0) { - 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_CLIP_CORNER: - if(list->clip_corner_off) def = true; - break; - case LV_STYLE_TEXT_LETTER_SPACE: - case LV_STYLE_TEXT_LINE_SPACE: - if(list->text_space_zero) def = true; - break; - case LV_STYLE_TRANSFORM_ANGLE: - case LV_STYLE_TRANSFORM_WIDTH: - case LV_STYLE_TRANSFORM_HEIGHT: - case LV_STYLE_TRANSFORM_ZOOM: - if(list->transform_all_zero) def = true; - break; - case LV_STYLE_BORDER_WIDTH: - if(list->border_width_zero) def = true; - break; - case LV_STYLE_BORDER_SIDE: - if(list->border_side_full) def = true; - break; - case LV_STYLE_BORDER_POST: - if(list->border_post_off) def = true; - break; - case LV_STYLE_OUTLINE_WIDTH: - if(list->outline_width_zero) def = true; - break; - case LV_STYLE_RADIUS: - if(list->radius_zero) def = true; - break; - case LV_STYLE_SHADOW_WIDTH: - if(list->shadow_width_zero) def = true; - break; - case LV_STYLE_PAD_TOP: - if(list->pad_all_zero) def = true; - else if(list->pad_top) return list->pad_top; - break; - case LV_STYLE_PAD_BOTTOM: - if(list->pad_all_zero) def = true; - break; - case LV_STYLE_PAD_LEFT: - if(list->pad_all_zero) def = true; - else if(list->pad_left) return list->pad_left; - break; - case LV_STYLE_PAD_RIGHT: - if(list->pad_all_zero) def = true; - break; - case LV_STYLE_MARGIN_TOP: - case LV_STYLE_MARGIN_BOTTOM: - case LV_STYLE_MARGIN_LEFT: - case LV_STYLE_MARGIN_RIGHT: - if(list->margin_all_zero) def = true; - break; - case LV_STYLE_BG_BLEND_MODE: - case LV_STYLE_BORDER_BLEND_MODE: - case LV_STYLE_IMAGE_BLEND_MODE: - case LV_STYLE_LINE_BLEND_MODE: - case LV_STYLE_OUTLINE_BLEND_MODE: - case LV_STYLE_PATTERN_BLEND_MODE: - case LV_STYLE_SHADOW_BLEND_MODE: - case LV_STYLE_TEXT_BLEND_MODE: - case LV_STYLE_VALUE_BLEND_MODE: - if(list->blend_mode_all_normal) def = true; - break; - case LV_STYLE_TEXT_DECOR: - if(list->text_decor_none) def = true; - break; - } - - if(def) { - break; - } - } -#endif - - lv_state_t state = lv_obj_get_state(parent); - prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS); - - res = _lv_style_list_get_int(list, prop, &value_act); - if(res == LV_RES_OK) return value_act; - - if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; - - /*If not found, check the `MAIN` style first*/ - if(part != LV_OBJ_PART_MAIN) { - part = LV_OBJ_PART_MAIN; - continue; - } - - /*Check the parent too.*/ - parent = lv_obj_get_parent(parent); - } - - /*Handle unset values*/ - prop = prop & (~LV_STYLE_STATE_MASK); - switch(prop) { - case LV_STYLE_BORDER_SIDE: - return LV_BORDER_SIDE_FULL; - case LV_STYLE_SIZE: - return LV_DPI / 20; - case LV_STYLE_SCALE_WIDTH: - return LV_DPI / 8; - case LV_STYLE_BG_GRAD_STOP: - return 255; - case LV_STYLE_TRANSFORM_ZOOM: - return LV_IMG_ZOOM_NONE; - case LV_STYLE_SCROLLBAR_TICKNESS: - return LV_DPX(10); - } - - return 0; -} - -/** - * Get a style property of a part of an object in the object's current state. - * If there is a running transitions it is taken into account - * @param obj pointer to an object - * @param part the part of the object which style property should be get. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop the property to get. E.g. `LV_STYLE_BORDER_COLOR`. - * The state of the object will be added internally - * @return the value of the property of the given part in the current state. - * If the property is not found a default value will be returned. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_color()` - * @note for performance reasons it's not checked if the property really has color type - */ -lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop) -{ - lv_style_property_t prop_ori = prop; - - lv_style_attr_t attr; - attr = prop_ori >> 8; - - lv_color_t value_act; - lv_res_t res = LV_RES_INV; - const lv_obj_t * parent = obj; - while(parent) { - lv_style_list_t * list = _lv_obj_get_style_list(parent, part); - - lv_state_t state = lv_obj_get_state(parent); - prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS); - - res = _lv_style_list_get_color(list, prop, &value_act); - if(res == LV_RES_OK) return value_act; - - if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; - - /*If not found, check the `MAIN` style first*/ - if(part != LV_OBJ_PART_MAIN) { - part = LV_OBJ_PART_MAIN; - continue; - } - - /*Check the parent too.*/ - parent = lv_obj_get_parent(parent); - } - - /*Handle unset values*/ - prop = prop & (~LV_STYLE_STATE_MASK); - switch(prop) { - case LV_STYLE_BG_COLOR: - case LV_STYLE_BG_GRAD_COLOR: - return LV_COLOR_WHITE; - } - - return LV_COLOR_BLACK; -} - /** * Get a style property of a part of an object in the object's current state. * If there is a running transitions it is taken into account @@ -539,52 +311,55 @@ lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_ * For example: `lv_obj_style_get_border_opa()` * @note for performance reasons it's not checked if the property really has opacity type */ -lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop) +lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, uint8_t part, lv_style_prop_t prop) { - lv_style_property_t prop_ori = prop; - - lv_style_attr_t attr; - attr = prop_ori >> 8; - - lv_opa_t value_act; - lv_res_t res = LV_RES_INV; + lv_style_value_t value_act; + lv_style_value_t value_final; + bool found = false; + bool inherit = prop & LV_STYLE_PROP_INHERIT ? true : false; const lv_obj_t * parent = obj; while(parent) { - lv_style_list_t * list = _lv_obj_get_style_list(parent, part); -#if LV_STYLE_CACHE_LEVEL >= 1 - if(!list->ignore_cache && list->style_cnt > 0) { - 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: - if(list->opa_scale_cover) def = true; - break; - case LV_STYLE_BG_OPA: - if(list->bg_opa_cover) return LV_OPA_COVER; /*Special case, not the default value is used*/ - if(list->bg_opa_transp) def = true; - break; - case LV_STYLE_IMAGE_RECOLOR_OPA: - if(list->img_recolor_opa_transp) def = true; - break; - } + int32_t weight = -1; + lv_state_t state = parent->state; + lv_state_t state_inv = ~state; + bool skip_trans = parent->style_list.skip_trans; + uint32_t i; + for(i = 0; i < parent->style_list.style_cnt; i++) { + lv_obj_style_t * obj_style = &parent->style_list.styles[i]; + if(obj_style->is_trans == false) break; + if(skip_trans) continue; + if(obj_style->part != part) continue; + found = lv_style_get_prop(obj_style->style, prop, &value_act); + if(found) return value_act; + } - if(def) { - break; + for(; i < parent->style_list.style_cnt; i++) { + lv_obj_style_t * obj_style = &parent->style_list.styles[i]; + if(obj_style->part != part) continue; + + /* Be sure the style not specifies other state than the requested. + * E.g. For HOVER+PRESS object state, HOVER style only is OK, but HOVER+FOCUS style is not*/ + if((obj_style->state & state_inv)) continue; + + /*Check only better candidates*/ + if(obj_style->state <= weight) continue; + + found = lv_style_get_prop(obj_style->style, prop, &value_act); + + if(found) { + if(obj_style->state == state) return value_act; + if(weight < obj_style->state) { + weight = obj_style->state; + value_final = value_act; + } } } -#endif - - lv_state_t state = lv_obj_get_state(parent); - prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS); - - res = _lv_style_list_get_opa(list, prop, &value_act); - if(res == LV_RES_OK) return value_act; - - if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; + if(weight >= 0) return value_final; + if(!inherit) break; /*If not found, check the `MAIN` style first*/ - if(part != LV_OBJ_PART_MAIN) { - part = LV_OBJ_PART_MAIN; + if(part != LV_PART_MAIN) { + part = LV_PART_MAIN; continue; } @@ -592,277 +367,57 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop parent = lv_obj_get_parent(parent); } - /*Handle unset values*/ - prop = prop & (~LV_STYLE_STATE_MASK); - switch(prop) { - case LV_STYLE_BG_OPA: - case LV_STYLE_IMAGE_RECOLOR_OPA: - case LV_STYLE_PATTERN_RECOLOR_OPA: - return LV_OPA_TRANSP; - } - - return LV_OPA_COVER; + return lv_style_prop_get_default(prop); } -/** - * Get a style property of a part of an object in the object's current state. - * If there is a running transitions it is taken into account - * @param obj pointer to an object - * @param part the part of the object which style property should be get. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop the property to get. E.g. `LV_STYLE_TEXT_FONT`. - * The state of the object will be added internally - * @return the value of the property of the given part in the current state. - * If the property is not found a default value will be returned. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has pointer type - */ -const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop) -{ - lv_style_property_t prop_ori = prop; - - lv_style_attr_t attr; - attr = prop_ori >> 8; - - const void * value_act; - lv_res_t res = LV_RES_INV; - const lv_obj_t * parent = obj; - while(parent) { - lv_style_list_t * list = _lv_obj_get_style_list(parent, part); -#if LV_STYLE_CACHE_LEVEL >= 1 - if(!list->ignore_cache && list->style_cnt > 0) { - 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_VALUE_STR: - if(list->value_txt_str) def = true; - break; - case LV_STYLE_PATTERN_IMAGE: - if(list->pattern_img_null) def = true; - break; - case LV_STYLE_TEXT_FONT: - if(list->text_font_normal) def = true; - break; - } - - if(def) { - break; - } - } -#endif - lv_state_t state = lv_obj_get_state(parent); - prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS); - - res = _lv_style_list_get_ptr(list, prop, &value_act); - if(res == LV_RES_OK) return value_act; - - if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; - - /*If not found, check the `MAIN` style first*/ - if(part != LV_OBJ_PART_MAIN) { - part = LV_OBJ_PART_MAIN; - continue; - } - - /*Check the parent too.*/ - parent = lv_obj_get_parent(parent); - } - - /*Handle unset values*/ - prop = prop & (~LV_STYLE_STATE_MASK); - switch(prop) { - case LV_STYLE_TEXT_FONT: - case LV_STYLE_VALUE_FONT: - return lv_theme_get_font_normal(); -#if LV_USE_ANIMATION - case LV_STYLE_TRANSITION_PATH: - return &lv_anim_path_def; -#endif - } - - return NULL; -} - -/** - * Get the local style of a part of an object. - * @param obj pointer to an object - * @param part the part of the object which style property should be set. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @return pointer to the local style if exists else `NULL`. - */ -lv_style_t * _lv_obj_get_local_style(lv_obj_t * obj, uint8_t part) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - lv_style_list_t * style_list = _lv_obj_get_style_list(obj, part); - return lv_style_list_get_local_style(style_list); -} - - -/** - * Set a local style property of a part of an object in a given state. - * @param obj pointer to an object - * @param part the part of the object which style property should be set. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param the value to set - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_width()` - * @note for performance reasons it's not checked if the property really has integer type - */ -void _lv_obj_set_style_local_int(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_style_int_t value) -{ - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - _lv_style_list_set_local_int(list, prop, value); -#if LV_USE_ANIMATION - trans_del(obj, part, prop, NULL); -#endif - _lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK)); -} - -/** - * Set a local style property of a part of an object in a given state. - * @param obj pointer to an object - * @param part the part of the object which style property should be set. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_COLOR | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param the value to set - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has color type - */ -void _lv_obj_set_style_local_color(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_color_t color) -{ - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - _lv_style_list_set_local_color(list, prop, color); -#if LV_USE_ANIMATION - trans_del(obj, part, prop, NULL); -#endif - _lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK)); -} - -/** - * Set a local style property of a part of an object in a given state. - * @param obj pointer to an object - * @param part the part of the object which style property should be set. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_OPA | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param the value to set - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has opacity type - */ -void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_opa_t opa) -{ - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - _lv_style_list_set_local_opa(list, prop, opa); -#if LV_USE_ANIMATION - trans_del(obj, part, prop, NULL); -#endif - _lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK)); -} - -/** - * Set a local style property of a part of an object in a given state. - * @param obj pointer to an object - * @param part the part of the object which style property should be set. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has pointer type - */ -void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, const void * value) -{ - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - _lv_style_list_set_local_ptr(list, prop, value); -#if LV_USE_ANIMATION - trans_del(obj, part, prop, NULL); -#endif - _lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK)); -} - -/** - * Reset a style to the default (empty) state. - * Release all used memories and cancel pending related transitions. - * Typically used in `LV_SIGNAL_CLEAN_UP. - * @param obj pointer to an object - * @param part the part of the object which style list should be reseted. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - */ -void _lv_obj_reset_style_list_no_refr(lv_obj_t * obj, uint8_t part) -{ - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - if(list == NULL) { - LV_LOG_WARN("_lv_obj_reset_style_list_no_refr: can't find style with `part`"); - return; - } - - _lv_style_list_reset(list); -#if LV_USE_ANIMATION - trans_del(obj, part, 0xFF, NULL); -#endif -} - - /** * Notify an object and its children about its style is modified * @param obj pointer to an object * @param part the part of the object which style property should be refreshed. * @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, uint8_t part, lv_style_property_t prop) +void _lv_obj_refresh_style(lv_obj_t * obj,lv_style_prop_t prop) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); -#if LV_STYLE_CACHE_LEVEL >= 1 - _lv_obj_invalidate_style_cache(obj, part, prop); -#else - LV_UNUSED(part); -#endif /*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_TRANSFORM_ANGLE: - case LV_STYLE_TRANSFORM_ZOOM: +// case LV_STYLE_CLIP_CORNER: +// case LV_STYLE_SIZE: +// case LV_STYLE_TRANSFORM_WIDTH: +// case LV_STYLE_TRANSFORM_HEIGHT: +// case LV_STYLE_TRANSFORM_ANGLE: +// case LV_STYLE_TRANSFORM_ZOOM: case LV_STYLE_PAD_TOP: case LV_STYLE_PAD_BOTTOM: case LV_STYLE_PAD_LEFT: case LV_STYLE_PAD_RIGHT: - case LV_STYLE_MARGIN_TOP: - case LV_STYLE_MARGIN_BOTTOM: - case LV_STYLE_MARGIN_LEFT: - case LV_STYLE_MARGIN_RIGHT: - case LV_STYLE_OUTLINE_WIDTH: - case LV_STYLE_OUTLINE_PAD: - case LV_STYLE_OUTLINE_OPA: - case LV_STYLE_SHADOW_WIDTH: - case LV_STYLE_SHADOW_OPA: - 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_VALUE_OPA: - case LV_STYLE_TEXT_LETTER_SPACE: - case LV_STYLE_TEXT_LINE_SPACE: +// case LV_STYLE_MARGIN_TOP: +// case LV_STYLE_MARGIN_BOTTOM: +// case LV_STYLE_MARGIN_LEFT: +// case LV_STYLE_MARGIN_RIGHT: +// case LV_STYLE_OUTLINE_WIDTH: +// case LV_STYLE_OUTLINE_PAD: +// case LV_STYLE_OUTLINE_OPA: +// case LV_STYLE_SHADOW_WIDTH: +// case LV_STYLE_SHADOW_OPA: +// 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_VALUE_OPA: +// case LV_STYLE_TEXT_LETTER_SPACE: +// case LV_STYLE_TEXT_LINE_SPACE: case LV_STYLE_TEXT_FONT: - case LV_STYLE_LINE_WIDTH: +// case LV_STYLE_LINE_WIDTH: real_refr = true; break; default: @@ -875,18 +430,20 @@ void _lv_obj_refresh_style(lv_obj_t * obj, uint8_t part, lv_style_property_t pro switch(prop) { case LV_STYLE_PROP_ALL: - case LV_STYLE_MARGIN_TOP: - case LV_STYLE_MARGIN_BOTTOM: - case LV_STYLE_MARGIN_LEFT: - case LV_STYLE_MARGIN_RIGHT: +// case LV_STYLE_MARGIN_TOP: +// case LV_STYLE_MARGIN_BOTTOM: +// case LV_STYLE_MARGIN_LEFT: +// case LV_STYLE_MARGIN_RIGHT: if(obj->parent) lv_signal_send(obj->parent, LV_SIGNAL_CHILD_CHG, obj); break; + default: + break; } lv_obj_invalidate(obj); /*Send style change signals*/ - if(prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_INHERIT_MASK)) refresh_children_style(obj); + if(prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_PROP_INHERIT)) refresh_children_style(obj); } else { lv_obj_invalidate(obj); @@ -908,6 +465,69 @@ void _lv_obj_remove_style_trans(lv_obj_t * obj) #if LV_USE_ANIMATION +lv_obj_style_t * _get_trans_style(lv_obj_t * obj, uint32_t part) +{ + uint32_t i; + for(i = 0; obj->style_list.style_cnt; i++) { + if(obj->style_list.styles[i].is_trans && obj->style_list.styles[i].part == part) break; + } + + /*Already have a transition style for it*/ + if(i != obj->style_list.style_cnt) return &obj->style_list.styles[i]; + + obj->style_list.style_cnt++; + obj->style_list.styles = lv_mem_realloc(obj->style_list.styles, obj->style_list.style_cnt * sizeof(lv_obj_style_t)); + + for(i = obj->style_list.style_cnt - 1; i > 1 ; i--) { + obj->style_list.styles[i] = obj->style_list.styles[i - 1]; + } + + _lv_memset_00(&obj->style_list.styles[0], sizeof(lv_obj_style_t)); + obj->style_list.styles[0].style = lv_mem_alloc(sizeof(lv_style_t)); + lv_style_init(obj->style_list.styles[0].style); + obj->style_list.styles[0].is_trans = 1; + return &obj->style_list.styles[0]; +} + + +lv_obj_style_t * _get_local_style(lv_obj_t * obj, uint32_t part, uint32_t state) +{ + uint32_t i; + for(i = 0; obj->style_list.style_cnt; i++) { + if(obj->style_list.styles[i].is_local && + obj->style_list.styles[i].part == part && + obj->style_list.styles[i].state == state) + { + return &obj->style_list.styles[i]; + } + } + + obj->style_list.style_cnt++; + obj->style_list.styles = lv_mem_realloc(obj->style_list.styles, obj->style_list.style_cnt * sizeof(lv_obj_style_t)); + + for(i = obj->style_list.style_cnt - 1; i > 1 ; i--) { + /* Copy only normal styles (not local and transition). + * The new local style will be added as the last local style*/ + if(obj->style_list.styles[i - 1].is_local || obj->style_list.styles[i - 1].is_trans) break; + obj->style_list.styles[i] = obj->style_list.styles[i - 1]; + } + + _lv_memset_00(&obj->style_list.styles[i], sizeof(lv_obj_style_t)); + obj->style_list.styles[i].style = lv_mem_alloc(sizeof(lv_style_t)); + lv_style_init(obj->style_list.styles[i].style); + obj->style_list.styles[i].is_local = 1; + return &obj->style_list.styles[i]; +} + + +void lv_obj_set_style_prop(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_prop_t prop, lv_style_value_t value) +{ + lv_obj_style_t * style_local = _get_local_style(obj, part, state); + lv_style_set_prop(style_local->style, prop, value); + _lv_obj_refresh_style(obj, prop); + +} + /** * Allocate and initialize a transition for a property of an object if the properties value is different in the new state. * It allocates `lv_style_trans_t` in `_lv_obj_style_trans_ll` and set only `start/end_values`. No animation will be created here. @@ -921,104 +541,41 @@ void _lv_obj_remove_style_trans(lv_obj_t * obj) * @param path the path of the transition * @return pointer to the allocated `the transaction` variable or `NULL` if no transition created */ -void _lv_obj_create_style_transition(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, - lv_state_t new_state, uint32_t time, uint32_t delay, lv_anim_path_t * path) +void _lv_obj_create_style_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8_t part, lv_state_t prev_state, + lv_state_t new_state, uint32_t time, uint32_t delay, const lv_anim_path_t * path) { lv_style_trans_t * tr; - lv_style_list_t * style_list = _lv_obj_get_style_list(obj, part); - lv_style_t * style_trans = _lv_style_list_get_transition_style(style_list); + lv_obj_style_t * style_trans = _get_trans_style(obj, part); /*Get the previous and current values*/ - if((prop & 0xF) < LV_STYLE_ID_COLOR) { /*Int*/ - style_list->skip_trans = 1; - obj->state = prev_state; - lv_style_int_t int1 = _lv_obj_get_style_int(obj, part, prop); - obj->state = new_state; - lv_style_int_t int2 = _lv_obj_get_style_int(obj, part, prop); - style_list->skip_trans = 0; + obj->style_list.skip_trans = 1; + obj->state = prev_state; + lv_style_value_t v1 = lv_obj_get_style_prop(obj, part, prop); + obj->state = new_state; + lv_style_value_t v2 = lv_obj_get_style_prop(obj, part, prop); + obj->style_list.skip_trans = 0; - if(int1 == int2) return; - obj->state = prev_state; - int1 = _lv_obj_get_style_int(obj, part, prop); - obj->state = new_state; - _lv_style_set_int(style_trans, prop, int1); /*Be sure `trans_style` has a valid value */ +// if(memcmp(&v1, &v2, sizeof(lv_style_value_t) == 0)) return; + if(v1._ptr == v2._ptr && v1._int == v2._int && v1._color.full == v2._color.full) return; + obj->state = prev_state; + v1 = lv_obj_get_style_prop(obj, part, prop); + obj->state = new_state; + lv_style_set_prop(style_trans->style, prop, v1); /*Be sure `trans_style` has a valid value */ - if(prop == LV_STYLE_RADIUS) { - if(int1 == LV_RADIUS_CIRCLE || int2 == LV_RADIUS_CIRCLE) { - lv_coord_t whalf = lv_obj_get_width(obj) / 2; - lv_coord_t hhalf = lv_obj_get_width(obj) / 2; - if(int1 == LV_RADIUS_CIRCLE) int1 = LV_MATH_MIN(whalf + 1, hhalf + 1); - if(int2 == LV_RADIUS_CIRCLE) int2 = LV_MATH_MIN(whalf + 1, hhalf + 1); - } + if(prop == LV_STYLE_RADIUS) { + if(v1._int == LV_RADIUS_CIRCLE || v2._int == LV_RADIUS_CIRCLE) { + lv_coord_t whalf = lv_obj_get_width(obj) / 2; + lv_coord_t hhalf = lv_obj_get_width(obj) / 2; + if(v1._int == LV_RADIUS_CIRCLE) v1._int = LV_MATH_MIN(whalf + 1, hhalf + 1); + if(v2._int == LV_RADIUS_CIRCLE) v2._int = LV_MATH_MIN(whalf + 1, hhalf + 1); } - - tr = _lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll)); - LV_ASSERT_MEM(tr); - if(tr == NULL) return; - tr->start_value._int = int1; - tr->end_value._int = int2; } - else if((prop & 0xF) < LV_STYLE_ID_OPA) { /*Color*/ - style_list->skip_trans = 1; - obj->state = prev_state; - lv_color_t c1 = _lv_obj_get_style_color(obj, part, prop); - obj->state = new_state; - lv_color_t c2 = _lv_obj_get_style_color(obj, part, prop); - style_list->skip_trans = 0; - if(c1.full == c2.full) return; - obj->state = prev_state; - c1 = _lv_obj_get_style_color(obj, part, prop); - obj->state = new_state; - _lv_style_set_color(style_trans, prop, c1); /*Be sure `trans_style` has a valid value */ - - tr = _lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll)); - LV_ASSERT_MEM(tr); - if(tr == NULL) return; - tr->start_value._color = c1; - tr->end_value._color = c2; - } - else if((prop & 0xF) < LV_STYLE_ID_PTR) { /*Opa*/ - style_list->skip_trans = 1; - obj->state = prev_state; - lv_opa_t o1 = _lv_obj_get_style_opa(obj, part, prop); - obj->state = new_state; - lv_opa_t o2 = _lv_obj_get_style_opa(obj, part, prop); - style_list->skip_trans = 0; - - if(o1 == o2) return; - - obj->state = prev_state; - o1 = _lv_obj_get_style_opa(obj, part, prop); - obj->state = new_state; - _lv_style_set_opa(style_trans, prop, o1); /*Be sure `trans_style` has a valid value */ - - tr = _lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll)); - LV_ASSERT_MEM(tr); - if(tr == NULL) return; - tr->start_value._opa = o1; - tr->end_value._opa = o2; - } - else { /*Ptr*/ - obj->state = prev_state; - style_list->skip_trans = 1; - const void * p1 = _lv_obj_get_style_ptr(obj, part, prop); - obj->state = new_state; - const void * p2 = _lv_obj_get_style_ptr(obj, part, prop); - style_list->skip_trans = 0; - - if(memcmp(&p1, &p2, sizeof(const void *)) == 0) return; - obj->state = prev_state; - p1 = _lv_obj_get_style_ptr(obj, part, prop); - obj->state = new_state; - _lv_style_set_ptr(style_trans, prop, p1); /*Be sure `trans_style` has a valid value */ - - tr = _lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll)); - LV_ASSERT_MEM(tr); - if(tr == NULL) return; - tr->start_value._ptr = p1; - tr->end_value._ptr = p2; - } + tr = _lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll)); + LV_ASSERT_MEM(tr); + if(tr == NULL) return; + tr->start_value = v1; + tr->end_value = v2; if(tr) { tr->obj = obj; @@ -1051,26 +608,27 @@ void _lv_obj_create_style_transition(lv_obj_t * obj, lv_style_property_t prop, u */ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2) { - _lv_style_state_cmp_t res = _LV_STYLE_STATE_CMP_SAME; - uint8_t part; - for(part = 0; part < _LV_OBJ_PART_MAX; part++) { - lv_style_list_t * style_list = _lv_obj_get_style_list(obj, part); - if(style_list == NULL) break; /*No more style lists*/ - - style_snapshot_t shot1; - style_snapshot_t shot2; - - obj->state = state1; - style_snapshot(obj, part, &shot1); - - obj->state = state2; - style_snapshot(obj, part, &shot2); - - _lv_style_state_cmp_t res_part = style_snapshot_compare(&shot1, &shot2); - if(res_part == _LV_STYLE_STATE_CMP_DIFF) return _LV_STYLE_STATE_CMP_DIFF; - if(res_part == _LV_STYLE_STATE_CMP_VISUAL_DIFF) res = _LV_STYLE_STATE_CMP_VISUAL_DIFF; - } - return res; + return _LV_STYLE_STATE_CMP_DIFF; +// _lv_style_state_cmp_t res = _LV_STYLE_STATE_CMP_SAME; +// uint8_t part; +// for(part = 0; part < _LV_OBJ_PART_MAX; part++) { +// lv_style_list_t * style_list = _lv_obj_get_style_list(obj, part); +// if(style_list == NULL) break; /*No more style lists*/ +// +// style_snapshot_t shot1; +// style_snapshot_t shot2; +// +// obj->state = state1; +// style_snapshot(obj, part, &shot1); +// +// obj->state = state2; +// style_snapshot(obj, part, &shot2); +// +// _lv_style_state_cmp_t res_part = style_snapshot_compare(&shot1, &shot2); +// if(res_part == _LV_STYLE_STATE_CMP_DIFF) return _LV_STYLE_STATE_CMP_DIFF; +// if(res_part == _LV_STYLE_STATE_CMP_VISUAL_DIFF) res = _LV_STYLE_STATE_CMP_VISUAL_DIFF; +// } +// return res; } /********************** @@ -1084,25 +642,18 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta */ static void report_style_change_core(void * style, lv_obj_t * obj) { - uint8_t part; - for(part = 0; part < 0xff; part++) { - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - if(list == NULL) break; + lv_obj_style_list_t * list = &obj->style_list; - uint8_t ci; - 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, part, LV_STYLE_PROP_ALL); - break; - } + uint32_t i; + for(i = 0; i < list->style_cnt; i++) { + if(style == NULL || list->styles[i].style == style) { + _lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); + break; } } - uint32_t i; for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { - lv_obj_t * child = lv_obj_get_child(obj, i); - report_style_change_core(style, child); + report_style_change_core(style, lv_obj_get_child(obj, i)); } } @@ -1134,7 +685,7 @@ static void refresh_children_style(lv_obj_t * obj) * @param prop a property or 0xFF to remove all properties * @param tr_limit delete transitions only "older" then this. `NULL` is not used */ -static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_style_trans_t * tr_limit) +static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, lv_style_trans_t * tr_limit) { lv_style_trans_t * tr; lv_style_trans_t * tr_prev; @@ -1148,13 +699,16 @@ static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv if(tr->obj == obj && (part == tr->part || part == 0xFF) && (prop == tr->prop || prop == 0xFF)) { /* Remove the transitioned property from trans. style * to allow changing it by normal styles*/ - lv_style_list_t * list = _lv_obj_get_style_list(tr->obj, tr->part); - lv_style_t * style_trans = _lv_style_list_get_transition_style(list); - lv_style_remove_prop(style_trans, tr->prop); + uint32_t i; + for(i = 0; i < obj->style_list.style_cnt; i++) { + if(obj->style_list.styles[i].is_trans && (part == 0xff || obj->style_list.styles[i].part == part)) { + lv_style_remove_prop(obj->style_list.styles[i].style, tr->prop); + lv_anim_del(tr, NULL); + _lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); + lv_mem_free(tr); + } + } - lv_anim_del(tr, NULL); - _lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); - lv_mem_free(tr); } tr = tr_prev; } @@ -1162,37 +716,62 @@ static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v) { - lv_style_list_t * list = _lv_obj_get_style_list(tr->obj, tr->part); - lv_style_t * style = _lv_style_list_get_transition_style(list); + lv_obj_style_list_t * list = &tr->obj->style_list; + + uint32_t i; + for(i = 0; i < list->style_cnt; i++) { + if(list->styles[i].is_trans == 0 || list->styles[i].part != tr->part) continue; + + lv_style_value_t value_final; + switch (tr->prop) { + case LV_STYLE_BORDER_SIDE: + case LV_STYLE_BORDER_POST: + case LV_STYLE_BG_IMG_MOSAIC: + case LV_STYLE_TRANSITION_PROP_1: + case LV_STYLE_TRANSITION_PROP_2: + case LV_STYLE_TRANSITION_PROP_3: + case LV_STYLE_TRANSITION_PROP_4: + case LV_STYLE_TRANSITION_PROP_5: + case LV_STYLE_TRANSITION_PROP_6: + case LV_STYLE_BG_BLEND_MODE: + case LV_STYLE_BORDER_BLEND_MODE: + case LV_STYLE_OUTLINE_BLEND_MODE: + case LV_STYLE_SHADOW_BLEND_MODE: + case LV_STYLE_TEXT_BLEND_MODE: + case LV_STYLE_LINE_BLEND_MODE: + if(v < 128) value_final._int = tr->start_value._int; + else value_final._int = tr->end_value._int; + break; + case LV_STYLE_TEXT_FONT: + case LV_STYLE_BG_IMG_SRC: + if(v < 128) value_final._ptr = tr->start_value._ptr; + else value_final._ptr = tr->end_value._ptr; + break; + + case LV_STYLE_BG_COLOR: + case LV_STYLE_BORDER_COLOR: + case LV_STYLE_TEXT_COLOR: + case LV_STYLE_SHADOW_COLOR: + case LV_STYLE_OUTLINE_COLOR: + case LV_STYLE_IMG_RECOLOR: + if(v <= 0) value_final._color = tr->start_value._color; + else if(v >= 255) value_final._color = tr->end_value._color; + else value_final._color = lv_color_mix(tr->end_value._color, tr->start_value._color, v); + break; + + default: + if(v == 0) value_final._int = tr->start_value._int; + else if(v == 255) value_final._int = tr->end_value._int; + else value_final._int = tr->start_value._int + ((int32_t)((int32_t)(tr->end_value._int - tr->start_value._int) * v) >> 8); + + break; + } + + lv_style_set_prop(list->styles[i].style, tr->prop, value_final); + _lv_obj_refresh_style(tr->obj, tr->prop); + break; - if((tr->prop & 0xF) < LV_STYLE_ID_COLOR) { /*Value*/ - lv_style_int_t x; - if(v == 0) x = tr->start_value._int; - else if(v == 255) x = tr->end_value._int; - else x = tr->start_value._int + ((int32_t)((int32_t)(tr->end_value._int - tr->start_value._int) * v) >> 8); - _lv_style_set_int(style, tr->prop, x); } - else if((tr->prop & 0xF) < LV_STYLE_ID_OPA) { /*Color*/ - lv_color_t x; - if(v <= 0) x = tr->start_value._color; - else if(v >= 255) x = tr->end_value._color; - else x = lv_color_mix(tr->end_value._color, tr->start_value._color, v); - _lv_style_set_color(style, tr->prop, x); - } - else if((tr->prop & 0xF) < LV_STYLE_ID_PTR) { /*Opa*/ - lv_opa_t x; - if(v <= 0) x = tr->start_value._opa; - else if(v >= 255) x = tr->end_value._opa; - else x = tr->start_value._opa + (((tr->end_value._opa - tr->start_value._opa) * v) >> 8); - _lv_style_set_opa(style, tr->prop, x); - } - else { - const void * x; - if(v < 128) x = tr->start_value._ptr; - else x = tr->end_value._ptr; - _lv_style_set_ptr(style, tr->prop, x); - } - _lv_obj_refresh_style(tr->obj, tr->part, tr->prop); } @@ -1200,29 +779,16 @@ static void trans_anim_start_cb(lv_anim_t * a) { lv_style_trans_t * tr = a->var; - lv_style_property_t prop_tmp = tr->prop; - - /*Start the animation from the current value*/ - if((prop_tmp & 0xF) < LV_STYLE_ID_COLOR) { /*Int*/ - tr->start_value._int = _lv_obj_get_style_int(tr->obj, tr->part, prop_tmp); - } - else if((prop_tmp & 0xF) < LV_STYLE_ID_OPA) { /*Color*/ - tr->start_value._color = _lv_obj_get_style_color(tr->obj, tr->part, prop_tmp); - } - else if((prop_tmp & 0xF) < LV_STYLE_ID_PTR) { /*Opa*/ - tr->start_value._opa = _lv_obj_get_style_opa(tr->obj, tr->part, prop_tmp); - } - else { /*Ptr*/ - tr->start_value._ptr = _lv_obj_get_style_ptr(tr->obj, tr->part, prop_tmp); - } + tr->start_value = lv_obj_get_style_prop(tr->obj, tr->part, tr->prop); /*Init prop to an invalid values to be sure `trans_del` won't delete this added `tr`*/ - tr->prop = 0; - /*Delete the relate transition if any*/ + lv_style_prop_t prop_tmp = tr->prop; + tr->prop = _LV_STYLE_PROP_INV; + + /*Delete the related transitions if any*/ trans_del(tr->obj, tr->part, prop_tmp, tr); tr->prop = prop_tmp; - } static void trans_anim_ready_cb(lv_anim_t * a) @@ -1237,13 +803,17 @@ static void trans_anim_ready_cb(lv_anim_t * a) _LV_LL_READ(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr_i) { if(tr_i != tr && tr_i->obj == tr->obj && tr_i->part == tr->part && tr_i->prop == tr->prop) { running = true; + break; } } if(!running) { - lv_style_list_t * list = _lv_obj_get_style_list(tr->obj, tr->part); - lv_style_t * style_trans = _lv_style_list_get_transition_style(list); - lv_style_remove_prop(style_trans, tr->prop); + uint32_t i; + for(i = 0; i < tr->obj->style_list.style_cnt; i++) { + if(tr->obj->style_list.styles[i].is_trans && tr->obj->style_list.styles[i].part == tr->part) { + lv_style_remove_prop(tr->obj->style_list.styles[i].style, tr->prop); + } + } } _lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); @@ -1252,274 +822,89 @@ static void trans_anim_ready_cb(lv_anim_t * a) static void fade_anim_cb(lv_obj_t * obj, lv_anim_value_t v) { - lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v); +// lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v); } static void fade_in_anim_ready(lv_anim_t * a) { - lv_style_remove_prop(_lv_obj_get_local_style(a->var, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); +// lv_style_remove_prop(_lv_obj_get_local_style(a->var, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); } #endif static void style_snapshot(lv_obj_t * obj, uint8_t part, style_snapshot_t * shot) { - _lv_obj_disable_style_caching(obj, true); - _lv_memset_00(shot, sizeof(style_snapshot_t)); - lv_draw_rect_dsc_init(&shot->rect); - lv_draw_label_dsc_init(&shot->label); - lv_draw_img_dsc_init(&shot->img); - lv_draw_line_dsc_init(&shot->line); - - lv_obj_init_draw_rect_dsc(obj, part, &shot->rect); - lv_obj_init_draw_label_dsc(obj, part, &shot->label); - lv_obj_init_draw_img_dsc(obj, part, &shot->img); - lv_obj_init_draw_line_dsc(obj, part, &shot->line); - - - shot->pad_top = lv_obj_get_style_pad_top(obj, part); - shot->pad_bottom = lv_obj_get_style_pad_bottom(obj, part); - shot->pad_right = lv_obj_get_style_pad_right(obj, part); - shot->pad_left = lv_obj_get_style_pad_left(obj, part); - shot->margin_top = lv_obj_get_style_margin_top(obj, part); - shot->margin_bottom = lv_obj_get_style_margin_bottom(obj, part); - shot->margin_left = lv_obj_get_style_margin_left(obj, part); - shot->margin_right = lv_obj_get_style_margin_right(obj, part); - shot->size = lv_obj_get_style_size(obj, part); - shot->transform_width = lv_obj_get_style_transform_width(obj, part); - shot->transform_height = lv_obj_get_style_transform_height(obj, part); - shot->transform_angle = lv_obj_get_style_transform_angle(obj, part); - shot->transform_zoom = lv_obj_get_style_transform_zoom(obj, part); - shot->scale_width = lv_obj_get_style_scale_width(obj, part); - shot->scale_border_width = lv_obj_get_style_scale_border_width(obj, part); - shot->scale_end_border_width = lv_obj_get_style_scale_end_border_width(obj, part); - shot->scale_end_line_width = lv_obj_get_style_scale_end_line_width(obj, part); - shot->scale_grad_color = lv_obj_get_style_scale_grad_color(obj, part); - shot->scale_end_color = lv_obj_get_style_scale_end_color(obj, part); - shot->opa_scale = lv_obj_get_style_opa_scale(obj, part); - shot->clip_corder = lv_obj_get_style_clip_corner(obj, part); - shot->border_post = lv_obj_get_style_border_post(obj, part); - - _lv_obj_disable_style_caching(obj, false); +// _lv_obj_disable_style_caching(obj, true); +// _lv_memset_00(shot, sizeof(style_snapshot_t)); +// lv_draw_rect_dsc_init(&shot->rect); +// lv_draw_label_dsc_init(&shot->label); +// lv_draw_img_dsc_init(&shot->img); +// lv_draw_line_dsc_init(&shot->line); +// +// lv_obj_init_draw_rect_dsc(obj, part, &shot->rect); +// lv_obj_init_draw_label_dsc(obj, part, &shot->label); +// lv_obj_init_draw_img_dsc(obj, part, &shot->img); +// lv_obj_init_draw_line_dsc(obj, part, &shot->line); +// +// +// shot->pad_top = lv_obj_get_style_pad_top(obj, part); +// shot->pad_bottom = lv_obj_get_style_pad_bottom(obj, part); +// shot->pad_right = lv_obj_get_style_pad_right(obj, part); +// shot->pad_left = lv_obj_get_style_pad_left(obj, part); +// shot->margin_top = lv_obj_get_style_margin_top(obj, part); +// shot->margin_bottom = lv_obj_get_style_margin_bottom(obj, part); +// shot->margin_left = lv_obj_get_style_margin_left(obj, part); +// shot->margin_right = lv_obj_get_style_margin_right(obj, part); +// shot->size = lv_obj_get_style_size(obj, part); +// shot->transform_width = lv_obj_get_style_transform_width(obj, part); +// shot->transform_height = lv_obj_get_style_transform_height(obj, part); +// shot->transform_angle = lv_obj_get_style_transform_angle(obj, part); +// shot->transform_zoom = lv_obj_get_style_transform_zoom(obj, part); +// shot->scale_width = lv_obj_get_style_scale_width(obj, part); +// shot->scale_border_width = lv_obj_get_style_scale_border_width(obj, part); +// shot->scale_end_border_width = lv_obj_get_style_scale_end_border_width(obj, part); +// shot->scale_end_line_width = lv_obj_get_style_scale_end_line_width(obj, part); +// shot->scale_grad_color = lv_obj_get_style_scale_grad_color(obj, part); +// shot->scale_end_color = lv_obj_get_style_scale_end_color(obj, part); +// shot->opa_scale = lv_obj_get_style_opa_scale(obj, part); +// shot->clip_corder = lv_obj_get_style_clip_corner(obj, part); +// shot->border_post = lv_obj_get_style_border_post(obj, part); +// +// _lv_obj_disable_style_caching(obj, false); } static _lv_style_state_cmp_t style_snapshot_compare(style_snapshot_t * shot1, style_snapshot_t * shot2) { - if(memcmp(shot1, shot2, sizeof(style_snapshot_t)) == 0) return _LV_STYLE_STATE_CMP_SAME; + return _LV_STYLE_STATE_CMP_DIFF; - - if(shot1->pad_top != shot2->pad_top) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->pad_bottom != shot2->pad_bottom) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->pad_left != shot2->pad_right) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->pad_right != shot2->pad_right) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->pad_top != shot2->pad_top) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->margin_top != shot2->margin_top) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->margin_bottom != shot2->margin_bottom) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->margin_left != shot2->margin_left) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->margin_right != shot2->margin_right) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->margin_top != shot2->margin_top) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->transform_width != shot2->transform_width) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->transform_height != shot2->transform_height) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->transform_angle != shot2->transform_angle) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->transform_zoom != shot2->transform_zoom) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->rect.outline_width != shot2->rect.outline_width) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->rect.outline_pad != shot2->rect.outline_pad) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->rect.outline_opa != shot2->rect.outline_opa) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->rect.value_font != shot2->rect.value_font) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->rect.value_align != shot2->rect.value_align) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->rect.value_font != shot2->rect.value_font) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->rect.shadow_spread != shot2->rect.shadow_spread) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->rect.shadow_width != shot2->rect.shadow_width) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->rect.shadow_ofs_x != shot2->rect.shadow_ofs_x) return _LV_STYLE_STATE_CMP_DIFF; - if(shot1->rect.shadow_ofs_y != shot2->rect.shadow_ofs_y) return _LV_STYLE_STATE_CMP_DIFF; - - /*If not returned earlier its just a visual difference, a simple redraw is enough*/ - return _LV_STYLE_STATE_CMP_VISUAL_DIFF; +// if(memcmp(shot1, shot2, sizeof(style_snapshot_t)) == 0) return _LV_STYLE_STATE_CMP_SAME; +// +// +// if(shot1->pad_top != shot2->pad_top) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->pad_bottom != shot2->pad_bottom) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->pad_left != shot2->pad_right) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->pad_right != shot2->pad_right) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->pad_top != shot2->pad_top) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->margin_top != shot2->margin_top) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->margin_bottom != shot2->margin_bottom) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->margin_left != shot2->margin_left) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->margin_right != shot2->margin_right) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->margin_top != shot2->margin_top) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->transform_width != shot2->transform_width) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->transform_height != shot2->transform_height) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->transform_angle != shot2->transform_angle) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->transform_zoom != shot2->transform_zoom) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->rect.outline_width != shot2->rect.outline_width) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->rect.outline_pad != shot2->rect.outline_pad) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->rect.outline_opa != shot2->rect.outline_opa) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->rect.value_font != shot2->rect.value_font) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->rect.value_align != shot2->rect.value_align) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->rect.value_font != shot2->rect.value_font) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->rect.shadow_spread != shot2->rect.shadow_spread) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->rect.shadow_width != shot2->rect.shadow_width) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->rect.shadow_ofs_x != shot2->rect.shadow_ofs_x) return _LV_STYLE_STATE_CMP_DIFF; +// if(shot1->rect.shadow_ofs_y != shot2->rect.shadow_ofs_y) return _LV_STYLE_STATE_CMP_DIFF; +// +// /*If not returned earlier its just a visual difference, a simple redraw is enough*/ +// return _LV_STYLE_STATE_CMP_VISUAL_DIFF; } - - -#if LV_STYLE_CACHE_LEVEL >= 1 - -static bool style_prop_is_cacheable(lv_style_property_t prop) -{ - switch(prop) { - case LV_STYLE_PROP_ALL: - case LV_STYLE_CLIP_CORNER: - case LV_STYLE_TEXT_LETTER_SPACE: - case LV_STYLE_TEXT_LINE_SPACE: - case LV_STYLE_TEXT_FONT: - case LV_STYLE_TEXT_DECOR: - 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_OUTLINE_WIDTH: - case LV_STYLE_RADIUS: - case LV_STYLE_SHADOW_WIDTH: - case LV_STYLE_OPA_SCALE: - case LV_STYLE_BG_OPA: - case LV_STYLE_BORDER_SIDE: - case LV_STYLE_BORDER_POST: - case LV_STYLE_IMAGE_RECOLOR_OPA: - case LV_STYLE_VALUE_STR: - case LV_STYLE_PATTERN_IMAGE: - case LV_STYLE_PAD_TOP: - case LV_STYLE_PAD_BOTTOM: - case LV_STYLE_PAD_LEFT: - case LV_STYLE_PAD_RIGHT: - case LV_STYLE_MARGIN_TOP: - case LV_STYLE_MARGIN_BOTTOM: - case LV_STYLE_MARGIN_LEFT: - case LV_STYLE_MARGIN_RIGHT: - case LV_STYLE_BG_BLEND_MODE: - case LV_STYLE_BORDER_BLEND_MODE: - case LV_STYLE_IMAGE_BLEND_MODE: - case LV_STYLE_LINE_BLEND_MODE: - case LV_STYLE_OUTLINE_BLEND_MODE: - case LV_STYLE_PATTERN_BLEND_MODE: - case LV_STYLE_SHADOW_BLEND_MODE: - case LV_STYLE_TEXT_BLEND_MODE: - case LV_STYLE_VALUE_BLEND_MODE: - return true; - break; - default: - 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) -{ - if(style_prop_is_cacheable(prop) == false) return; - - lv_style_list_t * list = _lv_obj_get_style_list(obj, part); - - bool ignore_cache_ori = list->ignore_cache; - list->ignore_cache = 1; - -#if LV_USE_OPA_SCALE - list->opa_scale_cover = lv_obj_get_style_opa_scale(obj, part) == LV_OPA_COVER ? 1 : 0; -#else - list->opa_scale_cover = 1; -#endif - list->text_decor_none = lv_obj_get_style_text_decor(obj, part) == LV_TEXT_DECOR_NONE ? 1 : 0; - list->text_font_normal = lv_obj_get_style_text_font(obj, part) == LV_THEME_DEFAULT_FONT_NORMAL ? 1 : 0; - - list->text_space_zero = 1; - if(lv_obj_get_style_text_letter_space(obj, part) != 0 || - lv_obj_get_style_text_line_space(obj, part) != 0) { - list->text_space_zero = 0; - } - - - lv_opa_t bg_opa = lv_obj_get_style_bg_opa(obj, part); - list->bg_opa_transp = bg_opa == LV_OPA_TRANSP ? 1 : 0; - list->bg_opa_cover = bg_opa == LV_OPA_COVER ? 1 : 0; - - list->border_width_zero = lv_obj_get_style_border_width(obj, part) == 0 ? 1 : 0; - list->border_side_full = lv_obj_get_style_border_side(obj, part) == LV_BORDER_SIDE_FULL ? 1 : 0; - list->border_post_off = lv_obj_get_style_border_post(obj, part) == 0 ? 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->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->radius_zero = lv_obj_get_style_radius(obj, part) == 0 ? 1 : 0; - list->shadow_width_zero = lv_obj_get_style_shadow_width(obj, part) == 0 ? 1 : 0; - list->value_txt_str = lv_obj_get_style_value_str(obj, part) == NULL ? 1 : 0; - - - list->transform_all_zero = 1; - if(lv_obj_get_style_transform_angle(obj, part) != 0 || - lv_obj_get_style_transform_width(obj, part) != 0 || - lv_obj_get_style_transform_height(obj, part) != 0 || - lv_obj_get_style_transform_zoom(obj, part) != LV_IMG_ZOOM_NONE) { - list->transform_all_zero = 0; - } - - list->pad_all_zero = 1; - lv_style_int_t pad_top = lv_obj_get_style_pad_top(obj, part); - lv_style_int_t pad_left = lv_obj_get_style_pad_left(obj, part); -#if LV_STYLE_CACHE_LEVEL >= 2 - list->pad_top = 0; - list->pad_left = 0; - if(pad_top > 0 && pad_top <= _LV_STLYE_CAHCE_INT_MAX) list->pad_top = pad_top; - if(pad_left > 0 && pad_left <= _LV_STLYE_CAHCE_INT_MAX) list->pad_left = pad_left; -#endif - if(pad_top != 0 || - pad_left != 0 || - lv_obj_get_style_pad_bottom(obj, part) != 0 || - lv_obj_get_style_pad_right(obj, part) != 0) { - list->pad_all_zero = 0; - } - - list->margin_all_zero = 1; - if(lv_obj_get_style_margin_top(obj, part) != 0 || - lv_obj_get_style_margin_bottom(obj, part) != 0 || - lv_obj_get_style_margin_left(obj, part) != 0 || - lv_obj_get_style_margin_right(obj, part) != 0) { - list->margin_all_zero = 0; - } - - list->blend_mode_all_normal = 1; -#if LV_USE_BLEND_MODES - if(lv_obj_get_style_bg_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL || - lv_obj_get_style_border_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL || - lv_obj_get_style_pattern_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL || - lv_obj_get_style_outline_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL || - lv_obj_get_style_value_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL || - lv_obj_get_style_text_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL || - lv_obj_get_style_line_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL || - lv_obj_get_style_image_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL || - lv_obj_get_style_shadow_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL) { - list->blend_mode_all_normal = 0; - } -#endif - list->ignore_cache = ignore_cache_ori; - list->valid_cache = 1; -} - -/** - * 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_MAX; 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_cover = lv_obj_get_style_opa_scale(obj, part) == LV_OPA_COVER ? 1 : 0; - list->text_decor_none = lv_obj_get_style_text_decor(obj, part) == LV_TEXT_DECOR_NONE ? 1 : 0; - list->text_font_normal = lv_obj_get_style_text_font(obj, part) == lv_theme_get_font_normal() ? 1 : 0; - list->img_recolor_opa_transp = lv_obj_get_style_image_recolor_opa(obj, part) == LV_OPA_TRANSP ? 1 : 0; - - list->text_space_zero = 1; - if(lv_obj_get_style_text_letter_space(obj, part) != 0 || - lv_obj_get_style_text_line_space(obj, part) != 0) { - list->text_space_zero = 0; - } - - list->ignore_cache = ignore_cache_ori; - } - - uint32_t i; - for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { - lv_obj_t * child = lv_obj_get_child(obj, i); - update_style_cache_children(child); - } - -} - -#endif /*LV_STYLE_CACHE_LEVEL >= 1*/ - diff --git a/src/lv_core/lv_obj_style.h b/src/lv_core/lv_obj_style.h index 83310533f..7bef09817 100644 --- a/src/lv_core/lv_obj_style.h +++ b/src/lv_core/lv_obj_style.h @@ -33,11 +33,24 @@ typedef enum { _LV_STYLE_STATE_CMP_DIFF, /*There are larger differences, the objects need to ne notfied*/ } _lv_style_state_cmp_t; +typedef struct { + lv_style_t * style; + uint16_t state; + uint8_t part; + uint8_t is_local :1; + uint8_t is_trans :1; +}lv_obj_style_t; + +typedef struct { + lv_obj_style_t * styles; + uint8_t style_cnt; + uint8_t skip_trans :1; +}lv_obj_style_list_t; + /********************** * GLOBAL PROTOTYPES **********************/ - /** * Initialize the object related style manager module. * Called by LVGL in `lv_init()` @@ -51,7 +64,7 @@ void _lv_obj_style_init(void); * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` * @param style pointer to a style to add (Only its pointer will be saved) */ -void lv_obj_add_style(lv_obj_t * obj, uint8_t part, lv_style_t * style); +void lv_obj_add_style(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_t * style); /** * Remove a style from the style list of an object. @@ -60,7 +73,7 @@ void lv_obj_add_style(lv_obj_t * obj, uint8_t part, lv_style_t * style); * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` * @param style pointer to a style to remove */ -void lv_obj_remove_style(lv_obj_t * obj, uint8_t part, lv_style_t * style); +void lv_obj_remove_style(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_t * style); /** * Reset a style to the default (empty) state. @@ -70,7 +83,7 @@ void lv_obj_remove_style(lv_obj_t * obj, uint8_t part, lv_style_t * style); * @param part the part of the object which style list should be reseted. * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` */ -void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part); +void lv_obj_remove_all_styles(struct _lv_obj_t * obj); /** * Notify all object if a style is modified @@ -79,18 +92,6 @@ void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part); */ void lv_obj_report_style_change(lv_style_t * style); -/** - * Remove a local style property from a part of an object with a given state. - * @param obj pointer to an object - * @param part the part of the object which style property should be removed. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @return true: the property was found and removed; false: the property was not found - */ -bool lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_property_t prop); - - #if LV_USE_ANIMATION /** @@ -99,7 +100,7 @@ bool lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_prope * @param time duration of the animation [ms] * @param delay wait before the animation starts [ms] */ -void lv_obj_fade_in(lv_obj_t * obj, uint32_t time, uint32_t delay); +void lv_obj_fade_in(struct _lv_obj_t * obj, uint32_t time, uint32_t delay); /** * Fade out (from fully cover to transparent) an object and all its children using an `opa_scale` animation. @@ -107,175 +108,11 @@ void lv_obj_fade_in(lv_obj_t * obj, uint32_t time, uint32_t delay); * @param time duration of the animation [ms] * @param delay wait before the animation starts [ms] */ -void lv_obj_fade_out(lv_obj_t * obj, uint32_t time, uint32_t delay); +void lv_obj_fade_out(struct _lv_obj_t * obj, uint32_t time, uint32_t delay); #endif -/** - * Get the style list of part of an object - * @param obj pointer to an object - * @param part the part of the object. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @return pointer to the style list - */ -lv_style_list_t * _lv_obj_get_style_list(const lv_obj_t * obj, uint8_t part); - -/** - * Enable/disable the use of style cache for an object - * @param obj pointer to an object - * @param dis true: disable; false: enable (re-enable) - */ -void _lv_obj_disable_style_caching(lv_obj_t * obj, bool dis); - - -#if LV_STYLE_CACHE_LEVEL > 0 - -/** - * 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, lv_style_property_t prop); -#endif - -/** - * Get a style property of a part of an object in the object's current state. - * If there is a running transitions it is taken into account - * @param obj pointer to an object - * @param part the part of the object which style property should be get. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop the property to get. E.g. `LV_STYLE_BORDER_WIDTH`. - * The state of the object will be added internally - * @return the value of the property of the given part in the current state. - * If the property is not found a default value will be returned. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_width()` - * @note for performance reasons it's not checked if the property really has integer type - */ -lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop); - -/** - * Get a style property of a part of an object in the object's current state. - * If there is a running transitions it is taken into account - * @param obj pointer to an object - * @param part the part of the object which style property should be get. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop the property to get. E.g. `LV_STYLE_BORDER_COLOR`. - * The state of the object will be added internally - * @return the value of the property of the given part in the current state. - * If the property is not found a default value will be returned. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_color()` - * @note for performance reasons it's not checked if the property really has color type - */ -lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop); - -/** - * Get a style property of a part of an object in the object's current state. - * If there is a running transitions it is taken into account - * @param obj pointer to an object - * @param part the part of the object which style property should be get. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop the property to get. E.g. `LV_STYLE_BORDER_OPA`. - * The state of the object will be added internally - * @return the value of the property of the given part in the current state. - * If the property is not found a default value will be returned. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has opacity type - */ -lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop); - -/** - * Get a style property of a part of an object in the object's current state. - * If there is a running transitions it is taken into account - * @param obj pointer to an object - * @param part the part of the object which style property should be get. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop the property to get. E.g. `LV_STYLE_TEXT_FONT`. - * The state of the object will be added internally - * @return the value of the property of the given part in the current state. - * If the property is not found a default value will be returned. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has pointer type - */ -const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop); - -/** - * Get the local style of a part of an object. - * @param obj pointer to an object - * @param part the part of the object which style property should be set. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @return pointer to the local style if exists else `NULL`. - */ -lv_style_t * _lv_obj_get_local_style(lv_obj_t * obj, uint8_t part); - -/** - * Set a local style property of a part of an object in a given state. - * @param obj pointer to an object - * @param part the part of the object which style property should be set. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param the value to set - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_width()` - * @note for performance reasons it's not checked if the property really has integer type - */ -void _lv_obj_set_style_local_int(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_style_int_t value); - -/** - * Set a local style property of a part of an object in a given state. - * @param obj pointer to an object - * @param part the part of the object which style property should be set. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_COLOR | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param the value to set - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has color type - */ -void _lv_obj_set_style_local_color(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_color_t color); - -/** - * Set a local style property of a part of an object in a given state. - * @param obj pointer to an object - * @param part the part of the object which style property should be set. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_OPA | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param the value to set - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has opacity type - */ -void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_opa_t opa); - -/** - * Set a local style property of a part of an object in a given state. - * @param obj pointer to an object - * @param part the part of the object which style property should be set. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_obj_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has pointer type - */ -void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, const void * value); - -/** - * Reset a style to the default (empty) state. - * Release all used memories and cancel pending related transitions. - * Typically used in `LV_SIGNAL_CLEAN_UP. - * @param obj pointer to an object - * @param part the part of the object which style list should be reseted. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - */ -void _lv_obj_reset_style_list_no_refr(lv_obj_t * obj, uint8_t part); +lv_style_value_t lv_obj_get_style_prop(const struct _lv_obj_t * obj, uint8_t part, lv_style_prop_t prop); /** * Notify an object and its children about its style is modified @@ -283,13 +120,14 @@ void _lv_obj_reset_style_list_no_refr(lv_obj_t * obj, uint8_t part); * @param part the part of the object which style property should be refreshed. * @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, uint8_t part, lv_style_property_t prop); +void _lv_obj_refresh_style(struct _lv_obj_t * obj, lv_style_prop_t prop); /** * Remove all transitions from an object * @param obj pointer to an object */ -void _lv_obj_remove_style_trans(lv_obj_t * obj); +void _lv_obj_remove_style_trans(struct _lv_obj_t * obj); +void lv_obj_set_style_prop(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_prop_t prop, lv_style_value_t value); #if LV_USE_ANIMATION @@ -306,8 +144,8 @@ void _lv_obj_remove_style_trans(lv_obj_t * obj); * @param path the path of the transition * @return pointer to the allocated `the transaction` variable or `NULL` if no transition created */ -void _lv_obj_create_style_transition(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, - lv_state_t new_state, uint32_t time, uint32_t delay, lv_anim_path_t * path); +void _lv_obj_create_style_transition(struct _lv_obj_t * obj, lv_style_prop_t prop, uint8_t part, lv_state_t prev_state, + lv_state_t new_state, uint32_t time, uint32_t delay, const lv_anim_path_t * path); #endif @@ -318,7 +156,238 @@ void _lv_obj_create_style_transition(lv_obj_t * obj, lv_style_property_t prop, u * @param state2 an other state * @return an element of `_lv_style_state_cmp_t` */ -_lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2); +_lv_style_state_cmp_t _lv_obj_style_state_compare(struct _lv_obj_t * obj, lv_state_t state1, lv_state_t state2); + + +static inline void lv_obj_set_style_bg_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) +{ + lv_style_value_t v; + v._color = value; + lv_obj_set_style_prop(obj, part, state, LV_STYLE_BG_COLOR, v); +} + +static inline void lv_obj_set_style_bg_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) +{ + lv_style_value_t v; + v._int = value; + lv_obj_set_style_prop(obj, part, state, LV_STYLE_BG_OPA, v); +} + +/********************* + * OBJ STYLE GET + *********************/ +static inline lv_coord_t lv_obj_get_style_radius(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_RADIUS); return v._int; } + +static inline bool lv_obj_get_style_clip_corner(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CLIP_CORNER); return v._int; } + +static inline lv_coord_t lv_obj_get_style_transform_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_WIDTH); return v._int; } + +static inline lv_coord_t lv_obj_get_style_transform_height(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_HEIGHT); return v._int; } + +static inline lv_coord_t lv_obj_get_style_transform_zoom(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ZOOM); return v._int; } + +static inline lv_coord_t lv_obj_get_style_transform_angle(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ANGLE); return v._int; } + +static inline lv_opa_t lv_obj_get_style_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA); return v._int; } + +static inline lv_coord_t lv_obj_get_style_pad_top(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_TOP); return v._int; } + +static inline lv_coord_t lv_obj_get_style_pad_bottom(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_BOTTOM); return v._int; } + +static inline lv_coord_t lv_obj_get_style_pad_left(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_LEFT); return v._int; } + +static inline lv_coord_t lv_obj_get_style_pad_right(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_RIGHT); return v._int; } + +static inline lv_coord_t lv_obj_get_style_margin_top(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MARGIN_TOP); return v._int; } + +static inline lv_coord_t lv_obj_get_style_margin_bottom(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MARGIN_BOTTOM); return v._int; } + +static inline lv_coord_t lv_obj_get_style_margin_left(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MARGIN_LEFT); return v._int; } + +static inline lv_coord_t lv_obj_get_style_margin_right(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MARGIN_RIGHT); return v._int; } + +static inline lv_color_t lv_obj_get_style_bg_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR); return v._color; } + +static inline lv_opa_t lv_obj_get_style_bg_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_OPA); return v._int; } + +static inline lv_color_t lv_obj_get_style_bg_grad_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR); return v._color; } + +static inline lv_grad_dir_t lv_obj_get_style_bg_grad_dir(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_DIR); return v._int; } + +static inline lv_blend_mode_t lv_obj_get_style_bg_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_BLEND_MODE); return v._int; } + +static inline lv_coord_t lv_obj_get_style_bg_main_stop(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_MAIN_STOP); return v._int; } + +static inline lv_coord_t lv_obj_get_style_bg_grad_stop(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_STOP); return v._int; } + +static inline lv_color_t lv_obj_get_style_border_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR); return v._color; } + +static inline lv_opa_t lv_obj_get_style_border_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_OPA); return v._int; } + +static inline lv_coord_t lv_obj_get_style_border_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_WIDTH); return v._int; } + +static inline lv_border_side_t lv_obj_get_style_border_side(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_SIDE); return v._int; } + +static inline bool lv_obj_get_style_border_post(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_POST); return v._int; } + +static inline lv_blend_mode_t lv_obj_get_style_border_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_BLEND_MODE); return v._int; } + +static inline lv_color_t lv_obj_get_style_text_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR); return v._color; } + +static inline lv_opa_t lv_obj_get_style_text_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_OPA); return v._int; } + +static inline const lv_font_t * lv_obj_get_style_text_font(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_FONT); return v._ptr; } + +static inline lv_coord_t lv_obj_get_style_text_letter_space(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LETTER_SPACE); return v._int; } + +static inline lv_coord_t lv_obj_get_style_text_line_space(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LINE_SPACE); return v._int; } + +static inline lv_text_decor_t lv_obj_get_style_text_decor(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_DECOR); return v._int; } + +static inline lv_blend_mode_t lv_obj_get_style_text_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_BLEND_MODE); return v._int; } + +static inline lv_opa_t lv_obj_get_style_img_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_OPA); return v._int; } + +static inline lv_blend_mode_t lv_obj_get_style_img_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_BLEND_MODE); return v._int; } + +static inline lv_color_t lv_obj_get_style_img_recolor(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR); return v._color; } + +static inline lv_opa_t lv_obj_get_style_img_recolor_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR_OPA); return v._int; } + +static inline lv_coord_t lv_obj_get_style_outline_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_WIDTH); return v._int; } + +static inline lv_color_t lv_obj_get_style_outline_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR); return v._color; } + +static inline lv_opa_t lv_obj_get_style_outline_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_OPA); return v._int; } + +static inline lv_coord_t lv_obj_get_style_outline_pad(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_PAD); return v._int; } + +static inline lv_blend_mode_t lv_obj_get_style_outline_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_BLEND_MODE); return v._int; } + +static inline lv_coord_t lv_obj_get_style_shadow_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_WIDTH); return v._int; } + +static inline lv_coord_t lv_obj_get_style_shadow_ofs_x(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFS_X); return v._int; } + +static inline lv_coord_t lv_obj_get_style_shadow_ofs_y(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFS_Y); return v._int; } + +static inline lv_coord_t lv_obj_get_style_shadow_spread(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_SPREAD); return v._int; } + +static inline lv_blend_mode_t lv_obj_get_style_shadow_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_BLEND_MODE); return v._int; } + +static inline lv_color_t lv_obj_get_style_shadow_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR); return v._color; } + +static inline lv_opa_t lv_obj_get_style_shadow_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OPA); return v._int; } + +static inline lv_coord_t lv_obj_get_style_line_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_WIDTH); return v._int; } + +static inline lv_blend_mode_t lv_obj_get_style_line_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_BLEND_MODE); return v._int; } + +static inline lv_coord_t lv_obj_get_style_line_dash_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_WIDTH); return v._int; } + +static inline lv_coord_t lv_obj_get_style_line_dash_gap(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_GAP); return v._int; } + +static inline lv_coord_t lv_obj_get_style_line_rounded(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_ROUNDED); return v._int; } + +static inline lv_color_t lv_obj_get_style_line_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR); return v._color; } + +static inline lv_opa_t lv_obj_get_style_line_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_OPA); return v._int; } + +static inline const char * lv_obj_get_style_content_text(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_TEXT); return v._ptr; } + +static inline lv_align_t lv_obj_get_style_content_align(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_ALIGN); return v._int; } + +static inline lv_coord_t lv_obj_get_style_content_ofs_x(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_X); return v._int; } + +static inline lv_coord_t lv_obj_get_style_content_ofs_y(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_Y); return v._int; } + +static inline uint16_t lv_obj_get_style_transition_time(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION_TIME); return v._int; } + +static inline uint16_t lv_obj_get_style_transition_delay(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION_DELAY); return v._int; } + +static inline const lv_anim_path_t * lv_obj_get_style_transition_path(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION_PATH); return v._ptr; } + +static inline lv_style_prop_t lv_obj_get_style_transition_prop_1(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION_PROP_1); return v._int; } + +static inline lv_style_prop_t lv_obj_get_style_transition_prop_2(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION_PROP_2); return v._int; } + +static inline lv_style_prop_t lv_obj_get_style_transition_prop_3(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION_PROP_3); return v._int; } + +static inline lv_style_prop_t lv_obj_get_style_transition_prop_4(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION_PROP_4); return v._int; } + +static inline lv_style_prop_t lv_obj_get_style_transition_prop_5(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION_PROP_5); return v._int; } + +static inline lv_style_prop_t lv_obj_get_style_transition_prop_6(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION_PROP_6); return v._int; } @@ -326,297 +395,6 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta * MACROS **********************/ - -/** - * Macro to declare the most important style set/get API functions. - * - * Get the value of a style property from an object in the object's current state - * ----------------------------------------------------------------------------- - * - Get the value of a style property from an object in the object's current state. - * - Transition animation is taken into account. - * - If the property is not set in the object's styles check the parent(s) if the property can be inherited - * - If still not found return a default value. - * - For example: - * `lv_style_int_t w = lv_obj_get_style_border_width(btn1, LV_BTN_PART_MAIN);` - * - * Set a local style property for an object in a given state - * --------------------------------------------------------- - * - For example: - * `lv_obj_set_style_local_border_width(btn1, LV_BTN_PART_MAIN, LV_STATE_PRESSED, 2);` - * - * Get a local style property's value of an object in a given state - * ---------------------------------------------------------------- - * - Return the best matching property in the given state. - * - E.g. if `state` parameter is LV_STATE_PRESSED | LV_STATE_CHECKED` but the property defined only in - * `LV_STATE_PRESSED` and `LV_STATE_DEFAULT` the best matching state is `LV_STATE_PRESSED` - * (because it has higher precedence) and it will be returned. - * - If the property is not found even in `LV_STATE_DEFAULT` `-1` is returned. - * - For example: - * `//Type of result should be lv_style_int_t/lv_opa_t/lv_color_t/const void * according to the type of the property` - * `lv_style_int_t result;` - * `lv_obj_get_style_local_border_width(btn1, LV_BTN_PART_MAIN, LV_STATE_PRESSED, &result);` - * `if(weight > 0) ...the property is found and loaded into result...` - * - * Get the value from a style in a given state - * ------------------------------------------- - * - The same rules applies to the return value then for "lv_obj_get_style_local_...()" above - * - For example - * `int16_t weight = lv_style_get_border_width(&style1, LV_STATE_PRESSED, &result);` - * `if(weight > 0) ...the property is found and loaded into result...` - - * Set a value in a style in a given state - * --------------------------------------- - * - For example - * `lv_style_set_border_width(&style1, LV_STATE_PRESSED, 2);` - */ - -#define _OBJ_GET_STYLE_scalar(prop_name, func_name, value_type, style_type) \ - static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \ - { \ - return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \ - } - -#define _OBJ_GET_STYLE_nonscalar(prop_name, func_name, value_type, style_type) \ - static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \ - { \ - return _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \ - } - -#define _OBJ_SET_STYLE_LOCAL_scalar(prop_name, func_name, value_type, style_type) \ - static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \ - { \ - _lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \ - } - -#define _OBJ_SET_STYLE_LOCAL_nonscalar(prop_name, func_name, value_type, style_type) \ - static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \ - { \ - _lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \ - } - -#define _OBJ_SET_STYLE_scalar(prop_name, func_name, value_type, style_type) \ - static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \ - { \ - _lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \ - } - -#define _OBJ_SET_STYLE_nonscalar(prop_name, func_name, value_type, style_type) \ - static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \ - { \ - _lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \ - } - -#define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type, scalar) \ - _OBJ_GET_STYLE_##scalar(prop_name, func_name, value_type, style_type) \ - _OBJ_SET_STYLE_LOCAL_##scalar(prop_name, func_name, value_type, style_type) \ - _OBJ_SET_STYLE_##scalar(prop_name, func_name, value_type, style_type) - -_LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(CLIP_CORNER, clip_corner, bool, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SIZE, size, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_WIDTH, transform_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_HEIGHT, transform_height, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_ANGLE, transform_angle, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_ZOOM, transform_zoom, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(OPA_SCALE, opa_scale, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_TOP, pad_top, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_BOTTOM, pad_bottom, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_LEFT, pad_left, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_RIGHT, pad_right, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_TOP, margin_top, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_BOTTOM, margin_bottom, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_LEFT, margin_left, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_RIGHT, margin_right, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BG_BLEND_MODE, bg_blend_mode, lv_blend_mode_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BG_MAIN_STOP, bg_main_stop, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_STOP, bg_grad_stop, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_DIR, bg_grad_dir, lv_grad_dir_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BG_COLOR, bg_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_COLOR, bg_grad_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BG_OPA, bg_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_WIDTH, border_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_SIDE, border_side, lv_border_side_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_BLEND_MODE, border_blend_mode, lv_blend_mode_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_POST, border_post, bool, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_COLOR, border_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_OPA, border_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_WIDTH, outline_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_PAD, outline_pad, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_BLEND_MODE, outline_blend_mode, lv_blend_mode_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_COLOR, outline_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_OPA, outline_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_WIDTH, shadow_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OFS_X, shadow_ofs_x, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OFS_Y, shadow_ofs_y, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_SPREAD, shadow_spread, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_BLEND_MODE, shadow_blend_mode, lv_blend_mode_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_COLOR, shadow_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OPA, shadow_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_REPEAT, pattern_repeat, bool, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_BLEND_MODE, pattern_blend_mode, lv_blend_mode_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_RECOLOR, pattern_recolor, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_OPA, pattern_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_RECOLOR_OPA, pattern_recolor_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_IMAGE, pattern_image, const void *, _ptr, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_LETTER_SPACE, value_letter_space, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_LINE_SPACE, value_line_space, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_BLEND_MODE, value_blend_mode, lv_blend_mode_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OFS_X, value_ofs_x, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OFS_Y, value_ofs_y, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_ALIGN, value_align, lv_align_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_COLOR, value_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OPA, value_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t *, _ptr, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char *, _ptr, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LETTER_SPACE, text_letter_space, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LINE_SPACE, text_line_space, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_DECOR, text_decor, lv_text_decor_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_BLEND_MODE, text_blend_mode, lv_blend_mode_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_COLOR, text_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_COLOR, text_sel_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_BG_COLOR, text_sel_bg_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_OPA, text_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t *, _ptr, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_WIDTH, line_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_BLEND_MODE, line_blend_mode, lv_blend_mode_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_WIDTH, line_dash_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_GAP, line_dash_gap, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_ROUNDED, line_rounded, bool, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_COLOR, line_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_OPA, line_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_BLEND_MODE, image_blend_mode, lv_blend_mode_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR, image_recolor, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_OPA, image_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR_OPA, image_recolor_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_TIME, transition_time, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_DELAY, transition_delay, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_1, transition_prop_1, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_2, transition_prop_2, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_3, transition_prop_3, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_4, transition_prop_4, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_5, transition_prop_5, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_6, transition_prop_6, lv_style_int_t, _int, scalar) -#if LV_USE_ANIMATION -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_t *, _ptr, scalar) -#else -/*For compatibility*/ -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, const void *, _ptr, scalar) -#endif -_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_WIDTH, scale_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_BORDER_WIDTH, scale_border_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_BORDER_WIDTH, scale_end_border_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_LINE_WIDTH, scale_end_line_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_GRAD_COLOR, scale_grad_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_COLOR, scale_end_color, lv_color_t, _color, nonscalar) - -_LV_OBJ_STYLE_SET_GET_DECLARE(SCROLLBAR_TICKNESS, scrollbar_tickness, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCROLLBAR_SPACE_SIDE, scrollbar_space_side, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCROLLBAR_SPACE_END, scrollbar_space_end, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCROLLBAR_RADIUS, scrollbar_radius, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCROLLBAR_BORDER_WIDTH, scrollbar_border_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCROLLBAR_BG_COLOR, scrollbar_bg_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCROLLBAR_BORDER_COLOR, scrollbar_border_color, lv_color_t, _color, nonscalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCROLLBAR_BG_OPA, scrollbar_bg_opa, lv_opa_t, _opa, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SCROLLBAR_BORDER_OPA, scrollbar_border_opa, lv_opa_t, _opa, scalar) - -#undef _LV_OBJ_STYLE_SET_GET_DECLARE - - -static inline void lv_obj_set_style_local_pad_all(lv_obj_t * obj, uint8_t part, lv_state_t state, lv_style_int_t value) -{ - lv_obj_set_style_local_pad_top(obj, part, state, value); - lv_obj_set_style_local_pad_bottom(obj, part, state, value); - lv_obj_set_style_local_pad_left(obj, part, state, value); - lv_obj_set_style_local_pad_right(obj, part, state, value); -} - - -static inline void lv_style_set_pad_all(lv_style_t * style, lv_state_t state, lv_style_int_t value) -{ - lv_style_set_pad_top(style, state, value); - lv_style_set_pad_bottom(style, state, value); - lv_style_set_pad_left(style, state, value); - lv_style_set_pad_right(style, state, value); -} - - -static inline void lv_obj_set_style_local_pad_hor(lv_obj_t * obj, uint8_t part, lv_state_t state, lv_style_int_t value) -{ - lv_obj_set_style_local_pad_left(obj, part, state, value); - lv_obj_set_style_local_pad_right(obj, part, state, value); -} - - -static inline void lv_style_set_pad_hor(lv_style_t * style, lv_state_t state, lv_style_int_t value) -{ - lv_style_set_pad_left(style, state, value); - lv_style_set_pad_right(style, state, value); -} - - -static inline void lv_obj_set_style_local_pad_ver(lv_obj_t * obj, uint8_t part, lv_state_t state, lv_style_int_t value) -{ - lv_obj_set_style_local_pad_top(obj, part, state, value); - lv_obj_set_style_local_pad_bottom(obj, part, state, value); -} - - -static inline void lv_style_set_pad_ver(lv_style_t * style, lv_state_t state, lv_style_int_t value) -{ - lv_style_set_pad_top(style, state, value); - lv_style_set_pad_bottom(style, state, value); -} - - -static inline void lv_obj_set_style_local_margin_all(lv_obj_t * obj, uint8_t part, lv_state_t state, - lv_style_int_t value) -{ - lv_obj_set_style_local_margin_top(obj, part, state, value); - lv_obj_set_style_local_margin_bottom(obj, part, state, value); - lv_obj_set_style_local_margin_left(obj, part, state, value); - lv_obj_set_style_local_margin_right(obj, part, state, value); -} - - -static inline void lv_style_set_margin_all(lv_style_t * style, lv_state_t state, lv_style_int_t value) -{ - lv_style_set_margin_top(style, state, value); - lv_style_set_margin_bottom(style, state, value); - lv_style_set_margin_left(style, state, value); - lv_style_set_margin_right(style, state, value); -} - - -static inline void lv_obj_set_style_local_margin_hor(lv_obj_t * obj, uint8_t part, lv_state_t state, - lv_style_int_t value) -{ - lv_obj_set_style_local_margin_left(obj, part, state, value); - lv_obj_set_style_local_margin_right(obj, part, state, value); -} - - -static inline void lv_style_set_margin_hor(lv_style_t * style, lv_state_t state, lv_style_int_t value) -{ - lv_style_set_margin_left(style, state, value); - lv_style_set_margin_right(style, state, value); -} - - -static inline void lv_obj_set_style_local_margin_ver(lv_obj_t * obj, uint8_t part, lv_state_t state, - lv_style_int_t value) -{ - lv_obj_set_style_local_margin_top(obj, part, state, value); - lv_obj_set_style_local_margin_bottom(obj, part, state, value); -} - - -static inline void lv_style_set_margin_ver(lv_style_t * style, lv_state_t state, lv_style_int_t value) -{ - lv_style_set_margin_top(style, state, value); - lv_style_set_margin_bottom(style, state, value); -} - - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index c60256d33..e0e9abb91 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -598,9 +598,9 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj) if(design_res == LV_DESIGN_RES_MASKED) return NULL; #if LV_USE_OPA_SCALE - if(design_res == LV_DESIGN_RES_COVER && lv_obj_get_style_opa_scale(obj, LV_OBJ_PART_MAIN) != LV_OPA_COVER) { - design_res = LV_DESIGN_RES_NOT_COVER; - } +// if(design_res == LV_DESIGN_RES_COVER && lv_obj_get_style_opa_scale(obj, LV_PART_MAIN) != LV_OPA_COVER) { +// design_res = LV_DESIGN_RES_NOT_COVER; +// } #endif uint32_t i; diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index 6e78c3ed2..0a93c443e 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -34,14 +34,6 @@ /********************** * STATIC PROTOTYPES **********************/ -LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop); -static lv_style_t * get_alloc_local_style(lv_style_list_t * list); -static inline void style_resize(lv_style_t * style, size_t sz); -static inline lv_style_property_t get_style_prop(const lv_style_t * style, size_t idx); -static inline uint8_t get_style_prop_id(const lv_style_t * style, size_t idx); -static inline uint8_t get_style_prop_attr(const lv_style_t * style, size_t idx); -static inline size_t get_prop_size(uint8_t prop_id); -static inline size_t get_next_prop_index(uint8_t prop_id, size_t id); /********************** * GLOBAL VARIABLES @@ -78,16 +70,16 @@ void lv_style_init(lv_style_t * style) */ void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src) { - if(style_src == NULL) return; - - LV_ASSERT_STYLE(style_dest); - LV_ASSERT_STYLE(style_src); - - if(style_src->map == NULL) return; - - uint16_t size = _lv_style_get_mem_size(style_src); - style_dest->map = lv_mem_alloc(size); - _lv_memcpy(style_dest->map, style_src->map, size); +// if(style_src == NULL) return; +// +// LV_ASSERT_STYLE(style_dest); +// LV_ASSERT_STYLE(style_src); +// +// if(style_src->map == NULL) return; +// +// uint16_t size = _lv_style_get_mem_size(style_src); +// style_dest->map = lv_mem_alloc(size); +// _lv_memcpy(style_dest->map, style_src->map, size); } /** @@ -97,222 +89,246 @@ void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src) * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` * @return true: the property was found and removed; false: the property wasn't found */ -bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop) +bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop) { if(style == NULL) return false; LV_ASSERT_STYLE(style); - int32_t id = get_property_index(style, prop); - /*The property exists but not sure it's state is the same*/ - if(id >= 0) { - lv_style_attr_t attr_found; - lv_style_attr_t attr_goal; + switch(prop) { - attr_found = get_style_prop_attr(style, id); - attr_goal = (prop >> 8) & 0xFFU; + case LV_STYLE_RADIUS: + style->has_radius = 0; + break; + case LV_STYLE_CLIP_CORNER: + if(style->ext) style->ext->has_clip_corner = 0; + break; + case LV_STYLE_TRANSFORM_WIDTH: + if(style->ext) style->ext->has_transform_width = 0; + break; + case LV_STYLE_TRANSFORM_HEIGHT: + if(style->ext) style->ext->has_transform_height = 0; + break; + case LV_STYLE_TRANSFORM_ZOOM: + if(style->ext) style->ext->has_transform_zoom = 0; + break; + case LV_STYLE_TRANSFORM_ANGLE: + if(style->ext) style->ext->has_transform_angle = 0; + break; - if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { - uint32_t map_size = _lv_style_get_mem_size(style); - uint8_t prop_size = get_prop_size(prop); + case LV_STYLE_PAD_TOP: + style->has_pad_top = 0; + break; + case LV_STYLE_PAD_BOTTOM: + style->has_pad_bottom = 0; + break; + case LV_STYLE_PAD_LEFT: + style->has_pad_left = 0; + break; + case LV_STYLE_PAD_RIGHT: + style->has_pad_right = 0; + break; + case LV_STYLE_MARGIN_TOP: + if(style->ext) style->ext->has_margin_top = 0; + break; + case LV_STYLE_MARGIN_BOTTOM: + if(style->ext) style->ext->has_margin_bottom = 0; + break; + case LV_STYLE_MARGIN_LEFT: + if(style->ext) style->ext->has_margin_left = 0; + break; + case LV_STYLE_MARGIN_RIGHT: + if(style->ext) style->ext->has_margin_right = 0; + break; - /*Move the props to fill the space of the property to delete*/ - uint32_t i; - for(i = id; i < map_size - prop_size; i++) { - style->map[i] = style->map[i + prop_size]; - } + case LV_STYLE_BG_COLOR: + style->has_bg_color = 0; + break; + case LV_STYLE_BG_OPA: + style->has_bg_opa = 0; + break; + case LV_STYLE_BG_GRAD_COLOR: + if(style->ext) style->ext->has_bg_grad_color = 0; + break; + case LV_STYLE_BG_GRAD_DIR: + if(style->ext) style->ext->has_bg_grad_dir = 0; + break; + case LV_STYLE_BG_BLEND_MODE: + if(style->ext) style->ext->has_bg_blend_mode = 0; + break; + case LV_STYLE_BG_MAIN_STOP: + if(style->ext) style->ext->has_bg_main_stop = 0; + break; + case LV_STYLE_BG_GRAD_STOP: + if(style->ext) style->ext->has_bg_grad_stop = 0; + break; + case LV_STYLE_BG_IMG_SRC: + if(style->ext) style->ext->has_bg_img_src = 0; + break; + case LV_STYLE_BG_IMG_MOSAIC: + if(style->ext) style->ext->has_bg_img_mosaic = 0; + break; - style_resize(style, map_size - prop_size); - return true; - } + case LV_STYLE_BORDER_COLOR: + style->has_border_color = 0; + break; + case LV_STYLE_BORDER_OPA: + style->has_border_opa = 0; + break; + case LV_STYLE_BORDER_WIDTH: + style->has_border_width = 0; + break; + case LV_STYLE_BORDER_SIDE: + style->has_border_side = 0; + break; + case LV_STYLE_BORDER_POST: + style->has_border_post = 0; + break; + case LV_STYLE_BORDER_BLEND_MODE: + if(style->ext) style->ext->has_border_blend_mode = 0; + break; + + case LV_STYLE_TEXT_COLOR: + style->has_text_color = 0; + break; + case LV_STYLE_TEXT_OPA: + style->has_text_opa = 0; + break; + case LV_STYLE_TEXT_FONT: + style->has_text_font = 0; + break; + case LV_STYLE_TEXT_LETTER_SPACE: + if(style->ext) style->ext->has_text_letter_space = 0; + break; + case LV_STYLE_TEXT_LINE_SPACE: + if(style->ext) style->ext->has_text_line_space = 0; + break; + case LV_STYLE_TEXT_DECOR: + if(style->ext) style->ext->has_text_decor = 0; + break; + case LV_STYLE_TEXT_BLEND_MODE: + if(style->ext) style->ext->has_text_blend_mode = 0; + break; + + case LV_STYLE_IMG_OPA: + style->has_img_opa = 0; + break; + case LV_STYLE_IMG_BLEND_MODE: + style->ext->has_img_blend_mode = 0; + break; + case LV_STYLE_IMG_RECOLOR: + if(style->ext) style->ext->has_img_recolor = 0; + break; + case LV_STYLE_IMG_RECOLOR_OPA: + if(style->ext) style->ext->has_img_recolor_opa = 0; + break; + + case LV_STYLE_OUTLINE_OPA: + if(style->ext) style->ext->has_outline_opa = 0; + break; + case LV_STYLE_OUTLINE_COLOR: + if(style->ext) style->ext->has_outline_color = 0; + break; + case LV_STYLE_OUTLINE_WIDTH: + if(style->ext) style->ext->has_outline_width = 0; + break; + case LV_STYLE_OUTLINE_PAD: + if(style->ext) style->ext->has_outline_pad = 0; + break; + case LV_STYLE_OUTLINE_BLEND_MODE: + if(style->ext) style->ext->has_outline_blend_mode = 0; + break; + + case LV_STYLE_SHADOW_WIDTH: + if(style->ext) style->ext->has_shadow_width = 0; + break; + case LV_STYLE_SHADOW_OFS_X: + if(style->ext) style->ext->has_shadow_ofs_x = 0; + break; + case LV_STYLE_SHADOW_OFS_Y: + if(style->ext) style->ext->has_shadow_ofs_y = 0; + break; + case LV_STYLE_SHADOW_SPREAD: + if(style->ext) style->ext->has_shadow_spread = 0; + break; + case LV_STYLE_SHADOW_BLEND_MODE: + if(style->ext) style->ext->has_shadow_blend_mode = 0; + break; + case LV_STYLE_SHADOW_COLOR: + if(style->ext) style->ext->has_shadow_color = 0; + break; + case LV_STYLE_SHADOW_OPA: + if(style->ext) style->ext->has_shadow_opa = 0; + break; + + case LV_STYLE_LINE_WIDTH: + if(style->ext) style->ext->has_line_width = 0; + break; + case LV_STYLE_LINE_BLEND_MODE: + if(style->ext) style->ext->has_line_blend_mode = 0; + break; + case LV_STYLE_LINE_DASH_GAP: + if(style->ext) style->ext->has_line_dash_gap = 0; + break; + case LV_STYLE_LINE_DASH_WIDTH: + if(style->ext) style->ext->has_line_dash_width = 0; + break; + case LV_STYLE_LINE_ROUNDED: + if(style->ext) style->ext->has_line_rounded = 0; + break; + case LV_STYLE_LINE_COLOR: + if(style->ext) style->ext->has_line_color = 0; + break; + case LV_STYLE_LINE_OPA: + if(style->ext) style->ext->has_line_opa = 0; + break; + + case LV_STYLE_CONTENT_ALIGN: + if(style->ext) style->ext->has_content_align = 0; + break; + case LV_STYLE_CONTENT_OFS_X: + if(style->ext) style->ext->has_content_ofs_x = 0; + break; + case LV_STYLE_CONTENT_OFS_Y: + if(style->ext) style->ext->has_content_ofs_y = 0; + break; + case LV_STYLE_CONTENT_TEXT: + if(style->ext) style->ext->has_content_text = 0; + break; + + case LV_STYLE_TRANSITION_TIME: + if(style->ext) style->ext->has_transition_time = 0; + break; + case LV_STYLE_TRANSITION_DELAY: + if(style->ext) style->ext->has_transition_delay = 0; + break; + case LV_STYLE_TRANSITION_PATH: + if(style->ext) style->ext->has_transition_path = 0; + break; + case LV_STYLE_TRANSITION_PROP_1: + if(style->ext) style->ext->has_transition_prop_1 = 0; + break; + case LV_STYLE_TRANSITION_PROP_2: + if(style->ext) style->ext->has_transition_prop_2 = 0; + break; + case LV_STYLE_TRANSITION_PROP_3: + if(style->ext) style->ext->has_transition_prop_3 = 0; + break; + case LV_STYLE_TRANSITION_PROP_4: + if(style->ext) style->ext->has_transition_prop_4 = 0; + break; + case LV_STYLE_TRANSITION_PROP_5: + if(style->ext) style->ext->has_transition_prop_5 = 0; + break; + case LV_STYLE_TRANSITION_PROP_6: + if(style->ext) style->ext->has_transition_prop_6 = 0; + break; + + default: + return false; } - return false; -} - -/** - * Initialize a style list - * @param list a style list to initialize - */ -void lv_style_list_init(lv_style_list_t * list) -{ - _lv_memset_00(list, sizeof(lv_style_list_t)); -#if LV_USE_ASSERT_STYLE - list->sentinel = LV_DEBUG_STYLE_LIST_SENTINEL_VALUE; -#endif -} - -/** - * Copy a style list with all its styles and local style properties - * @param list_dest pointer to the destination style list. (should be initialized with `lv_style_list_init()`) - * @param list_src pointer to the source (to copy) style list. - */ -void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * list_src) -{ - LV_ASSERT_STYLE_LIST(list_dest); - LV_ASSERT_STYLE_LIST(list_src); - - _lv_style_list_reset(list_dest); - - if(list_src->style_list == NULL) return; - - /*Copy the styles but skip the transitions*/ - if(list_src->has_local == 0) { - if(list_src->has_trans) { - list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *)); - _lv_memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *)); - list_dest->style_cnt = list_src->style_cnt - 1; - } - else { - list_dest->style_list = lv_mem_alloc(list_src->style_cnt * sizeof(lv_style_t *)); - _lv_memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *)); - list_dest->style_cnt = list_src->style_cnt; - } - } - else { - if(list_src->has_trans) { - list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 2) * sizeof(lv_style_t *)); - _lv_memcpy(list_dest->style_list, list_src->style_list + 2, (list_src->style_cnt - 2) * sizeof(lv_style_t *)); - list_dest->style_cnt = list_src->style_cnt - 2; - } - else { - list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *)); - _lv_memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *)); - list_dest->style_cnt = list_src->style_cnt - 1; - } - - lv_style_t * local_style = get_alloc_local_style(list_dest); - lv_style_copy(local_style, get_alloc_local_style((lv_style_list_t *)list_src)); - } -} - -/** - * Add a style to a style list. - * Only the the style pointer will be saved so the shouldn't be a local variable. - * (It should be static, global or dynamically allocated) - * @param list pointer to a style list - * @param style pointer to a style to add - */ -void _lv_style_list_add_style(lv_style_list_t * list, lv_style_t * style) -{ - LV_ASSERT_STYLE_LIST(list); - LV_ASSERT_STYLE(style); - - if(list == NULL) return; - - /*Remove the style first if already exists*/ - _lv_style_list_remove_style(list, style); - - lv_style_t ** new_classes; - if(list->style_cnt == 0) new_classes = lv_mem_alloc(sizeof(lv_style_t *)); - else new_classes = lv_mem_realloc(list->style_list, sizeof(lv_style_t *) * (list->style_cnt + 1)); - LV_ASSERT_MEM(new_classes); - if(new_classes == NULL) { - LV_LOG_WARN("lv_style_list_add_style: couldn't add the class"); - return; - } - - /*Make space for the new style at the beginning. Leave local and trans style if exists*/ - uint8_t i; - uint8_t first_style = 0; - if(list->has_trans) first_style++; - if(list->has_local) first_style++; - for(i = list->style_cnt; i > first_style; i--) { - new_classes[i] = new_classes[i - 1]; - } - - new_classes[first_style] = style; - list->style_cnt++; - list->style_list = new_classes; -} - -/** - * Remove a style from a style list - * @param style_list pointer to a style list - * @param style pointer to a style to remove - */ -void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style) -{ - LV_ASSERT_STYLE_LIST(list); - LV_ASSERT_STYLE(style); - - if(list->style_cnt == 0) return; - - /*Check if the style really exists here*/ - uint8_t i; - bool found = false; - for(i = 0; i < list->style_cnt; i++) { - if(list->style_list[i] == style) { - found = true; - break; - } - } - if(found == false) return; - - if(list->style_cnt == 1) { - lv_mem_free(list->style_list); - list->style_list = NULL; - list->style_cnt = 0; - list->has_local = 0; - return; - } - - lv_style_t ** new_classes = lv_mem_alloc(sizeof(lv_style_t *) * (list->style_cnt - 1)); - LV_ASSERT_MEM(new_classes); - if(new_classes == NULL) { - LV_LOG_WARN("lv_style_list_remove_style: couldn't reallocate class list"); - return; - } - uint8_t j; - for(i = 0, j = 0; i < list->style_cnt; i++) { - if(list->style_list[i] == style) continue; - new_classes[j] = list->style_list[i]; - j++; - - } - - lv_mem_free(list->style_list); - - list->style_cnt--; - list->style_list = new_classes; -} - -/** - * Remove all styles added from style list, clear the local style, transition style and free all allocated memories. - * Leave `ignore_trans` flag as it is. - * @param list pointer to a style list. - */ -void _lv_style_list_reset(lv_style_list_t * list) -{ - LV_ASSERT_STYLE_LIST(list); - - if(list == NULL) return; - - if(list->has_local) { - lv_style_t * local = lv_style_list_get_local_style(list); - if(local) { - lv_style_reset(local); - lv_mem_free(local); - } - } - - if(list->has_trans) { - lv_style_t * trans = _lv_style_list_get_transition_style(list); - if(trans) { - lv_style_reset(trans); - lv_mem_free(trans); - } - } - - if(list->style_cnt > 0) lv_mem_free(list->style_list); - list->style_list = NULL; - list->style_cnt = 0; - list->has_local = 0; - list->has_trans = 0; - list->skip_trans = 0; - - /* Intentionally leave `ignore_trans` as it is, - * because it's independent from the styles in the list*/ + return true; } /** @@ -322,685 +338,652 @@ void _lv_style_list_reset(lv_style_list_t * list) void lv_style_reset(lv_style_t * style) { LV_ASSERT_STYLE(style); - - lv_mem_free(style->map); - style->map = NULL; + lv_style_init(style); } -/** - * Get the size of the properties in a style in bytes - * @param style pointer to a style - * @return size of the properties in bytes - */ -uint16_t _lv_style_get_mem_size(const lv_style_t * style) +void _alloc_ext(lv_style_t * style) { - LV_ASSERT_STYLE(style); - - if(style->map == NULL) return 0; - - size_t i = 0; - uint8_t prop_id; - while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSING_PROP) { - i = get_next_prop_index(prop_id, i); - } - - return i + sizeof(lv_style_property_t); + if(style->ext) return; + style->ext = lv_mem_alloc(sizeof(lv_style_ext_t)); + LV_ASSERT_MEM(style->ext); } -/** - * Set an integer typed property in a style. - * @param style pointer to a style where the property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note shouldn't be used directly. Use the specific property set functions instead. - * For example: `lv_style_set_border_width()` - * @note for performance reasons it's not checked if the property really has integer type - */ -void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_int_t value) +void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value) { - LV_ASSERT_STYLE(style); - - int32_t id = get_property_index(style, prop); - /*The property already exists but not sure it's state is the same*/ - if(id >= 0) { - lv_style_attr_t attr_found; - lv_style_attr_t attr_goal; - - attr_found = get_style_prop_attr(style, id); - attr_goal = (prop >> 8) & 0xFFU; - - if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { - _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &value, sizeof(lv_style_int_t)); - return; - } - } - - /*Add new property if not exists yet*/ - uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(lv_style_int_t)); - lv_style_property_t end_mark = _LV_STYLE_CLOSING_PROP; - uint8_t end_mark_size = sizeof(end_mark); - - uint16_t size = _lv_style_get_mem_size(style); - if(size == 0) size += end_mark_size; - size += sizeof(lv_style_property_t) + sizeof(lv_style_int_t); - style_resize(style, size); - LV_ASSERT_MEM(style->map); if(style == NULL) return; + LV_ASSERT_STYLE(style); - _lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); - _lv_memcpy_small(style->map + size - sizeof(lv_style_int_t) - end_mark_size, &value, sizeof(lv_style_int_t)); - _lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); + switch(prop) { + + case LV_STYLE_RADIUS: + style->radius = value._int; + style->has_radius = 1; + break; + case LV_STYLE_CLIP_CORNER: + _alloc_ext(style); + style->ext->clip_corner = value._int; + style->ext->has_clip_corner = 1; + break; + case LV_STYLE_TRANSFORM_WIDTH: + _alloc_ext(style); + style->ext->transform_width = value._int; + style->ext->has_transform_width = 1; + break; + case LV_STYLE_TRANSFORM_HEIGHT: + _alloc_ext(style); + style->ext->transform_height = value._int; + style->ext->has_transform_height = 1; + break; + case LV_STYLE_TRANSFORM_ANGLE: + style->ext->transform_angle = value._int; + style->ext->has_transform_angle = 1; + break; + case LV_STYLE_TRANSFORM_ZOOM: + style->ext->transform_zoom = value._int; + style->ext->has_transform_zoom = 1; + break; + + case LV_STYLE_PAD_TOP: + style->pad_top = value._int; + style->has_pad_top = 1; + break; + case LV_STYLE_PAD_BOTTOM: + style->pad_bottom = value._int; + style->has_pad_bottom = 1; + break; + case LV_STYLE_PAD_LEFT: + style->pad_left = value._int; + style->has_pad_left = 1; + break; + case LV_STYLE_PAD_RIGHT: + style->pad_right = value._int; + style->has_pad_right = 1; + break; + case LV_STYLE_MARGIN_TOP: + _alloc_ext(style); + style->ext->margin_top = value._int; + style->ext->has_margin_top = 1; + break; + case LV_STYLE_MARGIN_BOTTOM: + _alloc_ext(style); + style->ext->margin_bottom = value._int; + style->ext->has_margin_bottom = 1; + break; + case LV_STYLE_MARGIN_LEFT: + _alloc_ext(style); + style->ext->margin_left = value._int; + style->ext->has_margin_left = 1; + break; + case LV_STYLE_MARGIN_RIGHT: + _alloc_ext(style); + style->ext->margin_right = value._int; + style->ext->has_margin_right = 1; + break; + + case LV_STYLE_BG_COLOR: + style->bg_color = value._color; + style->has_bg_color = 1; + break; + case LV_STYLE_BG_OPA: + style->bg_opa = value._int; + style->has_bg_opa = 1; + break; + case LV_STYLE_BG_GRAD_COLOR: + _alloc_ext(style); + style->ext->bg_grad_color = value._color; + style->ext->has_bg_grad_color = 1; + break; + case LV_STYLE_BG_GRAD_DIR: + _alloc_ext(style); + style->ext->bg_grad_dir = value._int; + style->ext->has_bg_grad_dir = 1; + break; + case LV_STYLE_BG_BLEND_MODE: + _alloc_ext(style); + style->ext->bg_blend_mode = value._int; + style->ext->has_bg_blend_mode = 1; + break; + case LV_STYLE_BG_MAIN_STOP: + _alloc_ext(style); + style->ext->bg_main_stop = value._int; + style->ext->has_bg_main_stop = 1; + break; + case LV_STYLE_BG_GRAD_STOP: + _alloc_ext(style); + style->ext->bg_grad_stop = value._int; + style->ext->has_bg_grad_stop = 1; + break; + case LV_STYLE_BG_IMG_SRC: + _alloc_ext(style); + style->ext->bg_img_src = value._ptr; + style->ext->has_bg_img_src = 1; + break; + + case LV_STYLE_BG_IMG_MOSAIC: + _alloc_ext(style); + style->ext->bg_img_mosaic = value._int; + style->ext->has_bg_img_mosaic = 1; + break; + + case LV_STYLE_BORDER_COLOR: + style->border_color = value._color; + style->has_border_color = 1; + break; + case LV_STYLE_BORDER_OPA: + style->border_opa = value._int; + style->has_border_opa = 1; + break; + case LV_STYLE_BORDER_WIDTH: + style->border_width = value._int; + style->has_border_width = 1; + break; + case LV_STYLE_BORDER_SIDE: + style->border_side = value._int; + style->has_border_side = 1; + break; + case LV_STYLE_BORDER_POST: + style->border_post = value._int; + style->has_border_post = 1; + break; + case LV_STYLE_BORDER_BLEND_MODE: + _alloc_ext(style); + style->ext->border_blend_mode = value._int; + style->ext->has_border_blend_mode = 1; + break; + + case LV_STYLE_TEXT_COLOR: + style->text_color = value._color; + style->has_text_color = 1; + break; + case LV_STYLE_TEXT_OPA: + style->text_opa = value._int; + style->has_text_opa = 1; + break; + case LV_STYLE_TEXT_LETTER_SPACE: + _alloc_ext(style); + style->ext->text_letter_space = value._int; + style->ext->text_letter_space = 1; + break; + case LV_STYLE_TEXT_LINE_SPACE: + _alloc_ext(style); + style->ext->text_line_space = value._int; + style->ext->has_text_line_space = 1; + break; + case LV_STYLE_TEXT_DECOR: + _alloc_ext(style); + style->ext->text_decor = value._int; + style->ext->has_text_decor = 1; + break; + case LV_STYLE_TEXT_BLEND_MODE: + _alloc_ext(style); + style->ext->text_blend_mode = value._int; + style->ext->has_text_blend_mode = 1; + break; + + case LV_STYLE_IMG_OPA: + style->img_opa = value._int; + style->has_img_opa = 1; + break; + case LV_STYLE_IMG_BLEND_MODE: + _alloc_ext(style); + style->ext->img_blend_mode = value._int; + style->ext->has_img_blend_mode = 1; + break; + case LV_STYLE_IMG_RECOLOR: + _alloc_ext(style); + style->ext->img_recolor = value._color; + style->ext->has_img_recolor = 1; + break; + case LV_STYLE_IMG_RECOLOR_OPA: + _alloc_ext(style); + style->ext->img_recolor_opa = value._int; + style->ext->has_img_recolor_opa= 1; + break; + + case LV_STYLE_OUTLINE_WIDTH: + _alloc_ext(style); + style->ext->outline_width = value._int; + style->ext->has_outline_width = 1; + break; + case LV_STYLE_OUTLINE_COLOR: + _alloc_ext(style); + style->ext->outline_color = value._color; + style->ext->has_outline_color = 1; + break; + case LV_STYLE_OUTLINE_OPA: + _alloc_ext(style); + style->ext->outline_opa = value._int; + style->ext->has_outline_opa = 1; + break; + case LV_STYLE_OUTLINE_PAD: + _alloc_ext(style); + style->ext->outline_pad = value._int; + style->ext->has_outline_pad = 1; + break; + case LV_STYLE_OUTLINE_BLEND_MODE: + _alloc_ext(style); + style->ext->outline_blend_mode = value._int; + style->ext->has_outline_blend_mode = 1; + break; + + case LV_STYLE_SHADOW_WIDTH: + _alloc_ext(style); + style->ext->shadow_width = value._int; + style->ext->has_shadow_width = 1; + break; + case LV_STYLE_SHADOW_OFS_X: + _alloc_ext(style); + style->ext->shadow_ofs_x = value._int; + style->ext->has_shadow_ofs_x = 1; + break; + case LV_STYLE_SHADOW_OFS_Y: + _alloc_ext(style); + style->ext->shadow_ofs_y = value._int; + style->ext->has_shadow_ofs_y = 1; + break; + case LV_STYLE_SHADOW_SPREAD: + _alloc_ext(style); + style->ext->shadow_spread = value._int; + style->ext->has_shadow_spread = 1; + break; + case LV_STYLE_SHADOW_BLEND_MODE: + _alloc_ext(style); + style->ext->shadow_blend_mode = value._int; + style->ext->has_shadow_blend_mode = 1; + break; + case LV_STYLE_SHADOW_COLOR: + _alloc_ext(style); + style->ext->shadow_color = value._color; + style->ext->has_shadow_color = 1; + break; + case LV_STYLE_SHADOW_OPA: + _alloc_ext(style); + style->ext->shadow_opa = value._int; + style->ext->has_shadow_opa = 1; + break; + + case LV_STYLE_LINE_WIDTH: + _alloc_ext(style); + style->ext->line_width = value._int; + style->ext->has_line_width = 1; + break; + case LV_STYLE_LINE_BLEND_MODE: + _alloc_ext(style); + style->ext->line_blend_mode = value._int; + style->ext->has_line_blend_mode = 1; + break; + case LV_STYLE_LINE_DASH_WIDTH: + _alloc_ext(style); + style->ext->line_dash_width = value._int; + style->ext->has_line_dash_width = 1; + break; + case LV_STYLE_LINE_DASH_GAP: + _alloc_ext(style); + style->ext->line_dash_gap = value._int; + style->ext->has_line_dash_gap = 1; + break; + case LV_STYLE_LINE_ROUNDED: + _alloc_ext(style); + style->ext->line_rounded = value._int; + style->ext->has_line_rounded = 1; + break; + case LV_STYLE_LINE_COLOR: + _alloc_ext(style); + style->ext->line_color = value._color; + style->ext->has_line_color = 1; + break; + case LV_STYLE_LINE_OPA: + _alloc_ext(style); + style->ext->line_color = value._color; + style->ext->has_line_opa = 1; + break; + + case LV_STYLE_CONTENT_TEXT: + _alloc_ext(style); + style->ext->content_text = value._ptr; + style->ext->has_content_text = 1; + break; + case LV_STYLE_CONTENT_ALIGN: + _alloc_ext(style); + style->ext->content_text = value._ptr; + style->ext->has_content_align = 1; + break; + case LV_STYLE_CONTENT_OFS_X: + _alloc_ext(style); + style->ext->content_ofs_x = value._int; + style->ext->has_content_ofs_x = 1; + break; + case LV_STYLE_CONTENT_OFS_Y: + _alloc_ext(style); + style->ext->content_ofs_y = value._int; + style->ext->has_content_ofs_y = 1; + break; + + case LV_STYLE_TRANSITION_TIME: + _alloc_ext(style); + style->ext->transition_time = value._int; + style->ext->has_transition_time = 1; + break; + case LV_STYLE_TRANSITION_DELAY: + _alloc_ext(style); + style->ext->transition_delay = value._int; + style->ext->has_transition_delay = 1; + break; + case LV_STYLE_TRANSITION_PATH: + _alloc_ext(style); + style->ext->transition_path = value._ptr; + style->ext->has_transition_path = 1; + break; + case LV_STYLE_TRANSITION_PROP_1: + _alloc_ext(style); + style->ext->transition_prop_1 = value._int; + style->ext->has_transition_prop_1 = 1; + break; + case LV_STYLE_TRANSITION_PROP_2: + _alloc_ext(style); + style->ext->transition_prop_2 = value._int; + style->ext->has_transition_prop_2 = 1; + break; + case LV_STYLE_TRANSITION_PROP_3: + _alloc_ext(style); + style->ext->transition_prop_3 = value._int; + style->ext->has_transition_prop_3 = 1; + break; + case LV_STYLE_TRANSITION_PROP_4: + _alloc_ext(style); + style->ext->transition_prop_4 = value._int; + style->ext->has_transition_prop_4 = 1; + break; + case LV_STYLE_TRANSITION_PROP_5: + _alloc_ext(style); + style->ext->transition_prop_5 = value._int; + style->ext->has_transition_prop_5 = 1; + break; + case LV_STYLE_TRANSITION_PROP_6: + _alloc_ext(style); + style->ext->transition_prop_6 = value._int; + style->ext->has_transition_prop_6 = 1; + break; + default: + break; + } } -/** - * Set a color typed property in a style. - * @param style pointer to a style where the property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_COLOR | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note shouldn't be used directly. Use the specific property set functions instead. - * For example: `lv_style_set_border_color()` - * @note for performance reasons it's not checked if the property really has color type - */ -void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_t color) +bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value) { - LV_ASSERT_STYLE(style); + switch(prop) { + case LV_STYLE_RADIUS: + if(style->has_radius) { value->_int = style->radius; return true; } + break; + case LV_STYLE_CLIP_CORNER: + if(style->ext && style->ext->has_clip_corner) { value->_int = style->ext->clip_corner; return true; } + break; + case LV_STYLE_TRANSFORM_WIDTH: + if(style->ext && style->ext->has_transform_width) { value->_int = style->ext->transform_width; return true; } + break; + case LV_STYLE_TRANSFORM_HEIGHT: + if(style->ext && style->ext->has_transform_height) { value->_int = style->ext->transform_height; return true; } + break; + case LV_STYLE_TRANSFORM_ZOOM: + if(style->ext && style->ext->has_transform_zoom) { value->_int = style->ext->transform_zoom; return true; } + break; + case LV_STYLE_TRANSFORM_ANGLE: + if(style->ext && style->ext->has_transform_angle) { value->_int = style->ext->transform_angle; return true; } + break; + case LV_STYLE_OPA: + if(style->ext && style->ext->has_opa) { value->_int = style->ext->opa; return true; } + break; - int32_t id = get_property_index(style, prop); - /*The property already exists but not sure it's state is the same*/ - if(id >= 0) { - lv_style_attr_t attr_found; - lv_style_attr_t attr_goal; + case LV_STYLE_PAD_TOP: + if(style->has_pad_top) { value->_int = style->pad_top; return true; } + break; + case LV_STYLE_PAD_BOTTOM: + if(style->has_pad_bottom) { value->_int = style->pad_bottom; return true; } + break; + case LV_STYLE_PAD_LEFT: + if(style->has_pad_left) { value->_int = style->pad_left; return true; } + break; + case LV_STYLE_PAD_RIGHT: + if(style->has_pad_right) { value->_int = style->pad_right; return true; } + break; + case LV_STYLE_MARGIN_TOP: + if(style->ext && style->ext->has_margin_top) { value->_int = style->ext->margin_top; return true; } + break; + case LV_STYLE_MARGIN_BOTTOM: + if(style->ext && style->ext->has_margin_bottom) { value->_int = style->ext->margin_left; return true; } + break; + case LV_STYLE_MARGIN_LEFT: + if(style->ext && style->ext->has_margin_left) { value->_int = style->ext->margin_left; return true; } + break; + case LV_STYLE_MARGIN_RIGHT: + if(style->ext && style->ext->has_margin_right) { value->_int = style->ext->margin_right; return true; } + break; - attr_found = get_style_prop_attr(style, id); - attr_goal = (prop >> 8) & 0xFFU; + case LV_STYLE_BG_COLOR: + if(style->has_bg_color) { value->_color = style->bg_color; return true; } + break; + case LV_STYLE_BG_OPA: + if(style->has_bg_opa) { value->_int = style->bg_opa; return true; } + break; + case LV_STYLE_BG_GRAD_COLOR: + if(style->ext && style->ext->has_bg_grad_color) { value->_color = style->ext->bg_grad_color; return true; } + break; + case LV_STYLE_BG_GRAD_DIR: + if(style->ext && style->ext->has_bg_grad_dir) { value->_int = style->ext->bg_grad_dir; return true; } + break; + case LV_STYLE_BG_BLEND_MODE: + if(style->ext && style->ext->has_bg_blend_mode) { value->_int = style->ext->bg_blend_mode; return true; } + break; + case LV_STYLE_BG_MAIN_STOP: + if(style->ext && style->ext->has_bg_main_stop) { value->_int = style->ext->bg_main_stop; return true; } + break; + case LV_STYLE_BG_GRAD_STOP: + if(style->ext && style->ext->has_bg_grad_stop) { value->_int = style->ext->bg_grad_stop; return true; } + break; + case LV_STYLE_BG_IMG_SRC: + if(style->ext && style->ext->has_bg_img_src) { value->_ptr = style->ext->bg_img_src; return true; } + break; + case LV_STYLE_BG_IMG_MOSAIC: + if(style->ext && style->ext->has_bg_img_mosaic) { value->_int = style->ext->bg_img_mosaic; return true; } + break; - if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { - _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &color, sizeof(lv_color_t)); - return; - } + case LV_STYLE_BORDER_COLOR: + if(style->has_border_color) { value->_color = style->border_color; return true; } + break; + case LV_STYLE_BORDER_OPA: + if(style->has_border_opa) { value->_int = style->border_opa; return true; } + break; + case LV_STYLE_BORDER_WIDTH: + if(style->has_border_width) { value->_int = style->border_width; return true; } + break; + case LV_STYLE_BORDER_SIDE: + if(style->has_border_side) { value->_int = style->border_side; return true; } + break; + case LV_STYLE_BORDER_POST: + if(style->has_border_post) { value->_int = style->border_post; return true; } + break; + case LV_STYLE_BORDER_BLEND_MODE: + if(style->ext && style->ext->has_border_blend_mode) { value->_int = style->ext->border_blend_mode; return true; } + break; + + case LV_STYLE_TEXT_COLOR: + if(style->has_text_color) { value->_color = style->text_color; return true; } + break; + case LV_STYLE_TEXT_OPA: + if(style->has_text_opa) { value->_int = style->text_opa; return true; } + break; + case LV_STYLE_TEXT_FONT: + if(style->has_text_font) { value->_ptr = style->text_font; return true; } + break; + case LV_STYLE_TEXT_LETTER_SPACE: + if(style->ext && style->ext->has_text_letter_space) { value->_int = style->ext->text_letter_space; return true; } + break; + case LV_STYLE_TEXT_LINE_SPACE: + if(style->ext && style->ext->has_text_letter_space) { value->_int = style->ext->text_line_space; return true; } + break; + case LV_STYLE_TEXT_DECOR: + if(style->ext && style->ext->has_text_letter_space) { value->_int = style->ext->text_decor; return true; } + break; + case LV_STYLE_TEXT_BLEND_MODE: + if(style->ext && style->ext->has_text_blend_mode) { value->_int = style->ext->text_blend_mode; return true; } + break; + + case LV_STYLE_IMG_OPA: + if(style->has_img_opa) { value->_int = style->img_opa; return true; } + break; + case LV_STYLE_IMG_BLEND_MODE: + if(style->ext && style->ext->has_img_blend_mode) { value->_int = style->ext->img_blend_mode; return true; } + break; + case LV_STYLE_IMG_RECOLOR: + if(style->ext && style->ext->has_img_recolor) { value->_color = style->ext->img_recolor; return true; } + break; + case LV_STYLE_IMG_RECOLOR_OPA: + if(style->ext && style->ext->has_img_recolor_opa) { value->_int = style->ext->img_recolor_opa; return true; } + break; + + + case LV_STYLE_OUTLINE_WIDTH: + if(style->ext && style->ext->has_outline_width) { value->_int = style->ext->outline_width; return true; } + break; + case LV_STYLE_OUTLINE_COLOR: + if(style->ext && style->ext->has_outline_color) { value->_color = style->ext->outline_color; return true; } + break; + case LV_STYLE_OUTLINE_OPA: + if(style->ext && style->ext->has_outline_opa) { value->_int = style->ext->outline_opa; return true; } + break; + case LV_STYLE_OUTLINE_PAD: + if(style->ext && style->ext->has_outline_pad) { value->_int = style->ext->outline_pad; return true; } + break; + case LV_STYLE_OUTLINE_BLEND_MODE: + if(style->ext && style->ext->has_outline_blend_mode) { value->_int = style->ext->outline_blend_mode; return true; } + break; + + case LV_STYLE_SHADOW_WIDTH: + if(style->ext && style->ext->has_shadow_width) { value->_int = style->ext->shadow_width; return true; } + break; + case LV_STYLE_SHADOW_OFS_X: + if(style->ext && style->ext->has_shadow_ofs_x) { value->_int = style->ext->shadow_ofs_x; return true; } + break; + case LV_STYLE_SHADOW_OFS_Y: + if(style->ext && style->ext->has_shadow_ofs_y) { value->_int = style->ext->shadow_ofs_y; return true; } + break; + case LV_STYLE_SHADOW_SPREAD: + if(style->ext && style->ext->has_shadow_spread) { value->_int = style->ext->shadow_spread; return true; } + break; + case LV_STYLE_SHADOW_BLEND_MODE: + if(style->ext && style->ext->has_shadow_blend_mode) { value->_int = style->ext->shadow_blend_mode; return true; } + break; + case LV_STYLE_SHADOW_COLOR: + if(style->ext && style->ext->has_shadow_color) { value->_color = style->ext->shadow_color; return true; } + break; + case LV_STYLE_SHADOW_OPA: + if(style->ext && style->ext->has_shadow_opa) { value->_int = style->ext->shadow_opa; return true; } + break; + + case LV_STYLE_LINE_WIDTH: + if(style->ext && style->ext->has_line_width) { value->_int = style->ext->line_width; return true; } + break; + case LV_STYLE_LINE_BLEND_MODE: + if(style->ext && style->ext->has_line_blend_mode) { value->_int = style->ext->line_blend_mode; return true; } + break; + case LV_STYLE_LINE_DASH_GAP: + if(style->ext && style->ext->has_line_dash_gap) { value->_int = style->ext->line_dash_gap; return true; } + break; + case LV_STYLE_LINE_DASH_WIDTH: + if(style->ext && style->ext->has_line_dash_width) { value->_int = style->ext->line_dash_width; return true; } + break; + case LV_STYLE_LINE_ROUNDED: + if(style->ext && style->ext->has_line_rounded) { value->_int = style->ext->line_rounded; return true; } + break; + case LV_STYLE_LINE_COLOR: + if(style->ext && style->ext->has_line_color) { value->_color = style->ext->line_color; return true; } + break; + case LV_STYLE_LINE_OPA: + if(style->ext && style->ext->has_line_opa) { value->_int = style->ext->line_opa; return true; } + break; + + case LV_STYLE_CONTENT_TEXT: + if(style->ext && style->ext->has_content_text) { value->_ptr = style->ext->content_text; return true; } + break; + case LV_STYLE_CONTENT_ALIGN: + if(style->ext && style->ext->has_content_align) { value->_int = style->ext->content_align; return true; } + break; + case LV_STYLE_CONTENT_OFS_X: + if(style->ext && style->ext->has_content_ofs_x) { value->_int = style->ext->content_ofs_x; return true; } + break; + case LV_STYLE_CONTENT_OFS_Y: + if(style->ext && style->ext->has_content_ofs_y) { value->_int = style->ext->content_ofs_x; return true; } + break; + + case LV_STYLE_TRANSITION_TIME: + if(style->ext && style->ext->has_transition_time) { value->_int = style->ext->transition_time; return true; } + break; + case LV_STYLE_TRANSITION_DELAY: + if(style->ext && style->ext->has_transition_delay) { value->_int = style->ext->transition_delay; return true; } + break; + case LV_STYLE_TRANSITION_PATH: + if(style->ext && style->ext->has_transition_path) { value->_int = style->ext->transition_path; return true; } + break; + case LV_STYLE_TRANSITION_PROP_1: + if(style->ext && style->ext->has_transition_prop_1) { value->_int = style->ext->transition_prop_1; return true; } + break; + case LV_STYLE_TRANSITION_PROP_2: + if(style->ext && style->ext->has_transition_prop_2) { value->_int = style->ext->transition_prop_2; return true; } + break; + case LV_STYLE_TRANSITION_PROP_3: + if(style->ext && style->ext->has_transition_prop_3) { value->_int = style->ext->transition_prop_3; return true; } + break; + case LV_STYLE_TRANSITION_PROP_4: + if(style->ext && style->ext->has_transition_prop_4) { value->_int = style->ext->transition_prop_4; return true; } + break; + case LV_STYLE_TRANSITION_PROP_5: + if(style->ext && style->ext->has_transition_prop_5) { value->_int = style->ext->transition_prop_5; return true; } + break; + case LV_STYLE_TRANSITION_PROP_6: + if(style->ext && style->ext->has_transition_prop_6) { value->_int = style->ext->transition_prop_6; return true; } + break; + default: + break; } - /*Add new property if not exists yet*/ - uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(lv_color_t)); - lv_style_property_t end_mark = _LV_STYLE_CLOSING_PROP; - uint8_t end_mark_size = sizeof(end_mark); - - uint16_t size = _lv_style_get_mem_size(style); - if(size == 0) size += end_mark_size; - - size += sizeof(lv_style_property_t) + sizeof(lv_color_t); - style_resize(style, size); - LV_ASSERT_MEM(style->map); - if(style == NULL) return; - - _lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); - _lv_memcpy_small(style->map + size - sizeof(lv_color_t) - end_mark_size, &color, sizeof(lv_color_t)); - _lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); + return false; } -/** - * Set an opacity typed property in a style. - * @param style pointer to a style where the property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_OPA | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note shouldn't be used directly. Use the specific property set functions instead. - * For example: `lv_style_set_border_opa()` - * @note for performance reasons it's not checked if the property really has opacity type - */ -void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t opa) +lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop) { - LV_ASSERT_STYLE(style); - - int32_t id = get_property_index(style, prop); - /*The property already exists but not sure it's state is the same*/ - if(id >= 0) { - lv_style_attr_t attr_found; - lv_style_attr_t attr_goal; - - attr_found = get_style_prop_attr(style, id); - attr_goal = (prop >> 8) & 0xFFU; - - if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { - _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &opa, sizeof(lv_opa_t)); - return; - } + lv_style_value_t value; + switch(prop) { + break; + case LV_STYLE_TRANSFORM_ZOOM: + value._int = LV_IMG_ZOOM_NONE; + break; + case LV_STYLE_BG_COLOR: + value._color = LV_COLOR_WHITE; + break; + case LV_STYLE_OPA: + case LV_STYLE_BORDER_OPA: + case LV_STYLE_TEXT_OPA: + case LV_STYLE_IMG_OPA: + case LV_STYLE_OUTLINE_OPA: + case LV_STYLE_SHADOW_OPA: + value._int = LV_OPA_COVER; + break; + case LV_STYLE_BORDER_SIDE: + value._int = LV_BORDER_SIDE_FULL; + break; + case LV_STYLE_TEXT_FONT: + value._ptr = lv_theme_get_font_normal(); + break; + case LV_STYLE_TRANSITION_PATH: + value._ptr = &lv_anim_path_def; + break; + default: + value._ptr = NULL; //Clear only the biggest member of the union + break; } - /*Add new property if not exists yet*/ - uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(lv_opa_t)); - lv_style_property_t end_mark = _LV_STYLE_CLOSING_PROP; - uint8_t end_mark_size = sizeof(end_mark); + return value; - uint16_t size = _lv_style_get_mem_size(style); - if(size == 0) size += end_mark_size; - - size += sizeof(lv_style_property_t) + sizeof(lv_opa_t); - style_resize(style, size); - LV_ASSERT_MEM(style->map); - if(style == NULL) return; - - _lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); - _lv_memcpy_small(style->map + size - sizeof(lv_opa_t) - end_mark_size, &opa, sizeof(lv_opa_t)); - _lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); -} - -/** - * Set a pointer typed property in a style. - * @param style pointer to a style where the property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_POINTER | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note shouldn't be used directly. Use the specific property set functions instead. - * For example: `lv_style_set_border_width()` - * @note for performance reasons it's not checked if the property is really has pointer type - */ -void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void * p) -{ - LV_ASSERT_STYLE(style); - - int32_t id = get_property_index(style, prop); - /*The property already exists but not sure it's state is the same*/ - if(id >= 0) { - lv_style_attr_t attr_found; - lv_style_attr_t attr_goal; - - attr_found = get_style_prop_attr(style, id); - attr_goal = (prop >> 8) & 0xFFU; - - if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { - _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &p, sizeof(const void *)); - return; - } - } - - /*Add new property if not exists yet*/ - uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(const void *)); - lv_style_property_t end_mark = _LV_STYLE_CLOSING_PROP; - uint8_t end_mark_size = sizeof(end_mark); - - uint16_t size = _lv_style_get_mem_size(style); - if(size == 0) size += end_mark_size; - - size += sizeof(lv_style_property_t) + sizeof(const void *); - style_resize(style, size); - LV_ASSERT_MEM(style->map); - if(style == NULL) return; - - _lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); - _lv_memcpy_small(style->map + size - sizeof(const void *) - end_mark_size, &p, sizeof(const void *)); - _lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); -} - -/** - * Get the a property from a style. - * Take into account the style state and return the property which matches the best. - * @param style pointer to a style where to search - * @param prop the property, might contain ORed style states too - * @param res buffer to store the result - * @return the weight of the found property (how well it fits to the style state). - * Higher number is means better fit - * -1 if the not found (`res` will be undefined) - */ -int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, void * v_res) -{ - lv_style_int_t * res = (lv_style_int_t *)v_res; - LV_ASSERT_STYLE(style); - - if(style == NULL) return -1; - if(style->map == NULL) return -1; - - int32_t id = get_property_index(style, prop); - if(id < 0) { - return -1; - } - else { - _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t)); - lv_style_attr_t attr_act; - attr_act = get_style_prop_attr(style, id); - - lv_style_attr_t attr_goal; - attr_goal = (prop >> 8) & 0xFF; - - return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); - } -} - -/** - * Get an opacity typed property from a style. - * @param style pointer to a style from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_OPA | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result value - * @return -1: the property wasn't found in the style. - * The matching state bits of the desired state (in `prop`) and the best matching property's state - * Higher value means match in higher precedence state. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has opacity type - */ -int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, void * v_res) -{ - lv_opa_t * res = (lv_opa_t *)v_res; - LV_ASSERT_STYLE(style); - - if(style == NULL) return -1; - if(style->map == NULL) return -1; - - int32_t id = get_property_index(style, prop); - if(id < 0) { - return -1; - } - else { - _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_opa_t)); - lv_style_attr_t attr_act; - attr_act = get_style_prop_attr(style, id); - - lv_style_attr_t attr_goal; - attr_goal = (prop >> 8) & 0xFF; - - return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); - } -} - -/** - * Get a color typed property from a style. - * @param style pointer to a style from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_COLOR | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result value - * @return -1: the property wasn't found in the style. - * The matching state bits of the desired state (in `prop`) and the best matching property's state - * Higher value means match in higher precedence state. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_style_get_border_color()` - * @note for performance reasons it's not checked if the property really has color type - */ -int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, void * v_res) -{ - lv_color_t * res = (lv_color_t *)v_res; - if(style == NULL) return -1; - if(style->map == NULL) return -1; - int32_t id = get_property_index(style, prop); - if(id < 0) { - return -1; - } - else { - _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_color_t)); - lv_style_attr_t attr_act; - attr_act = get_style_prop_attr(style, id); - - lv_style_attr_t attr_goal; - attr_goal = (prop >> 8) & 0xFF; - - return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); - } -} - -/** - * Get a pointer typed property from a style. - * @param style pointer to a style from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result value - * @return -1: the property wasn't found in the style. - * The matching state bits of the desired state (in `prop`) and the best matching property's state - * Higher value means match in higher precedence state. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_style_get_text_font()` - * @note for performance reasons it's not checked if the property really has pointer type - */ -int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * v_res) -{ - const void ** res = (const void **)v_res; - if(style == NULL) return -1; - if(style->map == NULL) return -1; - - int32_t id = get_property_index(style, prop); - if(id < 0) { - return -1; - } - else { - _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(const void *)); - lv_style_attr_t attr_act; - attr_act = get_style_prop_attr(style, id); - - lv_style_attr_t attr_goal; - attr_goal = (prop >> 8) & 0xFF; - - return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); - } -} - -/** - * Get the local style of a style list - * @param list pointer to a style list where the local property should be set - * @return pointer to the local style if exists else `NULL`. - */ -lv_style_t * lv_style_list_get_local_style(lv_style_list_t * list) -{ - LV_ASSERT_STYLE_LIST(list); - - if(!list->has_local) return NULL; - if(list->has_trans) return list->style_list[1]; - else return list->style_list[0]; -} - -/** - * Get the transition style of a style list - * @param list pointer to a style list where the local property should be set - * @return pointer to the transition style if exists else `NULL`. - */ -lv_style_t * _lv_style_list_get_transition_style(lv_style_list_t * list) -{ - LV_ASSERT_STYLE_LIST(list); - - if(!list->has_trans) return NULL; - return list->style_list[0]; -} - -/** - * Allocate the transition style in a style list. If already exists simply return it. - * @param list pointer to a style list - * @return the transition style of a style list - */ -lv_style_t * _lv_style_list_add_trans_style(lv_style_list_t * list) -{ - LV_ASSERT_STYLE_LIST(list); - if(list->has_trans) return _lv_style_list_get_transition_style(list); - - lv_style_t * trans_style = lv_mem_alloc(sizeof(lv_style_t)); - LV_ASSERT_MEM(trans_style); - if(trans_style == NULL) { - LV_LOG_WARN("lv_style_list_add_trans_style: couldn't create transition style"); - return NULL; - } - - lv_style_init(trans_style); - - _lv_style_list_add_style(list, trans_style); - list->has_trans = 1; - - /*If the list has local style trans was added after it. But trans should be the first so swap them*/ - if(list->has_local) { - lv_style_t * tmp = list->style_list[0]; - list->style_list[0] = list->style_list[1]; - list->style_list[1] = tmp; - } - return trans_style; -} - - -/** - * Set a local integer typed property in a style list. - * @param list pointer to a style list where the local property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note for performance reasons it's not checked if the property really has integer type - */ -void _lv_style_list_set_local_int(lv_style_list_t * list, lv_style_property_t prop, lv_style_int_t value) -{ - LV_ASSERT_STYLE_LIST(list); - - lv_style_t * local = get_alloc_local_style(list); - _lv_style_set_int(local, prop, value); -} - -/** - * Set a local opacity typed property in a style list. - * @param list pointer to a style list where the local property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_OPA | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note for performance reasons it's not checked if the property really has opacity type - */ -void _lv_style_list_set_local_opa(lv_style_list_t * list, lv_style_property_t prop, lv_opa_t value) -{ - LV_ASSERT_STYLE_LIST(list); - - lv_style_t * local = get_alloc_local_style(list); - _lv_style_set_opa(local, prop, value); -} - -/** - * Set a local color typed property in a style list. - * @param list pointer to a style list where the local property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_COLOR | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note for performance reasons it's not checked if the property really has color type - */ -void _lv_style_list_set_local_color(lv_style_list_t * list, lv_style_property_t prop, lv_color_t value) -{ - LV_ASSERT_STYLE_LIST(list); - - lv_style_t * local = get_alloc_local_style(list); - _lv_style_set_color(local, prop, value); -} - -/** - * Set a local pointer typed property in a style list. - * @param list pointer to a style list where the local property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note for performance reasons it's not checked if the property really has pointer type - */ -void _lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, const void * value) -{ - LV_ASSERT_STYLE_LIST(list); - - lv_style_t * local = get_alloc_local_style(list); - _lv_style_set_ptr(local, prop, value); -} - - - -/** - * Get an integer typed property from a style list. - * It will return the property which match best with given state. - * @param list pointer to a style list from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result - * @return LV_RES_OK: there was a matching property in the list - * LV_RES_INV: there was NO matching property in the list - * @note for performance reasons it's not checked if the property really has integer type - */ -lv_res_t _lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop, lv_style_int_t * res) -{ - LV_ASSERT_STYLE_LIST(list); - - if(list == NULL) return LV_RES_INV; - if(list->style_list == NULL) return LV_RES_INV; - - lv_style_attr_t attr; - attr = prop >> 8; - int16_t weight_goal = attr; - - int16_t weight = -1; - - lv_style_int_t value_act = 0; - - int16_t ci; - for(ci = 0; ci < list->style_cnt; ci++) { - /* changed class to _class to allow compilation as c++ */ - lv_style_t * _class = lv_style_list_get_style(list, ci); - int16_t weight_act = _lv_style_get_int(_class, prop, &value_act); - - /*On perfect match return the value immediately*/ - if(weight_act == weight_goal) { - *res = value_act; - return LV_RES_OK; - } - else if(list->has_trans && weight_act >= 0 && ci == 0 && !list->skip_trans) { - *res = value_act; - return LV_RES_OK; - } - /*If the found ID is better the current candidate then use it*/ - else if(weight_act > weight) { - weight = weight_act; - *res = value_act; - } - } - - if(weight >= 0) return LV_RES_OK; - else return LV_RES_INV; - -} - -/** - * Get a color typed property from a style list. - * It will return the property which match best with given state. - * @param list pointer to a style list from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_COLOR | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result - * @return LV_RES_OK: there was a matching property in the list - * LV_RES_INV: there was NO matching property in the list - * @note for performance reasons it's not checked if the property really has color type - */ -lv_res_t _lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t prop, lv_color_t * res) -{ - LV_ASSERT_STYLE_LIST(list); - - if(list == NULL) return LV_RES_INV; - if(list->style_list == NULL) return LV_RES_INV; - - lv_style_attr_t attr; - attr = prop >> 8; - int16_t weight_goal = attr; - - int16_t weight = -1; - - lv_color_t value_act; - value_act.full = 0; - - int16_t ci; - for(ci = 0; ci < list->style_cnt; ci++) { - lv_style_t * _class = lv_style_list_get_style(list, ci); - int16_t weight_act = _lv_style_get_color(_class, prop, &value_act); - /*On perfect match return the value immediately*/ - if(weight_act == weight_goal) { - *res = value_act; - return LV_RES_OK; - } - else if(list->has_trans && weight_act >= 0 && ci == 0 && !list->skip_trans) { - *res = value_act; - return LV_RES_OK; - } - /*If the found ID is better the current candidate then use it*/ - else if(weight_act > weight) { - weight = weight_act; - *res = value_act; - } - } - - if(weight >= 0) return LV_RES_OK; - else return LV_RES_INV; -} - -/** - * Get an opacity typed property from a style list. - * It will return the property which match best with given state. - * @param list pointer to a style list from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_OPA| (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result - * @return LV_RES_OK: there was a matching property in the list - * LV_RES_INV: there was NO matching property in the list - * @note for performance reasons it's not checked if the property really has opacity type - */ -lv_res_t _lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop, lv_opa_t * res) -{ - LV_ASSERT_STYLE_LIST(list); - - if(list == NULL) return LV_RES_INV; - if(list->style_list == NULL) return LV_RES_INV; - - lv_style_attr_t attr; - attr = prop >> 8; - int16_t weight_goal = attr; - - int16_t weight = -1; - - lv_opa_t value_act = LV_OPA_TRANSP; - - int16_t ci; - for(ci = 0; ci < list->style_cnt; ci++) { - lv_style_t * _class = lv_style_list_get_style(list, ci); - int16_t weight_act = _lv_style_get_opa(_class, prop, &value_act); - /*On perfect match return the value immediately*/ - if(weight_act == weight_goal) { - *res = value_act; - return LV_RES_OK; - } - else if(list->has_trans && weight_act >= 0 && ci == 0 && !list->skip_trans) { - *res = value_act; - return LV_RES_OK; - } - /*If the found ID is better the current candidate then use it*/ - else if(weight_act > weight) { - weight = weight_act; - *res = value_act; - } - } - - if(weight >= 0) return LV_RES_OK; - else return LV_RES_INV; -} - -/** - * Get a pointer typed property from a style list. - * It will return the property which match best with given state. - * @param list pointer to a style list from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result - * @return LV_RES_OK: there was a matching property in the list - * LV_RES_INV: there was NO matching property in the list - * @note for performance reasons it's not checked if the property really has pointer type - */ -lv_res_t _lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, const void ** res) -{ - LV_ASSERT_STYLE_LIST(list); - - if(list == NULL) return LV_RES_INV; - if(list->style_list == NULL) return LV_RES_INV; - - lv_style_attr_t attr; - attr = prop >> 8; - int16_t weight_goal = attr; - - int16_t weight = -1; - - const void * value_act; - - int16_t ci; - for(ci = 0; ci < list->style_cnt; ci++) { - lv_style_t * _class = lv_style_list_get_style(list, ci); - int16_t weight_act = _lv_style_get_ptr(_class, prop, &value_act); - /*On perfect match return the value immediately*/ - if(weight_act == weight_goal) { - *res = value_act; - return LV_RES_OK; - } - else if(list->has_trans && weight_act >= 0 && ci == 0 && !list->skip_trans) { - *res = value_act; - return LV_RES_OK; - } - /*If the found ID is better the current candidate then use it*/ - else if(weight_act > weight) { - weight = weight_act; - *res = value_act; - } - } - - if(weight >= 0) return LV_RES_OK; - else return LV_RES_INV; } /** @@ -1027,180 +1010,11 @@ bool lv_debug_check_style(const lv_style_t * style) * @param style pointer to a style * @return true: valid */ -bool lv_debug_check_style_list(const lv_style_list_t * list) +bool lv_debug_check_style_list(const void * list) { - if(list == NULL) return true; /*NULL list is still valid*/ - -#if LV_USE_ASSERT_STYLE - if(list->sentinel != LV_DEBUG_STYLE_LIST_SENTINEL_VALUE) { - LV_LOG_WARN("Invalid style (local variable or not initialized?)"); - return false; - } -#endif - return true; } /********************** * STATIC FUNCTIONS **********************/ - -static uint32_t stat[256]; -/** - * Get a property's index (byte index in `style->map`) from a style. - * Return best matching property's index considering the state of `prop` - * @param style pointer to a style - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @return - */ -LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop) -{ - LV_ASSERT_STYLE(style); - - if(style->map == NULL) return -1; - - uint8_t id_to_find = prop & 0xFF; - lv_style_attr_t attr; - attr = (prop >> 8) & 0xFF; - - int16_t weight = -1; - int16_t id_guess = -1; - - size_t i = 0; - - stat[prop & 0xFF]++; -// - if((prop & 0xFF) == LV_STYLE_PAD_TOP) { -// printf("pad top\n"); - } - - uint8_t prop_id; - while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSING_PROP) { - if(prop_id == id_to_find) { - lv_style_attr_t attr_i; - attr_i = get_style_prop_attr(style, i); - - /*If the state perfectly matches return this property*/ - if(LV_STYLE_ATTR_GET_STATE(attr_i) == LV_STYLE_ATTR_GET_STATE(attr)) { - return i; - } - /* Be sure the property not specifies other state than the requested. - * E.g. For HOVER+PRESS, HOVER only is OK, but HOVER+FOCUS not*/ - else if((LV_STYLE_ATTR_GET_STATE(attr_i) & (~LV_STYLE_ATTR_GET_STATE(attr))) == 0) { - /* Use this property if it describes better the requested state than the current candidate. - * E.g. for HOVER+FOCUS+PRESS prefer HOVER+FOCUS over FOCUS*/ - if(LV_STYLE_ATTR_GET_STATE(attr_i) > weight) { - weight = LV_STYLE_ATTR_GET_STATE(attr_i); - id_guess = i; - } - } - } - - i = get_next_prop_index(prop_id, i); - } - - return id_guess; -} - -/** - * Get he local style from a style list. Allocate it if not exists yet. - * @param list pointer to a style list - * @return pointer to the local style - */ -static lv_style_t * get_alloc_local_style(lv_style_list_t * list) -{ - LV_ASSERT_STYLE_LIST(list); - - if(list->has_local) return lv_style_list_get_style(list, list->has_trans ? 1 : 0); - - lv_style_t * local_style = lv_mem_alloc(sizeof(lv_style_t)); - LV_ASSERT_MEM(local_style); - if(local_style == NULL) { - LV_LOG_WARN("get_local_style: couldn't create local style"); - return NULL; - } - lv_style_init(local_style); - - /*Add the local style to the first place*/ - _lv_style_list_add_style(list, local_style); - list->has_local = 1; - - return local_style; -} - -/** - * Resizes a style map. Useful entry point for debugging. - * @param style pointer to the style to be resized. - * @param size new size - */ -static inline void style_resize(lv_style_t * style, size_t sz) -{ - style->map = lv_mem_realloc(style->map, sz); -} - -/** - * Get style property in index. - * @param style pointer to style. - * @param idx index of the style in style->map - * @return property in style->map + idx - */ -static inline lv_style_property_t get_style_prop(const lv_style_t * style, size_t idx) -{ - lv_style_property_t prop; - uint8_t * prop_p = (uint8_t *)∝ - prop_p[0] = style->map[idx]; - prop_p[1] = style->map[idx + 1]; - return prop; -} - -/** - * Get style property id in index. - * @param style pointer to style. - * @param idx index of the style in style->map - * @return id of property in style->map + idx - */ -static inline uint8_t get_style_prop_id(const lv_style_t * style, size_t idx) -{ - return get_style_prop(style, idx) & 0xFF; -} - -/** - * Get style property attributes for index. - * @param style pointer to style. - * @param idx index of the style in style->map - * @return attribute of property in style->map + idx - */ -static inline uint8_t get_style_prop_attr(const lv_style_t * style, size_t idx) -{ - return ((get_style_prop(style, idx) >> 8) & 0xFFU); -} - - -/** - * Get property size. - * @param prop_id property id. - * @param idx index of the style in style->map - * @return attribute of property in style->map + idx - */ -static inline size_t get_prop_size(uint8_t prop_id) -{ - prop_id &= 0xF; - size_t size = sizeof(lv_style_property_t); - if(prop_id < LV_STYLE_ID_COLOR) size += sizeof(lv_style_int_t); - else if(prop_id < LV_STYLE_ID_OPA) size += sizeof(lv_color_t); - else if(prop_id < LV_STYLE_ID_PTR) size += sizeof(lv_opa_t); - else size += sizeof(const void *); - return size; -} - -/** - * Get next property index, given current property and index. - * @param prop_id property id. - * @param idx index of the style in style->map - * @return index of next property in style->map - */ -static inline size_t get_next_prop_index(uint8_t prop_id, size_t idx) -{ - return idx + get_prop_size(prop_id); -} diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 0fdfb515b..df07456aa 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -29,26 +29,14 @@ extern "C" { #define LV_RADIUS_CIRCLE (0x7FFF) /**< A very big radius to always draw as circle*/ LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE); -#define LV_DEBUG_STYLE_SENTINEL_VALUE 0x2288AAEE -#define LV_DEBUG_STYLE_LIST_SENTINEL_VALUE 0x9977CCBB +#define LV_DEBUG_STYLE_SENTINEL_VALUE 0xAABBCCDD -#define LV_STYLE_PROP_INIT(name, group, id, attr) name = (((group << 4) + id) | ((attr) << 8)) - -#define LV_STYLE_ID_MASK 0x00FF - -#define LV_STYLE_ATTR_NONE 0 -#define LV_STYLE_ATTR_INHERIT (1 << 7) - -#define _LV_STYLE_CLOSING_PROP 0xFF +#define LV_STYLE_PROP_INHERIT (1 << 8) #define LV_STYLE_TRANS_NUM_MAX 6 #define LV_STYLE_PROP_ALL 0xFF -#if LV_STYLE_CACHE_LEVEL >= 2 -#define _LV_STLYE_CAHCE_INT_MAX 63 -#endif - /********************** * TYPEDEFS **********************/ @@ -85,199 +73,283 @@ enum { typedef uint8_t lv_text_decor_t; -typedef uint8_t lv_style_attr_t; +typedef union { + int32_t _int; + const void * _ptr; + lv_color_t _color; +}lv_style_value_t; -#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0x80) -#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x7F) +typedef enum { + _LV_STYLE_PROP_INV = 0, + LV_STYLE_RADIUS = 1, + LV_STYLE_CLIP_CORNER = 2, + LV_STYLE_TRANSFORM_WIDTH = 3, + LV_STYLE_TRANSFORM_HEIGHT = 4, + LV_STYLE_TRANSFORM_ZOOM = 5, + LV_STYLE_TRANSFORM_ANGLE = 6, + LV_STYLE_OPA = 7 | LV_STYLE_PROP_INHERIT, -#define LV_STYLE_ID_VALUE 0x0 /*max 9 pcs*/ -#define LV_STYLE_ID_COLOR 0x9 /*max 3 pcs*/ -#define LV_STYLE_ID_OPA 0xC /*max 2 pcs*/ -#define LV_STYLE_ID_PTR 0xE /*max 2 pcs*/ + LV_STYLE_PAD_TOP = 10, + LV_STYLE_PAD_BOTTOM = 11, + LV_STYLE_PAD_LEFT = 12, + LV_STYLE_PAD_RIGHT = 13, + LV_STYLE_MARGIN_TOP = 14, + LV_STYLE_MARGIN_BOTTOM = 15, + LV_STYLE_MARGIN_LEFT = 16, + LV_STYLE_MARGIN_RIGHT = 17, -enum { - /*Skip 0th property*/ - LV_STYLE_PROP_INIT(LV_STYLE_RADIUS, 0x0, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_CLIP_CORNER, 0x0, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SIZE, 0x0, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_WIDTH, 0x0, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_HEIGHT, 0x0, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ANGLE, 0x0, LV_STYLE_ID_VALUE + 6, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ZOOM, 0x0, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_OPA_SCALE, 0x0, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), + LV_STYLE_BG_COLOR = 20, + LV_STYLE_BG_OPA = 21, + LV_STYLE_BG_GRAD_COLOR = 22, + LV_STYLE_BG_GRAD_DIR = 23, + LV_STYLE_BG_BLEND_MODE = 24, + LV_STYLE_BG_MAIN_STOP = 25, + LV_STYLE_BG_GRAD_STOP = 26, + LV_STYLE_BG_IMG_SRC = 27, + LV_STYLE_BG_IMG_MOSAIC = 28, - LV_STYLE_PROP_INIT(LV_STYLE_PAD_TOP, 0x1, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_PAD_BOTTOM, 0x1, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_PAD_LEFT, 0x1, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_PAD_RIGHT, 0x1, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_MARGIN_TOP, 0x1, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_MARGIN_BOTTOM, 0x1, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_MARGIN_LEFT, 0x1, LV_STYLE_ID_VALUE + 6, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_MARGIN_RIGHT, 0x1, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), + LV_STYLE_BORDER_COLOR = 31, + LV_STYLE_BORDER_OPA = 32, + LV_STYLE_BORDER_WIDTH = 33, + LV_STYLE_BORDER_SIDE = 34, + LV_STYLE_BORDER_POST = 35, + LV_STYLE_BORDER_BLEND_MODE = 36, - LV_STYLE_PROP_INIT(LV_STYLE_BG_BLEND_MODE, 0x2, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BG_MAIN_STOP, 0x2, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_STOP, 0x2, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_DIR, 0x2, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BG_COLOR, 0x2, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_COLOR, 0x2, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BG_OPA, 0x2, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_TEXT_COLOR = 40 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_OPA = 41 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_FONT = 42 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_LETTER_SPACE = 43 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_LINE_SPACE = 44 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_DECOR = 45 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_BLEND_MODE = 46 | LV_STYLE_PROP_INHERIT, - LV_STYLE_PROP_INIT(LV_STYLE_BORDER_WIDTH, 0x3, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BORDER_SIDE, 0x3, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BORDER_BLEND_MODE, 0x3, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BORDER_POST, 0x3, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BORDER_COLOR, 0x3, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_BORDER_OPA, 0x3, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_IMG_OPA = 50, + LV_STYLE_IMG_BLEND_MODE = 51, + LV_STYLE_IMG_RECOLOR = 52, + LV_STYLE_IMG_RECOLOR_OPA = 53, - LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_WIDTH, 0x4, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_PAD, 0x4, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_BLEND_MODE, 0x4, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_COLOR, 0x4, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_OPA, 0x4, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_OUTLINE_WIDTH = 61, + LV_STYLE_OUTLINE_COLOR = 62, + LV_STYLE_OUTLINE_OPA = 63, + LV_STYLE_OUTLINE_PAD = 64, + LV_STYLE_OUTLINE_BLEND_MODE = 65, - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_WIDTH, 0x5, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_SPREAD, 0x5, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_BLEND_MODE, 0x5, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_COLOR, 0x5, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OPA, 0x5, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_SHADOW_WIDTH = 70, + LV_STYLE_SHADOW_OFS_X = 71, + LV_STYLE_SHADOW_OFS_Y = 72, + LV_STYLE_SHADOW_SPREAD = 73, + LV_STYLE_SHADOW_BLEND_MODE = 74, + LV_STYLE_SHADOW_COLOR = 75, + LV_STYLE_SHADOW_OPA = 76, - LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_BLEND_MODE, 0x6, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_REPEAT, 0x6, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_RECOLOR, 0x6, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_OPA, 0x6, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_RECOLOR_OPA, 0x6, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_IMAGE, 0x6, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_LINE_WIDTH = 80, + LV_STYLE_LINE_BLEND_MODE = 81, + LV_STYLE_LINE_DASH_WIDTH = 82, + LV_STYLE_LINE_DASH_GAP = 83, + LV_STYLE_LINE_ROUNDED = 84, + LV_STYLE_LINE_COLOR = 85, + LV_STYLE_LINE_OPA = 86, - LV_STYLE_PROP_INIT(LV_STYLE_VALUE_LETTER_SPACE, 0x7, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_VALUE_LINE_SPACE, 0x7, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_VALUE_BLEND_MODE, 0x7, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_VALUE_OFS_X, 0x7, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_VALUE_OFS_Y, 0x7, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_VALUE_ALIGN, 0x7, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_VALUE_COLOR, 0x7, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_VALUE_OPA, 0x7, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_VALUE_FONT, 0x7, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_VALUE_STR, 0x7, LV_STYLE_ID_PTR + 1, LV_STYLE_ATTR_NONE), + LV_STYLE_CONTENT_TEXT = 90, + LV_STYLE_CONTENT_ALIGN = 91, + LV_STYLE_CONTENT_OFS_X = 92, + LV_STYLE_CONTENT_OFS_Y = 93, + + LV_STYLE_TRANSITION_TIME = 100, + LV_STYLE_TRANSITION_DELAY = 101, + LV_STYLE_TRANSITION_PATH = 102, + LV_STYLE_TRANSITION_PROP_1 = 103, + LV_STYLE_TRANSITION_PROP_2 = 104, + LV_STYLE_TRANSITION_PROP_3 = 105, + LV_STYLE_TRANSITION_PROP_4 = 106, + LV_STYLE_TRANSITION_PROP_5 = 107, + LV_STYLE_TRANSITION_PROP_6 = 108, +}lv_style_prop_t; + +typedef struct { + uint32_t clip_corner :1; + int8_t transform_width :8; + int8_t transform_height:8; + uint16_t transform_zoom :14; + uint16_t transform_angle :14; + lv_opa_t opa; + + int8_t margin_top; + int8_t margin_bottom; + int8_t margin_left; + int8_t margin_right; + + lv_color_t bg_grad_color; + lv_grad_dir_t bg_grad_dir:3; + lv_blend_mode_t bg_blend_mode :2; + uint8_t bg_main_stop; + uint8_t bg_grad_stop; + const void * bg_img_src; + uint32_t bg_img_mosaic :1; + + lv_blend_mode_t border_blend_mode :2; + + uint8_t outline_width; + lv_color_t outline_color; + lv_opa_t outline_opa; + int8_t outline_pad; + lv_blend_mode_t outline_blend_mode :2; + + uint8_t shadow_width; + int8_t shadow_ofs_x; + int8_t shadow_ofs_y; + int8_t shadow_spread; + lv_blend_mode_t shadow_blend_mode :2; + lv_color_t shadow_color; + lv_opa_t shadow_opa; + + int8_t text_letter_space; + int8_t text_line_space; + lv_text_decor_t text_decor :2; + lv_blend_mode_t text_blend_mode :2; + + lv_blend_mode_t img_blend_mode :2; + lv_color_t img_recolor; + lv_opa_t img_recolor_opa; + + uint8_t line_width; + lv_blend_mode_t line_blend_mode :2; + uint8_t line_dash_width; + uint8_t line_dash_gap; + uint32_t line_rounded:1; + lv_color_t line_color; + lv_opa_t line_opa; + + uint32_t transition_time :16; + uint32_t transition_delay :16; + const lv_anim_path_cb_t * transition_path; + uint16_t transition_prop_1; + uint16_t transition_prop_2; + uint16_t transition_prop_3; + uint16_t transition_prop_4; + uint16_t transition_prop_5; + uint16_t transition_prop_6; + + const char * content_text; + lv_align_t content_align :5; + int8_t content_ofs_x; + int8_t content_ofs_y; + + uint32_t has_clip_corner :1; + uint32_t has_transform_width :1; + uint32_t has_transform_height :1; + uint32_t has_transform_zoom :1; + uint32_t has_transform_angle :1; + uint32_t has_opa :1; + + uint32_t has_margin_top :1; + uint32_t has_margin_bottom :1; + uint32_t has_margin_left :1; + uint32_t has_margin_right :1; + + uint32_t has_bg_grad_color :1; + uint32_t has_bg_grad_dir :1; + uint32_t has_bg_blend_mode :1; + uint32_t has_bg_main_stop :1; + uint32_t has_bg_grad_stop :1; + uint32_t has_bg_img_src :1; + uint32_t has_bg_img_mosaic :1; + + uint32_t has_border_blend_mode :1; + + uint32_t has_outline_width :1; + uint32_t has_outline_color :1; + uint32_t has_outline_opa :1; + uint32_t has_outline_pad :1; + uint32_t has_outline_blend_mode :1; + + uint32_t has_shadow_width :1; + uint32_t has_shadow_ofs_x :1; + uint32_t has_shadow_ofs_y :1; + uint32_t has_shadow_spread :1; + uint32_t has_shadow_blend_mode :1; + uint32_t has_shadow_color :1; + uint32_t has_shadow_opa :1; + + uint32_t has_text_letter_space :1; + uint32_t has_text_line_space :1; + uint32_t has_text_decor :1; + uint32_t has_text_blend_mode :1; + + uint32_t has_img_blend_mode :1; + uint32_t has_img_recolor :1; + uint32_t has_img_recolor_opa :1; + + uint32_t has_line_width :1; + uint32_t has_line_blend_mode :1; + uint32_t has_line_dash_width :1; + uint32_t has_line_dash_gap :1; + uint32_t has_line_rounded :1; + uint32_t has_line_color :1; + uint32_t has_line_opa :1; + + uint32_t has_content_text :1; + uint32_t has_content_align :1; + uint32_t has_content_ofs_x :1; + uint32_t has_content_ofs_y :1; + + uint32_t has_transition_time :1; + uint32_t has_transition_delay :1; + uint32_t has_transition_path :1; + uint32_t has_transition_prop_1 :1; + uint32_t has_transition_prop_2 :1; + uint32_t has_transition_prop_3 :1; + uint32_t has_transition_prop_4 :1; + uint32_t has_transition_prop_5 :1; + uint32_t has_transition_prop_6 :1; +}lv_style_ext_t; - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LETTER_SPACE, 0x8, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LINE_SPACE, 0x8, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_DECOR, 0x8, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_BLEND_MODE, 0x8, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_COLOR, 0x8, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_SEL_COLOR, 0x8, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_SEL_BG_COLOR, 0x8, LV_STYLE_ID_COLOR + 2, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_TEXT_FONT, 0x8, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_INHERIT), - - LV_STYLE_PROP_INIT(LV_STYLE_LINE_WIDTH, 0x9, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_LINE_BLEND_MODE, 0x9, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_LINE_DASH_WIDTH, 0x9, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_LINE_DASH_GAP, 0x9, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_LINE_ROUNDED, 0x9, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_LINE_COLOR, 0x9, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_LINE_OPA, 0x9, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), - - LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_BLEND_MODE, 0xA, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_RECOLOR, 0xA, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_OPA, 0xA, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), - LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_RECOLOR_OPA, 0xA, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_INHERIT), - - LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_TIME, 0xB, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_DELAY, 0xB, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_1, 0xB, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_2, 0xB, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_3, 0xB, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_4, 0xB, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_5, 0xB, LV_STYLE_ID_VALUE + 6, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_6, 0xB, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PATH, 0xB, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE), - - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_BORDER_WIDTH, 0xC, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_BORDER_WIDTH, 0xC, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xC, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xC, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), - - LV_STYLE_PROP_INIT(LV_STYLE_SCROLLBAR_TICKNESS, 0xD, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCROLLBAR_SPACE_SIDE, 0xD, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCROLLBAR_SPACE_END, 0xD, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCROLLBAR_RADIUS, 0xD, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCROLLBAR_BORDER_WIDTH, 0xD, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCROLLBAR_BG_COLOR, 0xD, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCROLLBAR_BORDER_COLOR, 0xD, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCROLLBAR_BG_OPA, 0xD, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCROLLBAR_BORDER_OPA, 0xD, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_NONE), -}; - -typedef uint16_t lv_style_property_t; - -#define LV_STYLE_STATE_POS 8 -#define LV_STYLE_STATE_MASK 0x7F00 -#define LV_STYLE_INHERIT_MASK 0x8000 - -typedef uint16_t lv_style_state_t; typedef struct { - uint8_t * map; #if LV_USE_ASSERT_STYLE uint32_t sentinel; #endif + const lv_font_t * text_font; + lv_style_ext_t * ext; + + lv_opa_t bg_opa; + lv_opa_t border_opa; + lv_opa_t text_opa; + lv_opa_t img_opa; + + int8_t pad_top :8; + int8_t pad_bottom :8; + int8_t pad_left :8; + int8_t pad_right :8; + + lv_color_t bg_color; + lv_color_t border_color; + + lv_color_t text_color; + uint32_t radius :8; + uint32_t border_width :8; + + uint32_t border_side:4; + uint32_t border_post:1; + + uint16_t has_text_font :1; + uint16_t has_bg_opa :1; + uint16_t has_border_opa :1; + uint16_t has_text_opa :1; + uint16_t has_img_opa :1; + uint16_t has_pad_top :1; + uint16_t has_pad_bottom :1; + uint16_t has_pad_left :1; + uint16_t has_pad_right :1; + uint16_t has_bg_color :1; + uint16_t has_border_color :1; + uint16_t has_text_color :1; + uint16_t has_radius :1; + uint16_t has_border_width :1; + uint16_t has_border_side :1; + uint16_t has_border_post :1; } lv_style_t; -typedef int16_t lv_style_int_t; - -typedef struct { - lv_style_t ** style_list; -#if LV_USE_ASSERT_STYLE - uint32_t sentinel; -#endif - uint32_t style_cnt : 5; - uint32_t has_local : 1; - 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*/ - -#if LV_STYLE_CACHE_LEVEL >= 1 - uint32_t valid_cache : 1; /*1: The cache is valid and can be used*/ - uint32_t ignore_cache : 1; /*1: Ignore cache while getting value of properties*/ - - /*32 properties*/ - uint32_t radius_zero : 1; - uint32_t opa_scale_cover : 1; - uint32_t clip_corner_off : 1; - uint32_t transform_all_zero : 1; - uint32_t pad_all_zero : 1; - uint32_t margin_all_zero : 1; - uint32_t blend_mode_all_normal : 1; - uint32_t bg_opa_transp : 1; - uint32_t bg_opa_cover : 1; - - uint32_t border_width_zero : 1; - uint32_t border_side_full : 1; - uint32_t border_post_off : 1; - - uint32_t outline_width_zero : 1; - uint32_t pattern_img_null : 1; - uint32_t shadow_width_zero : 1; - uint32_t value_txt_str : 1; - uint32_t img_recolor_opa_transp : 1; - - uint32_t text_space_zero : 1; - uint32_t text_decor_none : 1; - uint32_t text_font_normal : 1; -#endif - -#if LV_STYLE_CACHE_LEVEL >= 2 - uint32_t pad_top :6; - uint32_t pad_left :6; -#endif - -} lv_style_list_t; - /********************** * GLOBAL PROTOTYPES **********************/ @@ -295,69 +367,17 @@ void lv_style_init(lv_style_t * style); */ void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src); -/** - * Initialize a style list - * @param list a style list to initialize - */ -void lv_style_list_init(lv_style_list_t * list); - -/** - * Copy a style list with all its styles and local style properties - * @param list_dest pointer to the destination style list. (should be initialized with `lv_style_list_init()`) - * @param list_src pointer to the source (to copy) style list. - */ -void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * list_src); - -/** - * Add a style to a style list. - * Only the the style pointer will be saved so the shouldn't be a local variable. - * (It should be static, global or dynamically allocated) - * @param list pointer to a style list - * @param style pointer to a style to add - */ -void _lv_style_list_add_style(lv_style_list_t * list, lv_style_t * style); - -/** - * Remove a style from a style list - * @param style_list pointer to a style list - * @param style pointer to a style to remove - */ -void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style); - -/** - * Remove all styles added from style list, clear the local style, transition style and free all allocated memories. - * Leave `ignore_trans` flag as it is. - * @param list pointer to a style list. - */ -void _lv_style_list_reset(lv_style_list_t * style_list); - -static inline lv_style_t * lv_style_list_get_style(lv_style_list_t * list, uint8_t id) -{ - if(list->has_trans && list->skip_trans) id++; - if(list->style_cnt == 0 || id >= list->style_cnt) return NULL; - return list->style_list[id]; -} - /** * Clear all properties from a style and all allocated memories. * @param style pointer to a style */ void lv_style_reset(lv_style_t * style); -/** - * Get the size of the properties in a style in bytes - * @param style pointer to a style - * @return size of the properties in bytes - */ -uint16_t _lv_style_get_mem_size(const lv_style_t * style); +bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop); -/** - * Copy a style to an other - * @param dest pointer to the destination style - * @param src pointer to the source style - */ -void lv_style_copy(lv_style_t * dest, const lv_style_t * src); +void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value); +bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value); /** * Remove a property from a style * @param style pointer to a style @@ -365,229 +385,284 @@ void lv_style_copy(lv_style_t * dest, const lv_style_t * src); * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` * @return true: the property was found and removed; false: the property wasn't found */ -bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop); +bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop); -/** - * Set an integer typed property in a style. - * @param style pointer to a style where the property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note shouldn't be used directly. Use the specific property set functions instead. - * For example: `lv_style_set_border_width()` - * @note for performance reasons it's not checked if the property really has integer type - */ -void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_int_t value); +static inline void lv_style_set_radius(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_RADIUS, v); } -/** - * Set a color typed property in a style. - * @param style pointer to a style where the property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_COLOR | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note shouldn't be used directly. Use the specific property set functions instead. - * For example: `lv_style_set_border_color()` - * @note for performance reasons it's not checked if the property really has color type - */ -void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_t color); +static inline void lv_style_set_clip_corner(lv_style_t * style, bool value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_CLIP_CORNER, v); } -/** - * Set an opacity typed property in a style. - * @param style pointer to a style where the property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_OPA | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note shouldn't be used directly. Use the specific property set functions instead. - * For example: `lv_style_set_border_opa()` - * @note for performance reasons it's not checked if the property really has opacity type - */ -void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t opa); +static inline void lv_style_set_transform_width(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_WIDTH, v); } -/** - * Set a pointer typed property in a style. - * @param style pointer to a style where the property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_POINTER | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note shouldn't be used directly. Use the specific property set functions instead. - * For example: `lv_style_set_border_width()` - * @note for performance reasons it's not checked if the property really has pointer type - */ -void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void * p); +static inline void lv_style_set_transform_height(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_HEIGHT, v); } -/** - * Get an integer typed property from a style. - * @param style pointer to a style from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result value - * @return -1: the property wasn't found in the style. - * The matching state bits of the desired state (in `prop`) and the best matching property's state - * Higher value means match in higher precedence state. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_style_get_border_width()` - * @note for performance reasons it's not checked if the property really has integer type - */ -int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, void * res); +static inline void lv_style_set_transform_zoom(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_ZOOM, v); } -/** - * Get a color typed property from a style. - * @param style pointer to a style from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_COLOR | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result value - * @return -1: the property wasn't found in the style. - * The matching state bits of the desired state (in `prop`) and the best matching property's state - * Higher value means match in higher precedence state. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_style_get_border_color()` - * @note for performance reasons it's not checked if the property really has color type - */ -int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, void * res); +static inline void lv_style_set_transform_angle(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_ANGLE, v); } -/** - * Get an opacity typed property from a style. - * @param style pointer to a style from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_OPA | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result value - * @return -1: the property wasn't found in the style. - * The matching state bits of the desired state (in `prop`) and the best matching property's state - * Higher value means match in higher precedence state. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_style_get_border_opa()` - * @note for performance reasons it's not checked if the property really has opacity type - */ -int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, void * res); +static inline void lv_style_set_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_OPA, v); } -/** - * Get a pointer typed property from a style. - * @param style pointer to a style from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result value - * @return -1: the property wasn't found in the style. - * The matching state bits of the desired state (in `prop`) and the best matching property's state - * Higher value means match in higher precedence state. - * @note shouldn't be used directly. Use the specific property get functions instead. - * For example: `lv_style_get_text_font()` - * @note for performance reasons it's not checked if the property really has pointer type - */ -int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * res); +static inline void lv_style_set_pad_top(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_PAD_TOP, v); } -/** - * Get the local style of a style list - * @param list pointer to a style list where the local property should be set - * @return pointer to the local style if exists else `NULL`. - */ -lv_style_t * lv_style_list_get_local_style(lv_style_list_t * list); +static inline void lv_style_set_pad_bottom(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_PAD_BOTTOM, v); } -/** - * Get the transition style of a style list - * @param list pointer to a style list where the local property should be set - * @return pointer to the transition style if exists else `NULL`. - */ -lv_style_t * _lv_style_list_get_transition_style(lv_style_list_t * list); +static inline void lv_style_set_pad_left(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_PAD_LEFT, v); } -/** - * Allocate the transition style in a style list. If already exists simply return it. - * @param list pointer to a style list - * @return the transition style of a style list - */ -lv_style_t * _lv_style_list_add_trans_style(lv_style_list_t * list); +static inline void lv_style_set_pad_right(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_PAD_RIGHT, v); } -/** - * Set a local integer typed property in a style list. - * @param list pointer to a style list where the local property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note for performance reasons it's not checked if the property really has integer type - */ -void _lv_style_list_set_local_int(lv_style_list_t * list, lv_style_property_t prop, lv_style_int_t value); +static inline void lv_style_set_margin_top(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_MARGIN_TOP, v); } -/** - * Set a local color typed property in a style list. - * @param list pointer to a style list where the local property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_COLOR | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note for performance reasons it's not checked if the property really has color type - */ -void _lv_style_list_set_local_color(lv_style_list_t * list, lv_style_property_t prop, lv_color_t value); +static inline void lv_style_set_margin_bottom(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_MARGIN_BOTTOM, v); } -/** - * Set a local opacity typed property in a style list. - * @param list pointer to a style list where the local property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_OPA | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note for performance reasons it's not checked if the property really has opacity type - */ -void _lv_style_list_set_local_opa(lv_style_list_t * list, lv_style_property_t prop, lv_opa_t value); +static inline void lv_style_set_margin_left(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_MARGIN_LEFT, v); } -/** - * Set a local pointer typed property in a style list. - * @param list pointer to a style list where the local property should be set - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param value the value to set - * @note for performance reasons it's not checked if the property really has pointer type - */ -void _lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, const void * value); +static inline void lv_style_set_margin_right(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_MARGIN_RIGHT, v); } -/** - * Get an integer typed property from a style list. - * It will return the property which match best with given state. - * @param list pointer to a style list from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result - * @return LV_RES_OK: there was a matching property in the list - * LV_RES_INV: there was NO matching property in the list - * @note for performance reasons it's not checked if the property really has integer type - */ -lv_res_t _lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop, lv_style_int_t * res); +static inline void lv_style_set_bg_color(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {._color = value}; lv_style_set_prop(style, LV_STYLE_BG_COLOR, v); } -/** - * Get a color typed property from a style list. - * It will return the property which match best with given state. - * @param list pointer to a style list from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_COLOR | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result - * @return LV_RES_OK: there was a matching property in the list - * LV_RES_INV: there was NO matching property in the list - * @note for performance reasons it's not checked if the property really has color type - */ -lv_res_t _lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t prop, lv_color_t * res); +static inline void lv_style_set_bg_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_BG_OPA, v); } + +static inline void lv_style_set_bg_grad_color(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {._color = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_COLOR, v); } + +static inline void lv_style_set_bg_grad_dir(lv_style_t * style, lv_grad_dir_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_DIR, v); } + +static inline void lv_style_set_bg_blend_mode(lv_style_t * style, lv_blend_mode_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_BG_BLEND_MODE, v); } + +static inline void lv_style_set_bg_main_stop(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_BG_MAIN_STOP, v); } + +static inline void lv_style_set_bg_grad_stop(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_STOP, v); } + +static inline void lv_style_set_border_color(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {._color = value}; lv_style_set_prop(style, LV_STYLE_BORDER_COLOR, v); } + +static inline void lv_style_set_border_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_BORDER_OPA, v); } + +static inline void lv_style_set_border_width(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_BORDER_WIDTH, v); } + +static inline void lv_style_set_border_side(lv_style_t * style, lv_border_side_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_BORDER_SIDE, v); } + +static inline void lv_style_set_border_post(lv_style_t * style, bool value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_BORDER_POST, v); } + +static inline void lv_style_set_border_blend_mode(lv_style_t * style, lv_blend_mode_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_BORDER_BLEND_MODE, v); } + +static inline void lv_style_set_text_color(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {._color = value}; lv_style_set_prop(style, LV_STYLE_TEXT_COLOR, v); } + +static inline void lv_style_set_text_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TEXT_OPA, v); } + +static inline void lv_style_set_text_font(lv_style_t * style, const lv_font_t * value) { + lv_style_value_t v = {._ptr = value}; lv_style_set_prop(style, LV_STYLE_TEXT_FONT, v); } + +static inline void lv_style_set_text_letter_space(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TEXT_LETTER_SPACE, v); } + +static inline void lv_style_set_text_line_space(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TEXT_LINE_SPACE, v); } + +static inline void lv_style_set_text_decor(lv_style_t * style, lv_text_decor_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TEXT_DECOR, v); } + +static inline void lv_style_set_text_blend_mode(lv_style_t * style, lv_blend_mode_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TEXT_BLEND_MODE, v); } + +static inline void lv_style_set_img_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_IMG_OPA, v); } + +static inline void lv_style_set_img_blend_mode(lv_style_t * style, lv_blend_mode_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_IMG_BLEND_MODE, v); } + +static inline void lv_style_set_img_recolor(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {._color = value}; lv_style_set_prop(style, LV_STYLE_IMG_RECOLOR, v); } + +static inline void lv_style_set_img_recolor_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_IMG_RECOLOR_OPA, v); } + +static inline void lv_style_set_outline_width(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_WIDTH, v); } + +static inline void lv_style_set_outline_color(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {._color = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_COLOR, v); } + +static inline void lv_style_set_outline_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_OPA, v); } + +static inline void lv_style_set_outline_pad(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_PAD, v); } + +static inline void lv_style_set_outline_blend_mode(lv_style_t * style, lv_blend_mode_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_BLEND_MODE, v); } + +static inline void lv_style_set_shadow_width(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_WIDTH, v); } + +static inline void lv_style_set_shadow_ofs_x(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_OFS_X, v); } + +static inline void lv_style_set_shadow_ofs_y(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_OFS_Y, v); } + +static inline void lv_style_set_shadow_spread(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_SPREAD, v); } + +static inline void lv_style_set_shadow_blend_mode(lv_style_t * style, lv_blend_mode_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_BLEND_MODE, v); } + +static inline void lv_style_set_shadow_color(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {._color = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_COLOR, v); } + +static inline void lv_style_set_shadow_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_OPA, v); } + +static inline void lv_style_set_line_width(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_LINE_WIDTH, v); } + +static inline void lv_style_set_line_blend_mode(lv_style_t * style, lv_blend_mode_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_LINE_BLEND_MODE, v); } + +static inline void lv_style_set_line_dash_width(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_LINE_DASH_WIDTH, v); } + +static inline void lv_style_set_line_dash_gap(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_LINE_DASH_GAP, v); } + +static inline void lv_style_set_line_rounded(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_LINE_ROUNDED, v); } + +static inline void lv_style_set_line_color(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {._color = value}; lv_style_set_prop(style, LV_STYLE_LINE_COLOR, v); } + +static inline void lv_style_set_line_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_LINE_OPA, v); } + +static inline void lv_style_set_content_text(lv_style_t * style, const char * value) { + lv_style_value_t v = {._ptr = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_TEXT, v); } + +static inline void lv_style_set_content_align(lv_style_t * style, lv_align_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_ALIGN, v); } + +static inline void lv_style_set_content_ofs_x(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_X, v); } + +static inline void lv_style_set_content_ofs_y(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_Y, v); } + +static inline void lv_style_set_transition_time(lv_style_t * style, uint16_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION_TIME, v); } + +static inline void lv_style_set_transition_delay(lv_style_t * style, uint16_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION_DELAY, v); } + +static inline void lv_style_set_transition_path(lv_style_t * style, const lv_anim_path_t * value) { + lv_style_value_t v = {._ptr = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION_PATH, v); } + +static inline void lv_style_set_transition_prop_1(lv_style_t * style, lv_style_prop_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION_PROP_1, v); } + +static inline void lv_style_set_transition_prop_2(lv_style_t * style, lv_style_prop_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION_PROP_2, v); } + +static inline void lv_style_set_transition_prop_3(lv_style_t * style, lv_style_prop_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION_PROP_3, v); } + +static inline void lv_style_set_transition_prop_4(lv_style_t * style, lv_style_prop_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION_PROP_4, v); } + +static inline void lv_style_set_transition_prop_5(lv_style_t * style, lv_style_prop_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION_PROP_5, v); } + +static inline void lv_style_set_transition_prop_6(lv_style_t * style, lv_style_prop_t value) { + lv_style_value_t v = {._int = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION_PROP_6, v); } -/** - * Get an opacity typed property from a style list. - * It will return the property which match best with given state. - * @param list pointer to a style list from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_BORDER_OPA | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result - * @return LV_RES_OK: there was a matching property in the list - * LV_RES_INV: there was NO matching property in the list - * @note for performance reasons it's not checked if the property really has opacity type - */ -lv_res_t _lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop, lv_opa_t * res); -/** - * Get a pointer typed property from a style list. - * It will return the property which match best with given state. - * @param list pointer to a style list from where the property should be get - * @param prop a style property ORed with a state. - * E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)` - * @param res pointer to a buffer to store the result - * @return LV_RES_OK: there was a matching property in the list - * LV_RES_INV: there was NO matching property in the list - * @note for performance reasons it's not checked if the property really has pointer type - */ -lv_res_t _lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, const void ** res); + +//static inline void lv_style_set_pad_ver(lv_style_t * style, lv_style_int_t value) +//{ +// lv_style_set_pad_top(style, state, value); +// lv_style_set_pad_bottom(style, state, value); +//} + +// +//static inline void lv_obj_set_style_margin_all(lv_obj_t * obj, uint8_t part, lv_state_t state, +// lv_style_int_t value) +//{ +// lv_obj_set_style_local_margin_top(obj, part, state, value); +// lv_obj_set_style_local_margin_bottom(obj, part, state, value); +// lv_obj_set_style_local_margin_left(obj, part, state, value); +// lv_obj_set_style_local_margin_right(obj, part, state, value); +//} +// +// +//static inline void lv_style_set_margin_all(lv_style_t * style, lv_state_t state, lv_style_int_t value) +//{ +// lv_style_set_margin_top(style, state, value); +// lv_style_set_margin_bottom(style, state, value); +// lv_style_set_margin_left(style, state, value); +// lv_style_set_margin_right(style, state, value); +//} +// +// +//static inline void lv_obj_set_style_local_margin_hor(lv_obj_t * obj, uint8_t part, lv_state_t state, +// lv_style_int_t value) +//{ +// lv_obj_set_style_local_margin_left(obj, part, state, value); +// lv_obj_set_style_local_margin_right(obj, part, state, value); +//} +// +// +//static inline void lv_style_set_margin_hor(lv_style_t * style, lv_state_t state, lv_style_int_t value) +//{ +// lv_style_set_margin_left(style, state, value); +// lv_style_set_margin_right(style, state, value); +//} +// +// +//static inline void lv_obj_set_style_local_margin_ver(lv_obj_t * obj, uint8_t part, lv_state_t state, +// lv_style_int_t value) +//{ +// lv_obj_set_style_local_margin_top(obj, part, state, value); +// lv_obj_set_style_local_margin_bottom(obj, part, state, value); +//} +// +// +//static inline void lv_style_set_margin_ver(lv_style_t * style, lv_state_t state, lv_style_int_t value) +//{ +// lv_style_set_margin_top(style, state, value); +// lv_style_set_margin_bottom(style, state, value); +//} + + + +lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop); + +bool lv_style_prop_is_inherited(lv_style_prop_t prop); /** * Check whether a style is valid (initialized correctly) @@ -601,7 +676,7 @@ bool lv_debug_check_style(const lv_style_t * style); * @param style pointer to a style * @return true: valid */ -bool lv_debug_check_style_list(const lv_style_list_t * list); +bool lv_debug_check_style_list(const void * list); /************************* * GLOBAL VARIABLES diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index ef7918750..d8affe48a 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -75,7 +75,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin if(dsc->width == 0) return; if(start_angle == end_angle) return; - lv_style_int_t width = dsc->width; + lv_coord_t width = dsc->width; if(width > radius) width = radius; lv_draw_rect_dsc_t cir_dsc; diff --git a/src/lv_draw/lv_draw_label.h b/src/lv_draw/lv_draw_label.h index b6c81292f..7a5032859 100644 --- a/src/lv_draw/lv_draw_label.h +++ b/src/lv_draw/lv_draw_label.h @@ -32,8 +32,8 @@ typedef struct { lv_color_t sel_bg_color; const lv_font_t * font; lv_opa_t opa; - lv_style_int_t line_space; - lv_style_int_t letter_space; + lv_coord_t line_space; + lv_coord_t letter_space; uint32_t sel_start; uint32_t sel_end; lv_coord_t ofs_x; diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 1ae458f3f..37bd8a0f7 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -173,7 +173,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const fill_area.y1 = draw_area.y1 + disp_area->y1; fill_area.y2 = fill_area.y1; - lv_style_int_t dash_start = 0; + lv_coord_t dash_start = 0; if(dashed) { dash_start = (vdb->area.x1 + draw_area.x1) % (dsc->dash_gap + dsc->dash_width); } @@ -186,7 +186,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const if(dashed) { if(mask_res != LV_DRAW_MASK_RES_TRANSP) { - lv_style_int_t dash_cnt = dash_start; + lv_coord_t dash_cnt = dash_start; lv_coord_t i; for(i = 0; i < draw_area_w; i++, dash_cnt++) { if(dash_cnt <= dsc->dash_width) { @@ -276,12 +276,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); - lv_style_int_t dash_start = 0; + lv_coord_t dash_start = 0; if(dashed) { dash_start = (vdb->area.y1 + draw_area.y1) % (dsc->dash_gap + dsc->dash_width); } - lv_style_int_t dash_cnt = dash_start; + lv_coord_t dash_cnt = dash_start; int32_t h; for(h = draw_area.y1; h <= draw_area.y2; h++) { diff --git a/src/lv_draw/lv_draw_line.h b/src/lv_draw/lv_draw_line.h index eb4bbaf58..658710676 100644 --- a/src/lv_draw/lv_draw_line.h +++ b/src/lv_draw/lv_draw_line.h @@ -24,9 +24,9 @@ extern "C" { **********************/ typedef struct { lv_color_t color; - lv_style_int_t width; - lv_style_int_t dash_width; - lv_style_int_t dash_gap; + lv_coord_t width; + lv_coord_t dash_width; + lv_coord_t dash_gap; lv_opa_t opa; lv_blend_mode_t blend_mode : 2; uint8_t round_start : 1; diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 11be44f32..0022fc5aa 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -78,14 +78,12 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) dsc->bg_color = LV_COLOR_WHITE; dsc->bg_grad_color = LV_COLOR_BLACK; dsc->border_color = LV_COLOR_BLACK; - dsc->pattern_recolor = LV_COLOR_BLACK; dsc->value_color = LV_COLOR_BLACK; dsc->shadow_color = LV_COLOR_BLACK; dsc->bg_grad_color_stop = 0xFF; dsc->bg_opa = LV_OPA_COVER; dsc->outline_opa = LV_OPA_COVER; dsc->border_opa = LV_OPA_COVER; - dsc->pattern_opa = LV_OPA_COVER; dsc->pattern_font = LV_THEME_DEFAULT_FONT_NORMAL; dsc->value_opa = LV_OPA_COVER; dsc->value_font = LV_THEME_DEFAULT_FONT_NORMAL; @@ -1186,10 +1184,9 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const #if LV_USE_PATTERN static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { - if(dsc->pattern_image == NULL) return; - if(dsc->pattern_opa <= LV_OPA_MIN) return; + if(dsc->bg_img_src == NULL) return; - lv_img_src_t src_type = lv_img_src_get_type(dsc->pattern_image); + lv_img_src_t src_type = lv_img_src_get_type(dsc->bg_img_src); lv_draw_img_dsc_t img_dsc; lv_draw_label_dsc_t label_dsc; @@ -1198,7 +1195,7 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_VARIABLE) { lv_img_header_t header; - lv_res_t res = lv_img_decoder_get_info(dsc->pattern_image, &header); + lv_res_t res = lv_img_decoder_get_info(dsc->bg_img_src, &header); if(res != LV_RES_OK) { LV_LOG_WARN("draw_img: can't get image info"); return; @@ -1208,17 +1205,15 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const img_h = header.h; lv_draw_img_dsc_init(&img_dsc); - img_dsc.opa = dsc->pattern_opa; - img_dsc.recolor_opa = dsc->pattern_recolor_opa; - img_dsc.recolor = dsc->pattern_recolor; +// img_dsc.opa = dsc->pattern_opa; } else if(src_type == LV_IMG_SRC_SYMBOL) { lv_draw_label_dsc_init(&label_dsc); - label_dsc.color = dsc->pattern_recolor; +// label_dsc.color = dsc->pattern_recolor; label_dsc.font = dsc->pattern_font; - label_dsc.opa = dsc->pattern_opa; +// label_dsc.opa = dsc->pattern_opa; lv_point_t s; - _lv_txt_get_size(&s, dsc->pattern_image, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, + _lv_txt_get_size(&s, dsc->bg_img_src, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE); img_w = s.x; img_h = s.y; @@ -1236,7 +1231,7 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const lv_area_t coords_tmp; - if(dsc->pattern_repeat) { + if(dsc->bg_img_mosaic) { lv_draw_mask_radius_param_t radius_mask_param; lv_draw_mask_radius_init(&radius_mask_param, coords, dsc->radius, false); int16_t radius_mask_id = lv_draw_mask_add(&radius_mask_param, NULL); @@ -1251,8 +1246,8 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const coords_tmp.x1 = coords->x1 - ofs_x; coords_tmp.x2 = coords_tmp.x1 + img_w - 1; for(; coords_tmp.x1 <= coords->x2; coords_tmp.x1 += img_w, coords_tmp.x2 += img_w) { - if(src_type == LV_IMG_SRC_SYMBOL) lv_draw_label(&coords_tmp, clip, &label_dsc, dsc->pattern_image, NULL); - else lv_draw_img(&coords_tmp, clip, dsc->pattern_image, &img_dsc); + if(src_type == LV_IMG_SRC_SYMBOL) lv_draw_label(&coords_tmp, clip, &label_dsc, dsc->bg_img_src, NULL); + else lv_draw_img(&coords_tmp, clip, dsc->bg_img_src, &img_dsc); } } lv_draw_mask_remove_id(radius_mask_id); @@ -1281,8 +1276,8 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const radius_mask_id = lv_draw_mask_add(&radius_mask_param, NULL); } - if(src_type == LV_IMG_SRC_SYMBOL) lv_draw_label(&coords_tmp, clip, &label_dsc, dsc->pattern_image, NULL); - else lv_draw_img(&coords_tmp, clip, dsc->pattern_image, &img_dsc); + if(src_type == LV_IMG_SRC_SYMBOL) lv_draw_label(&coords_tmp, clip, &label_dsc, dsc->bg_img_src, NULL); + else lv_draw_img(&coords_tmp, clip, dsc->bg_img_src, &img_dsc); lv_draw_mask_remove_id(radius_mask_id); } diff --git a/src/lv_draw/lv_draw_rect.h b/src/lv_draw/lv_draw_rect.h index 0bf884832..bc8eac73e 100644 --- a/src/lv_draw/lv_draw_rect.h +++ b/src/lv_draw/lv_draw_rect.h @@ -24,48 +24,46 @@ extern "C" { **********************/ typedef struct { - lv_style_int_t radius; + lv_coord_t radius; /*Background*/ lv_color_t bg_color; lv_color_t bg_grad_color; lv_grad_dir_t bg_grad_dir; - lv_style_int_t bg_main_color_stop; - lv_style_int_t bg_grad_color_stop; + uint8_t bg_main_color_stop; + uint8_t bg_grad_color_stop; lv_opa_t bg_opa; lv_blend_mode_t bg_blend_mode; /*Border*/ lv_color_t border_color; - lv_style_int_t border_width; - lv_style_int_t border_side; + lv_coord_t border_width; + lv_border_side_t border_side; lv_opa_t border_opa; lv_blend_mode_t border_blend_mode; uint8_t border_post : 1; /*There is a border it will be drawn later. */ /*Outline*/ lv_color_t outline_color; - lv_style_int_t outline_width; - lv_style_int_t outline_pad; + lv_coord_t outline_width; + lv_coord_t outline_pad; lv_opa_t outline_opa; lv_blend_mode_t outline_blend_mode; /*Shadow*/ lv_color_t shadow_color; - lv_style_int_t shadow_width; - lv_style_int_t shadow_ofs_x; - lv_style_int_t shadow_ofs_y; - lv_style_int_t shadow_spread; + lv_coord_t shadow_width; + lv_coord_t shadow_ofs_x; + lv_coord_t shadow_ofs_y; + lv_coord_t shadow_spread; lv_opa_t shadow_opa; lv_blend_mode_t shadow_blend_mode; /*Pattern*/ - const void * pattern_image; + const void * bg_img_src; const lv_font_t * pattern_font; - lv_color_t pattern_recolor; - lv_opa_t pattern_opa; - lv_opa_t pattern_recolor_opa; - uint8_t pattern_repeat : 1; + lv_opa_t bg_img_opa; + uint8_t bg_img_mosaic : 1; lv_blend_mode_t pattern_blend_mode; /*Value*/ @@ -73,10 +71,10 @@ typedef struct { const lv_font_t * value_font; lv_opa_t value_opa; lv_color_t value_color; - lv_style_int_t value_ofs_x; - lv_style_int_t value_ofs_y; - lv_style_int_t value_letter_space; - lv_style_int_t value_line_space; + lv_coord_t value_ofs_x; + lv_coord_t value_ofs_y; + lv_coord_t value_letter_space; + lv_coord_t value_line_space; lv_align_t value_align; lv_blend_mode_t value_blend_mode; } lv_draw_rect_dsc_t; diff --git a/src/lv_hal/lv_hal_disp.c b/src/lv_hal/lv_hal_disp.c index 93e289a09..0ce054ffd 100644 --- a/src/lv_hal/lv_hal_disp.c +++ b/src/lv_hal/lv_hal_disp.c @@ -155,8 +155,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/ disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ disp->sys_layer = lv_obj_create(NULL, NULL); /*Create sys layer on the display*/ - lv_obj_reset_style_list(disp->top_layer, LV_OBJ_PART_MAIN); - lv_obj_reset_style_list(disp->sys_layer, LV_OBJ_PART_MAIN); + lv_obj_remove_all_styles(disp->top_layer); + lv_obj_remove_all_styles(disp->sys_layer); lv_obj_clear_flag(disp->top_layer, LV_OBJ_FLAG_CLICKABLE); lv_obj_clear_flag(disp->sys_layer, LV_OBJ_FLAG_CLICKABLE); diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index 0c8666ba0..8535816fa 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -161,8 +161,6 @@ void * lv_mem_alloc(size_t size) return &zero_mem; } - printf("alloc:%d\n", size); - #ifdef LV_ARCH_64 /*Round the size up to 8*/ size = (size + 7) & (~0x7); diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index ae8497259..27a267307 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -20,7 +20,6 @@ * STATIC PROTOTYPES **********************/ static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); -static void clear_styles(lv_obj_t * obj, lv_theme_style_t name); /********************** * STATIC VARIABLES @@ -62,7 +61,7 @@ lv_theme_t * lv_theme_get_act(void) void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name) { /* Remove the existing styles from all part of the object. */ - clear_styles(obj, name); + lv_obj_remove_all_styles(obj); /*Apply the theme including the base theme(s)*/ @@ -198,155 +197,3 @@ static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) th->apply_cb(act_theme, obj, name); } } - -static void clear_styles(lv_obj_t * obj, lv_theme_style_t name) -{ - switch(name) { - case LV_THEME_NONE: - break; - - case LV_THEME_SCR: - _lv_obj_reset_style_list_no_refr(obj, LV_OBJ_PART_MAIN); - break; - case LV_THEME_OBJ: - _lv_obj_reset_style_list_no_refr(obj, LV_OBJ_PART_MAIN); - break; - -#if LV_USE_BTN - case LV_THEME_BTN: - _lv_obj_reset_style_list_no_refr(obj, LV_BTN_PART_MAIN); - break; -#endif - -#if LV_USE_BTNMATRIX - case LV_THEME_BTNMATRIX: - _lv_obj_reset_style_list_no_refr(obj, LV_BTNMATRIX_PART_MAIN); - _lv_obj_reset_style_list_no_refr(obj, LV_BTNMATRIX_PART_BTN); - break; -#endif - -#if LV_USE_BAR - case LV_THEME_BAR: - _lv_obj_reset_style_list_no_refr(obj, LV_BAR_PART_MAIN); - _lv_obj_reset_style_list_no_refr(obj, LV_BAR_PART_INDIC); - break; -#endif - -#if LV_USE_SWITCH - case LV_THEME_SWITCH: - _lv_obj_reset_style_list_no_refr(obj, LV_SWITCH_PART_MAIN); - _lv_obj_reset_style_list_no_refr(obj, LV_SWITCH_PART_INDIC); - _lv_obj_reset_style_list_no_refr(obj, LV_SWITCH_PART_KNOB); - break; -#endif - -#if LV_USE_IMG - case LV_THEME_IMAGE: - _lv_obj_reset_style_list_no_refr(obj, LV_IMG_PART_MAIN); - break; -#endif - -#if LV_USE_IMGBTN - case LV_THEME_IMGBTN: - _lv_obj_reset_style_list_no_refr(obj, LV_IMG_PART_MAIN); - break; -#endif - -#if LV_USE_LABEL - case LV_THEME_LABEL: - _lv_obj_reset_style_list_no_refr(obj, LV_LABEL_PART_MAIN); - break; -#endif - -#if LV_USE_LINE - case LV_THEME_LINE: - _lv_obj_reset_style_list_no_refr(obj, LV_LABEL_PART_MAIN); - break; -#endif - -#if LV_USE_ARC - case LV_THEME_ARC: - _lv_obj_reset_style_list_no_refr(obj, LV_ARC_PART_BG); - _lv_obj_reset_style_list_no_refr(obj, LV_ARC_PART_INDIC); - break; -#endif - -#if LV_USE_SLIDER - case LV_THEME_SLIDER: - _lv_obj_reset_style_list_no_refr(obj, LV_SLIDER_PART_MAIN); - _lv_obj_reset_style_list_no_refr(obj, LV_SLIDER_PART_INDIC); - _lv_obj_reset_style_list_no_refr(obj, LV_SLIDER_PART_KNOB); - break; -#endif - -#if LV_USE_CHECKBOX - case LV_THEME_CHECKBOX: - _lv_obj_reset_style_list_no_refr(obj, LV_CHECKBOX_PART_MAIN); - _lv_obj_reset_style_list_no_refr(obj, LV_CHECKBOX_PART_BULLET); - break; -#endif - -#if LV_USE_ROLLER - case LV_THEME_ROLLER: - _lv_obj_reset_style_list_no_refr(obj, LV_ROLLER_PART_BG); - _lv_obj_reset_style_list_no_refr(obj, LV_ROLLER_PART_SELECTED); - break; -#endif - - -#if LV_USE_OBJMASK - case LV_THEME_OBJMASK: - _lv_obj_reset_style_list_no_refr(obj, LV_OBJMASK_PART_MAIN); - break; -#endif - -#if LV_USE_DROPDOWN - case LV_THEME_DROPDOWN: - _lv_obj_reset_style_list_no_refr(obj, LV_DROPDOWN_PART_MAIN); - _lv_obj_reset_style_list_no_refr(obj, LV_DROPDOWN_PART_LIST); - _lv_obj_reset_style_list_no_refr(obj, LV_DROPDOWN_PART_SELECTED); - break; -#endif - -#if LV_USE_CHART - case LV_THEME_CHART: - _lv_obj_reset_style_list_no_refr(obj, LV_CHART_PART_BG); - _lv_obj_reset_style_list_no_refr(obj, LV_CHART_PART_SERIES_BG); - _lv_obj_reset_style_list_no_refr(obj, LV_CHART_PART_SERIES); - break; -#endif -#if LV_USE_TABLE - case LV_THEME_TABLE: - _lv_obj_reset_style_list_no_refr(obj, LV_TABLE_PART_BG); - _lv_obj_reset_style_list_no_refr(obj, LV_TABLE_PART_CELL1); - _lv_obj_reset_style_list_no_refr(obj, LV_TABLE_PART_CELL2); - _lv_obj_reset_style_list_no_refr(obj, LV_TABLE_PART_CELL3); - _lv_obj_reset_style_list_no_refr(obj, LV_TABLE_PART_CELL4); - break; -#endif - -#if LV_USE_TEXTAREA - case LV_THEME_TEXTAREA: - _lv_obj_reset_style_list_no_refr(obj, LV_TEXTAREA_PART_MAIN); - _lv_obj_reset_style_list_no_refr(obj, LV_TEXTAREA_PART_PLACEHOLDER); - _lv_obj_reset_style_list_no_refr(obj, LV_TEXTAREA_PART_CURSOR); - break; -#endif - -#if LV_USE_LINEMETER - case LV_THEME_LINEMETER: - _lv_obj_reset_style_list_no_refr(obj, LV_LINEMETER_PART_MAIN); - break; -#endif -#if LV_USE_GAUGE - case LV_THEME_GAUGE: - _lv_obj_reset_style_list_no_refr(obj, LV_GAUGE_PART_MAIN); - _lv_obj_reset_style_list_no_refr(obj, LV_GAUGE_PART_MAJOR); - _lv_obj_reset_style_list_no_refr(obj, LV_GAUGE_PART_NEEDLE); - break; -#endif - default: - break; - } - -} diff --git a/src/lv_themes/lv_theme_empty.c b/src/lv_themes/lv_theme_empty.c index 027528d7c..b07fa6b07 100644 --- a/src/lv_themes/lv_theme_empty.c +++ b/src/lv_themes/lv_theme_empty.c @@ -87,7 +87,7 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco theme.flags = flags; style_init_reset(&styles->opa_cover); - lv_style_set_bg_opa(&styles->opa_cover, LV_STATE_DEFAULT, LV_OPA_COVER); + lv_style_set_bg_opa(&styles->opa_cover, LV_OPA_COVER); theme.apply_xcb = NULL; theme.apply_cb = theme_apply; @@ -99,8 +99,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) { LV_UNUSED(th); if(name == LV_THEME_SCR) { - _lv_obj_reset_style_list_no_refr(obj, LV_OBJ_PART_MAIN); - lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &styles->opa_cover); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->opa_cover); } } diff --git a/src/lv_widgets/lv_arc.h b/src/lv_widgets/lv_arc.h index 8caad7b68..47a6dd4cb 100644 --- a/src/lv_widgets/lv_arc.h +++ b/src/lv_widgets/lv_arc.h @@ -47,8 +47,6 @@ LV_CLASS_DECLARE_START(lv_arc, lv_obj); uint16_t indic_angle_end; \ uint16_t bg_angle_start; \ uint16_t bg_angle_end; \ - lv_style_list_t style_arc; \ - lv_style_list_t style_knob; /* Style of the knob */ \ int16_t value; /*Current value of the arc*/ \ int16_t min_value; /*Minimum value of the arc*/ \ int16_t max_value; /*Maximum value of the arc*/ \ diff --git a/src/lv_widgets/lv_bar.c b/src/lv_widgets/lv_bar.c index 04fe72311..f8801c7ac 100644 --- a/src/lv_widgets/lv_bar.c +++ b/src/lv_widgets/lv_bar.c @@ -553,16 +553,16 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area) lv_opa_t bg_opa = draw_indic_dsc.bg_opa; lv_opa_t border_opa = draw_indic_dsc.border_opa; lv_opa_t value_opa = draw_indic_dsc.value_opa; - const void * pattern_src = draw_indic_dsc.pattern_image; + const void * pattern_src = draw_indic_dsc.bg_img_src; draw_indic_dsc.bg_opa = LV_OPA_TRANSP; draw_indic_dsc.border_opa = LV_OPA_TRANSP; draw_indic_dsc.value_opa = LV_OPA_TRANSP; - draw_indic_dsc.pattern_image = NULL; + draw_indic_dsc.bg_img_src = NULL; lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc); draw_indic_dsc.bg_opa = bg_opa; draw_indic_dsc.border_opa = border_opa; draw_indic_dsc.value_opa = value_opa; - draw_indic_dsc.pattern_image = pattern_src; + draw_indic_dsc.bg_img_src = pattern_src; } @@ -608,7 +608,7 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area) draw_indic_dsc.bg_opa = LV_OPA_TRANSP; draw_indic_dsc.shadow_opa = LV_OPA_TRANSP; draw_indic_dsc.value_opa = LV_OPA_TRANSP; - draw_indic_dsc.pattern_image = NULL; + draw_indic_dsc.bg_img_src = NULL; lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc); lv_draw_mask_remove_id(mask_indic_id);