diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 50c56128a..7947da4f4 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -282,14 +282,13 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) new_obj->ext_attr = NULL; - lv_style_list_init(&new_obj->style_dsc); - - if(parent != NULL) { - lv_obj_add_style_class(new_obj, LV_OBJ_PART_MAIN, _t(PANEL)); + if(copy == NULL) { + lv_style_list_init(&new_obj->style_list); + if(parent != NULL) lv_obj_add_theme(new_obj, LV_OBJ_PART_MAIN, LV_THEME_PANEL); + else lv_obj_add_theme(new_obj, LV_OBJ_PART_MAIN, LV_THEME_SCR); } else { - lv_obj_add_style_class(new_obj, LV_OBJ_PART_MAIN, _t(SCR)); + lv_style_list_copy(&new_obj->style_list, ©->style_list); } - /*Copy the attributes if required*/ if(copy != NULL) { lv_area_copy(&new_obj->coords, ©->coords); @@ -1209,13 +1208,13 @@ void lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop lv_obj_refresh_style(obj); } -void lv_obj_add_style_class(lv_obj_t * obj, uint8_t part, lv_style_t * style) +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(obj, part); if(style_dsc == NULL) { - LV_LOG_WARN("lv_obj_add_style_class: can't find style with `type`"); + LV_LOG_WARN("lv_obj_add_style: can't find style with `type`"); return; } @@ -1224,6 +1223,12 @@ void lv_obj_add_style_class(lv_obj_t * obj, uint8_t part, lv_style_t * style) lv_obj_refresh_style(obj); } + +void lv_obj_add_theme(void * obj, uint8_t part, lv_theme_style_t name) +{ + lv_obj_add_style(obj, part, lv_theme_get_style(name)); +} + void lv_obj_reset_style(lv_obj_t * obj, uint8_t part) { lv_style_list_t * style_dsc = lv_obj_get_style(obj, part); @@ -2060,7 +2065,7 @@ lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj) lv_style_list_t * lv_obj_get_style(const lv_obj_t * obj, uint8_t part) { - if(part == LV_OBJ_PART_MAIN) return &obj->style_dsc; + if(part == LV_OBJ_PART_MAIN) return &((lv_obj_t*)obj)->style_list; lv_get_style_info_t info; info.part = part; @@ -2075,16 +2080,16 @@ lv_style_list_t * lv_obj_get_style(const lv_obj_t * obj, uint8_t part) } -lv_style_int_t lv_obj_get_style_int(lv_obj_t * obj, uint8_t part, lv_style_property_t prop) +lv_style_int_t lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop) { if(obj->state == obj->prev_state) { return lv_obj_get_style_int_core(obj, part, prop); } else { lv_style_int_t act_int = lv_obj_get_style_int_core(obj, part, prop); lv_obj_state_t state_ori = obj->state; - obj->state = obj->prev_state; + ((lv_obj_t*)obj)->state = obj->prev_state; lv_style_int_t prev_int = lv_obj_get_style_int_core(obj, part, prop); - obj->state = state_ori; + ((lv_obj_t*)obj)->state = state_ori; if(prop == LV_STYLE_RADIUS) { if(act_int == LV_RADIUS_CIRCLE || prev_int == LV_RADIUS_CIRCLE) { @@ -2108,31 +2113,31 @@ lv_style_int_t lv_obj_get_style_int(lv_obj_t * obj, uint8_t part, lv_style_prope -lv_color_t lv_obj_get_style_color(lv_obj_t * obj, uint8_t part, lv_style_property_t prop) +lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop) { if(obj->state == obj->prev_state) { return lv_obj_get_style_color_core(obj, part, prop); } else { lv_color_t act_color = lv_obj_get_style_color_core(obj, part, prop); lv_obj_state_t state_ori = obj->state; - obj->state = obj->prev_state; + ((lv_obj_t*)obj)->state = obj->prev_state; lv_color_t prev_color = lv_obj_get_style_color_core(obj, part, prop); - obj->state = state_ori; + ((lv_obj_t*)obj)->state = state_ori; return lv_color_mix(act_color, prev_color, obj->state_anim); } } -lv_opa_t lv_obj_get_style_opa(lv_obj_t * obj, uint8_t part, lv_style_property_t prop) +lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop) { if(obj->state == obj->prev_state) { return lv_obj_get_style_opa_core(obj, part, prop); } else { lv_opa_t act_opa = lv_obj_get_style_opa_core(obj, part, prop); lv_obj_state_t state_ori = obj->state; - obj->state = obj->prev_state; + ((lv_obj_t*)obj)->state = obj->prev_state; lv_opa_t prev_opa = lv_obj_get_style_opa_core(obj, part, prop); - obj->state = state_ori; + ((lv_obj_t*)obj)->state = state_ori; if(obj->state_anim >= 255) return act_opa; return prev_opa + (((act_opa - prev_opa) * obj->state_anim) >> 8); @@ -2140,7 +2145,7 @@ lv_opa_t lv_obj_get_style_opa(lv_obj_t * obj, uint8_t part, lv_style_property_t } -const void * lv_obj_get_style_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop) +const void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop) { if(obj->state == obj->prev_state) { return lv_obj_get_style_ptr_core(obj, part, prop); @@ -2148,9 +2153,9 @@ const void * lv_obj_get_style_ptr(lv_obj_t * obj, uint8_t part, lv_style_propert if(obj->state_anim > 128) return lv_obj_get_style_ptr_core(obj, part, prop); lv_obj_state_t state_ori = obj->state; - obj->state = obj->prev_state; - void * prev_ptr = lv_obj_get_style_ptr_core(obj, part, prop); - obj->state = state_ori; + ((lv_obj_t*)obj)->state = obj->prev_state; + const void * prev_ptr = lv_obj_get_style_ptr_core(obj, part, prop); + ((lv_obj_t*)obj)->state = state_ori; return prev_ptr; } @@ -2785,7 +2790,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) { if(sign == LV_SIGNAL_GET_STYLE) { lv_get_style_info_t * info = param; - if(info->part == LV_OBJ_PART_MAIN) info->result = &obj->style_dsc; + if(info->part == LV_OBJ_PART_MAIN) info->result = &obj->style_list; else info->result = NULL; return LV_RES_OK; } @@ -2851,7 +2856,7 @@ static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coor /** * Refresh the style of all children of an object. (Called recursively) - * @param style refresh objects only with this style_dsc. + * @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) diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 4a5365eac..a8e1cced7 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -26,6 +26,7 @@ extern "C" { #include "../lv_misc/lv_bidi.h" #include "../lv_hal/lv_hal.h" #include "../lv_draw/lv_draw_rect.h" +#include "../lv_themes/lv_theme.h" /********************* * DEFINES @@ -223,7 +224,7 @@ typedef struct _lv_obj_t lv_design_cb_t design_cb; /**< Object type specific design function*/ void * ext_attr; /**< Object type specific extended data*/ - lv_style_list_t style_dsc; + lv_style_list_t style_list; #if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY @@ -499,8 +500,9 @@ void lv_obj_set_style_opa(lv_obj_t * obj, uint8_t type, lv_style_property_t prop void lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, void * p); -void lv_obj_add_style_class(lv_obj_t * obj, uint8_t type, lv_style_t * style); +void lv_obj_add_style(lv_obj_t * obj, uint8_t type, lv_style_t * style); +void lv_obj_add_theme(void * obj, uint8_t part, lv_theme_style_t name); void lv_obj_reset_style(lv_obj_t * obj, uint8_t type); @@ -867,13 +869,13 @@ lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj); lv_style_list_t * lv_obj_get_style(const lv_obj_t * obj, uint8_t type); -lv_style_int_t lv_obj_get_style_int(lv_obj_t * obj, uint8_t type, lv_style_property_t prop); +lv_style_int_t lv_obj_get_style_int(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop); -lv_color_t lv_obj_get_style_color(lv_obj_t * obj, uint8_t type, lv_style_property_t prop); +lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop); -lv_opa_t lv_obj_get_style_opa(lv_obj_t * obj, uint8_t type, lv_style_property_t prop); +lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop); -const void * lv_obj_get_style_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop); +const void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop); ///** // * Get the style pointer of an object (if NULL get style of the parent) // * @param obj pointer to an object diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index 286e4c9d7..da952a248 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -73,6 +73,9 @@ void lv_style_init(lv_style_t * style) void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src) { lv_style_init(style_dest); + + if(style_src->map == NULL) return; + style_dest->map = lv_mem_alloc(style_src->size); memcpy(style_dest->map, style_src->map, style_src->size); style_dest->size = style_src->size; @@ -85,6 +88,27 @@ void lv_style_list_init(lv_style_list_t * list) list->has_local = 0; } +void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * list_src) +{ + lv_style_list_init(list_dest); + + if(list_src->style_list == NULL) return; + + if(list_src->has_local == 0) { + list_dest->style_list = lv_mem_alloc(list_src->style_cnt * sizeof(lv_style_t *)); + memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *)); + + list_dest->style_cnt = list_src->style_cnt; + } else { + list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *)); + memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *)); + list_dest->style_cnt = list_src->style_cnt - 1; + + lv_style_t * local_style = get_local_style(list_dest); + lv_style_copy(local_style, get_local_style(list_src)); + } +} + void lv_style_list_add_style(lv_style_list_t * list, lv_style_t * style) { diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index edaadeea6..f5b5306c7 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -203,6 +203,8 @@ void lv_style_init(lv_style_t * style); void lv_style_list_init(lv_style_list_t * style_dsc); +void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * list_src); + void lv_style_list_add_style(lv_style_list_t * style_dsc, lv_style_t * style); void lv_style_list_remove_style(lv_style_list_t * style_dsc, lv_style_t * class); diff --git a/src/lv_objx/lv_arc.c b/src/lv_objx/lv_arc.c index 9d0967343..b6d757b8c 100644 --- a/src/lv_objx/lv_arc.c +++ b/src/lv_objx/lv_arc.c @@ -84,7 +84,7 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new arc arc*/ if(copy == NULL) { lv_style_list_init(&ext->style_arc); - lv_style_list_reset(&new_arc->style_dsc); + lv_style_list_reset(&new_arc->style_list); _ot(new_arc, LV_ARC_PART_BG, ARC_BG); _ot(new_arc, LV_ARC_PART_ARC, ARC); @@ -286,7 +286,7 @@ static lv_style_list_t * lv_arc_get_style(lv_obj_t * arc, uint8_t part) switch(part) { case LV_ARC_PART_BG: - style_dsc_p = &arc->style_dsc; + style_dsc_p = &arc->style_list; break; case LV_ARC_PART_ARC: style_dsc_p = &ext->style_arc; diff --git a/src/lv_objx/lv_bar.c b/src/lv_objx/lv_bar.c index ffad888f9..1ca057d8c 100644 --- a/src/lv_objx/lv_bar.c +++ b/src/lv_objx/lv_bar.c @@ -620,7 +620,7 @@ static lv_style_list_t * lv_bar_get_style(lv_obj_t * bar, uint8_t part) switch(part) { case LV_BAR_PART_BG: - style_dsc_p = &bar->style_dsc; + style_dsc_p = &bar->style_list; break; case LV_BAR_PART_INDIC: style_dsc_p = &ext->style_indic; diff --git a/src/lv_objx/lv_btn.c b/src/lv_objx/lv_btn.c index 58ae174db..07faed58d 100644 --- a/src/lv_objx/lv_btn.c +++ b/src/lv_objx/lv_btn.c @@ -93,7 +93,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_obj_reset_style(new_btn, LV_BTN_PART_MAIN); - lv_obj_add_style_class(new_btn, LV_BTN_PART_MAIN, _t(BTN)); + lv_obj_add_style(new_btn, LV_BTN_PART_MAIN, _t(BTN)); } /*Copy 'copy'*/ else { @@ -215,7 +215,7 @@ lv_style_list_t * lv_btn_get_style(lv_obj_t * cont, uint8_t type) lv_style_list_t * style_dsc_p; switch(type) { case LV_BTN_PART_MAIN: - style_dsc_p = &cont->style_dsc; + style_dsc_p = &cont->style_list; break; default: style_dsc_p = NULL; diff --git a/src/lv_objx/lv_btnm.c b/src/lv_objx/lv_btnm.c index 577f63c17..a036b8e69 100644 --- a/src/lv_objx/lv_btnm.c +++ b/src/lv_objx/lv_btnm.c @@ -140,7 +140,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy) * @param btnm pointer to a button matrix object * @param map pointer a string array. The last string has to be: "". Use "\n" to make a line break. */ -void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[]) +void lv_btnm_set_map(lv_obj_t * btnm, const char * map[]) { LV_ASSERT_OBJ(btnm, LV_OBJX_NAME); LV_ASSERT_NULL(map); @@ -988,7 +988,7 @@ static lv_style_list_t * lv_btnm_get_style(lv_obj_t * btnm, uint8_t part) switch(part) { case LV_BTNM_PART_BG: - style_dsc_p = &btnm->style_dsc; + style_dsc_p = &btnm->style_list; break; case LV_BTNM_PART_BTN: style_dsc_p = &ext->style_btn; diff --git a/src/lv_objx/lv_btnm.h b/src/lv_objx/lv_btnm.h index 8d4af011b..cb4cf3a52 100644 --- a/src/lv_objx/lv_btnm.h +++ b/src/lv_objx/lv_btnm.h @@ -92,7 +92,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy); * @param btnm pointer to a button matrix object * @param map pointer a string array. The last string has to be: "". Use "\n" to make a line break. */ -void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[]); +void lv_btnm_set_map(lv_obj_t * btnm, const char * map[]); /** * Set the button control map (hidden, disabled etc.) for a button matrix. The diff --git a/src/lv_objx/lv_calendar.c b/src/lv_objx/lv_calendar.c index 56ac31586..b65c3e425 100644 --- a/src/lv_objx/lv_calendar.c +++ b/src/lv_objx/lv_calendar.c @@ -128,8 +128,8 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy) if(copy == NULL) { /*Different styles will be used from the styles while rendering so disable caching*/ - lv_style_list_reset(&new_calendar->style_dsc); - lv_style_list_add_style(&new_calendar->style_dsc, lv_theme_get_style(LV_THEME_CALENDAR_BG)); + lv_style_list_reset(&new_calendar->style_list); + lv_style_list_add_style(&new_calendar->style_list, lv_theme_get_style(LV_THEME_CALENDAR_BG)); lv_style_list_add_style(&ext->style_date_nums, lv_theme_get_style(LV_THEME_CALENDAR_DATE_NUMS)); lv_style_list_add_style(&ext->style_day_names, lv_theme_get_style(LV_THEME_CALENDAR_DAY_NAMES)); lv_style_list_add_style(&ext->style_header, lv_theme_get_style(LV_THEME_CALENDAR_HEADER)); @@ -547,7 +547,7 @@ static lv_style_list_t * lv_calendar_get_style(lv_obj_t * calendar, uint8_t part switch(part) { case LV_CALENDAR_PART_BG: - style_dsc_p = &calendar->style_dsc; + style_dsc_p = &calendar->style_list; break; case LV_CALENDAR_PART_HEADER: style_dsc_p = &ext->style_header; diff --git a/src/lv_objx/lv_cb.c b/src/lv_objx/lv_cb.c index c22ba7100..695718b80 100644 --- a/src/lv_objx/lv_cb.c +++ b/src/lv_objx/lv_cb.c @@ -209,7 +209,7 @@ static lv_style_list_t * lv_cb_get_style(lv_obj_t * cb, uint8_t type) lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb); switch(type) { case LV_CB_PART_BG: - style_dsc_p = &cb->style_dsc; + style_dsc_p = &cb->style_list; break; case LV_CB_PART_BULLET: style_dsc_p = lv_obj_get_style(ext->bullet, LV_BTN_PART_MAIN); diff --git a/src/lv_objx/lv_chart.c b/src/lv_objx/lv_chart.c index 250ba3103..31ba50f83 100644 --- a/src/lv_objx/lv_chart.c +++ b/src/lv_objx/lv_chart.c @@ -133,10 +133,10 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) if(copy == NULL) { lv_obj_set_size(new_chart, LV_DPI * 3, LV_DPI * 2); - lv_style_list_reset(&new_chart->style_dsc); - lv_obj_add_style_theme(new_chart, LV_CHART_PART_BG, LV_THEME_CHART_BG); - lv_obj_add_style_theme(new_chart, LV_CHART_PART_SERIES_BG, LV_THEME_CHART_SERIES_BG); - lv_obj_add_style_theme(new_chart, LV_CHART_PART_SERIES, LV_THEME_CHART_SERIES); + lv_style_list_reset(&new_chart->style_list); + lv_obj_add_theme(new_chart, LV_CHART_PART_BG, LV_THEME_CHART_BG); + lv_obj_add_theme(new_chart, LV_CHART_PART_SERIES_BG, LV_THEME_CHART_SERIES_BG); + lv_obj_add_theme(new_chart, LV_CHART_PART_SERIES, LV_THEME_CHART_SERIES); } else { lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy); @@ -674,7 +674,7 @@ static lv_style_list_t * lv_chart_get_style(lv_obj_t * chart, uint8_t part) switch(part) { case LV_CHART_PART_BG: - style_dsc_p = &chart->style_dsc; + style_dsc_p = &chart->style_list; break; case LV_CHART_PART_SERIES_BG: style_dsc_p = &ext->style_series_bg; diff --git a/src/lv_objx/lv_cont.c b/src/lv_objx/lv_cont.c index a8688645d..40f542b16 100644 --- a/src/lv_objx/lv_cont.c +++ b/src/lv_objx/lv_cont.c @@ -99,7 +99,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles if it's not screen*/ if(par != NULL) { lv_obj_reset_style(new_cont, LV_CONT_PART_MAIN); - lv_obj_add_style_class(new_cont, LV_CONT_PART_MAIN, _t(PANEL)); + lv_obj_add_style(new_cont, LV_CONT_PART_MAIN, _t(PANEL)); } } /*Copy an existing object*/ @@ -293,7 +293,7 @@ static lv_style_list_t * lv_cont_get_style(lv_obj_t * cont, uint8_t type) lv_style_list_t * style_dsc_p; switch(type) { case LV_CONT_PART_MAIN: - style_dsc_p = &cont->style_dsc; + style_dsc_p = &cont->style_list; break; default: style_dsc_p = NULL; diff --git a/src/lv_objx/lv_ddlist.c b/src/lv_objx/lv_ddlist.c index 5fb6e5b11..3686aee16 100644 --- a/src/lv_objx/lv_ddlist.c +++ b/src/lv_objx/lv_ddlist.c @@ -748,7 +748,7 @@ static lv_style_list_t * lv_ddlist_get_style(lv_obj_t * ddlist, uint8_t part) switch(part) { case LV_DDLIST_PART_BG: - style_dsc_p = &ddlist->style_dsc; + style_dsc_p = &ddlist->style_list; break; case LV_DDLIST_PART_SCRL: style_dsc_p = lv_obj_get_style(ext->page.scrl, LV_CONT_PART_MAIN); diff --git a/src/lv_objx/lv_gauge.c b/src/lv_objx/lv_gauge.c index 21fe535b3..01c0932a8 100644 --- a/src/lv_objx/lv_gauge.c +++ b/src/lv_objx/lv_gauge.c @@ -102,7 +102,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy) lv_gauge_set_critical_value(new_gauge, 80); lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI); - lv_style_list_reset(&new_gauge->style_dsc); + lv_style_list_reset(&new_gauge->style_list); lv_style_list_init(&ext->style_strong); _ot(new_gauge, LV_GAUGE_PART_MAIN, GAUGE); _ot(new_gauge, LV_GAUGE_PART_STRONG, GAUGE_STRONG); @@ -419,7 +419,7 @@ static lv_style_list_t * lv_gauge_get_style(lv_obj_t * gauge, uint8_t part) switch(part) { case LV_GAUGE_PART_MAIN: - style_dsc_p = &gauge->style_dsc; + style_dsc_p = &gauge->style_list; break; case LV_GAUGE_PART_STRONG: style_dsc_p = &ext->style_strong; diff --git a/src/lv_objx/lv_img.c b/src/lv_objx/lv_img.c index 78853b9f0..4a76b1d42 100644 --- a/src/lv_objx/lv_img.c +++ b/src/lv_objx/lv_img.c @@ -634,7 +634,7 @@ static lv_style_list_t * lv_img_get_style(lv_obj_t * img, uint8_t type) lv_style_list_t * style_dsc_p; switch(type) { case LV_IMG_PART_MAIN: - style_dsc_p = &img->style_dsc; + style_dsc_p = &img->style_list; break; default: style_dsc_p = NULL; diff --git a/src/lv_objx/lv_kb.c b/src/lv_objx/lv_kb.c index 603bcc7d2..dbf5d94d9 100644 --- a/src/lv_objx/lv_kb.c +++ b/src/lv_objx/lv_kb.c @@ -463,7 +463,7 @@ static lv_style_list_t * lv_kb_get_style(lv_obj_t * kb, uint8_t part) switch(part) { case LV_KB_PART_BG: - style_dsc_p = &kb->style_dsc; + style_dsc_p = &kb->style_list; break; case LV_KB_PART_BTN: style_dsc_p = &ext->btnm.style_btn; diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index f334b3afe..8b9592bc5 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -911,7 +911,7 @@ lv_style_list_t * lv_label_get_style(lv_obj_t * label, uint8_t type) lv_style_list_t * style_dsc_p; switch(type) { case LV_LABEL_PART_MAIN: - style_dsc_p = &label->style_dsc; + style_dsc_p = &label->style_list; break; default: style_dsc_p = NULL; diff --git a/src/lv_objx/lv_led.c b/src/lv_objx/lv_led.c index 5652b22fa..2be62ab92 100644 --- a/src/lv_objx/lv_led.c +++ b/src/lv_objx/lv_led.c @@ -82,8 +82,8 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy) if(copy == NULL) { lv_obj_set_size(new_led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF); - lv_style_list_init(&new_led->style_dsc); - lv_obj_add_style_class(new_led, LV_LED_PART_MAIN, lv_theme_get_style(LV_THEME_LED)); + lv_style_list_init(&new_led->style_list); + lv_obj_add_style(new_led, LV_LED_PART_MAIN, lv_theme_get_style(LV_THEME_LED)); } /*Copy an existing object*/ else { diff --git a/src/lv_objx/lv_list.c b/src/lv_objx/lv_list.c index 205dfb777..1ab7e6b6c 100644 --- a/src/lv_objx/lv_list.c +++ b/src/lv_objx/lv_list.c @@ -171,7 +171,7 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t if(ancestor_btn_signal == NULL) ancestor_btn_signal = lv_obj_get_signal_cb(liste); /*Set the default styles*/ - lv_style_list_reset(&liste->style_dsc); + lv_style_list_reset(&liste->style_list); _ot(liste, LV_BTN_PART_MAIN, LIST_BTN); lv_page_glue_obj(liste, true); @@ -919,10 +919,10 @@ static lv_style_list_t * lv_list_get_style(lv_obj_t * list, uint8_t part) switch(part) { case LV_LIST_PART_BG: - style_dsc_p = &list->style_dsc; + style_dsc_p = &list->style_list; break; case LV_LIST_PART_SCRL: - style_dsc_p = &ext->page.scrl->style_dsc; + style_dsc_p = &ext->page.scrl->style_list; break; case LV_LIST_PART_SCRLBAR: style_dsc_p = &ext->page.sb.style; diff --git a/src/lv_objx/lv_mbox.c b/src/lv_objx/lv_mbox.c index d9ef4829c..cd5512052 100644 --- a/src/lv_objx/lv_mbox.c +++ b/src/lv_objx/lv_mbox.c @@ -107,8 +107,8 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_set_event_cb(new_mbox, lv_mbox_default_event_cb); /*Set the default styles*/ - lv_style_list_reset(&new_mbox->style_dsc); - lv_obj_add_style_theme(new_mbox, LV_MBOX_PART_BG, LV_THEME_MBOX_BG); + lv_style_list_reset(&new_mbox->style_list); + lv_obj_add_theme(new_mbox, LV_MBOX_PART_BG, LV_THEME_MBOX_BG); } /*Copy an existing message box*/ @@ -150,12 +150,12 @@ void lv_mbox_add_btns(lv_obj_t * mbox, const char * btn_map[]) if(ext->btnm == NULL) { ext->btnm = lv_btnm_create(mbox, NULL); - lv_style_list_reset(&ext->btnm->style_dsc); - lv_obj_add_style_theme(ext->btnm, LV_BTNM_PART_BG, LV_THEME_MBOX_BTN_BG); + lv_style_list_reset(&ext->btnm->style_list); + lv_obj_add_theme(ext->btnm, LV_BTNM_PART_BG, LV_THEME_MBOX_BTN_BG); lv_style_list_reset(lv_obj_get_style(ext->btnm, LV_BTNM_PART_BTN)); - lv_obj_add_style_theme(ext->btnm, LV_BTNM_PART_BTN, LV_THEME_MBOX_BTN); + lv_obj_add_theme(ext->btnm, LV_BTNM_PART_BTN, LV_THEME_MBOX_BTN); } lv_btnm_set_map(ext->btnm, btn_map); @@ -481,7 +481,7 @@ static lv_style_list_t * lv_mbox_get_style(lv_obj_t * mbox, uint8_t part) switch(part) { case LV_MBOX_PART_BG: - style_dsc_p = &mbox->style_dsc; + style_dsc_p = &mbox->style_list; break; case LV_MBOX_PART_BTN_BG: style_dsc_p = ext->btnm ? lv_obj_get_style(ext->btnm, LV_BTNM_PART_BG) : NULL; @@ -518,7 +518,9 @@ static void mbox_realign(lv_obj_t * mbox) const lv_font_t * font = lv_obj_get_style_ptr(mbox, LV_MBOX_PART_BTN, LV_STYLE_FONT); lv_coord_t font_h = lv_font_get_line_height(font); + lv_mem_test(); lv_obj_set_size(ext->btnm, w, font_h + btn_top + btn_bottom + bg_top + bg_bottom); + lv_mem_test(); } } diff --git a/src/lv_objx/lv_page.c b/src/lv_objx/lv_page.c index 61a9dd11c..9ba1a2112 100644 --- a/src/lv_objx/lv_page.c +++ b/src/lv_objx/lv_page.c @@ -1084,7 +1084,7 @@ static lv_style_list_t * lv_page_get_style(lv_obj_t * page, uint8_t part) switch(part) { case LV_PAGE_PART_BG: - style_dsc_p = &page->style_dsc; + style_dsc_p = &page->style_list; break; case LV_PAGE_PART_SCRL: style_dsc_p = lv_obj_get_style(ext->scrl, LV_CONT_PART_MAIN); diff --git a/src/lv_objx/lv_roller.c b/src/lv_objx/lv_roller.c index 9d77c0dc8..63bc67982 100644 --- a/src/lv_objx/lv_roller.c +++ b/src/lv_objx/lv_roller.c @@ -484,7 +484,7 @@ static lv_style_list_t * lv_roller_get_style(lv_obj_t * roller, uint8_t part) switch(part) { case LV_ROLLER_PART_BG: - style_dsc_p = &roller->style_dsc; + style_dsc_p = &roller->style_list; break; case LV_ROLLER_PART_SCRL: style_dsc_p = lv_obj_get_style(ext->ddlist.page.scrl, LV_CONT_PART_MAIN); diff --git a/src/lv_objx/lv_slider.c b/src/lv_objx/lv_slider.c index 686dd36fb..c078b92d4 100644 --- a/src/lv_objx/lv_slider.c +++ b/src/lv_objx/lv_slider.c @@ -403,7 +403,7 @@ static lv_style_list_t * lv_slider_get_style(lv_obj_t * slider, uint8_t part) switch(part) { case LV_SLIDER_PART_BG: - style_dsc_p = &slider->style_dsc; + style_dsc_p = &slider->style_list; break; case LV_SLIDER_PART_INDIC: style_dsc_p = &ext->bar.style_indic; diff --git a/src/lv_objx/lv_spinbox.c b/src/lv_objx/lv_spinbox.c index 135c95594..ec38e45f3 100644 --- a/src/lv_objx/lv_spinbox.c +++ b/src/lv_objx/lv_spinbox.c @@ -417,7 +417,7 @@ static lv_style_list_t * lv_spinbox_get_style(lv_obj_t * ta, uint8_t part) switch(part) { case LV_SPINBOX_PART_BG: - style_dsc_p = &ta->style_dsc; + style_dsc_p = &ta->style_list; break; case LV_SPINBOX_PART_SCRLBAR: style_dsc_p = &ext->ta.page.sb.style; diff --git a/src/lv_objx/lv_sw.c b/src/lv_objx/lv_sw.c index 04ca02046..91daed83b 100644 --- a/src/lv_objx/lv_sw.c +++ b/src/lv_objx/lv_sw.c @@ -242,7 +242,7 @@ static lv_style_list_t * lv_sw_get_style(lv_obj_t * sw, uint8_t part) switch(part) { case LV_SW_PART_BG: - style_dsc_p = &sw->style_dsc; + style_dsc_p = &sw->style_list; break; case LV_SW_PART_INDIC: style_dsc_p = &ext->slider.bar.style_indic; diff --git a/src/lv_objx/lv_ta.c b/src/lv_objx/lv_ta.c index 842e6eb11..a565731d5 100644 --- a/src/lv_objx/lv_ta.c +++ b/src/lv_objx/lv_ta.c @@ -1550,7 +1550,7 @@ static lv_style_list_t * lv_ta_get_style(lv_obj_t * ta, uint8_t part) switch(part) { case LV_TA_PART_BG: - style_dsc_p = &ta->style_dsc; + style_dsc_p = &ta->style_list; break; case LV_TA_PART_SCRLBAR: style_dsc_p = &ext->page.sb.style; diff --git a/src/lv_objx/lv_table.c b/src/lv_objx/lv_table.c index 34768f3f3..3b9e8276c 100644 --- a/src/lv_objx/lv_table.c +++ b/src/lv_objx/lv_table.c @@ -93,12 +93,12 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new table table*/ if(copy == NULL) { - lv_style_list_reset(&new_table->style_dsc); - lv_obj_add_style_theme(new_table, LV_TABLE_PART_BG, LV_THEME_TABLE_BG); - lv_obj_add_style_theme(new_table, LV_TABLE_PART_CELL1, LV_THEME_TABLE_CELL1); - lv_obj_add_style_theme(new_table, LV_TABLE_PART_CELL2, LV_THEME_TABLE_CELL2); - lv_obj_add_style_theme(new_table, LV_TABLE_PART_CELL3, LV_THEME_TABLE_CELL3); - lv_obj_add_style_theme(new_table, LV_TABLE_PART_CELL4, LV_THEME_TABLE_CELL4); + lv_style_list_reset(&new_table->style_list); + lv_obj_add_theme(new_table, LV_TABLE_PART_BG, LV_THEME_TABLE_BG); + lv_obj_add_theme(new_table, LV_TABLE_PART_CELL1, LV_THEME_TABLE_CELL1); + lv_obj_add_theme(new_table, LV_TABLE_PART_CELL2, LV_THEME_TABLE_CELL2); + lv_obj_add_theme(new_table, LV_TABLE_PART_CELL3, LV_THEME_TABLE_CELL3); + lv_obj_add_theme(new_table, LV_TABLE_PART_CELL4, LV_THEME_TABLE_CELL4); } /*Copy an existing table*/ else { @@ -836,7 +836,7 @@ static lv_style_list_t * lv_table_get_style(lv_obj_t * table, uint8_t part) switch(part) { case LV_TABLE_PART_BG: - style_dsc_p = &table->style_dsc; + style_dsc_p = &table->style_list; break; case LV_TABLE_PART_CELL1: style_dsc_p = &ext->cell_style[0]; diff --git a/src/lv_objx/lv_tabview.c b/src/lv_objx/lv_tabview.c index 30adaf2b6..c5740f3e2 100644 --- a/src/lv_objx/lv_tabview.c +++ b/src/lv_objx/lv_tabview.c @@ -744,7 +744,7 @@ static lv_style_list_t * lv_tabview_get_style(lv_obj_t * tabview, uint8_t part) switch(part) { case LV_TABVIEW_PART_BG: - style_dsc_p = &tabview->style_dsc; + style_dsc_p = &tabview->style_list; break; case LV_TABVIEW_PART_BG_SCRL: style_dsc_p = lv_obj_get_style(ext->content, LV_PAGE_PART_SCRL); diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index de9629700..a34f5839d 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -59,11 +59,6 @@ lv_style_t * lv_theme_get_style(lv_theme_style_t name) } -void lv_obj_add_style_theme(void * obj, uint8_t part, lv_theme_style_t name) -{ - lv_obj_add_style_class(obj, part, lv_theme_get_style(name)); -} - /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index b12b0c13b..52e3f22a5 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -154,13 +154,11 @@ lv_theme_t * lv_theme_get_act(void); lv_style_t * lv_theme_get_style(lv_theme_style_t name); -void lv_obj_add_style_theme(void * obj, uint8_t part, lv_theme_style_t name); - /********************** * MACROS **********************/ #define _t(name) lv_theme_get_style(LV_THEME_ ## name) -#define _ot(obj, part, name) lv_obj_add_style_class(obj, part, _t(name)) +#define _ot(obj, part, name) lv_obj_add_style(obj, part, _t(name)) /********************** * POST INCLUDE diff --git a/src/lv_themes/lv_theme_alien.c b/src/lv_themes/lv_theme_alien.c index d9448f9b7..16c0d5d21 100644 --- a/src/lv_themes/lv_theme_alien.c +++ b/src/lv_themes/lv_theme_alien.c @@ -34,7 +34,6 @@ static lv_style_t transp; static lv_style_t panel; /*General fancy background (e.g. to chart or ta)*/ static lv_style_t btn; static lv_style_t sb; -static lv_style_t transp_tight; #if LV_USE_BAR static lv_style_t bar_indic; @@ -89,73 +88,40 @@ static void basic_init(void) { lv_style_init(&scr); lv_style_set_opa(&scr, LV_STYLE_BG_OPA, LV_OPA_COVER); - lv_style_set_color(&scr, LV_STYLE_BG_COLOR, LV_COLOR_MAKE(0x20, 0x20, 0x20)); - lv_style_set_color(&scr, LV_STYLE_TEXT_COLOR , LV_COLOR_GRAY); - - lv_style_init(&transp); - lv_style_set_opa(&transp, LV_STYLE_BG_OPA, LV_OPA_TRANSP); - lv_style_set_int(&transp, LV_STYLE_BORDER_WIDTH, 0); + lv_style_set_color(&scr, LV_STYLE_BG_COLOR, lv_color_hex(0x22252a)); + lv_style_set_color(&scr, LV_STYLE_TEXT_COLOR , lv_color_hex(0xb8b8b9)); lv_style_init(&panel); + lv_style_set_int(&panel, LV_STYLE_RADIUS, LV_DPI / 25); lv_style_set_opa(&panel, LV_STYLE_BG_OPA, LV_OPA_COVER); - lv_style_set_int(&panel, LV_STYLE_PAD_LEFT, LV_DPI / 20); - lv_style_set_int(&panel, LV_STYLE_PAD_RIGHT, LV_DPI / 20); - lv_style_set_int(&panel, LV_STYLE_PAD_TOP, LV_DPI / 20); - lv_style_set_int(&panel, LV_STYLE_PAD_BOTTOM, LV_DPI / 20); - lv_style_set_int(&panel, LV_STYLE_PAD_INNER, LV_DPI / 20); - lv_style_set_int(&panel, LV_STYLE_RADIUS, LV_DPI / 16); + lv_style_set_color(&panel, LV_STYLE_BG_COLOR, lv_color_hex(0x282b30)); + lv_style_set_color(&panel, LV_STYLE_BORDER_COLOR, lv_color_hex(0x3a3d42)); lv_style_set_int(&panel, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1); - lv_style_set_color(&panel, LV_STYLE_BG_COLOR, LV_COLOR_SILVER); - lv_style_set_color(&panel, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_BLUE); - lv_style_set_int(&panel, LV_STYLE_BG_GRAD_DIR, LV_GRAD_DIR_VER); - lv_style_set_color(&panel, LV_STYLE_BORDER_COLOR, LV_COLOR_GRAY); - lv_style_set_color(&panel, LV_STYLE_TEXT_COLOR, LV_COLOR_BLACK); - lv_style_set_ptr(&panel, LV_STYLE_FONT , &lv_font_roboto_16); - lv_style_set_int(&panel, LV_STYLE_LINE_WIDTH, 2); + lv_style_set_int(&panel, LV_STYLE_BORDER_SIDE , LV_BORDER_SIDE_TOP); + + lv_style_set_int(&panel, LV_STYLE_PAD_LEFT, LV_DPI / 5); + lv_style_set_int(&panel, LV_STYLE_PAD_RIGHT, LV_DPI / 5); + lv_style_set_int(&panel, LV_STYLE_PAD_TOP, LV_DPI / 5); + lv_style_set_int(&panel, LV_STYLE_PAD_BOTTOM, LV_DPI / 5); + lv_style_set_int(&panel, LV_STYLE_PAD_INNER, LV_DPI / 5); + lv_style_set_color(&panel, LV_STYLE_TEXT_COLOR, lv_color_hex(0x979a9f)); + lv_style_set_ptr(&panel, LV_STYLE_FONT, &lv_font_roboto_16); + lv_style_set_color(&panel, LV_STYLE_IMAGE_RECOLOR, lv_color_hex(0x979a9f)); lv_style_init(&btn); + lv_style_set_int(&btn, LV_STYLE_RADIUS, LV_RADIUS_CIRCLE); + lv_style_set_opa(&btn, LV_STYLE_BG_OPA, LV_OPA_COVER); + lv_style_set_color(&btn, LV_STYLE_BG_COLOR, lv_color_hex(0x007aff)); + lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_PRESSED, lv_color_hex(0x005ec4)); + lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR, lv_color_hex(0xffffff)); + lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_PRESSED, lv_color_hex(0xdddddd)); + lv_style_set_color(&btn, LV_STYLE_IMAGE_RECOLOR, LV_COLOR_WHITE); lv_style_set_int(&btn, LV_STYLE_PAD_LEFT, LV_DPI / 20); lv_style_set_int(&btn, LV_STYLE_PAD_RIGHT, LV_DPI / 20); lv_style_set_int(&btn, LV_STYLE_PAD_TOP, LV_DPI / 20); lv_style_set_int(&btn, LV_STYLE_PAD_BOTTOM, LV_DPI / 20); lv_style_set_int(&btn, LV_STYLE_PAD_INNER, LV_DPI / 16); - lv_style_set_int(&btn, LV_STYLE_RADIUS, 5); - lv_style_set_opa(&btn, LV_STYLE_BG_OPA, LV_OPA_COVER); - lv_style_set_int(&btn, LV_STYLE_BORDER_WIDTH, 2);//LV_DPI / 50 > 0 ? LV_DPI / 50 : 1); - lv_style_set_int(&btn, LV_STYLE_BG_GRAD_DIR, LV_GRAD_DIR_VER); - lv_style_set_color(&btn, LV_STYLE_BG_COLOR, LV_COLOR_RED); - lv_style_set_color(&btn, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_MAROON); - lv_style_set_color(&btn, LV_STYLE_BORDER_COLOR, LV_COLOR_NAVY); - lv_style_set_color(&btn, LV_STYLE_BORDER_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_AQUA); - lv_style_set_color(&btn, LV_STYLE_BG_GRAD_COLOR | LV_STYLE_STATE_PRESSED, LV_COLOR_LIME); - lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_CHECKED, LV_COLOR_BLUE); - lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR, LV_COLOR_LIME); - lv_style_set_color(&btn, LV_STYLE_IMAGE_RECOLOR, LV_COLOR_LIME); - lv_style_set_int(&btn, LV_STYLE_RADIUS | LV_STYLE_STATE_PRESSED, LV_RADIUS_CIRCLE); - lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_PRESSED, LV_COLOR_BLUE); - lv_style_set_color(&btn, LV_STYLE_IMAGE_RECOLOR | LV_STYLE_STATE_PRESSED, LV_COLOR_BLUE); - lv_style_set_ptr(&btn, LV_STYLE_FONT | LV_STYLE_STATE_PRESSED, &lv_font_roboto_28); - lv_style_set_opa(&btn, LV_STYLE_BG_OPA, LV_OPA_50); - lv_style_set_opa(&btn, LV_STYLE_BORDER_OPA, LV_OPA_70); - lv_style_set_opa(&btn, LV_STYLE_TEXT_OPA, LV_OPA_80); - lv_style_set_int(&btn, LV_STYLE_BORDER_WIDTH | LV_STYLE_STATE_FOCUS, 6); - lv_style_set_ptr(&btn, LV_STYLE_PATTERN_IMAGE | LV_STYLE_STATE_CHECKED, LV_SYMBOL_STOP); -// lv_style_set_int(&btn, LV_STYLE_PATTERN_REPEATE | LV_STYLE_STATE_CHECKED, 1); - lv_style_set_int(&btn, LV_STYLE_SHADOW_WIDTH, 5); - lv_style_set_int(&btn, LV_STYLE_SHADOW_OFFSET_Y, 3); - lv_style_set_int(&btn, LV_STYLE_TRANSITION_TIME, 200); - lv_style_set_ptr(&btn, LV_STYLE_FONT | LV_STYLE_STATE_CHECKED, &lv_font_roboto_12); - - lv_style_init(&transp_tight); - lv_style_set_opa(&transp_tight, LV_STYLE_BG_OPA, LV_OPA_TRANSP); - lv_style_set_opa(&transp_tight, LV_STYLE_BORDER_OPA, LV_OPA_TRANSP); - lv_style_set_opa(&transp_tight, LV_STYLE_SHADOW_OPA, LV_OPA_TRANSP); - lv_style_set_opa(&transp_tight, LV_STYLE_PATTERN_OPA, LV_OPA_TRANSP); - lv_style_set_int(&transp_tight, LV_STYLE_PAD_LEFT, 0); - lv_style_set_int(&transp_tight, LV_STYLE_PAD_RIGHT, 0); - lv_style_set_int(&transp_tight, LV_STYLE_PAD_TOP, 0); - lv_style_set_int(&transp_tight, LV_STYLE_PAD_BOTTOM, 0); - lv_style_set_int(&transp_tight, LV_STYLE_PAD_INNER, 0); + lv_style_set_int(&btn, LV_STYLE_TRANSITION_TIME, 100); } static void cont_init(void) @@ -649,13 +615,13 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name) #endif #if LV_USE_CB case LV_THEME_CB: - return &panel; + return &panel; case LV_THEME_CB_BULLET: return &btn; #endif #if LV_USE_DDLIST case LV_THEME_DDLIST_SCRL: - return &transp_tight; + return NULL; case LV_THEME_DDLIST_SEL: return &btn; #endif @@ -663,12 +629,13 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name) case LV_THEME_TABVIEW_BG: case LV_THEME_TABVIEW_BTNS_BG: case LV_THEME_TABVIEW_TAB_SCRL: - return &transp_tight; - case LV_THEME_TABVIEW_INDIC: - case LV_THEME_TABVIEW_TAB_BG: - return &panel; - case LV_THEME_TABVIEW_BTNS: case LV_THEME_TABVIEW_BG_SCRL: + return NULL; + case LV_THEME_TABVIEW_INDIC: + return &panel; + case LV_THEME_TABVIEW_TAB_BG: + return &scr; + case LV_THEME_TABVIEW_BTNS: return &btn; #endif #if LV_USE_LMETER @@ -712,7 +679,7 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name) case LV_THEME_MBOX_BG: return &panel; case LV_THEME_MBOX_BTN_BG: - return &transp_tight; + return NULL; case LV_THEME_MBOX_BTN: return &btn; #endif diff --git a/tests/lv_test_core/lv_test_obj.c b/tests/lv_test_core/lv_test_obj.c index 007bebfbd..915055e4d 100644 --- a/tests/lv_test_core/lv_test_obj.c +++ b/tests/lv_test_core/lv_test_obj.c @@ -63,7 +63,6 @@ static void create_delete_change_parent(void) lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation"); lv_test_assert_int_eq(0, lv_obj_count_children(obj), "New object's children count after creation"); - lv_test_assert_img_eq("lv_test_obj_1_1.png", "Draw test"); lv_test_print("Delete the created object"); lv_obj_del(obj); diff --git a/tests/lv_test_core/lv_test_style.c b/tests/lv_test_core/lv_test_style.c index b4c8c1992..55383a10a 100644 --- a/tests/lv_test_core/lv_test_style.c +++ b/tests/lv_test_core/lv_test_style.c @@ -23,6 +23,7 @@ static void empty_style(void); static void add_remove_read_prop(void); static void cascade(void); +static void copy(void); static void states(void); static void mem_leak(void); @@ -48,6 +49,7 @@ void lv_test_style(void) empty_style(); add_remove_read_prop(); cascade(); + copy(); states(); mem_leak(); } @@ -259,6 +261,52 @@ static void cascade(void) lv_style_list_reset(&style_list); } +static void copy(void) +{ + lv_test_print(""); + lv_test_print("Copy styles and style lists"); + lv_test_print("---------------------------"); + + + lv_test_print("Copy a style"); + lv_style_t style_src; + lv_style_init(&style_src); + lv_style_set_int(&style_src, LV_STYLE_LINE_SPACE, 5); + + lv_style_t style_dest; + lv_style_copy(&style_dest, &style_src); + + int16_t weight; + lv_style_int_t value; + + weight = lv_style_get_int(&style_dest, LV_STYLE_LINE_SPACE, &value); + lv_test_assert_int_eq(0, weight, "Get a copied property from a style"); + lv_test_assert_int_eq(5, value, "Get the value of a copied from a property"); + + lv_test_print("Copy a style list"); + lv_style_list_t list_src; + lv_style_list_init(&list_src); + lv_style_list_add_style(&list_src, &style_src); + lv_style_list_set_local_int(&list_src, LV_STYLE_LINE_DASH_WIDTH, 20); + + lv_style_list_t list_dest; + lv_style_list_copy(&list_dest, &list_src); + + lv_res_t found; + found = lv_style_list_get_int(&list_dest, LV_STYLE_LINE_SPACE, &value); + lv_test_assert_int_eq(LV_RES_OK, found, "Get a copied property from a list"); + lv_test_assert_int_eq(5, value, "Get the value of a copied property from a list"); + found = lv_style_list_get_int(&list_dest, LV_STYLE_LINE_DASH_WIDTH, &value); + lv_test_assert_int_eq(LV_RES_OK, found, "Get a copied local property from a list"); + lv_test_assert_int_eq(20, value, "Get the value of a copied local property from a list"); + + /*Clean up*/ + lv_style_list_reset(&list_dest); + lv_style_list_reset(&list_src); + + lv_style_reset(&style_dest); + lv_style_reset(&style_src); +} static void states(void) { diff --git a/tests/lv_test_objx/lv_test_cont.c b/tests/lv_test_objx/lv_test_cont.c new file mode 100644 index 000000000..9db7b14b5 --- /dev/null +++ b/tests/lv_test_objx/lv_test_cont.c @@ -0,0 +1,76 @@ +/** + * @file lv_test_cont.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "../../lvgl.h" +#include "../lv_test_assert.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ +static void create_copy(void); + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +void lv_test_cont(void) +{ + lv_test_print(""); + lv_test_print("==================="); + lv_test_print("Start lv_cont tests"); + lv_test_print("==================="); + + create_copy(); +} + + +/********************** + * STATIC FUNCTIONS + **********************/ + +static void create_copy(void) +{ + lv_test_print(""); + lv_test_print("Create and copy a container"); + lv_test_print("---------------------------"); + + lv_test_print("Create a container"); + lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count before creation"); + + lv_obj_t * obj = lv_cont_create(lv_scr_act(), NULL); + lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation"); + + lv_test_print("Test the default values"); + lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_left(obj), "Default left fit"); + lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_right(obj), "Default right fit"); + lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_top(obj), "Default top fit"); + lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_bottom(obj), "Default bottom fit"); + lv_test_assert_int_eq(LV_LAYOUT_OFF, lv_cont_get_layout(obj), "Default layout"); + + lv_test_print("Delete the container"); + lv_obj_del(obj); + obj = NULL; + lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count after delete"); + +} diff --git a/tests/lv_test_objx/lv_test_cont.h b/tests/lv_test_objx/lv_test_cont.h new file mode 100644 index 000000000..08bbd8b59 --- /dev/null +++ b/tests/lv_test_objx/lv_test_cont.h @@ -0,0 +1,38 @@ +/** + * @file lv_test_obj.h + * + */ + +#ifndef LV_TEST_CONT_H +#define LV_TEST_CONT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ +void lv_test_cont(void); + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*LV_TEST_CONT_H*/