From 10e07270154b92376a741f063e883993d50e8ae6 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 6 Sep 2020 14:25:42 +0200 Subject: [PATCH] move some part of lv_obj.c to lv_obj_pos.v and lv_obj_scroll.c --- src/lv_core/lv_disp.c | 6 +- src/lv_core/lv_grid.c | 160 + src/lv_core/lv_grid.h | 7 + src/lv_core/lv_indev.c | 6 +- src/lv_core/lv_indev.h | 2 +- .../{lv_scroll.c => lv_indev_scroll.c} | 8 +- .../{lv_scroll.h => lv_indev_scroll.h} | 8 +- src/lv_core/lv_obj.c | 2568 +---------------- src/lv_core/lv_obj.h | 531 +--- src/lv_core/lv_obj_pos.c | 670 +++++ src/lv_core/lv_obj_pos.h | 241 ++ src/lv_core/lv_obj_scroll.c | 246 ++ src/lv_core/lv_obj_scroll.h | 153 + src/lv_core/lv_obj_style.c | 1366 +++++++++ .../{lv_obj_style_dec.h => lv_obj_style.h} | 295 +- src/lv_font/lv_font.h | 2 +- src/lv_themes/lv_theme.c | 170 +- src/lv_themes/lv_theme_empty.c | 2 +- src/lv_themes/lv_theme_material.c | 162 +- src/lv_themes/lv_theme_mono.c | 162 +- src/lv_themes/lv_theme_template.c | 172 +- src/lv_widgets/lv_label.c | 2 +- 22 files changed, 3526 insertions(+), 3413 deletions(-) rename src/lv_core/{lv_scroll.c => lv_indev_scroll.c} (98%) rename src/lv_core/{lv_scroll.h => lv_indev_scroll.h} (88%) create mode 100644 src/lv_core/lv_obj_pos.c create mode 100644 src/lv_core/lv_obj_pos.h create mode 100644 src/lv_core/lv_obj_scroll.c create mode 100644 src/lv_core/lv_obj_scroll.h create mode 100644 src/lv_core/lv_obj_style.c rename src/lv_core/{lv_obj_style_dec.h => lv_obj_style.h} (58%) diff --git a/src/lv_core/lv_disp.c b/src/lv_core/lv_disp.c index 6cf6283ef..14f480dd0 100644 --- a/src/lv_core/lv_disp.c +++ b/src/lv_core/lv_disp.c @@ -230,8 +230,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); @@ -395,6 +395,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_grid.c b/src/lv_core/lv_grid.c index a7a08a588..3c8fcd820 100644 --- a/src/lv_core/lv_grid.c +++ b/src/lv_core/lv_grid.c @@ -98,6 +98,166 @@ bool _lv_grid_has_fr_row(struct _lv_obj_t * obj) return false; } + + +static void _grid_item_repos(lv_obj_t * cont, lv_obj_t * item, _lv_grid_calc_t * calc, uint32_t * child_id_ext, lv_point_t * grid_abs) +{ + if(_lv_obj_is_grid_item(item) == false) return; + + uint32_t col_pos; + uint32_t col_span; + uint32_t row_pos; + uint32_t row_span; + + if(cont->grid->row_dsc && cont->grid->col_dsc) { + col_pos = _GRID_GET_CELL_POS(item->x_set); + col_span = _GRID_GET_CELL_SPAN(item->x_set); + row_pos = _GRID_GET_CELL_POS(item->y_set); + row_span = _GRID_GET_CELL_SPAN(item->y_set); + } else { + col_span = 1; + row_span = 1; + + uint32_t child_id = 0; + if(child_id_ext) child_id = *child_id_ext; + else { + lv_obj_t * child = lv_obj_get_child_back(cont, NULL); + + while(child) { + if(child == item) break; + if(_GRID_IS_CELL(child->x_set) && _GRID_IS_CELL(child->y_set)) { + child_id++; + } + child = lv_obj_get_child_back(cont, child); + } + } + + if(cont->grid->row_dsc == NULL) { + col_pos = child_id % cont->grid->col_dsc_len; + row_pos = child_id / cont->grid->col_dsc_len; + } else { + col_pos = child_id / cont->grid->row_dsc_len; + row_pos = child_id % cont->grid->row_dsc_len; + } + } + + lv_coord_t col_w = calc->col_dsc[col_pos + col_span] - calc->col_dsc[col_pos]; + lv_coord_t row_h = calc->row_dsc[row_pos + row_span] - calc->row_dsc[row_pos]; + + uint8_t x_flag = _GRID_GET_CELL_FLAG(item->x_set); + uint8_t y_flag = _GRID_GET_CELL_FLAG(item->y_set); + + lv_coord_t x; + lv_coord_t y; + lv_coord_t w = lv_obj_get_width(item); + lv_coord_t h = lv_obj_get_height(item); + + switch(x_flag) { + case LV_GRID_START: + x = calc->col_dsc[col_pos]; + break; + case LV_GRID_STRETCH: + x = calc->col_dsc[col_pos]; + w = col_w; + item->w_set = LV_SIZE_STRETCH; + break; + case LV_GRID_CENTER: + x = calc->col_dsc[col_pos] + (col_w - w) / 2; + break; + case LV_GRID_END: + x = calc->col_dsc[col_pos + 1] - lv_obj_get_width(item); + break; + } + + switch(y_flag) { + case LV_GRID_START: + y = calc->row_dsc[row_pos]; + break; + case LV_GRID_STRETCH: + y = calc->row_dsc[row_pos]; + item->h_set = LV_SIZE_STRETCH; + h = row_h; + break; + case LV_GRID_CENTER: + y = calc->row_dsc[row_pos] + (row_h - h) / 2; + break; + case LV_GRID_END: + y = calc->row_dsc[row_pos + 1] - lv_obj_get_height(item); + break; + } + + /*Set a new size if required*/ + if(lv_obj_get_width(item) != w || lv_obj_get_height(item) != h) { + lv_area_t old_coords; + lv_area_copy(&old_coords, &item->coords); + lv_obj_invalidate(item); + lv_area_set_width(&item->coords, w); + lv_area_set_height(&item->coords, h); + lv_obj_invalidate(item); + item->signal_cb(item, LV_SIGNAL_COORD_CHG, &old_coords); + + /* If a children is a grid container and has an FR field it also needs to be updated + * because the FR cell size will change with child size change. */ + lv_obj_t * child = lv_obj_get_child(item, NULL); + while(child) { + if(_lv_grid_has_fr_col(child) || _lv_grid_has_fr_row(child)) { + lv_grid_full_refr(child); + } + child = lv_obj_get_child(item, child); + } + } + bool moved = true; + if(grid_abs) { + if(grid_abs->x + x == item->coords.x1 && grid_abs->y + y == item->coords.y1) moved = false; + } + + if(moved) _lv_obj_move_to(item, x, y, false); +} + +void lv_grid_full_refr(lv_obj_t * cont) +{ + /*Calculate the grid*/ + if(cont->grid == NULL) return; + _lv_grid_calc_t calc; + grid_calc(cont, &calc); + + /* 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_point_t grid_abs; + 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); + grid_abs.x = pad_left + cont->coords.x1 - lv_obj_get_scroll_left(cont); + grid_abs.y = pad_top + cont->coords.y1 - lv_obj_get_scroll_top(cont); + + uint32_t child_id = 0; + lv_obj_t * item = lv_obj_get_child_back(cont, NULL); + while(item) { + if(_GRID_IS_CELL(item->x_set) && _GRID_IS_CELL(item->y_set)) { + _grid_item_repos(cont, item, &calc, &child_id, &grid_abs); + child_id++; + } + item = lv_obj_get_child_back(cont, item); + } + grid_calc_free(&calc); + + if(cont->w_set == LV_SIZE_AUTO || cont->h_set == LV_SIZE_AUTO) { + lv_obj_set_size(cont, cont->w_set, cont->h_set); + } +} + +void lv_grid_item_refr_pos(lv_obj_t * item) +{ + /*Calculate the grid*/ + lv_obj_t * cont = lv_obj_get_parent(item); + if(cont->grid == NULL) return; + _lv_grid_calc_t calc; + grid_calc(cont, &calc); + + _grid_item_repos(cont, item, &calc, NULL, NULL); + + grid_calc_free(&calc); +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/lv_core/lv_grid.h b/src/lv_core/lv_grid.h index b64576072..846ca718a 100644 --- a/src/lv_core/lv_grid.h +++ b/src/lv_core/lv_grid.h @@ -75,6 +75,7 @@ extern "C" { /* Can't include lv_obj.h because it includes this header file */ struct _lv_obj_t; +typedef struct _lv_obj_t lv_obj_t; /** * Describe how to flow LV_GRID_POS_AUTO elements @@ -120,6 +121,12 @@ bool _lv_grid_has_fr_col(struct _lv_obj_t * obj); bool _lv_grid_has_fr_row(struct _lv_obj_t * obj); +void lv_grid_full_refr(lv_obj_t * cont); + +void lv_grid_item_refr_pos(lv_obj_t * item); + +bool _lv_obj_is_grid_item(lv_obj_t * obj); + /********************** * MACROS **********************/ diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index 5f3157b2c..50ad967df 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -9,11 +9,11 @@ #include "lv_indev.h" #include "lv_disp.h" #include "lv_obj.h" -#include "lv_scroll.h" +#include "lv_indev_scroll.h" +#include "lv_group.h" +#include "lv_refr.h" #include "../lv_hal/lv_hal_tick.h" -#include "../lv_core/lv_group.h" -#include "../lv_core/lv_refr.h" #include "../lv_misc/lv_task.h" #include "../lv_misc/lv_math.h" diff --git a/src/lv_core/lv_indev.h b/src/lv_core/lv_indev.h index 2b6c69161..53c5b8451 100644 --- a/src/lv_core/lv_indev.h +++ b/src/lv_core/lv_indev.h @@ -15,7 +15,7 @@ extern "C" { *********************/ #include "lv_obj.h" #include "../lv_hal/lv_hal_indev.h" -#include "../lv_core/lv_group.h" +#include "lv_group.h" /********************* * DEFINES diff --git a/src/lv_core/lv_scroll.c b/src/lv_core/lv_indev_scroll.c similarity index 98% rename from src/lv_core/lv_scroll.c rename to src/lv_core/lv_indev_scroll.c index 9fc7e5155..fa0fcfc89 100644 --- a/src/lv_core/lv_scroll.c +++ b/src/lv_core/lv_indev_scroll.c @@ -6,8 +6,8 @@ /********************* * INCLUDES *********************/ -#include "lv_scroll.h" #include "lv_indev.h" +#include "lv_indev_scroll.h" /********************* * DEFINES @@ -228,7 +228,7 @@ void _lv_scroll_handler(lv_indev_proc_t * proc) /*Respect the scroll limit area*/ scroll_limit_diff(proc, &diff_x, &diff_y); - lv_obj_scroll_by_raw(scroll_obj, diff_x, diff_y); + _lv_obj_scroll_by_raw(scroll_obj, diff_x, diff_y); proc->types.pointer.scroll_sum.x += diff_x; proc->types.pointer.scroll_sum.y += diff_y; } @@ -265,7 +265,7 @@ void _lv_scroll_throw_handler(lv_indev_proc_t * proc) proc->types.pointer.scroll_throw_vect.y = proc->types.pointer.scroll_throw_vect.y >> 1; } - lv_obj_scroll_by_raw(scroll_obj, 0, proc->types.pointer.scroll_throw_vect.y); + _lv_obj_scroll_by_raw(scroll_obj, 0, proc->types.pointer.scroll_throw_vect.y); } /*With snapping find the nearest snap point and scroll there*/ else { @@ -291,7 +291,7 @@ void _lv_scroll_throw_handler(lv_indev_proc_t * proc) proc->types.pointer.scroll_throw_vect.x = proc->types.pointer.scroll_throw_vect.x >> 1; } - lv_obj_scroll_by_raw(scroll_obj, proc->types.pointer.scroll_throw_vect.x, 0); + _lv_obj_scroll_by_raw(scroll_obj, proc->types.pointer.scroll_throw_vect.x, 0); } /*With snapping find the nearest snap point and scroll there*/ else { diff --git a/src/lv_core/lv_scroll.h b/src/lv_core/lv_indev_scroll.h similarity index 88% rename from src/lv_core/lv_scroll.h rename to src/lv_core/lv_indev_scroll.h index 293efd592..b43d608d5 100644 --- a/src/lv_core/lv_scroll.h +++ b/src/lv_core/lv_indev_scroll.h @@ -1,10 +1,10 @@ /** - * @file lv_scroll.h + * @file lv_indev_scroll.h * */ -#ifndef LV_SCROLL_H -#define LV_SCROLL_H +#ifndef LV_INDEV_SCROLL_H +#define LV_INDEV_SCROLL_H #ifdef __cplusplus extern "C" { @@ -48,4 +48,4 @@ void _lv_scroll_throw_handler(lv_indev_proc_t * proc); } /* extern "C" */ #endif -#endif /*LV_SCROLL_H*/ +#endif /*LV_INDEV_SCROLL_H*/ diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 780ac26b5..caeecc90d 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -49,9 +49,6 @@ #define LV_OBJ_DEF_WIDTH (LV_DPX(100)) #define LV_OBJ_DEF_HEIGHT (LV_DPX(50)) #define SCROLLBAR_MIN_SIZE (LV_DPX(10)) -#define SCROLL_ANIM_TIME_MIN 100 /*ms*/ -#define SCROLL_ANIM_TIME_MAX 300 /*ms*/ - #define GRID_DEBUG 1 /*Draw rectangles on grid cells*/ /********************** @@ -63,58 +60,19 @@ typedef struct _lv_event_temp_data { struct _lv_event_temp_data * prev; } lv_event_temp_data_t; -typedef struct { - lv_obj_t * obj; - lv_style_property_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_trans_t; /********************** * STATIC PROTOTYPES **********************/ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area, lv_design_mode_t mode); static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param); -static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff); -static void report_style_mod_core(void * style_p, lv_obj_t * obj); -static void refresh_children_style(lv_obj_t * obj); -static void base_dir_refr_children(lv_obj_t * obj); -static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, - lv_coord_t x_ofs, lv_coord_t y_ofs); -static void obj_align_mid_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, - lv_coord_t x_ofs, lv_coord_t y_ofs); -#if LV_USE_ANIMATION -static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, - lv_state_t new_state); -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_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); -static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v); -static void fade_in_anim_ready(lv_anim_t * a); -static void scroll_anim_x_cb(lv_obj_t * obj, lv_anim_value_t v); -static void scroll_anim_y_cb(lv_obj_t * obj, lv_anim_value_t v); -#endif static void lv_event_mark_deleted(lv_obj_t * obj); static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find); static void lv_obj_del_async_cb(void * obj); static void obj_del_core(lv_obj_t * obj); static lv_res_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc); static void scrollbar_draw(lv_obj_t * obj, const lv_area_t * clip_area); -static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop); -static void update_style_cache_children(lv_obj_t * obj); -static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop); +static void base_dir_refr_children(lv_obj_t * obj); /********************** * STATIC VARIABLES @@ -165,7 +123,7 @@ void lv_init(void) lv_gpu_stm32_dma2d_init(); #endif - _lv_ll_init(&LV_GC_ROOT(_lv_obj_style_trans_ll), sizeof(lv_style_trans_t)); + _lv_obj_style_init(); _lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t)); _lv_ll_init(&LV_GC_ROOT(_lv_indev_ll), sizeof(lv_indev_t)); @@ -697,706 +655,7 @@ void lv_obj_move_background(lv_obj_t * obj) * Coordinate set * ------------------*/ -static void move_obj_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, bool notify_parent) -{ - /*Convert x and y to absolute coordinates*/ - 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); - - x += pad_left + parent->coords.x1 - lv_obj_get_scroll_left(parent); - y += pad_top + parent->coords.y1 - lv_obj_get_scroll_top(parent); - } else { - /*If no parent then it's screen but screen can't be on a grid*/ - if(_GRID_IS_CELL(obj->x_set) || _GRID_IS_CELL(obj->x_set)) { - obj->x_set = 0; - obj->y_set = 0; - x = 0; - y = 0; - } - } - - /*Calculate and set the movement*/ - lv_point_t diff; - diff.x = x - obj->coords.x1; - diff.y = y - obj->coords.y1; - - /* Do nothing if the position is not changed */ - /* It is very important else recursive positioning can - * occur without position change*/ - if(diff.x == 0 && diff.y == 0) return; - - /*Invalidate the original area*/ - lv_obj_invalidate(obj); - - /*Save the original coordinates*/ - lv_area_t ori; - lv_obj_get_coords(obj, &ori); - - obj->coords.x1 += diff.x; - obj->coords.y1 += diff.y; - obj->coords.x2 += diff.x; - obj->coords.y2 += diff.y; - - refresh_children_position(obj, diff.x, diff.y); - - /*Inform the object about its new coordinates*/ - obj->signal_cb(obj, LV_SIGNAL_COORD_CHG, &ori); - - /*Send a signal to the parent too*/ - if(parent && notify_parent) parent->signal_cb(parent, LV_SIGNAL_CHILD_CHG, obj); - - /*Invalidate the new area*/ - lv_obj_invalidate(obj); -} - - -static bool refr_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h) -{ - /* Do nothing if the size is not changed */ - /* It is very important else recursive resizing can - * occur without size change*/ - if(lv_obj_get_width(obj) == w && lv_obj_get_height(obj) == h) { - return false; - } - /*Invalidate the original area*/ - lv_obj_invalidate(obj); - - /*Save the original coordinates*/ - lv_area_t ori; - lv_obj_get_coords(obj, &ori); - - /*Set the length and height*/ - obj->coords.y2 = obj->coords.y1 + h - 1; - if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) { - obj->coords.x1 = obj->coords.x2 - w + 1; - } - else { - obj->coords.x2 = obj->coords.x1 + w - 1; - } - - /*Send a signal to the object with its new coordinates*/ - obj->signal_cb(obj, LV_SIGNAL_COORD_CHG, &ori); - - /*Send a signal to the parent too*/ - lv_obj_t * par = lv_obj_get_parent(obj); - if(par != NULL) par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj); - - /*Invalidate the new area*/ - lv_obj_invalidate(obj); - return true; -} - -bool lv_obj_is_grid_item(lv_obj_t * obj); -static void lv_grid_full_refr(lv_obj_t * cont); - -static void _grid_item_repos(lv_obj_t * cont, lv_obj_t * item, _lv_grid_calc_t * calc, uint32_t * child_id_ext, lv_point_t * grid_abs) -{ - if(lv_obj_is_grid_item(item) == false) return; - - uint32_t col_pos; - uint32_t col_span; - uint32_t row_pos; - uint32_t row_span; - - if(cont->grid->row_dsc && cont->grid->col_dsc) { - col_pos = _GRID_GET_CELL_POS(item->x_set); - col_span = _GRID_GET_CELL_SPAN(item->x_set); - row_pos = _GRID_GET_CELL_POS(item->y_set); - row_span = _GRID_GET_CELL_SPAN(item->y_set); - } else { - col_span = 1; - row_span = 1; - - uint32_t child_id = 0; - if(child_id_ext) child_id = *child_id_ext; - else { - lv_obj_t * child = lv_obj_get_child_back(cont, NULL); - - while(child) { - if(child == item) break; - if(_GRID_IS_CELL(child->x_set) && _GRID_IS_CELL(child->y_set)) { - child_id++; - } - child = lv_obj_get_child_back(cont, child); - } - } - - if(cont->grid->row_dsc == NULL) { - col_pos = child_id % cont->grid->col_dsc_len; - row_pos = child_id / cont->grid->col_dsc_len; - } else { - col_pos = child_id / cont->grid->row_dsc_len; - row_pos = child_id % cont->grid->row_dsc_len; - } - } - - lv_coord_t col_w = calc->col_dsc[col_pos + col_span] - calc->col_dsc[col_pos]; - lv_coord_t row_h = calc->row_dsc[row_pos + row_span] - calc->row_dsc[row_pos]; - - uint8_t x_flag = _GRID_GET_CELL_FLAG(item->x_set); - uint8_t y_flag = _GRID_GET_CELL_FLAG(item->y_set); - - lv_coord_t x; - lv_coord_t y; - lv_coord_t w = lv_obj_get_width(item); - lv_coord_t h = lv_obj_get_height(item); - - switch(x_flag) { - case LV_GRID_START: - x = calc->col_dsc[col_pos]; - break; - case LV_GRID_STRETCH: - x = calc->col_dsc[col_pos]; - w = col_w; - item->w_set = LV_SIZE_STRETCH; - break; - case LV_GRID_CENTER: - x = calc->col_dsc[col_pos] + (col_w - w) / 2; - break; - case LV_GRID_END: - x = calc->col_dsc[col_pos + 1] - lv_obj_get_width(item); - break; - } - - switch(y_flag) { - case LV_GRID_START: - y = calc->row_dsc[row_pos]; - break; - case LV_GRID_STRETCH: - y = calc->row_dsc[row_pos]; - item->h_set = LV_SIZE_STRETCH; - h = row_h; - break; - case LV_GRID_CENTER: - y = calc->row_dsc[row_pos] + (row_h - h) / 2; - break; - case LV_GRID_END: - y = calc->row_dsc[row_pos + 1] - lv_obj_get_height(item); - break; - } - - /*Set a new size if required*/ - if(lv_obj_get_width(item) != w || lv_obj_get_height(item) != h) { - lv_area_t old_coords; - lv_area_copy(&old_coords, &item->coords); - lv_obj_invalidate(item); - lv_area_set_width(&item->coords, w); - lv_area_set_height(&item->coords, h); - lv_obj_invalidate(item); - item->signal_cb(item, LV_SIGNAL_COORD_CHG, &old_coords); - - /* If a children is a grid container and has an FR field it also needs to be updated - * because the FR cell size will change with child size change. */ - lv_obj_t * child = lv_obj_get_child(item, NULL); - while(child) { - if(_lv_grid_has_fr_col(child) || _lv_grid_has_fr_row(child)) { - lv_grid_full_refr(child); - } - child = lv_obj_get_child(item, child); - } - } - bool moved = true; - if(grid_abs) { - if(grid_abs->x + x == item->coords.x1 && grid_abs->y + y == item->coords.y1) moved = false; - } - - if(moved) move_obj_to(item, x, y, false); -} - -static void lv_grid_full_refr(lv_obj_t * cont) -{ - /*Calculate the grid*/ - if(cont->grid == NULL) return; - _lv_grid_calc_t calc; - grid_calc(cont, &calc); - - /* 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_point_t grid_abs; - 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); - grid_abs.x = pad_left + cont->coords.x1 - lv_obj_get_scroll_left(cont); - grid_abs.y = pad_top + cont->coords.y1 - lv_obj_get_scroll_top(cont); - - uint32_t child_id = 0; - lv_obj_t * item = lv_obj_get_child_back(cont, NULL); - while(item) { - if(_GRID_IS_CELL(item->x_set) && _GRID_IS_CELL(item->y_set)) { - _grid_item_repos(cont, item, &calc, &child_id, &grid_abs); - child_id++; - } - item = lv_obj_get_child_back(cont, item); - } - grid_calc_free(&calc); - - if(cont->w_set == LV_SIZE_AUTO || cont->h_set == LV_SIZE_AUTO) { - lv_obj_set_size(cont, cont->w_set, cont->h_set); - } -} - -static void lv_grid_item_refr_pos(lv_obj_t * item) -{ - /*Calculate the grid*/ - lv_obj_t * cont = lv_obj_get_parent(item); - if(cont->grid == NULL) return; - _lv_grid_calc_t calc; - grid_calc(cont, &calc); - - _grid_item_repos(cont, item, &calc, NULL, NULL); - - grid_calc_free(&calc); -} - -bool lv_obj_is_grid_item(lv_obj_t * obj) -{ - lv_obj_t * cont = lv_obj_get_parent(obj); - if(cont == NULL) return false; - if(cont->grid == NULL) return false; - if(_GRID_IS_CELL(obj->x_set) && _GRID_IS_CELL(obj->y_set)) return true; - return false; -} - -/** - * Set relative the position of an object (relative to the parent) - * @param obj pointer to an object - * @param x new distance from the left side of the parent - * @param y new distance from the top of the parent - */ -void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - obj->x_set = x; - obj->y_set = y; - - bool gi = lv_obj_is_grid_item(obj); - - /*For consistency set the size to stretched if the objects is stretched on the grid*/ - if(gi) { - if(_GRID_GET_CELL_FLAG(obj->x_set) == LV_GRID_STRETCH) obj->w_set = LV_SIZE_STRETCH; - if(_GRID_GET_CELL_FLAG(obj->y_set) == LV_GRID_STRETCH) obj->h_set = LV_SIZE_STRETCH; - } - - /*If not grid item but has grid position set the position to 0*/ - if(!gi) { - if(_GRID_IS_CELL(x)) { - obj->x_set = 0; - x = 0; - } - if(_GRID_IS_CELL(y)) { - obj->y_set = 0; - y = 0; - } - } - - /*If the object is on a grid item let the grid to position it. */ - if(gi) { - lv_area_t old_area; - lv_area_copy(&old_area, &obj->coords); - lv_grid_item_refr_pos(obj); - - lv_obj_t * cont = lv_obj_get_parent(obj); - - /*If the item was moved and grid is implicit in the changed direction refresh the whole grid.*/ - if((cont->grid->col_dsc == NULL && (old_area.x1 != obj->coords.x1 || old_area.x2 != obj->coords.x2)) || - (cont->grid->row_dsc == NULL && (old_area.y1 != obj->coords.y1 || old_area.y2 != obj->coords.y2))) - { - lv_grid_full_refr(cont); - } - } else { - move_obj_to(obj, x, y, true); - } -} - -/** - * Set the x coordinate of a object - * @param obj pointer to an object - * @param x new distance from the left side from the parent - */ -void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - lv_obj_set_pos(obj, x, lv_obj_get_y(obj)); -} - -/** - * Set the y coordinate of a object - * @param obj pointer to an object - * @param y new distance from the top of the parent - */ -void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - lv_obj_set_pos(obj, lv_obj_get_x(obj), y); -} - -void _lv_obj_calc_auto_size(lv_obj_t * obj, lv_coord_t * w, lv_coord_t * h) -{ - if(!w && !h) return; - -// static uint32_t cnt = 0; -// printf("auto_size: %d\n", cnt); -// cnt++; - - /*If no other effect the auto-size of zero by default*/ - if(w) *w = 0; - if(h) *h = 0; - - /*Get the grid size of the object has a defined grid*/ - lv_coord_t grid_w = 0; - lv_coord_t grid_h = 0; - if(obj->grid) { - _lv_grid_calc_t calc; - grid_calc(obj, &calc); - grid_w = calc.col_dsc[calc.col_dsc_len - 1] + lv_obj_get_style_pad_top(obj, LV_OBJ_PART_MAIN) + + lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN); - grid_h = calc.row_dsc[calc.row_dsc_len - 1] + lv_obj_get_style_pad_left(obj, LV_OBJ_PART_MAIN) + lv_obj_get_style_pad_right(obj, LV_OBJ_PART_MAIN);; - grid_calc_free(&calc); - } - - /*Get the children's most right and bottom position*/ - lv_coord_t children_w = 0; - lv_coord_t children_h = 0; - if(w) { - lv_obj_scroll_to_x(obj, 0, LV_ANIM_OFF); - lv_coord_t scroll_right = lv_obj_get_scroll_right(obj); - children_w = lv_obj_get_width(obj) + scroll_right; - } - - if(h) { - lv_obj_scroll_to_y(obj, 0, LV_ANIM_OFF); - lv_coord_t scroll_bottom = lv_obj_get_scroll_bottom(obj); - children_h = lv_obj_get_height(obj) + scroll_bottom; - } - - - /*auto_size = max(gird_size, children_size)*/ - if(w) *w = LV_MATH_MAX(children_w, grid_w); - if(h) *h = LV_MATH_MAX(children_h, grid_h); -} - -/** - * Set the size of an object - * @param obj pointer to an object - * @param w new width - * @param h new height - */ -void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - bool gi = lv_obj_is_grid_item(obj); - bool x_stretch = false; - bool y_stretch = false; - - if(gi) { - x_stretch = _GRID_GET_CELL_FLAG(obj->x_set) == LV_GRID_STRETCH ? true : false; - y_stretch = _GRID_GET_CELL_FLAG(obj->y_set) == LV_GRID_STRETCH ? true : false; - if(x_stretch) w = LV_SIZE_STRETCH; - if(y_stretch) h = LV_SIZE_STRETCH; - } - - obj->w_set = w; - obj->h_set = h; - - /*If both streched it was alraedy managed by the grid*/ - if(x_stretch && y_stretch) return; - - if(x_stretch) w = lv_obj_get_width(obj); - if(y_stretch) h = lv_obj_get_height(obj); - - /*Calculate the required auto sizes*/ - bool x_auto = obj->w_set == LV_SIZE_AUTO ? true : false; - bool y_auto = obj->h_set == LV_SIZE_AUTO ? true : false; - - lv_coord_t auto_w; - lv_coord_t auto_h; - if(x_auto && y_auto) { - _lv_obj_calc_auto_size(obj, &auto_w, &auto_h); - w = auto_w; - h = auto_h; - } - else if(x_auto) { - _lv_obj_calc_auto_size(obj, &auto_w, NULL); - w = auto_w; - } - else if(y_auto) { - _lv_obj_calc_auto_size(obj, NULL, &auto_h); - h = auto_h; - } - - refr_size(obj, w, h); -} - -/** - * Set the width of an object - * @param obj pointer to an object - * @param w new width - */ -void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - lv_obj_set_size(obj, w, lv_obj_get_height(obj)); -} - -/** - * Set the height of an object - * @param obj pointer to an object - * @param h new height - */ -void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - lv_obj_set_size(obj, lv_obj_get_width(obj), h); -} - -/** - * Set the width reduced by the left and right padding. - * @param obj pointer to an object - * @param w the width without paddings - */ -void lv_obj_set_width_fit(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_obj_set_width(obj, w - pleft - pright); -} - -/** - * Set the height reduced by the top and bottom padding. - * @param obj pointer to an object - * @param h the height without paddings - */ -void lv_obj_set_height_fit(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_obj_set_height(obj, h - ptop - pbottom); -} - -/** - * Set the width of an object by taking the left and right margin into account. - * The object width will be `obj_w = w - margin_left - margin_right` - * @param obj pointer to an object - * @param w new height including margins - */ -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_obj_set_width(obj, w - mleft - mright); -} - -/** - * Set the height of an object by taking the top and bottom margin into account. - * The object height will be `obj_h = h - margin_top - margin_bottom` - * @param obj pointer to an object - * @param h new height including margins - */ -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_obj_set_height(obj, h - mtop - mbottom); -} - -/** - * Align an object to an other object. - * @param obj pointer to an object to align - * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. - * @param align type of alignment (see 'lv_align_t' enum) - * @param x_ofs x coordinate offset after alignment - * @param y_ofs y coordinate offset after alignment - */ -void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - if(base == NULL) base = lv_obj_get_parent(obj); - - LV_ASSERT_OBJ(base, LV_OBJX_NAME); - - obj_align_core(obj, base, align, true, true, x_ofs, y_ofs); -} - -/** - * Moves all children with horizontally or vertically. - * It doesn't take into account any limits so any values are possible - * @param obj pointer to an object whose children should be moved - * @param x pixel to move horizontally - * @param y pixels to move vertically - */ -void lv_obj_scroll_by_raw(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) -{ - obj->scroll.x += x; - obj->scroll.y += y; - - refresh_children_position(obj, x, y); - lv_res_t res = lv_signal_send(obj, LV_SIGNAL_SCROLL, NULL); - if(res != LV_RES_OK) return; - lv_obj_invalidate(obj); -} -/** - * Moves all children with horizontally or vertically. - * Limits the scroll to the bounding box of the children. - * @param obj pointer to an object whose children should be moved - * @param x pixel to move horizontally - * @param y pixels to move vertically - */ -void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en) -{ - - if(x == 0 && y == 0) return; - - if(anim_en == LV_ANIM_ON) { - lv_disp_t * d = lv_obj_get_disp(obj); - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_var(&a, obj); - - lv_anim_path_t path; - lv_anim_path_init(&path); - lv_anim_path_set_cb(&path, lv_anim_path_ease_out); - - if(x) { - uint32_t t = lv_anim_speed_to_time((lv_disp_get_hor_res(d) * 3) >> 2, 0, x); - if(t < SCROLL_ANIM_TIME_MIN) t = SCROLL_ANIM_TIME_MIN; - if(t > SCROLL_ANIM_TIME_MAX) t = SCROLL_ANIM_TIME_MAX; - lv_anim_set_time(&a, t); - lv_anim_set_values(&a, obj->scroll.x, obj->scroll.x + x); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t) scroll_anim_x_cb); - lv_anim_set_path(&a, &path); - lv_anim_start(&a); - } - - if(y) { - uint32_t t = lv_anim_speed_to_time((lv_disp_get_ver_res(d) * 3) >> 2, 0, y); - if(t < SCROLL_ANIM_TIME_MIN) t = SCROLL_ANIM_TIME_MIN; - if(t > SCROLL_ANIM_TIME_MAX) t = SCROLL_ANIM_TIME_MAX; - lv_anim_set_time(&a, t); - lv_anim_set_values(&a, obj->scroll.y, obj->scroll.y + y); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t) scroll_anim_y_cb); - lv_anim_set_path(&a, &path); - lv_anim_start(&a); - } - } else { - lv_obj_scroll_by_raw(obj, x, y); - } -} - -/** - * Scroll the a given x coordinate to the left side of obj. - * @param obj pointer to an object which should be scrolled - * @param x the x coordinate to scroll to - * @param y the y coordinate to scroll to - */ -void lv_obj_scroll_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en) -{ - -} - -/** - * Scroll the a given x coordinate to the left side of obj. - * @param obj pointer to an object which should be scrolled - * @param x the x coordinate to scroll to - */ -void lv_obj_scroll_to_x(lv_obj_t * obj, lv_coord_t x, lv_anim_enable_t anim_en) -{ - lv_obj_scroll_by(obj, -x - obj->scroll.x, 0, anim_en); -} - -/** - * Scroll the a given y coordinate to the top side of obj. - * @param obj pointer to an object which should be scrolled - * @param y the y coordinate to scroll to - */ -void lv_obj_scroll_to_y(lv_obj_t * obj, lv_coord_t y, lv_anim_enable_t anim_en) -{ - lv_obj_scroll_by(obj, 0, -y - obj->scroll.y, anim_en); -} - - -/** - * Return the height of the area above the parent. - * That is the number of pixels the object can be scrolled down. - * Normally positive but can be negative when scrolled inside. - * @param obj - * @return - */ -lv_coord_t lv_obj_get_scroll_top(const lv_obj_t * obj) -{ - return -obj->scroll.y; -} - -/** - * Return the height of the area below the parent. - * That is the number of pixels the object can be scrolled up. - * Normally positive but can be negative when scrolled inside. - * @param obj - * @return - */ -lv_coord_t lv_obj_get_scroll_bottom(const lv_obj_t * obj) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - lv_coord_t y2 = LV_COORD_MIN; - - lv_obj_t * child = lv_obj_get_child(obj, NULL); - if(child == NULL) return 0; - - while(child) { - y2 = LV_MATH_MAX(y2, child->coords.y2 + lv_obj_get_style_margin_bottom(child, LV_OBJ_PART_MAIN)); - child = lv_obj_get_child(obj, child); - } - - return y2 - obj->coords.y2 + lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN); -} - -/** - * Return the weight of the area on the left the parent. - * That is the number of pixels the object can be scrolled down. - * Normally positive but can be negative when scrolled inside. - * @param obj - * @return - */ -lv_coord_t lv_obj_get_scroll_left(const lv_obj_t * obj) -{ - return -obj->scroll.x; -} - -/** - * Return the width of the area below the object. - * That is the number of pixels the object can be scrolled left. - * Normally positive but can be negative when scrolled inside. - * @param obj - * @return - */ -lv_coord_t lv_obj_get_scroll_right(const lv_obj_t * obj) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - lv_coord_t x2 = LV_COORD_MIN; - - lv_obj_t * child = lv_obj_get_child(obj, NULL); - if(child == NULL) return 0; - - while(child) { - x2 = LV_MATH_MAX(x2, child->coords.x2 + lv_obj_get_style_margin_right(child, LV_OBJ_PART_MAIN)); - child = lv_obj_get_child(obj, child); - } - - return x2 - obj->coords.x2 + lv_obj_get_style_pad_right(obj, LV_OBJ_PART_MAIN); -} /** * Set the size of an extended clickable area @@ -1433,317 +692,6 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right * Appearance set *--------------------*/ -/** - * Add a new style to the style list 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` - * @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) -{ - if(style == NULL) return; - - lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part); - if(style_dsc == NULL) { - LV_LOG_WARN("Can't find style with part: %d", part); - return; - } - - _lv_style_list_add_style(style_dsc, style); -#if LV_USE_ANIMATION - trans_del(obj, part, 0xFF, NULL); -#endif - lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); -} - -/** - * Remove a style from the style list 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` - * @param style pointer to a style to remove - */ -void lv_obj_remove_style(lv_obj_t * obj, uint8_t part, lv_style_t * style) -{ - if(style == NULL) return; - - lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part); - if(style_dsc == NULL) { - LV_LOG_WARN("Can't find style with part: %d", part); - return; - } - - _lv_style_list_remove_style(style_dsc, style); -#if LV_USE_ANIMATION - trans_del(obj, part, 0xFF, NULL); -#endif - lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); -} - -/** - * Reset a style to the default (empty) state. - * Release all used memories and cancel pending related transitions. - * Typically used in `LV_SIGN_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_clean_style_list(lv_obj_t * obj, uint8_t part) -{ - lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part); - if(style_dsc == NULL) { - LV_LOG_WARN("lv_obj_clean_style_list: can't find style with `part`"); - return; - } - - _lv_style_list_reset(style_dsc); -#if LV_USE_ANIMATION - trans_del(obj, part, 0xFF, NULL); -#endif -} - -/** - * Reset a style to the default (empty) state. - * Release all used memories and cancel pending related transitions. - * Also notifies the object about the style change. - * @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(lv_obj_t * obj, uint8_t part) -{ - lv_obj_clean_style_list(obj, part); - - lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); -} - -/** - * 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_opa()` - * @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 * style_dsc = lv_obj_get_style_list(obj, part); - _lv_style_list_set_local_int(style_dsc, 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 * style_dsc = lv_obj_get_style_list(obj, part); - _lv_style_list_set_local_color(style_dsc, 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 * style_dsc = lv_obj_get_style_list(obj, part); - _lv_style_list_set_local_opa(style_dsc, 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 * style_dsc = lv_obj_get_style_list(obj, part); - _lv_style_list_set_local_ptr(style_dsc, prop, value); -#if LV_USE_ANIMATION - trans_del(obj, part, prop, NULL); -#endif - lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK)); -} - -/** - * 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)` - * @note shouldn't be used directly. Use the specific property remove functions instead. - * For example: `lv_obj_style_remove_border_opa()` - * @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) -{ - 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; -} - -/** - * 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) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - invalidate_style_cache(obj, part, prop); - - /*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_PAD_TOP: - case LV_STYLE_PAD_BOTTOM: - case LV_STYLE_PAD_LEFT: - case LV_STYLE_PAD_RIGHT: - case LV_STYLE_PAD_INNER: - case LV_STYLE_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: - real_refr = true; - break; - default: - real_refr = false; - } - - if(real_refr) { - lv_obj_invalidate(obj); - obj->signal_cb(obj, LV_SIGNAL_STYLE_CHG, NULL); - - 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: - if(obj->parent) obj->parent->signal_cb(obj->parent, LV_SIGNAL_CHILD_CHG, obj); - break; - } - - lv_obj_invalidate(obj); - - /*Send style change signals*/ - if(prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_INHERIT_MASK)) refresh_children_style(obj); - } - else { - lv_obj_invalidate(obj); - } -} - -/** - * Notify all object if a style is modified - * @param style pointer to a style. Only the objects with this style will be notified - * (NULL to notify all objects) - */ -void lv_obj_report_style_mod(lv_style_t * style) -{ - lv_disp_t * d = lv_disp_get_next(NULL); - - while(d) { - lv_obj_t * i; - _LV_LL_READ(d->scr_ll, i) { - report_style_mod_core(style, i); - } - d = lv_disp_get_next(d); - } -} - -/** - * Enable/disable the use of style cahche 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) -{ - uint8_t part; - for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) { - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) break; - list->ignore_cache = dis; - } - for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) { - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) break; - list->ignore_cache = dis; - } -} - /*----------------- * Attribute set *----------------*/ @@ -1760,19 +708,6 @@ void lv_obj_set_adv_hittest(lv_obj_t * obj, bool en) obj->adv_hittest = en == false ? 0 : 1; } -/** - * Set how the scrollbars should behave. - * @param obj pointer to an object - * @param mode: LV_SCROLL_MODE_ON/OFF/AUTO/ACTIVE - */ -void lv_obj_set_scroll_mode(lv_obj_t * obj, lv_scroll_mode_t mode) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - if(obj->scroll_mode == mode) return; - obj->scroll_mode = mode; - lv_obj_invalidate(obj); -} /** * Set the base direction of the object @@ -1829,14 +764,14 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) #if LV_USE_ANIMATION == 0 obj->state = new_state; - lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); + _lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); #else lv_state_t prev_state = obj->state; obj->state = new_state; uint8_t part; for(part = 0; part < _LV_OBJ_PART_REAL_LAST; part++) { - lv_style_list_t * style_list = lv_obj_get_style_list(obj, 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; @@ -1856,31 +791,11 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) if(props[i] != 0) { _lv_style_list_add_trans_style(style_list); - lv_style_trans_t * tr = trans_create(obj, props[i], part, prev_state, new_state); - - /*If there is a pending anim for this property remove it*/ - if(tr) { - tr->obj = obj; - tr->prop = props[i]; - tr->part = part; - - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_var(&a, tr); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)trans_anim_cb); - lv_anim_set_start_cb(&a, trans_anim_start_cb); - lv_anim_set_ready_cb(&a, trans_anim_ready_cb); - lv_anim_set_values(&a, 0x00, 0xFF); - lv_anim_set_time(&a, time); - lv_anim_set_delay(&a, delay); - lv_anim_set_path(&a, path); - a.early_apply = 0; - lv_anim_start(&a); - } + _lv_obj_create_style_transition(obj, props[i], part, prev_state, new_state, time, delay, path); } } - lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); + _lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); } #endif @@ -1922,26 +837,6 @@ void lv_obj_clear_state(lv_obj_t * obj, lv_state_t state) } } -#if LV_USE_ANIMATION -/** - * Finish all pending transitions on a part of an object - * @param obj pointer to an object - * @param part part of the object, e.g `LV_BRN_PART_MAIN` or `LV_OBJ_PART_ALL` for all parts - */ -void lv_obj_finish_transitions(lv_obj_t * obj, uint8_t part) -{ - /*Animate all related transition to the end value*/ - lv_style_trans_t * tr; - _LV_LL_READ_BACK(LV_GC_ROOT(_lv_obj_style_trans_ll), tr) { - if(tr->obj == obj && (part == tr->part || part == LV_OBJ_PART_ALL)) { - trans_anim_cb(tr, 255); - } - } - - /*Free all related transition data*/ - trans_del(obj, part, 0xFF, NULL); -} -#endif /** * Set a an event handler function for an object. @@ -2305,238 +1200,6 @@ uint16_t lv_obj_count_children_recursive(const lv_obj_t * obj) * Coordinate get *--------------------*/ -/** - * Copy the coordinates of an object to an area - * @param obj pointer to an object - * @param cords_p pointer to an area to store the coordinates - */ -void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * cords_p) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - lv_area_copy(cords_p, &obj->coords); -} - -/** - * Get a bounding which includes all the the children. - * `margin` of the children also taken into account and makes the box larger (if positive) - * @param obj pointer to an object - * @param coords pointer to an area to store the coordinates - * @return LV_RES_INV: `obj` has no children and `coords` can't be set; `LV_RES_OK`: success - */ -lv_res_t lv_obj_get_children_box(const lv_obj_t * obj, lv_area_t * coords) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - coords->x1 = LV_COORD_MAX; - coords->y1 = LV_COORD_MAX; - coords->x2 = LV_COORD_MIN; - coords->y2 = LV_COORD_MIN; - - lv_obj_t * child = lv_obj_get_child(obj, NULL); - if(child == NULL) return LV_RES_INV; - - while(child) { - coords->x1 = LV_MATH_MIN(coords->x1, child->coords.x1 - lv_obj_get_style_margin_left(child, LV_OBJ_PART_MAIN)); - coords->y1 = LV_MATH_MIN(coords->y1, child->coords.y1 - lv_obj_get_style_margin_top(child, LV_OBJ_PART_MAIN)); - coords->x2 = LV_MATH_MAX(coords->x2, child->coords.x2 + lv_obj_get_style_margin_right(child, LV_OBJ_PART_MAIN)); - coords->y2 = LV_MATH_MAX(coords->y2, child->coords.y2 + lv_obj_get_style_margin_bottom(child, LV_OBJ_PART_MAIN)); - - child = lv_obj_get_child(obj, child); - } - - return LV_RES_OK; -} - -/** - * Reduce area retried by `lv_obj_get_coords()` the get graphically usable area of an object. - * (Without the size of the border or other extra graphical elements) - * @param coords_p store the result area here - */ -void lv_obj_get_inner_coords(const lv_obj_t * obj, lv_area_t * coords_p) -{ - 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); - - if(part & LV_BORDER_SIDE_LEFT) coords_p->x1 += w; - - if(part & LV_BORDER_SIDE_RIGHT) coords_p->x2 -= w; - - if(part & LV_BORDER_SIDE_TOP) coords_p->y1 += w; - - if(part & LV_BORDER_SIDE_BOTTOM) coords_p->y2 -= w; -} - -/** - * Get the x coordinate of object - * @param obj pointer to an object - * @return distance of 'obj' from the left side of its parent - */ -lv_coord_t lv_obj_get_x(const lv_obj_t * obj) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - lv_coord_t rel_x; - lv_obj_t * parent = lv_obj_get_parent(obj); - if(parent) { - rel_x = obj->coords.x1 - parent->coords.x1; - rel_x += lv_obj_get_scroll_left(parent); - rel_x -= lv_obj_get_style_pad_left(parent, LV_OBJ_PART_MAIN); - } - else { - rel_x = obj->coords.x1; - } - return rel_x; -} - -/** - * Get the y coordinate of object - * @param obj pointer to an object - * @return distance of 'obj' from the top of its parent - */ -lv_coord_t lv_obj_get_y(const lv_obj_t * obj) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - lv_coord_t rel_y; - lv_obj_t * parent = lv_obj_get_parent(obj); - if(parent) { - rel_y = obj->coords.y1 - parent->coords.y1; - rel_y += lv_obj_get_scroll_top(parent); - rel_y -= lv_obj_get_style_pad_top(parent, LV_OBJ_PART_MAIN); - } - else { - rel_y = obj->coords.y1; - } - return rel_y; -} - -/** - * Get the width of an object - * @param obj pointer to an object - * @return the width - */ -lv_coord_t lv_obj_get_width(const lv_obj_t * obj) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - return lv_area_get_width(&obj->coords); -} - -/** - * Get the height of an object - * @param obj pointer to an object - * @return the height - */ -lv_coord_t lv_obj_get_height(const lv_obj_t * obj) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - return lv_area_get_height(&obj->coords); -} - -/** - * Get that width reduced by the left and right padding. - * @param obj pointer to an object - * @return the width which still fits into the container - */ -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); - - return lv_obj_get_width(obj) - left - right; -} - -/** - * Get that height reduced by the top an bottom padding. - * @param obj pointer to an object - * @return the height which still fits into the container - */ -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); - - return lv_obj_get_height(obj) - top - bottom; -} - -/** - * Get the height of an object by taking the top and bottom margin into account. - * The returned height will be `obj_h + margin_top + margin_bottom` - * @param obj pointer to an object - * @return the height including thee margins - */ -lv_coord_t lv_obj_get_height_margin(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); - - return lv_obj_get_height(obj) + mtop + mbottom; -} - -/** - * Get the width of an object by taking the left and right margin into account. - * The returned width will be `obj_w + margin_left + margin_right` - * @param obj pointer to an object - * @return the height including thee margins - */ -lv_coord_t lv_obj_get_width_margin(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); - - return lv_obj_get_width(obj) + mleft + mright; -} - -/** - * Set that width reduced by the left and right padding of the parent. - * @param obj pointer to an object - * @param div indicates how many columns are assumed. - * If 1 the width will be set the the parent's width - * If 2 only half parent width - inner padding of the parent - * If 3 only third parent width - 2 * inner padding of the parent - * @param span how many columns are combined - * @return the width according to the given parameters - */ -lv_coord_t lv_obj_get_width_grid(lv_obj_t * obj, uint8_t div, uint8_t span) -{ - lv_coord_t obj_w = lv_obj_get_width_fit(obj); - lv_style_int_t pinner = lv_obj_get_style_pad_inner(obj, LV_OBJ_PART_MAIN); - - lv_coord_t r = (obj_w - (div - 1) * pinner) / div; - - r = r * span + (span - 1) * pinner; - return r; -} - -/** - * Get that height reduced by the top and bottom padding of the parent. - * @param obj pointer to an object - * @param div indicates how many rows are assumed. - * If 1 the height will be set the the parent's height - * If 2 only half parent height - inner padding of the parent - * If 3 only third parent height - 2 * inner padding of the parent - * @param span how many rows are combined - * @return the height according to the given parameters - */ -lv_coord_t lv_obj_get_height_grid(lv_obj_t * obj, uint8_t div, uint8_t span) -{ - lv_coord_t obj_h = lv_obj_get_height_fit(obj); - lv_style_int_t pinner = lv_obj_get_style_pad_inner(obj, LV_OBJ_PART_MAIN); - - lv_coord_t r = (obj_h - (div - 1) * pinner) / div; - - r = r * span + (span - 1) * pinner; - return r; -} - /** * Get the left padding of extended clickable area * @param obj pointer to an object @@ -2629,389 +1292,12 @@ lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj) * Appearance get *---------------*/ -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; -} - -/** - * 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(!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_BG_GRAD_DIR: - if(list->bg_grad_dir_none) def = true; - break; - 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: - case LV_STYLE_PAD_BOTTOM: - case LV_STYLE_PAD_LEFT: - 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; - } - - if(def) { - break; - } - } - - lv_state_t state = lv_obj_get_state(parent, part); - prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS); - - 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, part); - 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 - * @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) -{ - 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; - const lv_obj_t * parent = obj; - while(parent) { - lv_style_list_t * list = lv_obj_get_style_list(parent, part); - - 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; - } - - if(def) { - break; - } - } - - - lv_state_t state = lv_obj_get_state(parent, part); - prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS); - - 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 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_OPA: - case LV_STYLE_IMAGE_RECOLOR_OPA: - case LV_STYLE_PATTERN_RECOLOR_OPA: - return LV_OPA_TRANSP; - } - - return LV_OPA_COVER; -} - -/** - * 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(!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; - } - } - - lv_state_t state = lv_obj_get_state(parent, part); - 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); -} /*----------------- * Attribute get *----------------*/ -bool lv_obj_has_flag(lv_obj_t * obj, lv_obj_flag_t f) +bool lv_obj_has_flag(const lv_obj_t * obj, lv_obj_flag_t f) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -3031,18 +1317,6 @@ bool lv_obj_get_adv_hittest(const lv_obj_t * obj) } -/** - * Get how the scrollbars should behave. - * @param obj pointer to an object - * @return mode: LV_SCROLL_MODE_ON/OFF/AUTO/ACTIVE - */ -lv_scroll_mode_t lv_obj_get_scroll_mode(lv_obj_t * obj) -{ - LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - - return obj->scroll_mode; -} - lv_bidi_dir_t lv_obj_get_base_dir(const lv_obj_t * obj) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -3245,40 +1519,24 @@ bool lv_obj_is_focused(const lv_obj_t * obj) * OTHER FUNCTIONS *------------------*/ + /** - * Check if a given screen-space point is on an object's coordinates. - * - * This method is intended to be used mainly by advanced hit testing algorithms to check - * whether the point is even within the object (as an optimization). - * @param obj object to check - * @param point screen-space point + * Get the really focused object by taking `focus_parent` into account. + * @param obj the start object + * @return the object to really focus */ -bool lv_obj_is_point_on_coords(lv_obj_t * obj, const lv_point_t * point) +lv_obj_t * lv_obj_get_focused_obj(const lv_obj_t * obj) { -#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY - lv_area_t ext_area; - ext_area.x1 = obj->coords.x1 - obj->ext_click_pad_hor; - ext_area.x2 = obj->coords.x2 + obj->ext_click_pad_hor; - ext_area.y1 = obj->coords.y1 - obj->ext_click_pad_ver; - ext_area.y2 = obj->coords.y2 + obj->ext_click_pad_ver; - - if(!_lv_area_is_point_on(&ext_area, point, 0)) { -#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL - lv_area_t ext_area; - ext_area.x1 = obj->coords.x1 - obj->ext_click_pad.x1; - ext_area.x2 = obj->coords.x2 + obj->ext_click_pad.x2; - ext_area.y1 = obj->coords.y1 - obj->ext_click_pad.y1; - ext_area.y2 = obj->coords.y2 + obj->ext_click_pad.y2; - - if(!_lv_area_is_point_on(&ext_area, point, 0)) { -#else - if(!_lv_area_is_point_on(&obj->coords, point, 0)) { -#endif - return false; + if(obj == NULL) return NULL; + const lv_obj_t * focus_obj = obj; + while(lv_obj_has_flag(focus_obj, LV_OBJ_FLAG_FOCUS_BUBBLE) != false && focus_obj != NULL) { + focus_obj = lv_obj_get_parent(focus_obj); } - return true; + + return (lv_obj_t *)focus_obj; } + /** * Hit-test an object given a particular point in screen space. * @param obj object to hit-test @@ -3625,55 +1883,6 @@ lv_coord_t lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) return s; } -/** - * Fade in (from transparent to fully cover) an object and all its children using an `opa_scale` animation. - * @param obj the object to fade in - * @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) -{ -#if LV_USE_ANIMATION - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_var(&a, obj); - lv_anim_set_values(&a, LV_OPA_TRANSP, LV_OPA_COVER); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)opa_scale_anim); - lv_anim_set_ready_cb(&a, fade_in_anim_ready); - lv_anim_set_time(&a, time); - lv_anim_set_delay(&a, delay); - lv_anim_start(&a); -#else - (void) obj; /*Unused*/ - (void) time; /*Unused*/ - (void) delay; /*Unused*/ -#endif -} - -/** - * Fade out (from fully cover to transparent) an object and all its children using an `opa_scale` animation. - * @param obj the object to fade in - * @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) -{ -#if LV_USE_ANIMATION - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_var(&a, obj); - lv_anim_set_values(&a, LV_OPA_COVER, LV_OPA_TRANSP); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)opa_scale_anim); - lv_anim_set_time(&a, time); - lv_anim_set_delay(&a, delay); - lv_anim_start(&a); -#else - (void) obj; /*Unused*/ - (void) time; /*Unused*/ - (void) delay; /*Unused*/ -#endif -} - /** * Check if any object has a given type * @param obj pointer to an object @@ -3745,7 +1954,7 @@ static void obj_del_core(lv_obj_t * obj) /*Remove the animations from this object*/ #if LV_USE_ANIMATION lv_anim_del(obj, NULL); - trans_del(obj, 0xFF, 0xFF, NULL); + _lv_obj_remove_style_trans(obj); #endif /*Delete the user data*/ @@ -3950,21 +2159,19 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area return LV_DESIGN_RES_OK; } - -/** - * Get the really focused object by taking `focus_parent` into account. - * @param obj the start object - * @return the object to really focus - */ -lv_obj_t * lv_obj_get_focused_obj(const lv_obj_t * obj) +static void base_dir_refr_children(lv_obj_t * obj) { - if(obj == NULL) return NULL; - const lv_obj_t * focus_obj = obj; - while(lv_obj_has_flag(focus_obj, LV_OBJ_FLAG_FOCUS_BUBBLE) != false && focus_obj != NULL) { - focus_obj = lv_obj_get_parent(focus_obj); - } + lv_obj_t * child; + child = lv_obj_get_child(obj, NULL); - return (lv_obj_t *)focus_obj; + while(child) { + if(child->base_dir == LV_BIDI_DIR_INHERIT) { + lv_signal_send(child, LV_SIGNAL_BASE_DIR_CHG, NULL); + base_dir_refr_children(child); + } + + child = lv_obj_get_child(obj, child); + } } /** @@ -4001,7 +2208,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) if(obj->grid) { lv_obj_t * child = param; if(child) { - if(lv_obj_is_grid_item(child)) lv_grid_full_refr(obj); + if(_lv_obj_is_grid_item(child)) lv_grid_full_refr(obj); } else { lv_grid_full_refr(obj); } @@ -4022,7 +2229,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) obj->ext_draw_pad = LV_MATH_MAX(obj->ext_draw_pad, d); } else if(sign == LV_SIGNAL_STYLE_CHG) { - if(lv_obj_is_grid_item(obj)) lv_grid_full_refr(obj); + if(_lv_obj_is_grid_item(obj)) lv_grid_full_refr(obj); lv_obj_t * child = lv_obj_get_child(obj, NULL); while(child) { @@ -4076,509 +2283,12 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED); } else if(sign == LV_SIGNAL_CLEANUP) { - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_OBJ_PART_MAIN); } return res; } -/** - * Reposition the children of an object. (Called recursively) - * @param obj pointer to an object which children will be repositioned - * @param x_diff x coordinate shift - * @param y_diff y coordinate shift - */ -static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff) -{ - lv_obj_t * i; - _LV_LL_READ(obj->child_ll, i) { - i->coords.x1 += x_diff; - i->coords.y1 += y_diff; - i->coords.x2 += x_diff; - i->coords.y2 += y_diff; - - refresh_children_position(i, x_diff, y_diff); - } -} - -/** - * Refresh the style of all children of an object. (Called recursively) - * @param style refresh objects only with this style_list. - * @param obj pointer to an object - */ -static void report_style_mod_core(void * style, lv_obj_t * obj) -{ - uint8_t part; - for(part = 0; part != _LV_OBJ_PART_REAL_LAST; part++) { - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) break; - - 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; - } - } - } - - lv_obj_t * child = lv_obj_get_child(obj, NULL); - while(child) { - report_style_mod_core(style, child); - child = lv_obj_get_child(obj, child); - } - -} - - -/** - * Recursively refresh the style of the children. Go deeper until a not NULL style is found - * because the NULL styles are inherited from the parent - * @param obj pointer to an object - */ -static void refresh_children_style(lv_obj_t * obj) -{ - lv_obj_t * child = lv_obj_get_child(obj, NULL); - while(child != NULL) { - lv_obj_invalidate(child); - child->signal_cb(child, LV_SIGNAL_STYLE_CHG, NULL); - lv_obj_invalidate(child); - - refresh_children_style(child); /*Check children too*/ - child = lv_obj_get_child(obj, child); - } -} - -static void base_dir_refr_children(lv_obj_t * obj) -{ - lv_obj_t * child; - child = lv_obj_get_child(obj, NULL); - - while(child) { - if(child->base_dir == LV_BIDI_DIR_INHERIT) { - lv_signal_send(child, LV_SIGNAL_BASE_DIR_CHG, NULL); - base_dir_refr_children(child); - } - - child = lv_obj_get_child(obj, child); - } -} - -static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, - lv_coord_t x_ofs, lv_coord_t y_ofs) -{ - lv_point_t new_pos; - _lv_area_align(&base->coords, &obj->coords, align, &new_pos); - - /*Bring together the coordination system of base and obj*/ - lv_obj_t * par = lv_obj_get_parent(obj); - lv_coord_t par_abs_x = par->coords.x1; - lv_coord_t par_abs_y = par->coords.y1; - new_pos.x += x_ofs; - new_pos.y += y_ofs; - new_pos.x -= par_abs_x; - new_pos.y -= par_abs_y; - - if(x_set && y_set) lv_obj_set_pos(obj, new_pos.x, new_pos.y); - else if(x_set) lv_obj_set_x(obj, new_pos.x); - else if(y_set) lv_obj_set_y(obj, new_pos.y); -} - -static void obj_align_mid_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, - lv_coord_t x_ofs, lv_coord_t y_ofs) -{ - lv_coord_t new_x = lv_obj_get_x(obj); - lv_coord_t new_y = lv_obj_get_y(obj); - - lv_coord_t obj_w_half = lv_obj_get_width(obj) / 2; - lv_coord_t obj_h_half = lv_obj_get_height(obj) / 2; - - - switch(align) { - case LV_ALIGN_CENTER: - new_x = lv_obj_get_width(base) / 2 - obj_w_half; - new_y = lv_obj_get_height(base) / 2 - obj_h_half; - break; - - case LV_ALIGN_IN_TOP_LEFT: - new_x = -obj_w_half; - new_y = -obj_h_half; - break; - case LV_ALIGN_IN_TOP_MID: - new_x = lv_obj_get_width(base) / 2 - obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_IN_TOP_RIGHT: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_IN_BOTTOM_LEFT: - new_x = -obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - case LV_ALIGN_IN_BOTTOM_MID: - new_x = lv_obj_get_width(base) / 2 - obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_IN_BOTTOM_RIGHT: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_IN_LEFT_MID: - new_x = -obj_w_half; - new_y = lv_obj_get_height(base) / 2 - obj_h_half; - break; - - case LV_ALIGN_IN_RIGHT_MID: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = lv_obj_get_height(base) / 2 - obj_h_half; - break; - - case LV_ALIGN_OUT_TOP_LEFT: - new_x = -obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_OUT_TOP_MID: - new_x = lv_obj_get_width(base) / 2 - obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_OUT_TOP_RIGHT: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_OUT_BOTTOM_LEFT: - new_x = -obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_OUT_BOTTOM_MID: - new_x = lv_obj_get_width(base) / 2 - obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_OUT_BOTTOM_RIGHT: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_OUT_LEFT_TOP: - new_x = -obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_OUT_LEFT_MID: - new_x = -obj_w_half; - new_y = lv_obj_get_height(base) / 2 - obj_h_half; - break; - - case LV_ALIGN_OUT_LEFT_BOTTOM: - new_x = -obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_OUT_RIGHT_TOP: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_OUT_RIGHT_MID: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = lv_obj_get_height(base) / 2 - obj_h_half; - break; - - case LV_ALIGN_OUT_RIGHT_BOTTOM: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - } - - /*Bring together the coordination system of base and obj*/ - lv_obj_t * par = lv_obj_get_parent(obj); - lv_coord_t base_abs_x = base->coords.x1; - lv_coord_t base_abs_y = base->coords.y1; - lv_coord_t par_abs_x = par->coords.x1; - lv_coord_t par_abs_y = par->coords.y1; - new_x += x_ofs + base_abs_x; - new_y += y_ofs + base_abs_y; - new_x -= par_abs_x; - new_y -= par_abs_y; - if(x_set && y_set) lv_obj_set_pos(obj, new_x, new_y); - else if(x_set) lv_obj_set_x(obj, new_x); - else if(y_set) lv_obj_set_y(obj, new_y); - -} - - - -#if LV_USE_ANIMATION - -/** - * 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. - * @param obj and object to add the transition - * @param prop the property to apply the transaction - * @param part the part of the object to apply the transaction - * @param prev_state the previous state of the objects - * @param new_state the new state of the object - * @return pointer to the allocated `the transaction` variable or `NULL` if no transition created - */ -static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, - lv_state_t new_state) -{ - 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); - - /*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; - - if(int1 == int2) return NULL; - 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(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); - } - } - - tr = _lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll)); - LV_ASSERT_MEM(tr); - if(tr == NULL) return NULL; - 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 NULL; - 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 NULL; - 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 NULL; - - 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 NULL; - 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 NULL; - 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 NULL; - tr->start_value._ptr = p1; - tr->end_value._ptr = p2; - } - - return tr; -} - -/** - * Remove the transition from object's part's property. - * - Remove the transition from `_lv_obj_style_trans_ll` and free it - * - Delete pending transitions - * @param obj pointer to an object which transition(s) should be removed - * @param part a part of object or 0xFF to remove from all parts - * @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) -{ - lv_style_trans_t * tr; - lv_style_trans_t * tr_prev; - tr = _lv_ll_get_tail(&LV_GC_ROOT(_lv_obj_style_trans_ll)); - while(tr != NULL) { - if(tr == tr_limit) break; - - /*'tr' might be deleted, so get the next object while 'tr' is valid*/ - tr_prev = _lv_ll_get_prev(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); - - 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); - - lv_anim_del(tr, NULL); - _lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); - lv_mem_free(tr); - } - tr = tr_prev; - } -} - -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); - - 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); - -} - -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); - } - - /*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*/ - trans_del(tr->obj, tr->part, prop_tmp, tr); - - tr->prop = prop_tmp; - -} - -static void trans_anim_ready_cb(lv_anim_t * a) -{ - lv_style_trans_t * tr = a->var; - - /* Remove the transitioned property from trans. style - * if there no more transitions for this property - * It allows changing it by normal styles*/ - - bool running = false; - lv_style_trans_t * tr_i; - _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; - } - } - - 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); - } - - _lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); - lv_mem_free(tr); -} - -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); -} - -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); -} - - -static void scroll_anim_x_cb(lv_obj_t * obj, lv_anim_value_t v) -{ - lv_obj_scroll_by_raw(obj, v - obj->scroll.x, 0); -} - -static void scroll_anim_y_cb(lv_obj_t * obj, lv_anim_value_t v) -{ - lv_obj_scroll_by_raw(obj, 0, v - obj->scroll.y); -} -#endif static void lv_event_mark_deleted(lv_obj_t * obj) { @@ -4769,213 +2479,3 @@ static void scrollbar_draw(lv_obj_t * obj, const lv_area_t * clip_area) } } - -static bool style_prop_is_cacheble(lv_style_property_t prop) -{ - - switch(prop) { - case LV_STYLE_PROP_ALL: - case LV_STYLE_BG_GRAD_DIR: - case LV_STYLE_CLIP_CORNER: - case LV_STYLE_TEXT_LETTER_SPACE: - case LV_STYLE_TEXT_LINE_SPACE: - case LV_STYLE_TEXT_FONT: - 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_cacheble(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->bg_grad_dir_none = lv_obj_get_style_bg_grad_dir(obj, part) == LV_GRAD_DIR_NONE ? 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; - if(lv_obj_get_style_pad_top(obj, part) != 0 || - lv_obj_get_style_pad_bottom(obj, part) != 0 || - lv_obj_get_style_pad_left(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_REAL_LAST; part++) { - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) break; - - bool ignore_cache_ori = list->ignore_cache; - list->ignore_cache = 1; - - list->opa_scale_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; - } - - lv_obj_t * child = lv_obj_get_child(obj, NULL); - while(child) { - update_style_cache_children(child); - child = lv_obj_get_child(obj, child); - } - -} - -/** - * Mark the object and all of it's children's style lists as invalid. - * The cache will be updated when a cached property asked nest time - * @param obj pointer to an object - */ -static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop) -{ - if(style_prop_is_cacheble(prop) == false) return; - - if(part != LV_OBJ_PART_ALL) { - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) return; - list->valid_cache = 0; - } - else { - - for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) { - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) break; - list->valid_cache = 0; - } - for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) { - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) break; - list->valid_cache = 0; - } - } - - lv_obj_t * child = lv_obj_get_child(obj, NULL); - while(child) { - update_style_cache_children(child); - child = lv_obj_get_child(obj, child); - } -} diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index a3830df74..7e99a647e 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -184,14 +184,6 @@ enum { typedef uint8_t lv_dir_t; -enum { - LV_SCROLL_SNAP_ALIGN_NONE, - LV_SCROLL_SNAP_ALIGN_START, - LV_SCROLL_SNAP_ALIGN_END, - LV_SCROLL_SNAP_ALIGN_CENTER -}; -typedef uint8_t lv_scroll_snap_align_t; - enum { LV_OBJ_FLAG_HIDDEN = (1 << 0), @@ -207,14 +199,10 @@ enum { }; typedef uint16_t lv_obj_flag_t; -/** Scrollbar modes: shows when should the scrollbars be visible*/ -enum { - LV_SCROLL_MODE_OFF = 0x0, /**< Never show scroll bars*/ - LV_SCROLL_MODE_ON = 0x1, /**< Always show scroll bars*/ - LV_SCROLL_MODE_ACTIVE = 0x2, /**< Show scroll bars when object is being scrolled*/ - LV_SCROLL_MODE_AUTO = 0x3, /**< Show scroll bars when the content is large enough to be scrolled*/ -}; -typedef uint8_t lv_scroll_mode_t; + +#include "lv_obj_pos.h" +#include "lv_obj_scroll.h" + typedef struct _lv_obj_t { struct _lv_obj_t * parent; /**< Pointer to the parent object*/ @@ -420,171 +408,6 @@ void lv_obj_move_background(lv_obj_t * obj); * Coordinate set * ------------------*/ -/** - * Set relative the position of an object (relative to the parent) - * @param obj pointer to an object - * @param x new distance from the left side of the parent - * @param y new distance from the top of the parent - */ -void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y); - -/** - * Set the x coordinate of a object - * @param obj pointer to an object - * @param x new distance from the left side from the parent - */ -void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x); - -/** - * Set the y coordinate of a object - * @param obj pointer to an object - * @param y new distance from the top of the parent - */ -void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y); - - -void _lv_obj_calc_auto_size(lv_obj_t * obj, lv_coord_t * w, lv_coord_t * h); - -/** - * Set the size of an object - * @param obj pointer to an object - * @param w new width - * @param h new height - */ -void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h); - -/** - * Set the width of an object - * @param obj pointer to an object - * @param w new width - */ -void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w); - -/** - * Set the height of an object - * @param obj pointer to an object - * @param h new height - */ -void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h); - -/** - * Set the width reduced by the left and right padding. - * @param obj pointer to an object - * @param w the width without paddings - */ -void lv_obj_set_width_fit(lv_obj_t * obj, lv_coord_t w); - -/** - * Set the height reduced by the top and bottom padding. - * @param obj pointer to an object - * @param h the height without paddings - */ -void lv_obj_set_height_fit(lv_obj_t * obj, lv_coord_t h); - -/** - * Set the width of an object by taking the left and right margin into account. - * The object width will be `obj_w = w - margin_left - margin_right` - * @param obj pointer to an object - * @param w new height including margins - */ -void lv_obj_set_width_margin(lv_obj_t * obj, lv_coord_t w); - -/** - * Set the height of an object by taking the top and bottom margin into account. - * The object height will be `obj_h = h - margin_top - margin_bottom` - * @param obj pointer to an object - * @param h new height including margins - */ -void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h); - -/** - * Align an object to an other object. - * @param obj pointer to an object to align - * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. - * @param align type of alignment (see 'lv_align_t' enum) - * @param x_ofs x coordinate offset after alignment - * @param y_ofs y coordinate offset after alignment - */ -void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); - -/** - * Moves all children with horizontally or vertically. - * It doesn't take into account any limits so any values are possible - * @param obj pointer to an object whose children should be moved - * @param x pixel to move horizontally - * @param y pixels to move vertically - */ -void lv_obj_scroll_by_raw(lv_obj_t * obj, lv_coord_t x, lv_coord_t y); - -/** - * Moves all children with horizontally or vertically. - * Limits the scroll to the bounding box of the children. - * @param obj pointer to an object whose children should be moved - * @param x pixel to move horizontally - * @param y pixels to move vertically - */ -void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en); - -/** - * Scroll the a given x coordinate to the left side of obj. - * @param obj pointer to an object which should be scrolled - * @param x the x coordinate to scroll to - * @param y the y coordinate to scroll to - */ -void lv_obj_scroll_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en); - -/** - * Scroll the a given x coordinate to the left side of obj. - * @param obj pointer to an object which should be scrolled - * @param x the x coordinate to scroll to - */ -void lv_obj_scroll_to_x(lv_obj_t * obj, lv_coord_t x, lv_anim_enable_t anim_en); - -/** - * Scroll the a given y coordinate to the top side of obj. - * @param obj pointer to an object which should be scrolled - * @param y the y coordinate to scroll to - */ -void lv_obj_scroll_to_y(lv_obj_t * obj, lv_coord_t y, lv_anim_enable_t anim_en); - - -/** - * Return the height of the area above the parent. - * That is the number of pixels the object can be scrolled down. - * Normally positive but can be negative when scrolled inside. - * @param obj - * @return - */ -lv_coord_t lv_obj_get_scroll_top(const lv_obj_t * obj); - -/** - * Return the height of the area below the parent. - * That is the number of pixels the object can be scrolled up. - * Normally positive but can be negative when scrolled inside. - * @param obj - * @return - */ -lv_coord_t lv_obj_get_scroll_bottom(const lv_obj_t * obj); - - -/** - * Return the weight of the area on the left the parent. - * That is the number of pixels the object can be scrolled down. - * Normally positive but can be negative when scrolled inside. - * @param obj - * @return - */ -lv_coord_t lv_obj_get_scroll_left(const lv_obj_t * obj); - -/** - * Return the width of the area below the object. - * That is the number of pixels the object can be scrolled left. - * Normally positive but can be negative when scrolled inside. - * @param obj - * @return - */ -lv_coord_t lv_obj_get_scroll_right(const lv_obj_t * obj); - /** * Set the size of an extended clickable area * @param obj pointer to an object @@ -599,134 +422,6 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right * Appearance set *--------------------*/ -/** - * Add a new style to the style list 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` - * @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); - -/** - * Remove a style from the style list 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` - * @param style pointer to a style to remove - */ -void lv_obj_remove_style(lv_obj_t * obj, uint8_t part, lv_style_t * style); - -/** - * Reset a style to the default (empty) state. - * Release all used memories and cancel pending related transitions. - * Typically used in `LV_SIGN_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_clean_style_list(lv_obj_t * obj, uint8_t part); - -/** - * Reset a style to the default (empty) state. - * Release all used memories and cancel pending related transitions. - * Also notifies the object about the style change. - * @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(lv_obj_t * obj, uint8_t part); - -/** - * Notify an object (and its children) about its style is modified - * @param obj pointer to an object - * @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used to optimize what needs to be refreshed. - */ -void lv_obj_refresh_style(lv_obj_t * obj, uint8_t part, lv_style_property_t prop); - -/** - * Notify all object if a style is modified - * @param style pointer to a style. Only the objects with this style will be notified - * (NULL to notify all objects) - */ -void lv_obj_report_style_mod(lv_style_t * style); - -/** - * 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 type, 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_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_opa()` - * @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 type, 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_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 type, 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 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 type, lv_style_property_t prop, const void * value); - -/** - * 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)` - * @note shouldn't be used directly. Use the specific property remove functions instead. - * For example: `lv_obj_style_remove_border_opa()` - * @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); - -/** - * Enable/disable the use of style cahche 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); - /*----------------- * Attribute set *----------------*/ @@ -738,14 +433,6 @@ void _lv_obj_disable_style_caching(lv_obj_t * obj, bool dis); */ void lv_obj_set_adv_hittest(lv_obj_t * obj, bool en); - -/** - * Set how the scrollbars should behave. - * @param obj pointer to an object - * @param mode: LV_SCROLL_MODE_ON/OFF/AUTO/ACTIVE - */ -void lv_obj_set_scroll_mode(lv_obj_t * obj, lv_scroll_mode_t mode); - /** * Set the base direction of the object * @param obj pointer to an object @@ -783,14 +470,6 @@ void lv_obj_add_state(lv_obj_t * obj, lv_state_t state); */ void lv_obj_clear_state(lv_obj_t * obj, lv_state_t state); -#if LV_USE_ANIMATION -/** - * Finish all pending transitions on a part of an object - * @param obj pointer to an object - * @param part part of the object, e.g `LV_BRN_PART_MAIN` or `LV_OBJ_PART_ALL` for all parts - */ -void lv_obj_finish_transitions(lv_obj_t * obj, uint8_t part); -#endif /** * Set a an event handler function for an object. @@ -947,104 +626,6 @@ uint16_t lv_obj_count_children_recursive(const lv_obj_t * obj); * Coordinate get *--------------------*/ -/** - * Copy the coordinates of an object to an area - * @param obj pointer to an object - * @param cords_p pointer to an area to store the coordinates - */ -void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * cords_p); - -/** - * Reduce area retried by `lv_obj_get_coords()` the get graphically usable area of an object. - * (Without the size of the border or other extra graphical elements) - * @param coords_p store the result area here - */ -void lv_obj_get_inner_coords(const lv_obj_t * obj, lv_area_t * coords_p); - -/** - * Get the x coordinate of object - * @param obj pointer to an object - * @return distance of 'obj' from the left side of its parent - */ -lv_coord_t lv_obj_get_x(const lv_obj_t * obj); - -/** - * Get the y coordinate of object - * @param obj pointer to an object - * @return distance of 'obj' from the top of its parent - */ -lv_coord_t lv_obj_get_y(const lv_obj_t * obj); - -/** - * Get the width of an object - * @param obj pointer to an object - * @return the width - */ -lv_coord_t lv_obj_get_width(const lv_obj_t * obj); - -/** - * Get the height of an object - * @param obj pointer to an object - * @return the height - */ -lv_coord_t lv_obj_get_height(const lv_obj_t * obj); - -/** - * Get that width reduced by the left and right padding. - * @param obj pointer to an object - * @return the width which still fits into the container - */ -lv_coord_t lv_obj_get_width_fit(const lv_obj_t * obj); - -/** - * Get that height reduced by the top an bottom padding. - * @param obj pointer to an object - * @return the height which still fits into the container - */ -lv_coord_t lv_obj_get_height_fit(const lv_obj_t * obj); - -/** - * Get the height of an object by taking the top and bottom margin into account. - * The returned height will be `obj_h + margin_top + margin_bottom` - * @param obj pointer to an object - * @return the height including thee margins - */ -lv_coord_t lv_obj_get_height_margin(lv_obj_t * obj); - -/** - * Get the width of an object by taking the left and right margin into account. - * The returned width will be `obj_w + margin_left + margin_right` - * @param obj pointer to an object - * @return the height including thee margins - */ -lv_coord_t lv_obj_get_width_margin(lv_obj_t * obj); - -/** - * Divide the width of the object and get the width of a given number of columns. - * Take paddings into account. - * @param obj pointer to an object - * @param div indicates how many columns are assumed. - * If 1 the width will be set the the parent's width - * If 2 only half parent width - inner padding of the parent - * If 3 only third parent width - 2 * inner padding of the parent - * @param span how many columns are combined - * @return the width according to the given parameters - */ -lv_coord_t lv_obj_get_width_grid(lv_obj_t * obj, uint8_t div, uint8_t span); - -/** - * Divide the height of the object and get the width of a given number of columns. - * Take paddings into account. - * @param obj pointer to an object - * @param div indicates how many rows are assumed. - * If 1 the height will be set the the parent's height - * If 2 only half parent height - inner padding of the parent - * If 3 only third parent height - 2 * inner padding of the parent - * @param span how many rows are combined - * @return the height according to the given parameters - */ -lv_coord_t lv_obj_get_height_grid(lv_obj_t * obj, uint8_t div, uint8_t span); - /** * Get the left padding of extended clickable area * @param obj pointer to an object @@ -1084,97 +665,13 @@ lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj); * Appearance get *---------------*/ -/** - * Get the style list of an object's part. - * @param obj pointer to an object. - * @param part part the part of the object which style list should be get. - * E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB` - * @return pointer to the style list. (Can be `NULL`) - */ -lv_style_list_t * lv_obj_get_style_list(const lv_obj_t * obj, uint8_t part); - -/** - * 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); - - -#include "lv_obj_style_dec.h" /*----------------- * Attribute get *----------------*/ -bool lv_obj_has_flag(lv_obj_t * obj, lv_obj_flag_t f); +bool lv_obj_has_flag(const lv_obj_t * obj, lv_obj_flag_t f); /** * Get whether advanced hit-testing is enabled on an object @@ -1326,21 +823,6 @@ void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t */ lv_coord_t lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part); -/** - * Fade in (from transparent to fully cover) an object and all its children using an `opa_scale` animation. - * @param obj the object to fade in - * @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); - -/** - * Fade out (from fully cover to transparent) an object and all its children using an `opa_scale` animation. - * @param obj the object to fade in - * @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); /** * Check if any object has a given type @@ -1358,6 +840,9 @@ bool lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type); */ bool lv_debug_check_obj_valid(const lv_obj_t * obj); +void _lv_obj_move_children_by(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff); + +#include "lv_obj_style.h" /********************** * MACROS diff --git a/src/lv_core/lv_obj_pos.c b/src/lv_core/lv_obj_pos.c new file mode 100644 index 000000000..ec9c17dfe --- /dev/null +++ b/src/lv_core/lv_obj_pos.c @@ -0,0 +1,670 @@ +/** + * @file lv_obj_pos.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_obj.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ +static bool refr_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h); + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +/** + * Set relative the position of an object (relative to the parent) + * @param obj pointer to an object + * @param x new distance from the left side of the parent plus the parent's left padding or a grid cell + * @param y new distance from the top side of the parent plus the parent's right padding or a grid cell + * @note Zero value value means place the object is on the left padding of the parent, and not on the left edge. + * @note A grid cell can be and explicit placement with cell position and span: + * `LV_GRID_CELL_START/END/CENTER/STRETCH(pos, span)` + * or "auto" to place the object on the grid in the creation order of other children + * `LV_GRID_AUTO_START/END/CENTER/STRETCH` + * @note to use grid placement the parent needs have a defined grid with `lv_obj_set_grid` + */ +void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + obj->x_set = x; + obj->y_set = y; + + bool gi = _lv_obj_is_grid_item(obj); + + /*For consistency set the size to stretched if the objects is stretched on the grid*/ + if(gi) { + if(_GRID_GET_CELL_FLAG(obj->x_set) == LV_GRID_STRETCH) obj->w_set = LV_SIZE_STRETCH; + if(_GRID_GET_CELL_FLAG(obj->y_set) == LV_GRID_STRETCH) obj->h_set = LV_SIZE_STRETCH; + } + + /*If not grid item but has grid position set the position to 0*/ + if(!gi) { + if(_GRID_IS_CELL(x)) { + obj->x_set = 0; + x = 0; + } + if(_GRID_IS_CELL(y)) { + obj->y_set = 0; + y = 0; + } + } + + /*If the object is on a grid item let the grid to position it. */ + if(gi) { + lv_area_t old_area; + lv_area_copy(&old_area, &obj->coords); + lv_grid_item_refr_pos(obj); + + lv_obj_t * cont = lv_obj_get_parent(obj); + + /*If the item was moved and grid is implicit in the changed direction refresh the whole grid.*/ + if((cont->grid->col_dsc == NULL && (old_area.x1 != obj->coords.x1 || old_area.x2 != obj->coords.x2)) || + (cont->grid->row_dsc == NULL && (old_area.y1 != obj->coords.y1 || old_area.y2 != obj->coords.y2))) + { + lv_grid_full_refr(cont); + } + } else { + _lv_obj_move_to(obj, x, y, true); + } +} + +/** + * Set the x coordinate of a object + * @param obj pointer to an object + * @param x new distance from the left side from the parent plus the parent's left padding or a grid cell + */ +void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + lv_obj_set_pos(obj, x, lv_obj_get_y(obj)); +} + +/** + * Set the y coordinate of a object + * @param obj pointer to an object + * @param y new distance from the top of the parent plus the parent's top padding or a grid cell + */ +void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + lv_obj_set_pos(obj, lv_obj_get_x(obj), y); +} + +/** + * Set the size of an object. + * @param obj pointer to an object + * @param w new width in pixels or `LV_SIZE_AUTO` to set the size to involve all children + * @param h new height in pixels or `LV_SIZE_AUTO` to set the size to involve all children + */ +void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + bool gi = _lv_obj_is_grid_item(obj); + bool x_stretch = false; + bool y_stretch = false; + + if(gi) { + x_stretch = _GRID_GET_CELL_FLAG(obj->x_set) == LV_GRID_STRETCH ? true : false; + y_stretch = _GRID_GET_CELL_FLAG(obj->y_set) == LV_GRID_STRETCH ? true : false; + if(x_stretch) w = LV_SIZE_STRETCH; + if(y_stretch) h = LV_SIZE_STRETCH; + } + + obj->w_set = w; + obj->h_set = h; + + /*If both stretched it was already managed by the grid*/ + if(x_stretch && y_stretch) return; + + if(x_stretch) w = lv_obj_get_width(obj); + if(y_stretch) h = lv_obj_get_height(obj); + + /*Calculate the required auto sizes*/ + bool x_auto = obj->w_set == LV_SIZE_AUTO ? true : false; + bool y_auto = obj->h_set == LV_SIZE_AUTO ? true : false; + + lv_coord_t auto_w; + lv_coord_t auto_h; + if(x_auto && y_auto) { + _lv_obj_calc_auto_size(obj, &auto_w, &auto_h); + w = auto_w; + h = auto_h; + } + else if(x_auto) { + _lv_obj_calc_auto_size(obj, &auto_w, NULL); + w = auto_w; + } + else if(y_auto) { + _lv_obj_calc_auto_size(obj, NULL, &auto_h); + h = auto_h; + } + + refr_size(obj, w, h); +} + +/** + * Set the width of an object + * @param obj pointer to an object + * @param w new width in pixels or `LV_SIZE_AUTO` to set the size to involve all children + */ +void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + lv_obj_set_size(obj, w, lv_obj_get_height(obj)); +} + +/** + * Set the height of an object + * @param obj pointer to an object + * @param h new height in pixels or `LV_SIZE_AUTO` to set the size to involve all children + */ +void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + lv_obj_set_size(obj, lv_obj_get_width(obj), h); +} + +/** + * Set the width reduced by the left and right padding. + * @param obj pointer to an object + * @param w the width without paddings in pixels + */ +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_obj_set_width(obj, w + pleft + pright); +} + +/** + * Set the height reduced by the top and bottom padding. + * @param obj pointer to an object + * @param h the height without paddings in pixels + */ +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_obj_set_height(obj, h + ptop + pbottom); +} + +/** + * Set the width of an object by taking the left and right margin into account. + * The object width will be `obj_w = w - margin_left - margin_right` + * @param obj pointer to an object + * @param w new height including margins in pixels + */ +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_obj_set_width(obj, w - mleft - mright); +} + +/** + * Set the height of an object by taking the top and bottom margin into account. + * The object height will be `obj_h = h - margin_top - margin_bottom` + * @param obj pointer to an object + * @param h new height including margins in pixels + */ +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_obj_set_height(obj, h - mtop - mbottom); +} + +/** + * Align an object to an other object. + * @param obj pointer to an object to align + * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. + * @param align type of alignment (see 'lv_align_t' enum) + * @param x_ofs x coordinate offset after alignment + * @param y_ofs y coordinate offset after alignment + */ +void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + if(base == NULL) base = lv_obj_get_parent(obj); + + LV_ASSERT_OBJ(base, LV_OBJX_NAME); + + lv_point_t new_pos; + _lv_area_align(&base->coords, &obj->coords, align, &new_pos); + + /*Bring together the coordination system of base and obj*/ + lv_obj_t * par = lv_obj_get_parent(obj); + lv_coord_t par_abs_x = par->coords.x1; + lv_coord_t par_abs_y = par->coords.y1; + new_pos.x += x_ofs; + new_pos.y += y_ofs; + new_pos.x -= par_abs_x; + new_pos.y -= par_abs_y; + + lv_obj_set_pos(obj, new_pos.x, new_pos.y); +} + + +/** + * Copy the coordinates of an object to an area + * @param obj pointer to an object + * @param coords_out pointer to an area to store the coordinates + */ +void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * coords_out) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + lv_area_copy(coords_out, &obj->coords); +} + +/** + * Reduce area retried by `lv_obj_get_coords()` the get graphically usable area of an object. + * (Without the size of the border or other extra graphical elements) + * @param coords_out store the result area here + */ +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); + + if(part & LV_BORDER_SIDE_LEFT) coords_out->x1 += w; + if(part & LV_BORDER_SIDE_RIGHT) coords_out->x2 -= w; + if(part & LV_BORDER_SIDE_TOP) coords_out->y1 += w; + if(part & LV_BORDER_SIDE_BOTTOM) coords_out->y2 -= w; +} + +/** + * Get the x coordinate of object. + * @param obj pointer to an object + * @return distance of 'obj' from the left side of its parent plus the parent's left padding + * @note Zero return value means the object is on the left padding of the parent, and not on the left edge. + * @note Scrolling of the parent doesn't change the returned value. + * @note The returned value is always the distance from the parent even if the position is grid cell or other special value. + */ +lv_coord_t lv_obj_get_x(const lv_obj_t * obj) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + lv_coord_t rel_x; + lv_obj_t * parent = lv_obj_get_parent(obj); + if(parent) { + rel_x = obj->coords.x1 - parent->coords.x1; + rel_x += lv_obj_get_scroll_left(parent); + rel_x -= lv_obj_get_style_pad_left(parent, LV_OBJ_PART_MAIN); + } + else { + rel_x = obj->coords.x1; + } + return rel_x; +} + +/** + * Get the y coordinate of object. + * @param obj pointer to an object + * @return distance of 'obj' from the top side of its parent plus the parent's top padding + * @note Zero return value means the object is on the top padding of the parent, and not on the top edge. + * @note Scrolling of the parent doesn't change the returned value. + * @note The returned value is always the distance from the parent even if the position is grid cell or other special value. + */ +lv_coord_t lv_obj_get_y(const lv_obj_t * obj) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + lv_coord_t rel_y; + lv_obj_t * parent = lv_obj_get_parent(obj); + if(parent) { + rel_y = obj->coords.y1 - parent->coords.y1; + rel_y += lv_obj_get_scroll_top(parent); + rel_y -= lv_obj_get_style_pad_top(parent, LV_OBJ_PART_MAIN); + } + else { + rel_y = obj->coords.y1; + } + return rel_y; +} + +/** + * Get the width of an object + * @param obj pointer to an object + * @return the width in pixels + * @note The returned value is always the width in pixels even if the width is set to `LV_SIZE_AUTO` or other special value. + */ +lv_coord_t lv_obj_get_width(const lv_obj_t * obj) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + return lv_area_get_width(&obj->coords); +} + +/** + * Get the height of an object + * @param obj pointer to an object + * @return the height in pixels + * @note The returned value is always the width in pixels even if the width is set to `LV_SIZE_AUTO` or other special value. + */ +lv_coord_t lv_obj_get_height(const lv_obj_t * obj) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + return lv_area_get_height(&obj->coords); +} + +/** + * Get that width reduced by the left and right padding. + * @param obj pointer to an object + * @return the width which still fits into the container without causing overflow + */ +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); + + return lv_obj_get_width(obj) - left - right; +} + +/** + * Get that height reduced by the top an bottom padding. + * @param obj pointer to an object + * @return the height which still fits into the container without causing overflow + */ +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); + + return lv_obj_get_height(obj) - top - bottom; +} + +/** + * Get the height of an object by taking the top and bottom margin into account. + * The returned height will be `obj_h + margin_top + margin_bottom` + * @param obj pointer to an object + * @return the height including the margins + */ +lv_coord_t lv_obj_get_height_margin(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); + + return lv_obj_get_height(obj) + mtop + mbottom; +} + +/** + * Get the width of an object by taking the left and right margin into account. + * The returned width will be `obj_w + margin_left + margin_right` + * @param obj pointer to an object + * @return the height including the margins + */ +lv_coord_t lv_obj_get_width_margin(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); + + return lv_obj_get_width(obj) + mleft + mright; +} + +/** + * Check if a given screen-space point is on an object's coordinates. + * + * This method is intended to be used mainly by advanced hit testing algorithms to check + * whether the point is even within the object (as an optimization). + * @param obj object to check + * @param point screen-space point + */ +bool lv_obj_is_point_on_coords(lv_obj_t * obj, const lv_point_t * point) +{ +#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY + lv_area_t ext_area; + ext_area.x1 = obj->coords.x1 - obj->ext_click_pad_hor; + ext_area.x2 = obj->coords.x2 + obj->ext_click_pad_hor; + ext_area.y1 = obj->coords.y1 - obj->ext_click_pad_ver; + ext_area.y2 = obj->coords.y2 + obj->ext_click_pad_ver; + + if(!_lv_area_is_point_on(&ext_area, point, 0)) { +#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL + lv_area_t ext_area; + ext_area.x1 = obj->coords.x1 - obj->ext_click_pad.x1; + ext_area.x2 = obj->coords.x2 + obj->ext_click_pad.x2; + ext_area.y1 = obj->coords.y1 - obj->ext_click_pad.y1; + ext_area.y2 = obj->coords.y2 + obj->ext_click_pad.y2; + + if(!_lv_area_is_point_on(&ext_area, point, 0)) { +#else + if(!_lv_area_is_point_on(&obj->coords, point, 0)) { +#endif + return false; + } + return true; +} + +/** + * Calculate the "auto size". It's `auto_size = max(gird_size, children_size)` + * @param obj pointer to an object + * @param w_out store the width here. NULL to not calculate width + * @param h_out store the height here. NULL to not calculate height + */ +void _lv_obj_calc_auto_size(lv_obj_t * obj, lv_coord_t * w_out, lv_coord_t * h_out) +{ + if(!w_out && !h_out) return; + + /*If no other effect the auto-size of zero by default*/ + if(w_out) *w_out = 0; + if(h_out) *h_out = 0; + + /*Get the grid size of the object has a defined grid*/ + lv_coord_t grid_w = 0; + lv_coord_t grid_h = 0; + if(obj->grid) { + _lv_grid_calc_t calc; + grid_calc(obj, &calc); + grid_w = calc.col_dsc[calc.col_dsc_len - 1] + lv_obj_get_style_pad_top(obj, LV_OBJ_PART_MAIN) + + lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN); + grid_h = calc.row_dsc[calc.row_dsc_len - 1] + lv_obj_get_style_pad_left(obj, LV_OBJ_PART_MAIN) + lv_obj_get_style_pad_right(obj, LV_OBJ_PART_MAIN);; + grid_calc_free(&calc); + } + + /*Get the children's most right and bottom position*/ + lv_coord_t children_w = 0; + lv_coord_t children_h = 0; + if(w_out) { + lv_obj_scroll_to_x(obj, 0, LV_ANIM_OFF); + lv_coord_t scroll_right = lv_obj_get_scroll_right(obj); + children_w = lv_obj_get_width(obj) + scroll_right; + } + + if(h_out) { + lv_obj_scroll_to_y(obj, 0, LV_ANIM_OFF); + lv_coord_t scroll_bottom = lv_obj_get_scroll_bottom(obj); + children_h = lv_obj_get_height(obj) + scroll_bottom; + } + + + /*auto_size = max(gird_size, children_size)*/ + if(w_out) *w_out = LV_MATH_MAX(children_w, grid_w); + if(h_out) *h_out = LV_MATH_MAX(children_h, grid_h); +} + +/** + * Move an object to a given x and y coordinate. + * It's the core function to move objects but user should use `lv_obj_set_pos/x/y/..` etc. + * @param obj pointer to an object to move + * @param x the new x coordinate in pixels + * @param y the new y coordinate in pixels + * @param notify_parent true: send `LV_SIGNAL_CHILD_CHG` to the parent if `obj` moved; false: do not notify the parent + */ +void _lv_obj_move_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, bool notify_parent) +{ + /*Convert x and y to absolute coordinates*/ + 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); + + x += pad_left + parent->coords.x1 - lv_obj_get_scroll_left(parent); + y += pad_top + parent->coords.y1 - lv_obj_get_scroll_top(parent); + } else { + /*If no parent then it's screen but screen can't be on a grid*/ + if(_GRID_IS_CELL(obj->x_set) || _GRID_IS_CELL(obj->x_set)) { + obj->x_set = 0; + obj->y_set = 0; + x = 0; + y = 0; + } + } + + /*Calculate and set the movement*/ + lv_point_t diff; + diff.x = x - obj->coords.x1; + diff.y = y - obj->coords.y1; + + /* Do nothing if the position is not changed */ + /* It is very important else recursive positioning can + * occur without position change*/ + if(diff.x == 0 && diff.y == 0) return; + + /*Invalidate the original area*/ + lv_obj_invalidate(obj); + + /*Save the original coordinates*/ + lv_area_t ori; + lv_obj_get_coords(obj, &ori); + + obj->coords.x1 += diff.x; + obj->coords.y1 += diff.y; + obj->coords.x2 += diff.x; + obj->coords.y2 += diff.y; + + _lv_obj_move_children_by(obj, diff.x, diff.y); + + /*Inform the object about its new coordinates*/ + obj->signal_cb(obj, LV_SIGNAL_COORD_CHG, &ori); + + /*Send a signal to the parent too*/ + if(parent && notify_parent) parent->signal_cb(parent, LV_SIGNAL_CHILD_CHG, obj); + + /*Invalidate the new area*/ + lv_obj_invalidate(obj); +} + + +/** + * Reposition the children of an object. (Called recursively) + * @param obj pointer to an object which children will be repositioned + * @param x_diff x coordinate shift + * @param y_diff y coordinate shift + */ +void _lv_obj_move_children_by(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff) +{ + lv_obj_t * i; + _LV_LL_READ(obj->child_ll, i) { + i->coords.x1 += x_diff; + i->coords.y1 += y_diff; + i->coords.x2 += x_diff; + i->coords.y2 += y_diff; + + _lv_obj_move_children_by(i, x_diff, y_diff); + } +} + +/** + * Check if an object is valid grid item or not. + * @param obj pointer to an object to check + * @return true: grid item; false: not grid item + */ +bool _lv_obj_is_grid_item(lv_obj_t * obj) +{ + lv_obj_t * cont = lv_obj_get_parent(obj); + if(cont == NULL) return false; + if(cont->grid == NULL) return false; + if(_GRID_IS_CELL(obj->x_set) && _GRID_IS_CELL(obj->y_set)) return true; + return false; +} + + +/********************** + * STATIC FUNCTIONS + **********************/ + +/** + * Set the size of an object. + * It's the core function to set the size of objects but user should use `lv_obj_set_size/width/height/..` etc. + * @param obj pointer to an object + * @param w the new width in pixels + * @param h the new height in pixels + * @return true: the size was changed; false: `w` and `h` was equal to the current width and height so nothing happened. + */ +static bool refr_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h) +{ + /* Do nothing if the size is not changed */ + /* It is very important else recursive resizing can + * occur without size change*/ + if(lv_obj_get_width(obj) == w && lv_obj_get_height(obj) == h) { + return false; + } + /*Invalidate the original area*/ + lv_obj_invalidate(obj); + + /*Save the original coordinates*/ + lv_area_t ori; + lv_obj_get_coords(obj, &ori); + + /*Set the length and height*/ + obj->coords.y2 = obj->coords.y1 + h - 1; + if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) { + obj->coords.x1 = obj->coords.x2 - w + 1; + } + else { + obj->coords.x2 = obj->coords.x1 + w - 1; + } + + /*Send a signal to the object with its new coordinates*/ + obj->signal_cb(obj, LV_SIGNAL_COORD_CHG, &ori); + + /*Send a signal to the parent too*/ + lv_obj_t * par = lv_obj_get_parent(obj); + if(par != NULL) par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj); + + /*Invalidate the new area*/ + lv_obj_invalidate(obj); + return true; +} + diff --git a/src/lv_core/lv_obj_pos.h b/src/lv_core/lv_obj_pos.h new file mode 100644 index 000000000..d7363c5e4 --- /dev/null +++ b/src/lv_core/lv_obj_pos.h @@ -0,0 +1,241 @@ +/** + * @file lv_obj_pos.h + * + */ + +#ifndef LV_OBJ_POS_H +#define LV_OBJ_POS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../lv_misc/lv_area.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/* Can't include lv_obj.h because it includes this header file */ +struct _lv_obj_t; +typedef struct _lv_obj_t lv_obj_t; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/** + * Set relative the position of an object (relative to the parent) + * @param obj pointer to an object + * @param x new distance from the left side of the parent + * @param y new distance from the top of the parent + */ +void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y); + +/** + * Set the x coordinate of a object + * @param obj pointer to an object + * @param x new distance from the left side from the parent + */ +void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x); + +/** + * Set the y coordinate of a object + * @param obj pointer to an object + * @param y new distance from the top of the parent + */ +void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y); + + +void _lv_obj_calc_auto_size(lv_obj_t * obj, lv_coord_t * w, lv_coord_t * h); + +/** + * Set the size of an object + * @param obj pointer to an object + * @param w new width + * @param h new height + */ +void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h); + +/** + * Set the width of an object + * @param obj pointer to an object + * @param w new width + */ +void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w); + +/** + * Set the height of an object + * @param obj pointer to an object + * @param h new height + */ +void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h); + +/** + * Set the width reduced by the left and right padding. + * @param obj pointer to an object + * @param w the width without paddings + */ +void lv_obj_set_content_width(lv_obj_t * obj, lv_coord_t w); + +/** + * Set the height reduced by the top and bottom padding. + * @param obj pointer to an object + * @param h the height without paddings + */ +void lv_obj_set_content_height(lv_obj_t * obj, lv_coord_t h); + +/** + * Set the width of an object by taking the left and right margin into account. + * The object width will be `obj_w = w - margin_left - margin_right` + * @param obj pointer to an object + * @param w new height including margins + */ +void lv_obj_set_width_margin(lv_obj_t * obj, lv_coord_t w); + +/** + * Set the height of an object by taking the top and bottom margin into account. + * The object height will be `obj_h = h - margin_top - margin_bottom` + * @param obj pointer to an object + * @param h new height including margins + */ +void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h); + +/** + * Align an object to an other object. + * @param obj pointer to an object to align + * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. + * @param align type of alignment (see 'lv_align_t' enum) + * @param x_ofs x coordinate offset after alignment + * @param y_ofs y coordinate offset after alignment + */ +void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); + + +/** + * Copy the coordinates of an object to an area + * @param obj pointer to an object + * @param cords_p pointer to an area to store the coordinates + */ +void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * cords_p); + +/** + * Reduce area retried by `lv_obj_get_coords()` the get graphically usable area of an object. + * (Without the size of the border or other extra graphical elements) + * @param coords_p store the result area here + */ +void lv_obj_get_inner_coords(const lv_obj_t * obj, lv_area_t * coords_p); + +/** + * Get the x coordinate of object + * @param obj pointer to an object + * @return distance of 'obj' from the left side of its parent + */ +lv_coord_t lv_obj_get_x(const lv_obj_t * obj); + +/** + * Get the y coordinate of object + * @param obj pointer to an object + * @return distance of 'obj' from the top of its parent + */ +lv_coord_t lv_obj_get_y(const lv_obj_t * obj); + +/** + * Get the width of an object + * @param obj pointer to an object + * @return the width + */ +lv_coord_t lv_obj_get_width(const lv_obj_t * obj); + +/** + * Get the height of an object + * @param obj pointer to an object + * @return the height + */ +lv_coord_t lv_obj_get_height(const lv_obj_t * obj); + +/** + * Get that width reduced by the left and right padding. + * @param obj pointer to an object + * @return the width which still fits into the container + */ +lv_coord_t lv_obj_get_width_fit(const lv_obj_t * obj); + +/** + * Get that height reduced by the top an bottom padding. + * @param obj pointer to an object + * @return the height which still fits into the container + */ +lv_coord_t lv_obj_get_height_fit(const lv_obj_t * obj); + +/** + * Get the height of an object by taking the top and bottom margin into account. + * The returned height will be `obj_h + margin_top + margin_bottom` + * @param obj pointer to an object + * @return the height including thee margins + */ +lv_coord_t lv_obj_get_height_margin(lv_obj_t * obj); + +/** + * Get the width of an object by taking the left and right margin into account. + * The returned width will be `obj_w + margin_left + margin_right` + * @param obj pointer to an object + * @return the height including thee margins + */ +lv_coord_t lv_obj_get_width_margin(lv_obj_t * obj); + + +/** + * Check if a given screen-space point is on an object's coordinates. + * + * This method is intended to be used mainly by advanced hit testing algorithms to check + * whether the point is even within the object (as an optimization). + * @param obj object to check + * @param point screen-space point + */ +bool lv_obj_is_point_on_coords(lv_obj_t * obj, const lv_point_t * point); + +/** + * Divide the width of the object and get the width of a given number of columns. + * Take paddings into account. + * @param obj pointer to an object + * @param div indicates how many columns are assumed. + * If 1 the width will be set the the parent's width + * If 2 only half parent width - inner padding of the parent + * If 3 only third parent width - 2 * inner padding of the parent + * @param span how many columns are combined + * @return the width according to the given parameters + */ +lv_coord_t lv_obj_get_width_grid(lv_obj_t * obj, uint8_t div, uint8_t span); + +/** + * Divide the height of the object and get the width of a given number of columns. + * Take paddings into account. + * @param obj pointer to an object + * @param div indicates how many rows are assumed. + * If 1 the height will be set the the parent's height + * If 2 only half parent height - inner padding of the parent + * If 3 only third parent height - 2 * inner padding of the parent + * @param span how many rows are combined + * @return the height according to the given parameters + */ +lv_coord_t lv_obj_get_height_grid(lv_obj_t * obj, uint8_t div, uint8_t span); + +void _lv_obj_move_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, bool notify_parent); + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*LV_OBJ_POS_H*/ diff --git a/src/lv_core/lv_obj_scroll.c b/src/lv_core/lv_obj_scroll.c new file mode 100644 index 000000000..4d94a5ba0 --- /dev/null +++ b/src/lv_core/lv_obj_scroll.c @@ -0,0 +1,246 @@ +/** + * @file lv_obj_scroll.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_obj_scroll.h" +#include "lv_obj.h" + +/********************* + * DEFINES + *********************/ +#define SCROLL_ANIM_TIME_MIN 100 /*ms*/ +#define SCROLL_ANIM_TIME_MAX 300 /*ms*/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ +static void scroll_anim_x_cb(lv_obj_t * obj, lv_anim_value_t v); +static void scroll_anim_y_cb(lv_obj_t * obj, lv_anim_value_t v); + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +/** + * Set how the scrollbars should behave. + * @param obj pointer to an object + * @param mode: LV_SCROLL_MODE_ON/OFF/AUTO/ACTIVE + */ +void lv_obj_set_scroll_mode(lv_obj_t * obj, lv_scroll_mode_t mode) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + if(obj->scroll_mode == mode) return; + obj->scroll_mode = mode; + lv_obj_invalidate(obj); +} + +/** + * Get how the scrollbars should behave. + * @param obj pointer to an object + * @return mode: LV_SCROLL_MODE_ON/OFF/AUTO/ACTIVE + */ +lv_scroll_mode_t lv_obj_get_scroll_mode(lv_obj_t * obj) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + return obj->scroll_mode; +} + +/** + * Moves all children with horizontally or vertically. + * It doesn't take into account any limits so any values are possible + * @param obj pointer to an object whose children should be moved + * @param x pixel to move horizontally + * @param y pixels to move vertically + */ +void _lv_obj_scroll_by_raw(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) +{ + obj->scroll.x += x; + obj->scroll.y += y; + + _lv_obj_move_children_by(obj, x, y); + lv_res_t res = lv_signal_send(obj, LV_SIGNAL_SCROLL, NULL); + if(res != LV_RES_OK) return; + lv_obj_invalidate(obj); +} +/** + * Moves all children with horizontally or vertically. + * Limits the scroll to the bounding box of the children. + * @param obj pointer to an object whose children should be moved + * @param x pixel to move horizontally + * @param y pixels to move vertically + */ +void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en) +{ + if(x == 0 && y == 0) return; + + if(anim_en == LV_ANIM_ON) { + lv_disp_t * d = lv_obj_get_disp(obj); + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, obj); + + lv_anim_path_t path; + lv_anim_path_init(&path); + lv_anim_path_set_cb(&path, lv_anim_path_ease_out); + + if(x) { + uint32_t t = lv_anim_speed_to_time((lv_disp_get_hor_res(d) * 3) >> 2, 0, x); + if(t < SCROLL_ANIM_TIME_MIN) t = SCROLL_ANIM_TIME_MIN; + if(t > SCROLL_ANIM_TIME_MAX) t = SCROLL_ANIM_TIME_MAX; + lv_anim_set_time(&a, t); + lv_anim_set_values(&a, obj->scroll.x, obj->scroll.x + x); + lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t) scroll_anim_x_cb); + lv_anim_set_path(&a, &path); + lv_anim_start(&a); + } + + if(y) { + uint32_t t = lv_anim_speed_to_time((lv_disp_get_ver_res(d) * 3) >> 2, 0, y); + if(t < SCROLL_ANIM_TIME_MIN) t = SCROLL_ANIM_TIME_MIN; + if(t > SCROLL_ANIM_TIME_MAX) t = SCROLL_ANIM_TIME_MAX; + lv_anim_set_time(&a, t); + lv_anim_set_values(&a, obj->scroll.y, obj->scroll.y + y); + lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t) scroll_anim_y_cb); + lv_anim_set_path(&a, &path); + lv_anim_start(&a); + } + } else { + _lv_obj_scroll_by_raw(obj, x, y); + } +} + +/** + * Scroll the a given x coordinate to the left side of obj. + * @param obj pointer to an object which should be scrolled + * @param x the x coordinate to scroll to + * @param y the y coordinate to scroll to + */ +void lv_obj_scroll_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en) +{ + +} + +/** + * Scroll the a given x coordinate to the left side of obj. + * @param obj pointer to an object which should be scrolled + * @param x the x coordinate to scroll to + */ +void lv_obj_scroll_to_x(lv_obj_t * obj, lv_coord_t x, lv_anim_enable_t anim_en) +{ + lv_obj_scroll_by(obj, -x - obj->scroll.x, 0, anim_en); +} + +/** + * Scroll the a given y coordinate to the top side of obj. + * @param obj pointer to an object which should be scrolled + * @param y the y coordinate to scroll to + */ +void lv_obj_scroll_to_y(lv_obj_t * obj, lv_coord_t y, lv_anim_enable_t anim_en) +{ + lv_obj_scroll_by(obj, 0, -y - obj->scroll.y, anim_en); +} + + +/** + * Return the height of the area above the parent. + * That is the number of pixels the object can be scrolled down. + * Normally positive but can be negative when scrolled inside. + * @param obj + * @return + */ +lv_coord_t lv_obj_get_scroll_top(const lv_obj_t * obj) +{ + return -obj->scroll.y; +} + +/** + * Return the height of the area below the parent. + * That is the number of pixels the object can be scrolled up. + * Normally positive but can be negative when scrolled inside. + * @param obj + * @return + */ +lv_coord_t lv_obj_get_scroll_bottom(const lv_obj_t * obj) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + lv_coord_t y2 = LV_COORD_MIN; + + lv_obj_t * child = lv_obj_get_child(obj, NULL); + if(child == NULL) return 0; + + while(child) { + y2 = LV_MATH_MAX(y2, child->coords.y2 + lv_obj_get_style_margin_bottom(child, LV_OBJ_PART_MAIN)); + child = lv_obj_get_child(obj, child); + } + + return y2 - obj->coords.y2 + lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN); +} + +/** + * Return the weight of the area on the left the parent. + * That is the number of pixels the object can be scrolled down. + * Normally positive but can be negative when scrolled inside. + * @param obj + * @return + */ +lv_coord_t lv_obj_get_scroll_left(const lv_obj_t * obj) +{ + return -obj->scroll.x; +} + +/** + * Return the width of the area below the object. + * That is the number of pixels the object can be scrolled left. + * Normally positive but can be negative when scrolled inside. + * @param obj + * @return + */ +lv_coord_t lv_obj_get_scroll_right(const lv_obj_t * obj) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + lv_coord_t x2 = LV_COORD_MIN; + + lv_obj_t * child = lv_obj_get_child(obj, NULL); + if(child == NULL) return 0; + + while(child) { + x2 = LV_MATH_MAX(x2, child->coords.x2 + lv_obj_get_style_margin_right(child, LV_OBJ_PART_MAIN)); + child = lv_obj_get_child(obj, child); + } + + return x2 - obj->coords.x2 + lv_obj_get_style_pad_right(obj, LV_OBJ_PART_MAIN); +} + +/********************** + * STATIC FUNCTIONS + **********************/ + +static void scroll_anim_x_cb(lv_obj_t * obj, lv_anim_value_t v) +{ + _lv_obj_scroll_by_raw(obj, v - obj->scroll.x, 0); +} + +static void scroll_anim_y_cb(lv_obj_t * obj, lv_anim_value_t v) +{ + _lv_obj_scroll_by_raw(obj, 0, v - obj->scroll.y); +} diff --git a/src/lv_core/lv_obj_scroll.h b/src/lv_core/lv_obj_scroll.h new file mode 100644 index 000000000..fa5ab753d --- /dev/null +++ b/src/lv_core/lv_obj_scroll.h @@ -0,0 +1,153 @@ +/** + * @file lv_obj_scroll.h + * + */ + +#ifndef LV_OBJ_SCROLL_H +#define LV_OBJ_SCROLL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../lv_misc/lv_area.h" +#include "../lv_misc/lv_anim.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +struct _lv_obj_t; +typedef struct _lv_obj_t lv_obj_t; + +/** Scrollbar modes: shows when should the scrollbars be visible*/ +enum { + LV_SCROLL_MODE_OFF = 0x0, /**< Never show scroll bars*/ + LV_SCROLL_MODE_ON = 0x1, /**< Always show scroll bars*/ + LV_SCROLL_MODE_ACTIVE = 0x2, /**< Show scroll bars when object is being scrolled*/ + LV_SCROLL_MODE_AUTO = 0x3, /**< Show scroll bars when the content is large enough to be scrolled*/ +}; +typedef uint8_t lv_scroll_mode_t; + + +enum { + LV_SCROLL_SNAP_ALIGN_NONE, + LV_SCROLL_SNAP_ALIGN_START, + LV_SCROLL_SNAP_ALIGN_END, + LV_SCROLL_SNAP_ALIGN_CENTER +}; +typedef uint8_t lv_scroll_snap_align_t; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/** + * Set how the scrollbars should behave. + * @param obj pointer to an object + * @param mode: LV_SCROLL_MODE_ON/OFF/AUTO/ACTIVE + */ +void lv_obj_set_scroll_mode(lv_obj_t * obj, lv_scroll_mode_t mode); + +/** + * Get how the scrollbars should behave. + * @param obj pointer to an object + * @return mode: LV_SCROLL_MODE_ON/OFF/AUTO/ACTIVE + */ +lv_scroll_mode_t lv_obj_get_scroll_mode(lv_obj_t * obj); + +/** + * Moves all children with horizontally or vertically. + * It doesn't take into account any limits so any values are possible + * @param obj pointer to an object whose children should be moved + * @param x pixel to move horizontally + * @param y pixels to move vertically + */ +void _lv_obj_scroll_by_raw(lv_obj_t * obj, lv_coord_t x, lv_coord_t y); + +/** + * Moves all children with horizontally or vertically. + * Limits the scroll to the bounding box of the children. + * @param obj pointer to an object whose children should be moved + * @param x pixel to move horizontally + * @param y pixels to move vertically + */ +void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en); + +/** + * Scroll the a given x coordinate to the left side of obj. + * @param obj pointer to an object which should be scrolled + * @param x the x coordinate to scroll to + * @param y the y coordinate to scroll to + */ +void lv_obj_scroll_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en); + +/** + * Scroll the a given x coordinate to the left side of obj. + * @param obj pointer to an object which should be scrolled + * @param x the x coordinate to scroll to + */ +void lv_obj_scroll_to_x(lv_obj_t * obj, lv_coord_t x, lv_anim_enable_t anim_en); + +/** + * Scroll the a given y coordinate to the top side of obj. + * @param obj pointer to an object which should be scrolled + * @param y the y coordinate to scroll to + */ +void lv_obj_scroll_to_y(lv_obj_t * obj, lv_coord_t y, lv_anim_enable_t anim_en); + + +/** + * Return the height of the area above the parent. + * That is the number of pixels the object can be scrolled down. + * Normally positive but can be negative when scrolled inside. + * @param obj + * @return + */ +lv_coord_t lv_obj_get_scroll_top(const lv_obj_t * obj); + +/** + * Return the height of the area below the parent. + * That is the number of pixels the object can be scrolled up. + * Normally positive but can be negative when scrolled inside. + * @param obj + * @return + */ +lv_coord_t lv_obj_get_scroll_bottom(const lv_obj_t * obj); + + +/** + * Return the weight of the area on the left the parent. + * That is the number of pixels the object can be scrolled down. + * Normally positive but can be negative when scrolled inside. + * @param obj + * @return + */ +lv_coord_t lv_obj_get_scroll_left(const lv_obj_t * obj); + +/** + * Return the width of the area below the object. + * That is the number of pixels the object can be scrolled left. + * Normally positive but can be negative when scrolled inside. + * @param obj + * @return + */ +lv_coord_t lv_obj_get_scroll_right(const lv_obj_t * obj); + + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*LV_OBJ_SCROLL_H*/ diff --git a/src/lv_core/lv_obj_style.c b/src/lv_core/lv_obj_style.c new file mode 100644 index 000000000..9fa0be8b9 --- /dev/null +++ b/src/lv_core/lv_obj_style.c @@ -0,0 +1,1366 @@ +/** + * @file lv_obj_style.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_obj.h" +#include "lv_disp.h" +#include "../lv_themes/lv_theme.h" +#include "../lv_misc/lv_gc.h" + +#if defined(LV_GC_INCLUDE) + #include LV_GC_INCLUDE +#endif /* LV_ENABLE_GC */ + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +typedef struct { + lv_obj_t * obj; + lv_style_property_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_trans_t; + +/********************** + * STATIC PROTOTYPES + **********************/ +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_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); +#endif + +static bool style_prop_is_cacheable(lv_style_property_t prop); +static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop); +static void update_style_cache_children(lv_obj_t * obj); +static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop); +static void fade_anim_cb(lv_obj_t * obj, lv_anim_value_t v); +static void fade_in_anim_ready(lv_anim_t * a); + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +/** + * Initialize the object related style manager module. + * Called by LVGL in `lv_init()` + */ +void _lv_obj_style_init(void) +{ + _lv_ll_init(&LV_GC_ROOT(_lv_obj_style_trans_ll), sizeof(lv_style_trans_t)); +} + +/** + * Add a new style to the style list 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` + * @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) +{ + 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); +} + +/** + * Remove a style from the style list 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` + * @param style pointer to a style to remove + */ +void lv_obj_remove_style(lv_obj_t * obj, uint8_t part, 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_remove_style(list, style); +#if LV_USE_ANIMATION + trans_del(obj, part, 0xFF, NULL); +#endif + _lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); +} + +/** + * Reset a style to the default (empty) state. + * Release all used memories and cancel pending related transitions. + * Also notifies the object about the style change. + * @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(lv_obj_t * obj, uint8_t part) +{ + _lv_obj_reset_style_list_no_refr(obj, part); + + _lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); +} + +/** + * Notify all object if a style is modified + * @param style pointer to a style. Only the objects with this style will be notified + * (NULL to notify all objects) + */ +void lv_obj_report_style_change(lv_style_t * style) +{ + lv_disp_t * d = lv_disp_get_next(NULL); + + while(d) { + lv_obj_t * i; + _LV_LL_READ(d->scr_ll, i) { + report_style_change_core(style, i); + } + d = lv_disp_get_next(d); + } +} + +/** + * 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) +{ + 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; +} + + +#if LV_USE_ANIMATION +/** + * Fade in (from transparent to fully cover) an object and all its children using an `opa_scale` animation. + * @param obj the object to fade in + * @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) +{ + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, obj); + lv_anim_set_values(&a, LV_OPA_TRANSP, LV_OPA_COVER); + lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)fade_anim_cb); + lv_anim_set_ready_cb(&a, fade_in_anim_ready); + lv_anim_set_time(&a, time); + lv_anim_set_delay(&a, delay); + lv_anim_start(&a); +} + +/** + * Fade out (from fully cover to transparent) an object and all its children using an `opa_scale` animation. + * @param obj the object to fade in + * @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) +{ + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, obj); + lv_anim_set_values(&a, LV_OPA_COVER, LV_OPA_TRANSP); + lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)fade_anim_cb); + lv_anim_set_time(&a, time); + lv_anim_set_delay(&a, delay); + lv_anim_start(&a); +} +#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) +{ + uint8_t part; + for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) { + lv_style_list_t * list = _lv_obj_get_style_list(obj, part); + if(list == NULL) break; + list->ignore_cache = dis; + } + for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) { + lv_style_list_t * list = _lv_obj_get_style_list(obj, part); + if(list == NULL) break; + list->ignore_cache = dis; + } +} + + +/** + * 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(!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_BG_GRAD_DIR: + if(list->bg_grad_dir_none) def = true; + break; + 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: + case LV_STYLE_PAD_BOTTOM: + case LV_STYLE_PAD_LEFT: + 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; + } + + if(def) { + break; + } + } + + lv_state_t state = lv_obj_get_state(parent, part); + prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS); + + 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, part); + 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 + * @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) +{ + 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; + const lv_obj_t * parent = obj; + while(parent) { + lv_style_list_t * list = _lv_obj_get_style_list(parent, part); + + 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; + } + + if(def) { + break; + } + } + + + lv_state_t state = lv_obj_get_state(parent, part); + prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS); + + 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 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_OPA: + case LV_STYLE_IMAGE_RECOLOR_OPA: + case LV_STYLE_PATTERN_RECOLOR_OPA: + return LV_OPA_TRANSP; + } + + return LV_OPA_COVER; +} + +/** + * 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(!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; + } + } + + lv_state_t state = lv_obj_get_state(parent, part); + 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) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + invalidate_style_cache(obj, part, prop); + + /*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_PAD_TOP: + case LV_STYLE_PAD_BOTTOM: + case LV_STYLE_PAD_LEFT: + case LV_STYLE_PAD_RIGHT: + case LV_STYLE_PAD_INNER: + case LV_STYLE_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: + real_refr = true; + break; + default: + real_refr = false; + } + + if(real_refr) { + lv_obj_invalidate(obj); + obj->signal_cb(obj, LV_SIGNAL_STYLE_CHG, NULL); + + 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: + if(obj->parent) obj->parent->signal_cb(obj->parent, LV_SIGNAL_CHILD_CHG, obj); + break; + } + + lv_obj_invalidate(obj); + + /*Send style change signals*/ + if(prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_INHERIT_MASK)) refresh_children_style(obj); + } + else { + lv_obj_invalidate(obj); + } +} + +/** + * Remove all transitions from an object + * @param obj pointer to an object + */ +void _lv_obj_remove_style_trans(lv_obj_t * obj) +{ + trans_del(obj, 0xFF, 0xFF, NULL); +} + +#if LV_USE_ANIMATION + +/** + * 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. + * @param obj and object to add the transition + * @param prop the property to apply the transaction + * @param part the part of the object to apply the transaction + * @param prev_state the previous state of the objects + * @param new_state the new state of the object + * @param time duration of transition in [ms] + * @param delay delay before starting the transition in [ms] + * @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) +{ + 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); + + /*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; + + 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(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); + } + } + + 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; + } + + if(tr) { + tr->obj = obj; + tr->prop = prop; + tr->part = part; + + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, tr); + lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)trans_anim_cb); + lv_anim_set_start_cb(&a, trans_anim_start_cb); + lv_anim_set_ready_cb(&a, trans_anim_ready_cb); + lv_anim_set_values(&a, 0x00, 0xFF); + lv_anim_set_time(&a, time); + lv_anim_set_delay(&a, delay); + lv_anim_set_path(&a, path); + a.early_apply = 0; + lv_anim_start(&a); + } +} + +#endif + +/********************** + * STATIC FUNCTIONS + **********************/ + +/** + * Refresh the style of all children of an object. (Called recursively) + * @param style refresh objects only with this style_list. + * @param obj pointer to an object + */ +static void report_style_change_core(void * style, lv_obj_t * obj) +{ + uint8_t part; + for(part = 0; part != _LV_OBJ_PART_REAL_LAST; part++) { + lv_style_list_t * list = _lv_obj_get_style_list(obj, part); + if(list == NULL) break; + + 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; + } + } + } + + lv_obj_t * child = lv_obj_get_child(obj, NULL); + while(child) { + report_style_change_core(style, child); + child = lv_obj_get_child(obj, child); + } + +} + +/** + * Recursively refresh the style of the children. Go deeper until a not NULL style is found + * because the NULL styles are inherited from the parent + * @param obj pointer to an object + */ +static void refresh_children_style(lv_obj_t * obj) +{ + lv_obj_t * child = lv_obj_get_child(obj, NULL); + while(child != NULL) { + lv_obj_invalidate(child); + child->signal_cb(child, LV_SIGNAL_STYLE_CHG, NULL); + lv_obj_invalidate(child); + + refresh_children_style(child); /*Check children too*/ + child = lv_obj_get_child(obj, child); + } +} + +#if LV_USE_ANIMATION +/** + * Remove the transition from object's part's property. + * - Remove the transition from `_lv_obj_style_trans_ll` and free it + * - Delete pending transitions + * @param obj pointer to an object which transition(s) should be removed + * @param part a part of object or 0xFF to remove from all parts + * @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) +{ + lv_style_trans_t * tr; + lv_style_trans_t * tr_prev; + tr = _lv_ll_get_tail(&LV_GC_ROOT(_lv_obj_style_trans_ll)); + while(tr != NULL) { + if(tr == tr_limit) break; + + /*'tr' might be deleted, so get the next object while 'tr' is valid*/ + tr_prev = _lv_ll_get_prev(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); + + 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); + + lv_anim_del(tr, NULL); + _lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); + lv_mem_free(tr); + } + tr = tr_prev; + } +} + +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); + + 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); + +} + +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); + } + + /*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*/ + trans_del(tr->obj, tr->part, prop_tmp, tr); + + tr->prop = prop_tmp; + +} + +static void trans_anim_ready_cb(lv_anim_t * a) +{ + lv_style_trans_t * tr = a->var; + + /* Remove the transitioned property from trans. style + * if there no more transitions for this property + * It allows changing it by normal styles*/ + bool running = false; + lv_style_trans_t * tr_i; + _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; + } + } + + 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); + } + + _lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); + lv_mem_free(tr); +} + +#endif + +static bool style_prop_is_cacheable(lv_style_property_t prop) +{ + + switch(prop) { + case LV_STYLE_PROP_ALL: + case LV_STYLE_BG_GRAD_DIR: + case LV_STYLE_CLIP_CORNER: + case LV_STYLE_TEXT_LETTER_SPACE: + case LV_STYLE_TEXT_LINE_SPACE: + case LV_STYLE_TEXT_FONT: + 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->bg_grad_dir_none = lv_obj_get_style_bg_grad_dir(obj, part) == LV_GRAD_DIR_NONE ? 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; + if(lv_obj_get_style_pad_top(obj, part) != 0 || + lv_obj_get_style_pad_bottom(obj, part) != 0 || + lv_obj_get_style_pad_left(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_REAL_LAST; part++) { + lv_style_list_t * list = _lv_obj_get_style_list(obj, part); + if(list == NULL) break; + + bool ignore_cache_ori = list->ignore_cache; + list->ignore_cache = 1; + + list->opa_scale_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; + } + + lv_obj_t * child = lv_obj_get_child(obj, NULL); + while(child) { + update_style_cache_children(child); + child = lv_obj_get_child(obj, child); + } + +} + +/** + * Mark the object and all of it's children's style lists as invalid. + * The cache will be updated when a cached property asked nest time + * @param obj pointer to an object + */ +static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop) +{ + if(style_prop_is_cacheable(prop) == false) return; + + if(part != LV_OBJ_PART_ALL) { + lv_style_list_t * list = _lv_obj_get_style_list(obj, part); + if(list == NULL) return; + list->valid_cache = 0; + } + else { + + for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) { + lv_style_list_t * list = _lv_obj_get_style_list(obj, part); + if(list == NULL) break; + list->valid_cache = 0; + } + for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) { + lv_style_list_t * list = _lv_obj_get_style_list(obj, part); + if(list == NULL) break; + list->valid_cache = 0; + } + } + + lv_obj_t * child = lv_obj_get_child(obj, NULL); + while(child) { + update_style_cache_children(child); + child = lv_obj_get_child(obj, child); + } +} + +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); +} + +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); +} diff --git a/src/lv_core/lv_obj_style_dec.h b/src/lv_core/lv_obj_style.h similarity index 58% rename from src/lv_core/lv_obj_style_dec.h rename to src/lv_core/lv_obj_style.h index 8876412c3..fddf35f93 100644 --- a/src/lv_core/lv_obj_style_dec.h +++ b/src/lv_core/lv_obj_style.h @@ -1,20 +1,305 @@ - /** - * @file lv_obj_style_dec.h + * @file lv_obj_style.h * */ -#ifndef LV_OBJ_STYLE_DEC_H -#define LV_OBJ_STYLE_DEC_H +#ifndef LV_OBJ_STYLE_H +#define LV_OB_STYLE_H #ifdef __cplusplus extern "C" { #endif +/********************* + * INCLUDES + *********************/ +#include +#include +#include "lv_style.h" + /********************* * DEFINES *********************/ +/********************** + * TYPEDEFS + **********************/ +/* Can't include lv_obj.h because it includes this header file */ +struct _lv_obj_t; +typedef struct _lv_obj_t lv_obj_t; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + + +/** + * Initialize the object related style manager module. + * Called by LVGL in `lv_init()` + */ +void _lv_obj_style_init(void); + +/** + * Add a new style to the style list 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` + * @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); + +/** + * Remove a style from the style list 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` + * @param style pointer to a style to remove + */ +void lv_obj_remove_style(lv_obj_t * obj, uint8_t part, lv_style_t * style); + +/** + * Reset a style to the default (empty) state. + * Release all used memories and cancel pending related transitions. + * Also notifies the object about the style change. + * @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(lv_obj_t * obj, uint8_t part); + +/** + * Notify all object if a style is modified + * @param style pointer to a style. Only the objects with this style will be notified + * (NULL to notify all objects) + */ +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 + +/** + * Fade in (from transparent to fully cover) an object and all its children using an `opa_scale` animation. + * @param obj the object to fade in + * @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); + +/** + * Fade out (from fully cover to transparent) an object and all its children using an `opa_scale` animation. + * @param obj the object to fade in + * @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); + +#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); + +/** + * 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); + +/** + * 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); + +/** + * Remove all transitions from an object + * @param obj pointer to an object + */ +void _lv_obj_remove_style_trans(lv_obj_t * obj); + +#if LV_USE_ANIMATION + +/** + * 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. + * @param obj and object to add the transition + * @param prop the property to apply the transaction + * @param part the part of the object to apply the transaction + * @param prev_state the previous state of the objects + * @param new_state the new state of the object + * @param time duration of transition in [ms] + * @param delay delay before starting the transition in [ms] + * @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); +#endif + + +/********************** + * MACROS + **********************/ + + /** * Macro to declare the most important style set/get API functions. * @@ -309,4 +594,4 @@ static inline void lv_style_set_margin_ver(lv_style_t * style, lv_state_t state, } /* extern "C" */ #endif -#endif /*LV_OBJ_H*/ +#endif /*LV_TEMPL_H*/ diff --git a/src/lv_font/lv_font.h b/src/lv_font/lv_font.h index b3ecb881c..644a55e42 100644 --- a/src/lv_font/lv_font.h +++ b/src/lv_font/lv_font.h @@ -73,7 +73,7 @@ typedef struct _lv_font_struct { uint8_t subpx : 2; /**< An element of `lv_font_subpx_t`*/ int8_t underline_position; /**< Distance between the top of the underline and base line (< 0 means below the base line)*/ - int8_t underline_thickness; /**< Thickness of the underline*/ + int8_t underline_thickness; /**< Thickness of the underline*/ void * dsc; /**< Store implementation specific or run_time data or caching here*/ #if LV_USE_USER_DATA diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index a13527f38..e5db6d723 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -206,269 +206,269 @@ static void clear_styles(lv_obj_t * obj, lv_theme_style_t name) break; case LV_THEME_SCR: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_OBJ_PART_MAIN); break; case LV_THEME_OBJ: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_OBJ_PART_MAIN); break; #if LV_USE_CONT case LV_THEME_CONT: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_OBJ_PART_MAIN); break; #endif #if LV_USE_BTN case LV_THEME_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_BTN_PART_MAIN); break; #endif #if LV_USE_BTNMATRIX case LV_THEME_BTNMATRIX: - lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG); - lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN); + _lv_obj_reset_style_list_no_refr(obj, LV_BTNMATRIX_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_BTNMATRIX_PART_BTN); break; #endif #if LV_USE_KEYBOARD case LV_THEME_KEYBOARD: - lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG); - lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN); + _lv_obj_reset_style_list_no_refr(obj, LV_KEYBOARD_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_KEYBOARD_PART_BTN); break; #endif #if LV_USE_BAR case LV_THEME_BAR: - lv_obj_clean_style_list(obj, LV_BAR_PART_BG); - lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC); + _lv_obj_reset_style_list_no_refr(obj, LV_BAR_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_BAR_PART_INDIC); break; #endif #if LV_USE_SWITCH case LV_THEME_SWITCH: - lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG); - lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC); - lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB); + _lv_obj_reset_style_list_no_refr(obj, LV_SWITCH_PART_BG); + _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_CANVAS case LV_THEME_CANVAS: - lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_CANVAS_PART_MAIN); break; #endif #if LV_USE_IMG case LV_THEME_IMAGE: - lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_IMGBTN case LV_THEME_IMGBTN: - lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_LABEL case LV_THEME_LABEL: - lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_LINE case LV_THEME_LINE: - lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_ARC case LV_THEME_ARC: - lv_obj_clean_style_list(obj, LV_ARC_PART_BG); - lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC); + _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_SPINNER case LV_THEME_SPINNER: - lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG); - lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC); + _lv_obj_reset_style_list_no_refr(obj, LV_SPINNER_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_SPINNER_PART_INDIC); break; #endif #if LV_USE_SLIDER case LV_THEME_SLIDER: - lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG); - lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC); - lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB); + _lv_obj_reset_style_list_no_refr(obj, LV_SLIDER_PART_BG); + _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_clean_style_list(obj, LV_CHECKBOX_PART_BG); - lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET); + _lv_obj_reset_style_list_no_refr(obj, LV_CHECKBOX_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_CHECKBOX_PART_BULLET); break; #endif #if LV_USE_MSGBOX case LV_THEME_MSGBOX: - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_MSGBOX_PART_BG); break; case LV_THEME_MSGBOX_BTNS: - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG); - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN); + _lv_obj_reset_style_list_no_refr(obj, LV_MSGBOX_PART_BTN_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_MSGBOX_PART_BTN); break; #endif #if LV_USE_LED case LV_THEME_LED: - lv_obj_clean_style_list(obj, LV_LED_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_LED_PART_MAIN); break; #endif #if LV_USE_PAGE case LV_THEME_PAGE: - lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE); - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR); + _lv_obj_reset_style_list_no_refr(obj, LV_PAGE_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_PAGE_PART_SCROLLABLE); + _lv_obj_reset_style_list_no_refr(obj, LV_PAGE_PART_SCROLLBAR); break; #endif #if LV_USE_TABVIEW case LV_THEME_TABVIEW: - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN); + _lv_obj_reset_style_list_no_refr(obj, LV_TABVIEW_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_TABVIEW_PART_BG_SCRLLABLE); + _lv_obj_reset_style_list_no_refr(obj, LV_TABVIEW_PART_TAB_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_TABVIEW_PART_INDIC); + _lv_obj_reset_style_list_no_refr(obj, LV_TABVIEW_PART_TAB_BTN); break; case LV_THEME_TABVIEW_PAGE: - lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE); + _lv_obj_reset_style_list_no_refr(obj, LV_PAGE_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_PAGE_PART_SCROLLABLE); break; #endif #if LV_USE_TILEVIEW case LV_THEME_TILEVIEW: - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG); - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); + _lv_obj_reset_style_list_no_refr(obj, LV_TILEVIEW_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_TILEVIEW_PART_SCROLLBAR); + _lv_obj_reset_style_list_no_refr(obj, LV_TILEVIEW_PART_EDGE_FLASH); break; #endif #if LV_USE_ROLLER case LV_THEME_ROLLER: - lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG); - lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED); + _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_clean_style_list(obj, LV_OBJMASK_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_OBJMASK_PART_MAIN); break; #endif #if LV_USE_LIST case LV_THEME_LIST: - lv_obj_clean_style_list(obj, LV_LIST_PART_BG); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR); + _lv_obj_reset_style_list_no_refr(obj, LV_LIST_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_LIST_PART_SCROLLABLE); + _lv_obj_reset_style_list_no_refr(obj, LV_LIST_PART_SCROLLBAR); break; case LV_THEME_LIST_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_BTN_PART_MAIN); break; #endif #if LV_USE_DROPDOWN case LV_THEME_DROPDOWN: - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED); + _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_SCROLLBAR); + _lv_obj_reset_style_list_no_refr(obj, LV_DROPDOWN_PART_SELECTED); break; #endif #if LV_USE_CHART case LV_THEME_CHART: - lv_obj_clean_style_list(obj, LV_CHART_PART_BG); - lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG); - lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES); + _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_clean_style_list(obj, LV_TABLE_PART_BG); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4); + _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_WIN case LV_THEME_WIN: - lv_obj_clean_style_list(obj, LV_WIN_PART_BG); - lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR); - lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); - lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER); + _lv_obj_reset_style_list_no_refr(obj, LV_WIN_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_WIN_PART_SCROLLBAR); + _lv_obj_reset_style_list_no_refr(obj, LV_WIN_PART_CONTENT_SCROLLABLE); + _lv_obj_reset_style_list_no_refr(obj, LV_WIN_PART_HEADER); break; case LV_THEME_WIN_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_BTN_PART_MAIN); break; #endif #if LV_USE_TEXTAREA case LV_THEME_TEXTAREA: - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); + _lv_obj_reset_style_list_no_refr(obj, LV_TEXTAREA_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_TEXTAREA_PART_PLACEHOLDER); + _lv_obj_reset_style_list_no_refr(obj, LV_TEXTAREA_PART_CURSOR); + _lv_obj_reset_style_list_no_refr(obj, LV_TEXTAREA_PART_SCROLLBAR); break; #endif #if LV_USE_SPINBOX case LV_THEME_SPINBOX: - lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG); - lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR); + _lv_obj_reset_style_list_no_refr(obj, LV_SPINBOX_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_SPINBOX_PART_CURSOR); break; case LV_THEME_SPINBOX_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_BTN_PART_MAIN); break; #endif #if LV_USE_CALENDAR case LV_THEME_CALENDAR: - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); + _lv_obj_reset_style_list_no_refr(obj, LV_CALENDAR_PART_BG); + _lv_obj_reset_style_list_no_refr(obj, LV_CALENDAR_PART_DATE); + _lv_obj_reset_style_list_no_refr(obj, LV_CALENDAR_PART_HEADER); + _lv_obj_reset_style_list_no_refr(obj, LV_CALENDAR_PART_DAY_NAMES); break; #endif #if LV_USE_CPICKER case LV_THEME_CPICKER: - lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN); - lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB); + _lv_obj_reset_style_list_no_refr(obj, LV_CPICKER_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_CPICKER_PART_KNOB); break; #endif #if LV_USE_LINEMETER case LV_THEME_LINEMETER: - lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_LINEMETER_PART_MAIN); break; #endif #if LV_USE_GAUGE case LV_THEME_GAUGE: - lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN); - lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR); - lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE); + _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: diff --git a/src/lv_themes/lv_theme_empty.c b/src/lv_themes/lv_theme_empty.c index 6900ef23c..027528d7c 100644 --- a/src/lv_themes/lv_theme_empty.c +++ b/src/lv_themes/lv_theme_empty.c @@ -99,7 +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_clean_style_list(obj, LV_OBJ_PART_MAIN); + _lv_obj_reset_style_list_no_refr(obj, LV_OBJ_PART_MAIN); lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &styles->opa_cover); } } diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 5f7e5f43d..5116e85e8 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -961,7 +961,7 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s inited = true; - lv_obj_report_style_mod(NULL); + lv_obj_report_style_change(NULL); return &theme; } @@ -978,34 +978,34 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; case LV_THEME_SCR: - list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->scr); break; case LV_THEME_OBJ: - list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; #if LV_USE_CONT case LV_THEME_CONT: - list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; #endif #if LV_USE_BTN case LV_THEME_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->btn); break; #endif #if LV_USE_BTNMATRIX case LV_THEME_BTNMATRIX: - list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_small); - list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); + list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->bg_click); break; @@ -1013,11 +1013,11 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_KEYBOARD case LV_THEME_KEYBOARD: - list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG); + list = _lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG); _lv_style_list_add_style(list, &styles->scr); _lv_style_list_add_style(list, &styles->kb_bg); - list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); + list = _lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->bg_click); break; @@ -1025,23 +1025,23 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BAR case LV_THEME_BAR: - list = lv_obj_get_style_list(obj, LV_BAR_PART_BG); + list = _lv_obj_get_style_list(obj, LV_BAR_PART_BG); _lv_style_list_add_style(list, &styles->bar_bg); - list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_BAR_PART_INDIC); _lv_style_list_add_style(list, &styles->bar_indic); break; #endif #if LV_USE_SWITCH case LV_THEME_SWITCH: - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_BG); _lv_style_list_add_style(list, &styles->bar_bg); - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC); _lv_style_list_add_style(list, &styles->bar_indic); - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB); + list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB); _lv_style_list_add_style(list, &styles->sw_knob); break; #endif @@ -1073,14 +1073,14 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_ARC case LV_THEME_ARC: - list = lv_obj_get_style_list(obj, LV_ARC_PART_BG); + list = _lv_obj_get_style_list(obj, LV_ARC_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->arc_bg); - list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); _lv_style_list_add_style(list, &styles->arc_indic); - list = lv_obj_get_style_list(obj, LV_ARC_PART_KNOB); + list = _lv_obj_get_style_list(obj, LV_ARC_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->bg_click); _lv_style_list_add_style(list, &styles->arc_knob); @@ -1089,34 +1089,34 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINNER case LV_THEME_SPINNER: - list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SPINNER_PART_BG); _lv_style_list_add_style(list, &styles->arc_bg); - list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC); _lv_style_list_add_style(list, &styles->arc_indic); break; #endif #if LV_USE_SLIDER case LV_THEME_SLIDER: - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SLIDER_PART_BG); _lv_style_list_add_style(list, &styles->bar_bg); _lv_style_list_add_style(list, &styles->slider_bg); - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC); _lv_style_list_add_style(list, &styles->bar_indic); - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB); + list = _lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB); _lv_style_list_add_style(list, &styles->slider_knob); break; #endif #if LV_USE_CHECKBOX case LV_THEME_CHECKBOX: - list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG); _lv_style_list_add_style(list, &styles->cb_bg); - list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); + list = _lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->cb_bullet); break; @@ -1124,60 +1124,60 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_MSGBOX case LV_THEME_MSGBOX: - list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->mbox_bg); break; case LV_THEME_MSGBOX_BTNS: - list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG); + list = _lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG); _lv_style_list_add_style(list, &styles->pad_small); - list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); + list = _lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); _lv_style_list_add_style(list, &styles->btn); break; #endif #if LV_USE_LED case LV_THEME_LED: - list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_LED_PART_MAIN); _lv_style_list_add_style(list, &styles->led); break; #endif #if LV_USE_PAGE case LV_THEME_PAGE: - list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->pad_inner); - list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); #if LV_USE_ANIMATION - list = lv_obj_get_style_list(obj, LV_PAGE_PART_EDGE_FLASH); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_EDGE_FLASH); _lv_style_list_add_style(list, &styles->edge_flash); #endif break; #endif #if LV_USE_TABVIEW case LV_THEME_TABVIEW: - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG); _lv_style_list_add_style(list, &styles->scr); - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG); _lv_style_list_add_style(list, &styles->tabview_btns_bg); - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC); _lv_style_list_add_style(list, &styles->tabview_indic); - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); _lv_style_list_add_style(list, &styles->tabview_btns); break; case LV_THEME_TABVIEW_PAGE: - list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->tabview_page_scrl); break; @@ -1185,14 +1185,14 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TILEVIEW case LV_THEME_TILEVIEW: - list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG); _lv_style_list_add_style(list, &styles->scr); - list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); #if LV_USE_ANIMATION - list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); + list = _lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); _lv_style_list_add_style(list, &styles->edge_flash); #endif break; @@ -1201,125 +1201,125 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_ROLLER case LV_THEME_ROLLER: - list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); + list = _lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->roller_bg); - list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED); + list = _lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED); _lv_style_list_add_style(list, &styles->roller_sel); break; #endif #if LV_USE_OBJMASK case LV_THEME_OBJMASK: - list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN); break; #endif #if LV_USE_LIST case LV_THEME_LIST: - list = lv_obj_get_style_list(obj, LV_LIST_PART_BG); + list = _lv_obj_get_style_list(obj, LV_LIST_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->list_bg); - list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); break; case LV_THEME_LIST_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->list_btn); break; #endif #if LV_USE_DROPDOWN case LV_THEME_DROPDOWN: - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->bg_click); _lv_style_list_add_style(list, &styles->pad_small); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->ddlist_page); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED); _lv_style_list_add_style(list, &styles->ddlist_sel); break; #endif #if LV_USE_CHART case LV_THEME_CHART: - list = lv_obj_get_style_list(obj, LV_CHART_PART_BG); + list = _lv_obj_get_style_list(obj, LV_CHART_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->chart_bg); _lv_style_list_add_style(list, &styles->pad_small); - list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG); + list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG); _lv_style_list_add_style(list, &styles->pad_small); _lv_style_list_add_style(list, &styles->chart_series_bg); - list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES); + list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES); _lv_style_list_add_style(list, &styles->chart_series); break; #endif #if LV_USE_TABLE case LV_THEME_TABLE: - list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1); _lv_style_list_add_style(list, &styles->table_cell); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2); _lv_style_list_add_style(list, &styles->table_cell); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3); _lv_style_list_add_style(list, &styles->table_cell); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); _lv_style_list_add_style(list, &styles->table_cell); break; #endif #if LV_USE_WIN case LV_THEME_WIN: - list = lv_obj_get_style_list(obj, LV_WIN_PART_BG); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_BG); _lv_style_list_add_style(list, &styles->scr); - list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); - list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); _lv_style_list_add_style(list, &styles->tabview_page_scrl); - list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_HEADER); _lv_style_list_add_style(list, &styles->tabview_btns_bg); break; case LV_THEME_WIN_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->tabview_btns); break; #endif #if LV_USE_TEXTAREA case LV_THEME_TEXTAREA: - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_small); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); _lv_style_list_add_style(list, &styles->ta_placeholder); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); _lv_style_list_add_style(list, &styles->ta_cursor); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); break; @@ -1328,16 +1328,16 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINBOX case LV_THEME_SPINBOX: - list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_small); - list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); + list = _lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); _lv_style_list_add_style(list, &styles->spinbox_cursor); break; case LV_THEME_SPINBOX_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->bg_click); break; @@ -1345,46 +1345,46 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CALENDAR case LV_THEME_CALENDAR: - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE); _lv_style_list_add_style(list, &styles->calendar_date_nums); - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER); _lv_style_list_add_style(list, &styles->calendar_header); - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); _lv_style_list_add_style(list, &styles->calendar_daynames); break; #endif #if LV_USE_CPICKER case LV_THEME_CPICKER: - list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN); _lv_style_list_add_style(list, &styles->cpicker_bg); - list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB); + list = _lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB); _lv_style_list_add_style(list, &styles->cpicker_indic); break; #endif #if LV_USE_LINEMETER case LV_THEME_LINEMETER: - list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->lmeter); break; #endif #if LV_USE_GAUGE case LV_THEME_GAUGE: - list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->gauge_main); - list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR); + list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR); _lv_style_list_add_style(list, &styles->gauge_strong); - list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE); + list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE); _lv_style_list_add_style(list, &styles->gauge_needle); break; #endif @@ -1392,7 +1392,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; } - lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); + _lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } /********************** diff --git a/src/lv_themes/lv_theme_mono.c b/src/lv_themes/lv_theme_mono.c index e9f0f9015..8a251cc12 100644 --- a/src/lv_themes/lv_theme_mono.c +++ b/src/lv_themes/lv_theme_mono.c @@ -577,23 +577,23 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; case LV_THEME_SCR: - list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->scr); break; case LV_THEME_OBJ: - list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; #if LV_USE_CONT case LV_THEME_CONT: - list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; #endif #if LV_USE_BTN case LV_THEME_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->txt_underline); @@ -602,10 +602,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BTNMATRIX case LV_THEME_BTNMATRIX: - list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); + list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->txt_underline); @@ -614,11 +614,11 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_KEYBOARD case LV_THEME_KEYBOARD: - list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG); + list = _lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_small); - list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); + list = _lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; @@ -626,12 +626,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BAR case LV_THEME_BAR: - list = lv_obj_get_style_list(obj, LV_BAR_PART_BG); + list = _lv_obj_get_style_list(obj, LV_BAR_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_none); _lv_style_list_add_style(list, &styles->round); - list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_BAR_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); _lv_style_list_add_style(list, &styles->round); @@ -640,16 +640,16 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SWITCH case LV_THEME_SWITCH: - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_none); _lv_style_list_add_style(list, &styles->round); - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB); + list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_none); _lv_style_list_add_style(list, &styles->round); @@ -658,51 +658,51 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CANVAS case LV_THEME_CANVAS: - list = lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN); break; #endif #if LV_USE_IMG case LV_THEME_IMAGE: - list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_IMGBTN case LV_THEME_IMGBTN: - list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_LABEL case LV_THEME_LABEL: - list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_LINE case LV_THEME_LINE: - list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_ARC case LV_THEME_ARC: - list = lv_obj_get_style_list(obj, LV_ARC_PART_BG); + list = _lv_obj_get_style_list(obj, LV_ARC_PART_BG); _lv_style_list_add_style(list, &styles->arc_bg); - list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); _lv_style_list_add_style(list, &styles->arc_indic); break; #endif #if LV_USE_SPINNER case LV_THEME_SPINNER: - list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SPINNER_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tick_line); - list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); _lv_style_list_add_style(list, &styles->tick_line); @@ -711,15 +711,15 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SLIDER case LV_THEME_SLIDER: - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SLIDER_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_none); - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB); + list = _lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); _lv_style_list_add_style(list, &styles->pad_small); @@ -729,10 +729,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CHECKBOX case LV_THEME_CHECKBOX: - list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG); _lv_style_list_add_style(list, &styles->pad_small); - list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); + list = _lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->pad_small); @@ -741,15 +741,15 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_MSGBOX case LV_THEME_MSGBOX: - list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_MSGBOX_BTNS: - list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG); + list = _lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG); _lv_style_list_add_style(list, &styles->pad_inner); - list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); + list = _lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->txt_underline); @@ -758,40 +758,40 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_LED case LV_THEME_LED: - list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_LED_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); break; #endif #if LV_USE_PAGE case LV_THEME_PAGE: - list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->pad_inner); - list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); break; #endif #if LV_USE_TABVIEW case LV_THEME_TABVIEW: - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG); _lv_style_list_add_style(list, &styles->scr); - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG); _lv_style_list_add_style(list, &styles->tab_bg); _lv_style_list_add_style(list, &styles->pad_small); - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->txt_underline); break; case LV_THEME_TABVIEW_PAGE: - list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->pad_normal); break; @@ -799,13 +799,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TILEVIEW case LV_THEME_TILEVIEW: - list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); - list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); + list = _lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); _lv_style_list_add_style(list, &styles->bg); break; #endif @@ -813,11 +813,11 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_ROLLER case LV_THEME_ROLLER: - list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); + list = _lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->big_line_space); - list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED); + list = _lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); _lv_style_list_add_style(list, &styles->no_radius); @@ -827,23 +827,23 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_OBJMASK case LV_THEME_OBJMASK: - list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN); break; #endif #if LV_USE_LIST case LV_THEME_LIST: - list = lv_obj_get_style_list(obj, LV_LIST_PART_BG); + list = _lv_obj_get_style_list(obj, LV_LIST_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_none); _lv_style_list_add_style(list, &styles->clip_corner); - list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); break; case LV_THEME_LIST_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->list_btn); @@ -854,18 +854,18 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_DROPDOWN case LV_THEME_DROPDOWN: - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->big_line_space); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); _lv_style_list_add_style(list, &styles->no_radius); @@ -874,35 +874,35 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CHART case LV_THEME_CHART: - list = lv_obj_get_style_list(obj, LV_CHART_PART_BG); + list = _lv_obj_get_style_list(obj, LV_CHART_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG); + list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->border_none); - list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES); + list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES); _lv_style_list_add_style(list, &styles->chart_series); break; #endif #if LV_USE_TABLE case LV_THEME_TABLE: - list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->no_radius); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->no_radius); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->no_radius); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->no_radius); break; @@ -910,21 +910,21 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_WIN case LV_THEME_WIN: - list = lv_obj_get_style_list(obj, LV_WIN_PART_BG); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); - list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_HEADER); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_WIN_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; @@ -932,13 +932,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TEXTAREA case LV_THEME_TEXTAREA: - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); _lv_style_list_add_style(list, &styles->ta_cursor); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); break; #endif @@ -946,10 +946,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINBOX case LV_THEME_SPINBOX: - list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); + list = _lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); _lv_style_list_add_style(list, &styles->pad_none); @@ -958,7 +958,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; case LV_THEME_SPINBOX_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->txt_underline); @@ -967,31 +967,31 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CALENDAR case LV_THEME_CALENDAR: - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->pad_small); _lv_style_list_add_style(list, &styles->border_none); _lv_style_list_add_style(list, &styles->calendar_date); - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER); _lv_style_list_add_style(list, &styles->pad_normal); _lv_style_list_add_style(list, &styles->border_none); - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_small); break; #endif #if LV_USE_CPICKER case LV_THEME_CPICKER: - list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB); + list = _lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); break; @@ -999,7 +999,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_LINEMETER case LV_THEME_LINEMETER: - list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); _lv_style_list_add_style(list, &styles->linemeter); @@ -1007,14 +1007,14 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_GAUGE case LV_THEME_GAUGE: - list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); - list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR); + list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR); _lv_style_list_add_style(list, &styles->gauge_major); - list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE); + list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE); _lv_style_list_add_style(list, &styles->gauge_needle); break; #endif @@ -1023,7 +1023,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) } - lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); + _lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } diff --git a/src/lv_themes/lv_theme_template.c b/src/lv_themes/lv_theme_template.c index 722e72e07..6777d2846 100644 --- a/src/lv_themes/lv_theme_template.c +++ b/src/lv_themes/lv_theme_template.c @@ -420,24 +420,24 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; case LV_THEME_SCR: - list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); break; case LV_THEME_OBJ: - list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; #if LV_USE_CONT case LV_THEME_CONT: - list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; #endif #if LV_USE_BTN case LV_THEME_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; @@ -445,10 +445,10 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BTNMATRIX case LV_THEME_BTNMATRIX: - list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); + list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; @@ -456,10 +456,10 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_KEYBOARD case LV_THEME_KEYBOARD: - list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG); + list = _lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); + list = _lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; @@ -467,11 +467,11 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BAR case LV_THEME_BAR: - list = lv_obj_get_style_list(obj, LV_BAR_PART_BG); + list = _lv_obj_get_style_list(obj, LV_BAR_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); - list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_BAR_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); break; @@ -479,16 +479,16 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SWITCH case LV_THEME_SWITCH: - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); _lv_style_list_add_style(list, &styles->round); - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB); + list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); _lv_style_list_add_style(list, &styles->round); @@ -497,42 +497,42 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CANVAS case LV_THEME_CANVAS: - list = lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN); break; #endif #if LV_USE_IMG case LV_THEME_IMAGE: - list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_IMGBTN case LV_THEME_IMGBTN: - list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_LABEL case LV_THEME_LABEL: - list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_LINE case LV_THEME_LINE: - list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_ARC case LV_THEME_ARC: - list = lv_obj_get_style_list(obj, LV_ARC_PART_BG); + list = _lv_obj_get_style_list(obj, LV_ARC_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tick_line); _lv_style_list_add_style(list, &styles->round); - list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); _lv_style_list_add_style(list, &styles->tick_line); @@ -541,11 +541,11 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINNER case LV_THEME_SPINNER: - list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SPINNER_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tick_line); - list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); _lv_style_list_add_style(list, &styles->tick_line); @@ -554,14 +554,14 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SLIDER case LV_THEME_SLIDER: - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SLIDER_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB); + list = _lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); break; @@ -569,9 +569,9 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CHECKBOX case LV_THEME_CHECKBOX: - list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG); - list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); + list = _lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; @@ -579,15 +579,15 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_MSGBOX case LV_THEME_MSGBOX: - list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_MSGBOX_BTNS: - list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG); + list = _lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); + list = _lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; @@ -595,7 +595,7 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_LED case LV_THEME_LED: - list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_LED_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); _lv_style_list_add_style(list, &styles->round); @@ -603,44 +603,44 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_PAGE case LV_THEME_PAGE: - list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->gray); - list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); break; #endif #if LV_USE_TABVIEW case LV_THEME_TABVIEW: - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); + list = _lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; case LV_THEME_TABVIEW_PAGE: - list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->gray); - list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); + list = _lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->bg); break; @@ -648,13 +648,13 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TILEVIEW case LV_THEME_TILEVIEW: - list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); + list = _lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); _lv_style_list_add_style(list, &styles->bg); break; #endif @@ -662,10 +662,10 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_ROLLER case LV_THEME_ROLLER: - list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); + list = _lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED); + list = _lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); break; @@ -674,23 +674,23 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_OBJMASK case LV_THEME_OBJMASK: - list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN); break; #endif #if LV_USE_LIST case LV_THEME_LIST: - list = lv_obj_get_style_list(obj, LV_LIST_PART_BG); + list = _lv_obj_get_style_list(obj, LV_LIST_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLABLE); + list = _lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLABLE); - list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_LIST_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; @@ -698,17 +698,17 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_DROPDOWN case LV_THEME_DROPDOWN: - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED); + list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); break; @@ -716,53 +716,53 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CHART case LV_THEME_CHART: - list = lv_obj_get_style_list(obj, LV_CHART_PART_BG); + list = _lv_obj_get_style_list(obj, LV_CHART_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG); + list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES); + list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); break; #endif #if LV_USE_TABLE case LV_THEME_TABLE: - list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); + list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); _lv_style_list_add_style(list, &styles->bg); break; #endif #if LV_USE_WIN case LV_THEME_WIN: - list = lv_obj_get_style_list(obj, LV_WIN_PART_BG); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER); + list = _lv_obj_get_style_list(obj, LV_WIN_PART_HEADER); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_WIN_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; @@ -770,17 +770,17 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TEXTAREA case LV_THEME_TEXTAREA: - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); _lv_style_list_add_style(list, &styles->gray); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); - list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); + list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); break; #endif @@ -788,15 +788,15 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINBOX case LV_THEME_SPINBOX: - list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); + list = _lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); + list = _lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_SPINBOX_BTN: - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; @@ -804,28 +804,28 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CALENDAR case LV_THEME_CALENDAR: - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->tight); - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); + list = _lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); break; #endif #if LV_USE_CPICKER case LV_THEME_CPICKER: - list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); - list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB); + list = _lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); break; @@ -833,21 +833,21 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_LINEMETER case LV_THEME_LINEMETER: - list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); break; #endif #if LV_USE_GAUGE case LV_THEME_GAUGE: - list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); + list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); - list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR); + list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR); _lv_style_list_add_style(list, &styles->tick_line); - list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE); + list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE); _lv_style_list_add_style(list, &styles->bg); break; #endif @@ -855,7 +855,7 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; } - lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); + _lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } /********************** diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index f06595269..cfb74e16e 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -161,7 +161,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) ext->dot_end = copy_ext->dot_end; /*Refresh the style with new signal function*/ - lv_obj_refresh_style(new_label, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); + _lv_obj_refresh_style(new_label, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); } LV_LOG_INFO("label created");