minor fixes

This commit is contained in:
Gabor Kiss-Vamosi
2020-01-05 01:16:13 +01:00
parent 32770da251
commit 6e2a707cfc
15 changed files with 131 additions and 214 deletions

View File

@@ -652,7 +652,7 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
refresh_children_position(obj, diff.x, diff.y);
/*Inform the object about its new coordinates*/
obj->signal_cb(obj, LV_SIGNAL_CORD_CHG, &ori);
obj->signal_cb(obj, LV_SIGNAL_COORD_CHG, &ori);
/*Send a signal to the parent too*/
par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj);
@@ -719,7 +719,7 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
}
/*Send a signal to the object with its new coordinates*/
obj->signal_cb(obj, LV_SIGNAL_CORD_CHG, &ori);
obj->signal_cb(obj, LV_SIGNAL_COORD_CHG, &ori);
/*Send a signal to the parent too*/
lv_obj_t * par = lv_obj_get_parent(obj);
@@ -2211,7 +2211,6 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_p
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight_goal = lv_obj_get_state(obj);
int16_t weight = -1;
lv_color_t value;
@@ -2221,6 +2220,7 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_p
if(dsc == NULL) continue;
state = lv_obj_get_state(parent);
int16_t weight_goal = state;
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
int16_t weight_act;
@@ -2411,7 +2411,6 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_propert
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight_goal = lv_obj_get_state(obj);
int16_t weight = -1;
void * value;
@@ -2421,6 +2420,7 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_propert
if(dsc == NULL) continue;
state = lv_obj_get_state(parent);
int16_t weight_goal = state;
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
int16_t weight_act;
@@ -2649,6 +2649,17 @@ lv_obj_state_t lv_obj_get_state(const lv_obj_t * obj)
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
return obj->state;
uint8_t state = 0;
const lv_obj_t * parent = obj;
while(parent) {
state |= parent->state;
parent = lv_obj_get_parent(parent);
}
return state;
}
/**

View File

@@ -116,7 +116,7 @@ enum {
/*General signals*/
LV_SIGNAL_CLEANUP, /**< Object is being deleted */
LV_SIGNAL_CHILD_CHG, /**< Child was removed/added */
LV_SIGNAL_CORD_CHG, /**< Object coordinates/size have changed */
LV_SIGNAL_COORD_CHG, /**< Object coordinates/size have changed */
LV_SIGNAL_PARENT_SIZE_CHG, /**< Parent's size has changed */
LV_SIGNAL_STYLE_CHG, /**< Object's style has changed */
LV_SIGNAL_BASE_DIR_CHG, /**<The base dir has changed*/

View File

@@ -114,9 +114,9 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_LETTER_SPACE, 0x6, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_LINE_SPACE, 0x6, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_BLEND_MODE, 0x6, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_BLEND_MODE, 0x6, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_COLOR, 0x6, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_OPA, 0x6, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_OPA, 0x6, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_FONT, 0x6, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_LINE_WIDTH, 0x7, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
@@ -124,10 +124,10 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_LINE_COLOR, 0x7, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_LINE_OPA, 0x7, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_BLEND_MODE, 0x8, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_RECOLOR, 0x8, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_RECOLOR_OPA, 0x8, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_BLEND_MODE, 0x8, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_RECOLOR, 0x8, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_RECOLOR_OPA, 0x8, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_OVERLAY_COLOR, 0x9, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_OVERLAY_OPA, 0x9, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),

View File

