minor fixes for objects

This commit is contained in:
Gabor Kiss-Vamosi
2017-12-03 00:35:39 +01:00
parent 596b15799d
commit 03d076197f
9 changed files with 35 additions and 7 deletions

View File

@@ -460,11 +460,15 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
res = ancestor_signal(ddlist, sign, param);
if(res != LV_RES_OK) return res;
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(sign == LV_SIGNAL_STYLE_CHG) {
lv_ddlist_refr_size(ddlist, 0);
}
else if(sign == LV_SIGNAL_CLEANUP) {
ext->label = NULL;
}
else if(sign == LV_SIGNAL_FOCUS) {
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->opened == false) {
ext->opened = true;
lv_ddlist_refr_size(ddlist, true);
@@ -522,13 +526,18 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void *
res = ancestor_scrl_signal(scrl, sign, param);
if(res != LV_RES_OK) return res;
lv_obj_t *ddlist = lv_obj_get_parent(scrl);
if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
/* Because of the wider selected rectangle ext. size
* In this way by dragging the scrollable part the wider rectangle area can be redrawn too*/
lv_obj_t *ddlist = lv_obj_get_parent(scrl);
lv_style_t *style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
if(scrl->ext_size < style->body.padding.hor) scrl->ext_size = style->body.padding.hor;
}
else if(sign == LV_SIGNAL_CLEANUP) {
lv_ddlist_ext_t *ext = lv_obj_get_ext_attr(ddlist);
ext->label = NULL; /*The label is already deleted*/
}
return res;
}

View File

@@ -123,7 +123,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
* @param needle_cnt new count of needles
* @param colors an array of colors for needles (with 'num' elements)
*/
void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, lv_color_t * colors)
void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t * colors)
{
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
if(ext->values != NULL) {

View File

@@ -67,7 +67,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy);
* @param needle_cnt new count of needles
* @param colors an array of colors for needles (with 'num' elements)
*/
void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, lv_color_t * colors);
void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t * colors);
/**
* Set the value of a needle

View File

@@ -165,8 +165,13 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
}
if(fn != NULL) {
ext->fn = lv_mem_realloc(ext->fn, strlen(fn) + 1);
strcpy(ext->fn, fn);
/* Don't refresh if set the the current 'fn'
* 'lv_mem_realloc' first allocates a new mem and then frees the old
* in this case it would free itself so it wouldn't be anything to 'strcpy' */
if(ext->fn != fn) {
ext->fn = lv_mem_realloc(ext->fn, strlen(fn) + 1);
strcpy(ext->fn, fn);
}
} else {
ext->fn = NULL;
}

View File

@@ -169,8 +169,9 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, l
lv_obj_set_width(liste, w);
#if USE_LV_IMG != 0
lv_obj_t * img = NULL;
if(img_fn != NULL && img_fn[0] != '\0') {
lv_obj_t * img = lv_img_create(liste, NULL);
img = lv_img_create(liste, NULL);
lv_img_set_file(img, img_fn);
lv_obj_set_style(img, ext->style_img);
lv_obj_set_click(img, false);

View File

@@ -315,6 +315,9 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
int32_t id = -1;
lv_obj_t * roller = lv_obj_get_parent(roller_scrl);
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
if(ext->ddlist.label == NULL) return LV_RES_INV; /*On delete the ddlist signal deletes the label so nothing left to do here*/
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
const lv_font_t * font = style_label->text.font;
lv_coord_t font_h = lv_font_get_height_scale(font);

View File

@@ -91,6 +91,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
ext->cursor.pos = 0;
ext->cursor.type = LV_CURSOR_LINE;
ext->cursor.valid_x = 0;
ext->one_line = 0;
ext->label = NULL;

View File

@@ -90,6 +90,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
ext->anim_time = LV_TABVIEW_ANIM_TIME;
ext->tab_name_ptr = lv_mem_alloc(sizeof(char*));
ext->tab_name_ptr[0] = "";
ext->tab_cnt = 0;
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_func(new_tabview, lv_tabview_signal);
@@ -503,6 +504,8 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
lv_mem_free(ext->tab_name_ptr);
ext->tab_name_ptr = NULL;
ext->btns = NULL; /*These objects were children so they are already invalid*/
ext->content= NULL;
}
else if(sign == LV_SIGNAL_CORD_CHG) {
if(ext->content != NULL &&

View File

@@ -448,6 +448,12 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param)
lv_win_realign(win);
}
}
else if(sign == LV_SIGNAL_CLEANUP) {
ext->header = NULL; /*These objects were children so they are already invalid*/
ext->page = NULL;
ext->title = NULL;
}
return res;
}