add style copy + minor refactoring
This commit is contained in:
@@ -282,14 +282,13 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
|||||||
|
|
||||||
new_obj->ext_attr = NULL;
|
new_obj->ext_attr = NULL;
|
||||||
|
|
||||||
lv_style_list_init(&new_obj->style_dsc);
|
if(copy == NULL) {
|
||||||
|
lv_style_list_init(&new_obj->style_list);
|
||||||
if(parent != NULL) {
|
if(parent != NULL) lv_obj_add_theme(new_obj, LV_OBJ_PART_MAIN, LV_THEME_PANEL);
|
||||||
lv_obj_add_style_class(new_obj, LV_OBJ_PART_MAIN, _t(PANEL));
|
else lv_obj_add_theme(new_obj, LV_OBJ_PART_MAIN, LV_THEME_SCR);
|
||||||
} else {
|
} 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*/
|
/*Copy the attributes if required*/
|
||||||
if(copy != NULL) {
|
if(copy != NULL) {
|
||||||
lv_area_copy(&new_obj->coords, ©->coords);
|
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);
|
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;
|
if(style == NULL) return;
|
||||||
|
|
||||||
lv_style_list_t * style_dsc = lv_obj_get_style(obj, part);
|
lv_style_list_t * style_dsc = lv_obj_get_style(obj, part);
|
||||||
if(style_dsc == NULL) {
|
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;
|
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);
|
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)
|
void lv_obj_reset_style(lv_obj_t * obj, uint8_t part)
|
||||||
{
|
{
|
||||||
lv_style_list_t * style_dsc = lv_obj_get_style(obj, 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)
|
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;
|
lv_get_style_info_t info;
|
||||||
info.part = part;
|
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) {
|
if(obj->state == obj->prev_state) {
|
||||||
return lv_obj_get_style_int_core(obj, part, prop);
|
return lv_obj_get_style_int_core(obj, part, prop);
|
||||||
} else {
|
} else {
|
||||||
lv_style_int_t act_int = lv_obj_get_style_int_core(obj, part, prop);
|
lv_style_int_t act_int = lv_obj_get_style_int_core(obj, part, prop);
|
||||||
lv_obj_state_t state_ori = obj->state;
|
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);
|
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(prop == LV_STYLE_RADIUS) {
|
||||||
if(act_int == LV_RADIUS_CIRCLE || prev_int == LV_RADIUS_CIRCLE) {
|
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) {
|
if(obj->state == obj->prev_state) {
|
||||||
return lv_obj_get_style_color_core(obj, part, prop);
|
return lv_obj_get_style_color_core(obj, part, prop);
|
||||||
} else {
|
} else {
|
||||||
lv_color_t act_color = lv_obj_get_style_color_core(obj, part, prop);
|
lv_color_t act_color = lv_obj_get_style_color_core(obj, part, prop);
|
||||||
lv_obj_state_t state_ori = obj->state;
|
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);
|
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);
|
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) {
|
if(obj->state == obj->prev_state) {
|
||||||
return lv_obj_get_style_opa_core(obj, part, prop);
|
return lv_obj_get_style_opa_core(obj, part, prop);
|
||||||
} else {
|
} else {
|
||||||
lv_opa_t act_opa = lv_obj_get_style_opa_core(obj, part, prop);
|
lv_opa_t act_opa = lv_obj_get_style_opa_core(obj, part, prop);
|
||||||
lv_obj_state_t state_ori = obj->state;
|
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);
|
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;
|
if(obj->state_anim >= 255) return act_opa;
|
||||||
return prev_opa + (((act_opa - prev_opa) * obj->state_anim) >> 8);
|
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) {
|
if(obj->state == obj->prev_state) {
|
||||||
return lv_obj_get_style_ptr_core(obj, part, prop);
|
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);
|
if(obj->state_anim > 128) return lv_obj_get_style_ptr_core(obj, part, prop);
|
||||||
|
|
||||||
lv_obj_state_t state_ori = obj->state;
|
lv_obj_state_t state_ori = obj->state;
|
||||||
obj->state = obj->prev_state;
|
((lv_obj_t*)obj)->state = obj->prev_state;
|
||||||
void * prev_ptr = lv_obj_get_style_ptr_core(obj, part, prop);
|
const void * prev_ptr = lv_obj_get_style_ptr_core(obj, part, prop);
|
||||||
obj->state = state_ori;
|
((lv_obj_t*)obj)->state = state_ori;
|
||||||
|
|
||||||
return prev_ptr;
|
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) {
|
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||||
lv_get_style_info_t * info = param;
|
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;
|
else info->result = NULL;
|
||||||
return LV_RES_OK;
|
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)
|
* 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
|
* @param obj pointer to an object
|
||||||
*/
|
*/
|
||||||
static void report_style_mod_core(void * style, lv_obj_t * obj)
|
static void report_style_mod_core(void * style, lv_obj_t * obj)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ extern "C" {
|
|||||||
#include "../lv_misc/lv_bidi.h"
|
#include "../lv_misc/lv_bidi.h"
|
||||||
#include "../lv_hal/lv_hal.h"
|
#include "../lv_hal/lv_hal.h"
|
||||||
#include "../lv_draw/lv_draw_rect.h"
|
#include "../lv_draw/lv_draw_rect.h"
|
||||||
|
#include "../lv_themes/lv_theme.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
@@ -223,7 +224,7 @@ typedef struct _lv_obj_t
|
|||||||
lv_design_cb_t design_cb; /**< Object type specific design function*/
|
lv_design_cb_t design_cb; /**< Object type specific design function*/
|
||||||
|
|
||||||
void * ext_attr; /**< Object type specific extended data*/
|
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
|
#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_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);
|
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_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)
|
// * Get the style pointer of an object (if NULL get style of the parent)
|
||||||
// * @param obj pointer to an object
|
// * @param obj pointer to an object
|
||||||
|
|||||||
@@ -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)
|
void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src)
|
||||||
{
|
{
|
||||||
lv_style_init(style_dest);
|
lv_style_init(style_dest);
|
||||||
|
|
||||||
|
if(style_src->map == NULL) return;
|
||||||
|
|
||||||
style_dest->map = lv_mem_alloc(style_src->size);
|
style_dest->map = lv_mem_alloc(style_src->size);
|
||||||
memcpy(style_dest->map, style_src->map, style_src->size);
|
memcpy(style_dest->map, style_src->map, style_src->size);
|
||||||
style_dest->size = 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;
|
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)
|
void lv_style_list_add_style(lv_style_list_t * list, lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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_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_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);
|
void lv_style_list_remove_style(lv_style_list_t * style_dsc, lv_style_t * class);
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
/*Init the new arc arc*/
|
/*Init the new arc arc*/
|
||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
lv_style_list_init(&ext->style_arc);
|
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_BG, ARC_BG);
|
||||||
_ot(new_arc, LV_ARC_PART_ARC, ARC);
|
_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) {
|
switch(part) {
|
||||||
case LV_ARC_PART_BG:
|
case LV_ARC_PART_BG:
|
||||||
style_dsc_p = &arc->style_dsc;
|
style_dsc_p = &arc->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_ARC_PART_ARC:
|
case LV_ARC_PART_ARC:
|
||||||
style_dsc_p = &ext->style_arc;
|
style_dsc_p = &ext->style_arc;
|
||||||
|
|||||||
@@ -620,7 +620,7 @@ static lv_style_list_t * lv_bar_get_style(lv_obj_t * bar, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_BAR_PART_BG:
|
case LV_BAR_PART_BG:
|
||||||
style_dsc_p = &bar->style_dsc;
|
style_dsc_p = &bar->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_BAR_PART_INDIC:
|
case LV_BAR_PART_INDIC:
|
||||||
style_dsc_p = &ext->style_indic;
|
style_dsc_p = &ext->style_indic;
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Set the default styles*/
|
/*Set the default styles*/
|
||||||
lv_obj_reset_style(new_btn, LV_BTN_PART_MAIN);
|
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'*/
|
/*Copy 'copy'*/
|
||||||
else {
|
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;
|
lv_style_list_t * style_dsc_p;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_BTN_PART_MAIN:
|
case LV_BTN_PART_MAIN:
|
||||||
style_dsc_p = &cont->style_dsc;
|
style_dsc_p = &cont->style_list;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
style_dsc_p = NULL;
|
style_dsc_p = NULL;
|
||||||
|
|||||||
@@ -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 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.
|
* @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_OBJ(btnm, LV_OBJX_NAME);
|
||||||
LV_ASSERT_NULL(map);
|
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) {
|
switch(part) {
|
||||||
case LV_BTNM_PART_BG:
|
case LV_BTNM_PART_BG:
|
||||||
style_dsc_p = &btnm->style_dsc;
|
style_dsc_p = &btnm->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_BTNM_PART_BTN:
|
case LV_BTNM_PART_BTN:
|
||||||
style_dsc_p = &ext->style_btn;
|
style_dsc_p = &ext->style_btn;
|
||||||
|
|||||||
@@ -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 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.
|
* @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
|
* Set the button control map (hidden, disabled etc.) for a button matrix. The
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
|
|
||||||
/*Different styles will be used from the styles while rendering so disable caching*/
|
/*Different styles will be used from the styles while rendering so disable caching*/
|
||||||
lv_style_list_reset(&new_calendar->style_dsc);
|
lv_style_list_reset(&new_calendar->style_list);
|
||||||
lv_style_list_add_style(&new_calendar->style_dsc, lv_theme_get_style(LV_THEME_CALENDAR_BG));
|
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_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_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));
|
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) {
|
switch(part) {
|
||||||
case LV_CALENDAR_PART_BG:
|
case LV_CALENDAR_PART_BG:
|
||||||
style_dsc_p = &calendar->style_dsc;
|
style_dsc_p = &calendar->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_CALENDAR_PART_HEADER:
|
case LV_CALENDAR_PART_HEADER:
|
||||||
style_dsc_p = &ext->style_header;
|
style_dsc_p = &ext->style_header;
|
||||||
|
|||||||
@@ -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);
|
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_CB_PART_BG:
|
case LV_CB_PART_BG:
|
||||||
style_dsc_p = &cb->style_dsc;
|
style_dsc_p = &cb->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_CB_PART_BULLET:
|
case LV_CB_PART_BULLET:
|
||||||
style_dsc_p = lv_obj_get_style(ext->bullet, LV_BTN_PART_MAIN);
|
style_dsc_p = lv_obj_get_style(ext->bullet, LV_BTN_PART_MAIN);
|
||||||
|
|||||||
@@ -133,10 +133,10 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
lv_obj_set_size(new_chart, LV_DPI * 3, LV_DPI * 2);
|
lv_obj_set_size(new_chart, LV_DPI * 3, LV_DPI * 2);
|
||||||
|
|
||||||
lv_style_list_reset(&new_chart->style_dsc);
|
lv_style_list_reset(&new_chart->style_list);
|
||||||
lv_obj_add_style_theme(new_chart, LV_CHART_PART_BG, LV_THEME_CHART_BG);
|
lv_obj_add_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_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_obj_add_theme(new_chart, LV_CHART_PART_SERIES, LV_THEME_CHART_SERIES);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
|
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) {
|
switch(part) {
|
||||||
case LV_CHART_PART_BG:
|
case LV_CHART_PART_BG:
|
||||||
style_dsc_p = &chart->style_dsc;
|
style_dsc_p = &chart->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_CHART_PART_SERIES_BG:
|
case LV_CHART_PART_SERIES_BG:
|
||||||
style_dsc_p = &ext->style_series_bg;
|
style_dsc_p = &ext->style_series_bg;
|
||||||
|
|||||||
@@ -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*/
|
/*Set the default styles if it's not screen*/
|
||||||
if(par != NULL) {
|
if(par != NULL) {
|
||||||
lv_obj_reset_style(new_cont, LV_CONT_PART_MAIN);
|
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*/
|
/*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;
|
lv_style_list_t * style_dsc_p;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_CONT_PART_MAIN:
|
case LV_CONT_PART_MAIN:
|
||||||
style_dsc_p = &cont->style_dsc;
|
style_dsc_p = &cont->style_list;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
style_dsc_p = NULL;
|
style_dsc_p = NULL;
|
||||||
|
|||||||
@@ -748,7 +748,7 @@ static lv_style_list_t * lv_ddlist_get_style(lv_obj_t * ddlist, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_DDLIST_PART_BG:
|
case LV_DDLIST_PART_BG:
|
||||||
style_dsc_p = &ddlist->style_dsc;
|
style_dsc_p = &ddlist->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_DDLIST_PART_SCRL:
|
case LV_DDLIST_PART_SCRL:
|
||||||
style_dsc_p = lv_obj_get_style(ext->page.scrl, LV_CONT_PART_MAIN);
|
style_dsc_p = lv_obj_get_style(ext->page.scrl, LV_CONT_PART_MAIN);
|
||||||
|
|||||||
@@ -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_gauge_set_critical_value(new_gauge, 80);
|
||||||
lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI);
|
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);
|
lv_style_list_init(&ext->style_strong);
|
||||||
_ot(new_gauge, LV_GAUGE_PART_MAIN, GAUGE);
|
_ot(new_gauge, LV_GAUGE_PART_MAIN, GAUGE);
|
||||||
_ot(new_gauge, LV_GAUGE_PART_STRONG, GAUGE_STRONG);
|
_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) {
|
switch(part) {
|
||||||
case LV_GAUGE_PART_MAIN:
|
case LV_GAUGE_PART_MAIN:
|
||||||
style_dsc_p = &gauge->style_dsc;
|
style_dsc_p = &gauge->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_GAUGE_PART_STRONG:
|
case LV_GAUGE_PART_STRONG:
|
||||||
style_dsc_p = &ext->style_strong;
|
style_dsc_p = &ext->style_strong;
|
||||||
|
|||||||
@@ -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;
|
lv_style_list_t * style_dsc_p;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_IMG_PART_MAIN:
|
case LV_IMG_PART_MAIN:
|
||||||
style_dsc_p = &img->style_dsc;
|
style_dsc_p = &img->style_list;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
style_dsc_p = NULL;
|
style_dsc_p = NULL;
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ static lv_style_list_t * lv_kb_get_style(lv_obj_t * kb, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_KB_PART_BG:
|
case LV_KB_PART_BG:
|
||||||
style_dsc_p = &kb->style_dsc;
|
style_dsc_p = &kb->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_KB_PART_BTN:
|
case LV_KB_PART_BTN:
|
||||||
style_dsc_p = &ext->btnm.style_btn;
|
style_dsc_p = &ext->btnm.style_btn;
|
||||||
|
|||||||
@@ -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;
|
lv_style_list_t * style_dsc_p;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_LABEL_PART_MAIN:
|
case LV_LABEL_PART_MAIN:
|
||||||
style_dsc_p = &label->style_dsc;
|
style_dsc_p = &label->style_list;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
style_dsc_p = NULL;
|
style_dsc_p = NULL;
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
lv_obj_set_size(new_led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF);
|
lv_obj_set_size(new_led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF);
|
||||||
|
|
||||||
lv_style_list_init(&new_led->style_dsc);
|
lv_style_list_init(&new_led->style_list);
|
||||||
lv_obj_add_style_class(new_led, LV_LED_PART_MAIN, lv_theme_get_style(LV_THEME_LED));
|
lv_obj_add_style(new_led, LV_LED_PART_MAIN, lv_theme_get_style(LV_THEME_LED));
|
||||||
}
|
}
|
||||||
/*Copy an existing object*/
|
/*Copy an existing object*/
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -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);
|
if(ancestor_btn_signal == NULL) ancestor_btn_signal = lv_obj_get_signal_cb(liste);
|
||||||
|
|
||||||
/*Set the default styles*/
|
/*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);
|
_ot(liste, LV_BTN_PART_MAIN, LIST_BTN);
|
||||||
|
|
||||||
lv_page_glue_obj(liste, true);
|
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) {
|
switch(part) {
|
||||||
case LV_LIST_PART_BG:
|
case LV_LIST_PART_BG:
|
||||||
style_dsc_p = &list->style_dsc;
|
style_dsc_p = &list->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_LIST_PART_SCRL:
|
case LV_LIST_PART_SCRL:
|
||||||
style_dsc_p = &ext->page.scrl->style_dsc;
|
style_dsc_p = &ext->page.scrl->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_LIST_PART_SCRLBAR:
|
case LV_LIST_PART_SCRLBAR:
|
||||||
style_dsc_p = &ext->page.sb.style;
|
style_dsc_p = &ext->page.sb.style;
|
||||||
|
|||||||
@@ -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);
|
lv_obj_set_event_cb(new_mbox, lv_mbox_default_event_cb);
|
||||||
|
|
||||||
/*Set the default styles*/
|
/*Set the default styles*/
|
||||||
lv_style_list_reset(&new_mbox->style_dsc);
|
lv_style_list_reset(&new_mbox->style_list);
|
||||||
lv_obj_add_style_theme(new_mbox, LV_MBOX_PART_BG, LV_THEME_MBOX_BG);
|
lv_obj_add_theme(new_mbox, LV_MBOX_PART_BG, LV_THEME_MBOX_BG);
|
||||||
|
|
||||||
}
|
}
|
||||||
/*Copy an existing message box*/
|
/*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) {
|
if(ext->btnm == NULL) {
|
||||||
ext->btnm = lv_btnm_create(mbox, NULL);
|
ext->btnm = lv_btnm_create(mbox, NULL);
|
||||||
|
|
||||||
lv_style_list_reset(&ext->btnm->style_dsc);
|
lv_style_list_reset(&ext->btnm->style_list);
|
||||||
lv_obj_add_style_theme(ext->btnm, LV_BTNM_PART_BG, LV_THEME_MBOX_BTN_BG);
|
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_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);
|
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) {
|
switch(part) {
|
||||||
case LV_MBOX_PART_BG:
|
case LV_MBOX_PART_BG:
|
||||||
style_dsc_p = &mbox->style_dsc;
|
style_dsc_p = &mbox->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_MBOX_PART_BTN_BG:
|
case LV_MBOX_PART_BTN_BG:
|
||||||
style_dsc_p = ext->btnm ? lv_obj_get_style(ext->btnm, LV_BTNM_PART_BG) : NULL;
|
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);
|
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_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_obj_set_size(ext->btnm, w, font_h + btn_top + btn_bottom + bg_top + bg_bottom);
|
||||||
|
lv_mem_test();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1084,7 +1084,7 @@ static lv_style_list_t * lv_page_get_style(lv_obj_t * page, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_PAGE_PART_BG:
|
case LV_PAGE_PART_BG:
|
||||||
style_dsc_p = &page->style_dsc;
|
style_dsc_p = &page->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_PAGE_PART_SCRL:
|
case LV_PAGE_PART_SCRL:
|
||||||
style_dsc_p = lv_obj_get_style(ext->scrl, LV_CONT_PART_MAIN);
|
style_dsc_p = lv_obj_get_style(ext->scrl, LV_CONT_PART_MAIN);
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ static lv_style_list_t * lv_roller_get_style(lv_obj_t * roller, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_ROLLER_PART_BG:
|
case LV_ROLLER_PART_BG:
|
||||||
style_dsc_p = &roller->style_dsc;
|
style_dsc_p = &roller->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_ROLLER_PART_SCRL:
|
case LV_ROLLER_PART_SCRL:
|
||||||
style_dsc_p = lv_obj_get_style(ext->ddlist.page.scrl, LV_CONT_PART_MAIN);
|
style_dsc_p = lv_obj_get_style(ext->ddlist.page.scrl, LV_CONT_PART_MAIN);
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ static lv_style_list_t * lv_slider_get_style(lv_obj_t * slider, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_SLIDER_PART_BG:
|
case LV_SLIDER_PART_BG:
|
||||||
style_dsc_p = &slider->style_dsc;
|
style_dsc_p = &slider->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_SLIDER_PART_INDIC:
|
case LV_SLIDER_PART_INDIC:
|
||||||
style_dsc_p = &ext->bar.style_indic;
|
style_dsc_p = &ext->bar.style_indic;
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ static lv_style_list_t * lv_spinbox_get_style(lv_obj_t * ta, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_SPINBOX_PART_BG:
|
case LV_SPINBOX_PART_BG:
|
||||||
style_dsc_p = &ta->style_dsc;
|
style_dsc_p = &ta->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_SPINBOX_PART_SCRLBAR:
|
case LV_SPINBOX_PART_SCRLBAR:
|
||||||
style_dsc_p = &ext->ta.page.sb.style;
|
style_dsc_p = &ext->ta.page.sb.style;
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ static lv_style_list_t * lv_sw_get_style(lv_obj_t * sw, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_SW_PART_BG:
|
case LV_SW_PART_BG:
|
||||||
style_dsc_p = &sw->style_dsc;
|
style_dsc_p = &sw->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_SW_PART_INDIC:
|
case LV_SW_PART_INDIC:
|
||||||
style_dsc_p = &ext->slider.bar.style_indic;
|
style_dsc_p = &ext->slider.bar.style_indic;
|
||||||
|
|||||||
@@ -1550,7 +1550,7 @@ static lv_style_list_t * lv_ta_get_style(lv_obj_t * ta, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_TA_PART_BG:
|
case LV_TA_PART_BG:
|
||||||
style_dsc_p = &ta->style_dsc;
|
style_dsc_p = &ta->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_TA_PART_SCRLBAR:
|
case LV_TA_PART_SCRLBAR:
|
||||||
style_dsc_p = &ext->page.sb.style;
|
style_dsc_p = &ext->page.sb.style;
|
||||||
|
|||||||
@@ -93,12 +93,12 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Init the new table table*/
|
/*Init the new table table*/
|
||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
lv_style_list_reset(&new_table->style_dsc);
|
lv_style_list_reset(&new_table->style_list);
|
||||||
lv_obj_add_style_theme(new_table, LV_TABLE_PART_BG, LV_THEME_TABLE_BG);
|
lv_obj_add_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_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_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_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_obj_add_theme(new_table, LV_TABLE_PART_CELL4, LV_THEME_TABLE_CELL4);
|
||||||
}
|
}
|
||||||
/*Copy an existing table*/
|
/*Copy an existing table*/
|
||||||
else {
|
else {
|
||||||
@@ -836,7 +836,7 @@ static lv_style_list_t * lv_table_get_style(lv_obj_t * table, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_TABLE_PART_BG:
|
case LV_TABLE_PART_BG:
|
||||||
style_dsc_p = &table->style_dsc;
|
style_dsc_p = &table->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_TABLE_PART_CELL1:
|
case LV_TABLE_PART_CELL1:
|
||||||
style_dsc_p = &ext->cell_style[0];
|
style_dsc_p = &ext->cell_style[0];
|
||||||
|
|||||||
@@ -744,7 +744,7 @@ static lv_style_list_t * lv_tabview_get_style(lv_obj_t * tabview, uint8_t part)
|
|||||||
|
|
||||||
switch(part) {
|
switch(part) {
|
||||||
case LV_TABVIEW_PART_BG:
|
case LV_TABVIEW_PART_BG:
|
||||||
style_dsc_p = &tabview->style_dsc;
|
style_dsc_p = &tabview->style_list;
|
||||||
break;
|
break;
|
||||||
case LV_TABVIEW_PART_BG_SCRL:
|
case LV_TABVIEW_PART_BG_SCRL:
|
||||||
style_dsc_p = lv_obj_get_style(ext->content, LV_PAGE_PART_SCRL);
|
style_dsc_p = lv_obj_get_style(ext->content, LV_PAGE_PART_SCRL);
|
||||||
|
|||||||
@@ -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
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|||||||
@@ -154,13 +154,11 @@ lv_theme_t * lv_theme_get_act(void);
|
|||||||
|
|
||||||
lv_style_t * lv_theme_get_style(lv_theme_style_t name);
|
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
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
#define _t(name) lv_theme_get_style(LV_THEME_ ## name)
|
#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
|
* POST INCLUDE
|
||||||
|
|||||||
@@ -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 panel; /*General fancy background (e.g. to chart or ta)*/
|
||||||
static lv_style_t btn;
|
static lv_style_t btn;
|
||||||
static lv_style_t sb;
|
static lv_style_t sb;
|
||||||
static lv_style_t transp_tight;
|
|
||||||
|
|
||||||
#if LV_USE_BAR
|
#if LV_USE_BAR
|
||||||
static lv_style_t bar_indic;
|
static lv_style_t bar_indic;
|
||||||
@@ -89,73 +88,40 @@ static void basic_init(void)
|
|||||||
{
|
{
|
||||||
lv_style_init(&scr);
|
lv_style_init(&scr);
|
||||||
lv_style_set_opa(&scr, LV_STYLE_BG_OPA, LV_OPA_COVER);
|
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_BG_COLOR, lv_color_hex(0x22252a));
|
||||||
lv_style_set_color(&scr, LV_STYLE_TEXT_COLOR , LV_COLOR_GRAY);
|
lv_style_set_color(&scr, LV_STYLE_TEXT_COLOR , lv_color_hex(0xb8b8b9));
|
||||||
|
|
||||||
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_init(&panel);
|
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_opa(&panel, LV_STYLE_BG_OPA, LV_OPA_COVER);
|
||||||
lv_style_set_int(&panel, LV_STYLE_PAD_LEFT, LV_DPI / 20);
|
lv_style_set_color(&panel, LV_STYLE_BG_COLOR, lv_color_hex(0x282b30));
|
||||||
lv_style_set_int(&panel, LV_STYLE_PAD_RIGHT, LV_DPI / 20);
|
lv_style_set_color(&panel, LV_STYLE_BORDER_COLOR, lv_color_hex(0x3a3d42));
|
||||||
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_int(&panel, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
|
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_int(&panel, LV_STYLE_BORDER_SIDE , LV_BORDER_SIDE_TOP);
|
||||||
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_int(&panel, LV_STYLE_PAD_LEFT, LV_DPI / 5);
|
||||||
lv_style_set_color(&panel, LV_STYLE_BORDER_COLOR, LV_COLOR_GRAY);
|
lv_style_set_int(&panel, LV_STYLE_PAD_RIGHT, LV_DPI / 5);
|
||||||
lv_style_set_color(&panel, LV_STYLE_TEXT_COLOR, LV_COLOR_BLACK);
|
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_ptr(&panel, LV_STYLE_FONT, &lv_font_roboto_16);
|
||||||
lv_style_set_int(&panel, LV_STYLE_LINE_WIDTH, 2);
|
lv_style_set_color(&panel, LV_STYLE_IMAGE_RECOLOR, lv_color_hex(0x979a9f));
|
||||||
|
|
||||||
lv_style_init(&btn);
|
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_LEFT, LV_DPI / 20);
|
||||||
lv_style_set_int(&btn, LV_STYLE_PAD_RIGHT, 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_TOP, LV_DPI / 20);
|
||||||
lv_style_set_int(&btn, LV_STYLE_PAD_BOTTOM, 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_PAD_INNER, LV_DPI / 16);
|
||||||
lv_style_set_int(&btn, LV_STYLE_RADIUS, 5);
|
lv_style_set_int(&btn, LV_STYLE_TRANSITION_TIME, 100);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cont_init(void)
|
static void cont_init(void)
|
||||||
@@ -655,7 +621,7 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name)
|
|||||||
#endif
|
#endif
|
||||||
#if LV_USE_DDLIST
|
#if LV_USE_DDLIST
|
||||||
case LV_THEME_DDLIST_SCRL:
|
case LV_THEME_DDLIST_SCRL:
|
||||||
return &transp_tight;
|
return NULL;
|
||||||
case LV_THEME_DDLIST_SEL:
|
case LV_THEME_DDLIST_SEL:
|
||||||
return &btn;
|
return &btn;
|
||||||
#endif
|
#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_BG:
|
||||||
case LV_THEME_TABVIEW_BTNS_BG:
|
case LV_THEME_TABVIEW_BTNS_BG:
|
||||||
case LV_THEME_TABVIEW_TAB_SCRL:
|
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:
|
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;
|
return &btn;
|
||||||
#endif
|
#endif
|
||||||
#if LV_USE_LMETER
|
#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:
|
case LV_THEME_MBOX_BG:
|
||||||
return &panel;
|
return &panel;
|
||||||
case LV_THEME_MBOX_BTN_BG:
|
case LV_THEME_MBOX_BTN_BG:
|
||||||
return &transp_tight;
|
return NULL;
|
||||||
case LV_THEME_MBOX_BTN:
|
case LV_THEME_MBOX_BTN:
|
||||||
return &btn;
|
return &btn;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ static void create_delete_change_parent(void)
|
|||||||
lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL);
|
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(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_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_test_print("Delete the created object");
|
||||||
lv_obj_del(obj);
|
lv_obj_del(obj);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
static void empty_style(void);
|
static void empty_style(void);
|
||||||
static void add_remove_read_prop(void);
|
static void add_remove_read_prop(void);
|
||||||
static void cascade(void);
|
static void cascade(void);
|
||||||
|
static void copy(void);
|
||||||
static void states(void);
|
static void states(void);
|
||||||
static void mem_leak(void);
|
static void mem_leak(void);
|
||||||
|
|
||||||
@@ -48,6 +49,7 @@ void lv_test_style(void)
|
|||||||
empty_style();
|
empty_style();
|
||||||
add_remove_read_prop();
|
add_remove_read_prop();
|
||||||
cascade();
|
cascade();
|
||||||
|
copy();
|
||||||
states();
|
states();
|
||||||
mem_leak();
|
mem_leak();
|
||||||
}
|
}
|
||||||
@@ -259,6 +261,52 @@ static void cascade(void)
|
|||||||
lv_style_list_reset(&style_list);
|
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)
|
static void states(void)
|
||||||
{
|
{
|
||||||
|
|||||||
76
tests/lv_test_objx/lv_test_cont.c
Normal file
76
tests/lv_test_objx/lv_test_cont.c
Normal file
@@ -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");
|
||||||
|
|
||||||
|
}
|
||||||
38
tests/lv_test_objx/lv_test_cont.h
Normal file
38
tests/lv_test_objx/lv_test_cont.h
Normal file
@@ -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*/
|
||||||
Reference in New Issue
Block a user