@@ -765,7 +765,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(sign == LV_SIGNAL_CLEANUP) {
lv_mem_free(ext->button_areas);
lv_mem_free(ext->ctrl_bits);
} else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_COORD_CHG) {
lv_btnm_set_map(btnm, ext->map_p);
} else if(sign == LV_SIGNAL_PRESSED) {
lv_indev_t * indev = lv_indev_get_act();

View File

@@ -272,7 +272,7 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
} else if(sign == LV_SIGNAL_CHILD_CHG) {
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
} else if(sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_COORD_CHG) {
if(lv_obj_get_width(cont) != lv_area_get_width(param) || lv_obj_get_height(cont) != lv_area_get_height(param)) {
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
@@ -718,7 +718,7 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
lv_obj_invalidate(cont);
/*Notify the object about its new coordinates*/
cont->signal_cb(cont, LV_SIGNAL_CORD_CHG, &ori);
cont->signal_cb(cont, LV_SIGNAL_COORD_CHG, &ori);
/*Inform the parent about the new coordinates*/
par->signal_cb(par, LV_SIGNAL_CHILD_CHG, cont);

View File

@@ -119,9 +119,12 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
ext->dot.tmp_ptr = NULL;
ext->dot_tmp_alloc = 0;
lv_obj_reset_style(new_label, LV_LABEL_PART_MAIN);
lv_obj_set_design_cb(new_label, lv_label_design);
lv_obj_set_signal_cb(new_label, lv_label_signal);
/*Init the new label*/
if(copy == NULL) {
lv_obj_set_click(new_label, false);
@@ -1171,7 +1174,7 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
lv_label_revert_dots(label);
lv_label_refr_text(label);
} else if(sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_COORD_CHG) {
if(lv_area_get_width(&label->coords) != lv_area_get_width(param) ||
lv_area_get_height(&label->coords) != lv_area_get_height(param)) {
lv_label_revert_dots(label);

View File

@@ -36,6 +36,7 @@
**********************/
static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param);
static lv_style_dsc_t * lv_list_get_style(lv_obj_t * list, uint8_t part);
static void lv_list_btn_single_select(lv_obj_t * btn);
static bool lv_list_is_list_btn(lv_obj_t * list_btn);
static bool lv_list_is_list_img(lv_obj_t * list_btn);
@@ -83,14 +84,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_del(new_list);
return NULL;
}
ext->style_img = NULL;
ext->styles_btn[LV_BTN_STATE_REL] = &lv_style_btn_rel;
ext->styles_btn[LV_BTN_STATE_PR] = &lv_style_btn_pr;
ext->styles_btn[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_rel;
ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
ext->single_mode = false;
ext->single_mode = 0;
ext->size = 0;
#if LV_USE_GROUP
@@ -108,22 +102,6 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
lv_page_set_scrl_layout(new_list, LV_LIST_LAYOUT_DEF);
lv_list_set_sb_mode(new_list, LV_SB_MODE_DRAG);
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_list_set_style(new_list, LV_LIST_STYLE_BG, th->style.list.bg);
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, th->style.list.scrl);
lv_list_set_style(new_list, LV_LIST_STYLE_SB, th->style.list.sb);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_REL, th->style.list.btn.rel);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_PR, th->style.list.btn.pr);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, th->style.list.btn.tgl_rel);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, th->style.list.btn.tgl_pr);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_INA, th->style.list.btn.ina);
} else {
lv_list_set_style(new_list, LV_LIST_STYLE_BG, &lv_style_transp_fit);
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, &lv_style_pretty);
}
} else {
lv_list_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
@@ -138,14 +116,8 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
copy_btn = lv_list_get_next_btn(copy, copy_btn);
}
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_REL, copy_ext->styles_btn[LV_BTN_STATE_REL]);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_PR, copy_ext->styles_btn[LV_BTN_STATE_PR]);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, copy_ext->styles_btn[LV_BTN_STATE_TGL_REL]);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, copy_ext->styles_btn[LV_BTN_STATE_TGL_REL]);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_INA, copy_ext->styles_btn[LV_BTN_STATE_INA]);
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_list);
// lv_obj_refresh_style(new_list);
}
LV_LOG_INFO("list created");
@@ -199,11 +171,8 @@ 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_btn_set_style(liste, LV_BTN_STYLE_REL, ext->styles_btn[LV_BTN_STATE_REL]);
lv_btn_set_style(liste, LV_BTN_STYLE_PR, ext->styles_btn[LV_BTN_STATE_PR]);
lv_btn_set_style(liste, LV_BTN_STYLE_TGL_REL, ext->styles_btn[LV_BTN_STATE_TGL_REL]);
lv_btn_set_style(liste, LV_BTN_STYLE_TGL_PR, ext->styles_btn[LV_BTN_STATE_TGL_PR]);
lv_btn_set_style(liste, LV_BTN_STYLE_INA, ext->styles_btn[LV_BTN_STATE_INA]);
lv_style_dsc_reset(&liste->style_dsc);
_ot(liste, LV_BTN_PART_MAIN, LIST_BTN);
lv_page_glue_obj(liste, true);
lv_btn_set_layout(liste, LV_LAYOUT_ROW_M);
@@ -231,22 +200,28 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
if(img_src) {
img = lv_img_create(liste, NULL);
lv_img_set_src(img, img_src);
lv_obj_set_style(img, ext->style_img);
lv_obj_set_click(img, false);
if(img_signal == NULL) img_signal = lv_obj_get_signal_cb(img);
}
#endif
if(txt != NULL) {
lv_coord_t btn_hor_pad = ext->styles_btn[LV_BTN_STYLE_REL]->body.padding.left -
ext->styles_btn[LV_BTN_STYLE_REL]->body.padding.right;
lv_obj_t * label = lv_label_create(liste, NULL);
lv_label_set_text(label, txt);
lv_obj_set_click(label, false);
lv_label_set_long_mode(label, LV_LABEL_LONG_SROLL_CIRC);
if(lv_obj_get_base_dir(liste) == LV_BIDI_DIR_RTL) lv_obj_set_width(label, label->coords.x2 - liste->coords.x1 - btn_hor_pad);
else lv_obj_set_width(label, liste->coords.x2 - label->coords.x1 - btn_hor_pad);
if(lv_obj_get_base_dir(liste) == LV_BIDI_DIR_RTL) {
lv_coord_t pad = lv_obj_get_style_value(liste, LV_BTN_PART_MAIN, LV_STYLE_PAD_LEFT);
lv_obj_set_width(label, label->coords.x2 - liste->coords.x1 - pad);
}
else {
lv_coord_t pad = lv_obj_get_style_value(liste, LV_BTN_PART_MAIN, LV_STYLE_PAD_RIGHT);
lv_obj_set_width(label, liste->coords.x2 - label->coords.x1 - pad);
}
if(label_signal == NULL) label_signal = lv_obj_get_signal_cb(label);
lv_label_set_body_draw(label, true);
}
#if LV_USE_GROUP
/* If this is the first item to be added to the list and the list is
* focused, select it */
@@ -352,61 +327,6 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
#endif
/**
* Set a style of a list
* @param list pointer to a list object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, const lv_style_t * style)
{
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
lv_btn_style_t btn_style_refr = LV_BTN_STYLE_REL;
lv_obj_t * btn;
switch(type) {
case LV_LIST_STYLE_BG:
lv_page_set_style(list, LV_PAGE_STYLE_BG, style);
/*style change signal will call 'refr_btn_width' */
break;
case LV_LIST_STYLE_SCRL: lv_page_set_style(list, LV_PAGE_STYLE_SCRL, style); break;
case LV_LIST_STYLE_SB: lv_page_set_style(list, LV_PAGE_STYLE_SB, style); break;
case LV_LIST_STYLE_EDGE_FLASH: lv_page_set_style(list, LV_PAGE_STYLE_EDGE_FLASH, style); break;
case LV_LIST_STYLE_BTN_REL:
ext->styles_btn[LV_BTN_STATE_REL] = style;
btn_style_refr = LV_BTN_STYLE_REL;
break;
case LV_LIST_STYLE_BTN_PR:
ext->styles_btn[LV_BTN_STATE_PR] = style;
btn_style_refr = LV_BTN_STYLE_PR;
break;
case LV_LIST_STYLE_BTN_TGL_REL:
ext->styles_btn[LV_BTN_STATE_TGL_REL] = style;
btn_style_refr = LV_BTN_STYLE_TGL_REL;
break;
case LV_LIST_STYLE_BTN_TGL_PR:
ext->styles_btn[LV_BTN_STATE_TGL_PR] = style;
btn_style_refr = LV_BTN_STYLE_TGL_PR;
break;
case LV_LIST_STYLE_BTN_INA:
ext->styles_btn[LV_BTN_STATE_INA] = style;
btn_style_refr = LV_BTN_STYLE_INA;
break;
}
/*Refresh existing buttons' style*/
if(type == LV_LIST_STYLE_BTN_PR || type == LV_LIST_STYLE_BTN_REL || type == LV_LIST_STYLE_BTN_TGL_REL ||
type == LV_LIST_STYLE_BTN_TGL_PR || type == LV_LIST_STYLE_BTN_INA) {
btn = lv_list_get_prev_btn(list, NULL);
while(btn != NULL) {
lv_btn_set_style(btn, btn_style_refr, ext->styles_btn[btn_style_refr]);
btn = lv_list_get_prev_btn(list, btn);
}
}
}
/**
* Set layout of a list
* @param list pointer to a list object
@@ -642,35 +562,6 @@ lv_layout_t lv_list_get_layout(lv_obj_t * list)
return lv_page_get_scrl_layout(list);
}
/**
* Get a style of a list
* @param list pointer to a list object
* @param type which style should be get
* @return style pointer to a style
*/
const lv_style_t * lv_list_get_style(const lv_obj_t * list, lv_list_style_t type)
{
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
const lv_style_t * style = NULL;
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
switch(type) {
case LV_LIST_STYLE_BG: style = lv_page_get_style(list, LV_PAGE_STYLE_BG); break;
case LV_LIST_STYLE_SCRL: style = lv_page_get_style(list, LV_PAGE_STYLE_SCRL); break;
case LV_LIST_STYLE_SB: style = lv_page_get_style(list, LV_PAGE_STYLE_SB); break;
case LV_LIST_STYLE_EDGE_FLASH: style = lv_page_get_style(list, LV_PAGE_STYLE_EDGE_FLASH); break;
case LV_LIST_STYLE_BTN_REL: style = ext->styles_btn[LV_BTN_STATE_REL]; break;
case LV_LIST_STYLE_BTN_PR: style = ext->styles_btn[LV_BTN_STATE_PR]; break;
case LV_LIST_STYLE_BTN_TGL_REL: style = ext->styles_btn[LV_BTN_STATE_TGL_REL]; break;
case LV_LIST_STYLE_BTN_TGL_PR: style = ext->styles_btn[LV_BTN_STATE_TGL_PR]; break;
case LV_LIST_STYLE_BTN_INA: style = ext->styles_btn[LV_BTN_STATE_INA]; break;
default: style = NULL; break;
}
return style;
}
/*=====================
* Other functions
*====================*/
@@ -796,6 +687,12 @@ void lv_list_focus(const lv_obj_t * btn, lv_anim_enable_t anim)
static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
{
lv_res_t res;
if(sign == LV_SIGNAL_GET_STYLE) {
uint8_t ** type_p = param;
lv_style_dsc_t ** style_dsc_p = param;
*style_dsc_p = lv_list_get_style(list, **type_p);
return LV_RES_OK;
}
/* Include the ancient signal function */
res = ancestor_page_signal(list, sign, param);
@@ -950,7 +847,23 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, "");
if(sign == LV_SIGNAL_RELEASED) {
if((sign == LV_SIGNAL_COORD_CHG && (lv_obj_get_width(btn) != lv_area_get_width(param) || lv_obj_get_height(btn) != lv_area_get_height(param))) ||
sign == LV_SIGNAL_STYLE_CHG) {
lv_obj_t * label = lv_list_get_btn_label(btn);
if(label) {
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_PART_MAIN, LV_STYLE_FONT);
lv_coord_t font_h = lv_font_get_line_height(font);
if(lv_obj_get_base_dir(btn) == LV_BIDI_DIR_RTL) {
lv_coord_t pad = lv_obj_get_style_value(btn, LV_BTN_PART_MAIN, LV_STYLE_PAD_LEFT);
lv_obj_set_size(label, label->coords.x2 - btn->coords.x1 - pad, font_h);
}
else {
lv_coord_t pad = lv_obj_get_style_value(btn, LV_BTN_PART_MAIN, LV_STYLE_PAD_RIGHT);
lv_obj_set_size(label, btn->coords.x2 - label->coords.x1 - pad, font_h);
}
}
}
else if(sign == LV_SIGNAL_RELEASED) {
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
@@ -992,6 +905,42 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
return res;
}
/**
* Get the style descriptor of a part of the object
* @param list pointer the object
* @param part the part from `lv_page_list_t`. (LV_LIST_PART_...)
* @return pointer to the style descriptor of the specified part
*/
static lv_style_dsc_t * lv_list_get_style(lv_obj_t * list, uint8_t part)
{
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
lv_style_dsc_t * style_dsc_p;
switch(part) {
case LV_LIST_PART_BG:
style_dsc_p = &list->style_dsc;
break;
case LV_LIST_PART_SCRL:
style_dsc_p = &ext->page.scrl->style_dsc;
break;
case LV_LIST_PART_SCRLBAR:
style_dsc_p = &ext->page.sb.style;
break;
#if LV_USE_ANIMATION
case LV_PAGE_PART_EDGE_FLASH:
style_dsc_p = &ext->page.edge_flash.style;
break;
#endif
default:
style_dsc_p = NULL;
}
return style_dsc_p;
}
/**
* Make a single button selected in the list, deselect others.
* @param btn pointer to the currently pressed list btn object

View File

@@ -48,8 +48,6 @@ typedef struct
{
lv_page_ext_t page; /*Ext. of ancestor*/
/*New data for this type */
const lv_style_t * styles_btn[_LV_BTN_STATE_NUM]; /*Styles of the list element buttons*/
const lv_style_t * style_img; /*Style of the list element images on buttons*/
uint16_t size; /*the number of items(buttons) in the list*/
uint8_t single_mode : 1; /* whether single selected mode is enabled */
@@ -65,15 +63,10 @@ typedef struct
/** List styles. */
enum {
LV_LIST_STYLE_BG, /**< List background style */
LV_LIST_STYLE_SCRL, /**< List scrollable area style. */
LV_LIST_STYLE_SB, /**< List scrollbar style. */
LV_LIST_STYLE_EDGE_FLASH, /**< List edge flash style. */
LV_LIST_STYLE_BTN_REL, /**< Same meaning as the ordinary button styles. */
LV_LIST_STYLE_BTN_PR,
LV_LIST_STYLE_BTN_TGL_REL,
LV_LIST_STYLE_BTN_TGL_PR,
LV_LIST_STYLE_BTN_INA,
LV_LIST_PART_BG, /**< List background style */
LV_LIST_PART_SCRL, /**< List scrollable area style. */
LV_LIST_PART_SCRLBAR, /**< List scrollbar style. */
LV_LIST_PART_EDGE_FLASH, /**< List edge flash style. */
};
typedef uint8_t lv_list_style_t;
@@ -180,14 +173,6 @@ static inline void lv_list_set_anim_time(lv_obj_t * list, uint16_t anim_time)
lv_page_set_anim_time(list, anim_time);
}
/**
* Set a style of a list
* @param list pointer to a list object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, const lv_style_t * style);
/**
* Set layout of a list
* @param list pointer to a list object
@@ -312,14 +297,6 @@ static inline uint16_t lv_list_get_anim_time(const lv_obj_t * list)
return lv_page_get_anim_time(list);
}
/**
* Get a style of a list
* @param list pointer to a list object
* @param type which style should be get
* @return style pointer to a style
* */
const lv_style_t * lv_list_get_style(const lv_obj_t * list, lv_list_style_t type);
/*=====================
* Other functions
*====================*/

View File

@@ -822,7 +822,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
}
}
} else if(sign == LV_SIGNAL_STYLE_CHG) {
ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_COORD_CHG, &ext->scrl->coords);
lv_style_value_t sb_width = lv_obj_get_style_value(page, LV_PAGE_PART_SCRLBAR, LV_STYLE_SIZE);
lv_area_set_height(&ext->sb.hor_area, sb_width);
@@ -833,12 +833,12 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
/*Refresh the ext. size because the scrollbars might be positioned out of the page*/
lv_obj_refresh_ext_draw_pad(page);
} else if(sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_COORD_CHG) {
/*Refresh the scrollbar and notify the scrl if the size is changed*/
if(ext->scrl != NULL && (lv_obj_get_width(page) != lv_area_get_width(param) ||
lv_obj_get_height(page) != lv_area_get_height(param))) {
/*If no hor_fit enabled set the scrollable's width to the page's width*/
ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_COORD_CHG, &ext->scrl->coords);
/*The scrollbars are important only if they are visible now*/
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
@@ -905,7 +905,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
lv_obj_t * page = lv_obj_get_parent(scrl);
lv_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
if(sign == LV_SIGNAL_CORD_CHG) {
if(sign == LV_SIGNAL_COORD_CHG) {
/*Limit the position of the scrollable object to be always visible
* (Do not let its edge inner then its parent respective edge)*/
lv_coord_t new_x = lv_obj_get_x(scrl);

View File

@@ -405,7 +405,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
refr_height(roller);
refr_position(roller, false);
} else if(sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_COORD_CHG) {
if(lv_obj_get_width(roller) != lv_area_get_width(param) ||
lv_obj_get_height(roller) != lv_area_get_height(param)) {

View File

@@ -328,7 +328,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
}
#endif
} else if(sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_COORD_CHG) {
/* The knob size depends on slider size.
* During the drawing method the ext. size is used by the knob so refresh the ext. size.*/
if(lv_obj_get_width(slider) != lv_area_get_width(param) ||

View File

@@ -1328,9 +1328,7 @@ static lv_design_res_t lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t
cur_area.x2 += ext->label->coords.x1;
cur_area.y2 += ext->label->coords.y1;
if(ext->cursor.type == LV_CURSOR_LINE) {
lv_draw_line_dsc_t cur_line_dsc;
lv_draw_line_dsc_init(&cur_line_dsc);
lv_obj_init_draw_line_dsc(ta, LV_TA_PART_CURSOR, &cur_line_dsc);
@@ -1417,7 +1415,7 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
lv_label_set_text(ext->label, NULL);
refr_cursor_area(ta);
}
} else if(sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_COORD_CHG) {
/*Set the label width according to the text area width*/
if(ext->label) {
if(lv_obj_get_width(ta) != lv_area_get_width(param) || lv_obj_get_height(ta) != lv_area_get_height(param)) {
@@ -1516,7 +1514,7 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void
const lv_font_t * font = lv_obj_get_style_ptr(ta, LV_TA_PART_BG, LV_STYLE_FONT);
lv_coord_t font_h = lv_font_get_line_height(font);
scrl->ext_draw_pad = LV_MATH_MAX(scrl->ext_draw_pad, line_space + font_h);
} else if(sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_COORD_CHG) {
/*Set the label width according to the text area width*/
if(ext->label) {
if(lv_obj_get_width(scrl) != lv_area_get_width(param) ||

View File

@@ -606,7 +606,7 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
ext->content = NULL;
} else if(sign == LV_SIGNAL_STYLE_CHG) {
tabview_realign(tabview);
} else if(sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_COORD_CHG) {
if(ext->content != NULL && (lv_obj_get_width(tabview) != lv_area_get_width(param) ||
lv_obj_get_height(tabview) != lv_area_get_height(param))) {
tabview_realign(tabview);

View File

@@ -96,6 +96,13 @@ typedef enum {
LV_THEME_TA,
LV_THEME_TA_CURSOR,
LV_THEME_TA_SCRLBAR,
LV_THEME_LIST_BG,
LV_THEME_LIST_SCRL,
LV_THEME_LIST_SCRLBAR,
LV_THEME_LIST_EDGE_FLASH,
LV_THEME_LIST_BTN,
}lv_theme_style_t;
typedef struct {

View File

@@ -108,7 +108,11 @@ static void basic_init(void)
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_WHITE);
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_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_50);
@@ -495,41 +499,7 @@ static void spinbox_init(void)
static void list_init(void)
{
#if LV_USE_LIST != 0
static lv_style_t list_bg, list_rel, list_pr, list_trel, list_tpr, list_ina;
lv_style_copy(&list_rel, &def);
list_rel.body.opa = LV_OPA_TRANSP;
list_rel.body.border.width = 1;
list_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 50, 85);
list_rel.body.border.opa = LV_OPA_COVER;
list_rel.text.color = lv_color_hsv_to_rgb(_hue, 10, 94);
list_rel.text.font = _font;
list_rel.image.color = lv_color_hsv_to_rgb(_hue, 10, 94);
lv_style_copy(&list_pr, &list_rel);
list_pr.body.opa = LV_OPA_COVER;
list_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 34, 41);
list_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 34, 41);
list_pr.text.color = lv_color_hsv_to_rgb(_hue, 7, 96);
list_pr.image.color = lv_color_hsv_to_rgb(_hue, 7, 96);
lv_style_copy(&list_trel, &list_rel);
lv_style_copy(&list_tpr, &list_pr);
lv_style_copy(&list_ina, &def);
lv_style_copy(&list_bg, &list_rel);
list_bg.body.padding.left = 0;
list_bg.body.padding.right = 0;
list_bg.body.padding.top = 0;
list_bg.body.padding.bottom = 0;
theme.style.list.sb = &sb;
theme.style.list.bg = &list_bg;
theme.style.list.scrl = &lv_style_transp_tight;
theme.style.list.btn.rel = &list_rel;
theme.style.list.btn.pr = &list_pr;
theme.style.list.btn.tgl_rel = &list_trel;
theme.style.list.btn.tgl_pr = &list_tpr;
theme.style.list.btn.ina = &list_ina;
#endif
}
@@ -717,6 +687,8 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name)
return &gauge_strong;
case LV_THEME_TA_CURSOR:
return &ta_cursor;
case LV_THEME_LIST_BTN:
return &btn;
}
return NULL;