Compatibility with malloc/free/realloc wrappers

This commit is contained in:
Gabor
2017-01-02 14:10:32 +01:00
parent 3d399ad842
commit b23b986683
22 changed files with 293 additions and 143 deletions

View File

@@ -61,42 +61,47 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_t * new_btn;
new_btn = lv_rect_create(par, copy);
dm_assert(new_btn);
/*Allocate the extended data*/
lv_obj_alloc_ext(new_btn, sizeof(lv_btn_ext_t));
lv_btn_ext_t * ext = lv_obj_alloc_ext(new_btn, sizeof(lv_btn_ext_t));
dm_assert(ext);
ext->state = LV_BTN_STATE_REL;
ext->pr_action = NULL;
ext->rel_action = NULL;
ext->lpr_action = NULL;
ext->lpr_rep_action = NULL;
ext->lpr_exec = 0;
ext->tgl = 0;
if(ancestor_design_f == NULL) {
ancestor_design_f = lv_obj_get_design_f(new_btn);
}
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_btn);
lv_obj_set_signal_f(new_btn, lv_btn_signal);
lv_obj_set_design_f(new_btn, lv_btn_design);
lv_btn_ext_t * ext = lv_obj_get_ext(new_btn);
ext->lpr_exec = 0;
/*If no copy do the basic initialization*/
if(copy == NULL)
{
ext->state = LV_BTN_STATE_REL;
ext->pr_action = NULL;
ext->rel_action = NULL;
ext->lpr_action = NULL;
ext->tgl = 0;
if(copy == NULL) {
lv_rect_set_layout(new_btn, LV_RECT_LAYOUT_CENTER);
lv_obj_set_style(new_btn, lv_btns_get(LV_BTNS_DEF, NULL));
}
/*Copy 'copy'*/
else{
lv_btn_ext_t * ori_btn_ext = lv_obj_get_ext(copy);
ext->state = ori_btn_ext->state;
ext->pr_action = ori_btn_ext->pr_action;
ext->rel_action = ori_btn_ext->rel_action;
ext->lpr_action = ori_btn_ext->lpr_action;
ext->tgl = ori_btn_ext->tgl;
else {
lv_btn_ext_t * copy_ext = lv_obj_get_ext(copy);
ext->state = copy_ext->state;
ext->pr_action = copy_ext->pr_action;
ext->rel_action = copy_ext->rel_action;
ext->lpr_action = copy_ext->lpr_action;
ext->lpr_rep_action = copy_ext->lpr_action;
ext->tgl = copy_ext->tgl;
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_btn) == false) {
lv_obj_set_style(new_btn, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_btn, lv_obj_get_style(copy));
lv_obj_iso_style(new_btn, sizeof(lv_btns_t));
}
}
lv_obj_set_style(new_btn, lv_btns_get(LV_BTNS_DEF, NULL));
return new_btn;
}
@@ -106,7 +111,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void* param)
bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
{
bool valid;
@@ -144,6 +149,7 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void* param)
lv_obj_inv(btn);
break;
case LV_SIGNAL_PRESSING:
/*When the button begins to drag revert pressed states to released*/
if(lv_dispi_is_dragging(param) != false) {
if(ext->state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
else if(ext->state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);

View File

@@ -68,14 +68,17 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_btnm_ext_t * ext = lv_obj_alloc_ext(new_btnm, sizeof(lv_btnm_ext_t));
dm_assert(ext);
ext->btn_cnt = 0;
ext->btn_pr = LV_BTNM_BTN_PR_INVALID;
ext->btn_areas = NULL;
ext->cb = NULL;
ext->map_p = NULL;
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_btnm);
lv_obj_set_signal_f(new_btnm, lv_btnm_signal);
lv_obj_set_design_f(new_btnm, lv_btnm_design);
ext->btn_cnt = 0;
ext->btn_pr = LV_BTNM_BTN_PR_INVALID;
/*Init the new button matrix object*/
if(copy == NULL) {
@@ -85,7 +88,14 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
}
/*Copy an existing object*/
else {
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_btnm) == false) {
lv_obj_set_style(new_btnm, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_btnm, lv_obj_get_style(copy));
lv_obj_iso_style(new_btnm, sizeof(lv_btnms_t));
}
lv_btnm_set_map(new_btnm, lv_btnm_get_map(copy));
}
return new_btnm;

View File

@@ -58,6 +58,8 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
lv_cb_ext_t * ext = lv_obj_alloc_ext(new_cb, sizeof(lv_cb_ext_t));
dm_assert(ext);
ext->bullet = NULL;
ext->label = NULL;
lv_obj_set_signal_f(new_cb, lv_cb_signal);
@@ -79,7 +81,13 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
ext->bullet = lv_btn_create(new_cb, copy_ext->bullet);
ext->label = lv_label_create(new_cb, copy_ext->label);
lv_obj_set_style(new_cb, lv_obj_get_style(copy));
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_cb) == false) {
lv_obj_set_style(new_cb, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_cb, lv_obj_get_style(copy));
lv_obj_iso_style(new_cb, sizeof(lv_cbs_t));
}
}
lv_obj_align_us(new_cb, NULL, LV_ALIGN_CENTER, 0, 0);

View File

@@ -41,7 +41,7 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask);
**********************/
static lv_charts_t lv_charts_def;
static lv_charts_t lv_charts_transp;
static lv_design_f_t ancestor_design_fp;
static lv_design_f_t ancestor_design_f;
/**********************
* MACROS
@@ -70,26 +70,23 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_chart_ext_t * ext = lv_obj_alloc_ext(new_chart, sizeof(lv_chart_ext_t));
dm_assert(ext);
if(ancestor_design_fp == NULL) {
ancestor_design_fp = lv_obj_get_design_f(new_chart);
}
ll_init(&ext->dl_ll, sizeof(cord_t *));
ext->dl_num = 0;
ext->ymin = LV_CHART_YMIN_DEF;
ext->ymax = LV_CHART_YMAX_DEF;
ext->hdiv_num = LV_CHART_HDIV_DEF;
ext->vdiv_num = LV_CHART_VDIV_DEF;
ext->pnum = LV_CHART_PNUM_DEF;
ext->type = LV_CHART_LINE;
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_chart);
lv_obj_set_signal_f(new_chart, lv_chart_signal);
lv_obj_set_design_f(new_chart, lv_chart_design);
/*Init the new chart background object*/
if(copy == NULL) {
ext->type = LV_CHART_LINE;
lv_obj_set_style(new_chart, lv_charts_get(LV_CHARTS_DEF, NULL));
ext->ymin = LV_CHART_YMIN_DEF;
ext->ymax = LV_CHART_YMAX_DEF;
ext->hdiv_num = LV_CHART_HDIV_DEF;
ext->vdiv_num = LV_CHART_VDIV_DEF;
ext->pnum = LV_CHART_PNUM_DEF;
} else {
lv_chart_ext_t * ext_copy = lv_obj_get_ext(copy);
ext->type = ext_copy->type;
@@ -98,6 +95,14 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
ext->hdiv_num = ext_copy->hdiv_num;
ext->vdiv_num = ext_copy->vdiv_num;
ext->pnum = ext_copy->pnum;
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_chart) == false) {
lv_obj_set_style(new_chart, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_chart, lv_obj_get_style(copy));
lv_obj_iso_style(new_chart, sizeof(lv_charts_t));
}
}
return new_chart;
@@ -348,10 +353,10 @@ static bool lv_chart_design(lv_obj_t * chart, const area_t * mask, lv_design_mod
{
if(mode == LV_DESIGN_COVER_CHK) {
/*Return false if the object is not covers the mask_p area*/
return ancestor_design_fp(chart, mask, mode);
return ancestor_design_f(chart, mask, mode);
} else if(mode == LV_DESIGN_DRAW_MAIN) {
/*Draw the rectangle ancient*/
ancestor_design_fp(chart, mask, mode);
ancestor_design_f(chart, mask, mode);
/*Draw the object*/

View File

@@ -56,32 +56,38 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
/*Create a basic object*/
new_img = lv_obj_create(par, copy);
dm_assert(new_img);
/*Extend the basic object to image object*/
lv_obj_alloc_ext(new_img, sizeof(lv_img_ext_t));
lv_img_ext_t * ext = lv_obj_alloc_ext(new_img, sizeof(lv_img_ext_t));
dm_assert(ext);
ext->fn = NULL;
ext->w = lv_obj_get_width(new_img);
ext->h = lv_obj_get_height(new_img);
ext->transp = 0;
/*Init the new object*/
lv_obj_set_signal_f(new_img, lv_img_signal);
lv_obj_set_design_f(new_img, lv_img_design);
lv_img_ext_t * img_ext = lv_obj_get_ext(new_img);
if(copy == NULL) {
img_ext->fn = NULL;
img_ext->w = lv_obj_get_width(new_img);
img_ext->h = lv_obj_get_height(new_img);
img_ext->transp = 0;
/*Enable auto size for non screens*/
if(par != NULL) {
img_ext->auto_size = 1;
} else {
img_ext->auto_size = 0;
}
/* Enable auto size for non screens
* because image screens are wallpapers
* and must be screen sized*/
if(par != NULL) ext->auto_size = 1;
else ext->auto_size = 0;
lv_obj_set_style(new_img, lv_imgs_get(LV_IMGS_DEF, NULL));
} else {
img_ext->auto_size = LV_EA(copy, lv_img_ext_t)->auto_size;
ext->auto_size = lv_img_get_auto_size(copy);
lv_img_set_file(new_img, LV_EA(copy, lv_img_ext_t)->fn);
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_img) == false) {
lv_obj_set_style(new_img, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_img, lv_obj_get_style(copy));
lv_obj_iso_style(new_img, sizeof(lv_imgs_t));
}
}
return new_img;

View File

@@ -66,14 +66,17 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_alloc_ext(new_label, sizeof(lv_label_ext_t));
lv_label_ext_t * ext = lv_obj_get_ext(new_label);
dm_assert(ext);
ext->txt = NULL;
ext->static_txt = 0;
ext->dot_end = LV_LABEL_DOT_END_INV;
ext->long_mode = LV_LABEL_LONG_EXPAND;
lv_obj_set_design_f(new_label, lv_label_design);
lv_obj_set_signal_f(new_label, lv_label_signal);
/*Init the new label*/
if(copy == NULL) {
ext->dot_end = LV_LABEL_DOT_END_INV;
lv_obj_set_opa(new_label, OPA_COVER);
lv_obj_set_click(new_label, false);
lv_obj_set_style(new_label, lv_labels_get(LV_LABELS_DEF, NULL));
@@ -83,9 +86,17 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
/*Copy 'copy' if not NULL*/
else {
lv_label_ext_t * copy_ext = lv_obj_get_ext(copy);
lv_label_set_long_mode(new_label, lv_label_get_long_mode(copy));
if(copy_ext->static_txt == 0) lv_label_set_text(new_label, lv_label_get_text(copy));
else lv_label_set_text_static(new_label, lv_label_get_text(copy));
lv_label_set_long_mode(new_label, lv_label_get_long_mode(copy));
if(copy_ext->static_txt == 0) lv_label_set_text(new_label, lv_label_get_text(copy));
else lv_label_set_text_static(new_label, lv_label_get_text(copy));
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_label) == false) {
lv_obj_set_style(new_label, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_label, lv_obj_get_style(copy));
lv_obj_iso_style(new_label, sizeof(lv_labels_t));
}
}
return new_label;
}

View File

@@ -64,13 +64,13 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_led_ext_t * ext = lv_obj_alloc_ext(new_led, sizeof(lv_led_ext_t));
dm_assert(ext);
ext->bright = LV_LED_BRIGHTNESS_DEF;
lv_obj_set_signal_f(new_led, lv_led_signal);
lv_obj_set_design_f(new_led, lv_led_design);
/*Init the new led object*/
if(copy == NULL) {
ext->bright = LV_LED_BRIGHTNESS_DEF;
lv_obj_set_style(new_led, lv_leds_get(LV_LEDS_DEF, NULL));
lv_obj_set_size_us(new_led, 40, 40);
}
@@ -78,6 +78,14 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
else {
lv_led_ext_t * copy_ext = lv_obj_get_ext(copy);
ext->bright = copy_ext->bright;
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_led) == false) {
lv_obj_set_style(new_led, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_led, lv_obj_get_style(copy));
lv_obj_iso_style(new_led, sizeof(lv_leds_t));
}
}
return new_led;

View File

@@ -64,16 +64,18 @@ lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy)
/*Extend the basic object to rectangle object*/
lv_line_ext_t * ext = lv_obj_alloc_ext(new_line, sizeof(lv_line_ext_t));
dm_assert(ext);
ext->point_num = 0;
ext->point_array = NULL;
ext->auto_size = 1;
ext->y_inv = 0;
ext->upscale = 0;
lv_obj_set_design_f(new_line, lv_line_design);
lv_obj_set_signal_f(new_line, lv_line_signal);
/*Init the new rectangle*/
if(copy == NULL) {
ext->point_num = 0;
ext->point_array = NULL;
ext->auto_size = 1;
ext->y_inv = 0;
ext->upscale = 0;
lv_obj_set_style(new_line, lv_lines_get(LV_LINES_DEF, NULL));
}
/*Copy an existing object*/
@@ -84,9 +86,9 @@ lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy)
lv_line_set_upscale(new_line,lv_line_get_upscale(copy));
lv_line_set_points(new_line, LV_EA(copy, lv_line_ext_t)->point_array,
LV_EA(copy, lv_line_ext_t)->point_num);
lv_obj_set_style(new_line, lv_obj_get_style(copy));
}
return new_line;
}

View File

@@ -61,18 +61,27 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_t * new_list = lv_page_create(par, copy);
dm_assert(new_list);
lv_list_ext_t * ext = lv_obj_alloc_ext(new_list, sizeof(lv_list_ext_t));
dm_assert(ext);
ext ->fit = LV_LIST_FIT_WIDTH;
lv_obj_set_signal_f(new_list, lv_list_signal);
/*Init the new list object*/
if(copy == NULL) {
ext ->fit = LV_LIST_FIT_WIDTH;
lv_obj_set_size_us(new_list, 120, 150);
lv_obj_set_style(new_list, lv_lists_get(LV_LISTS_DEF, NULL));
lv_rect_set_layout(LV_EA(new_list, lv_list_ext_t)->page_ext.scrl, LV_LIST_LAYOUT_DEF);
} else {
lv_list_ext_t * copy_ext = lv_obj_get_ext(copy);
ext ->fit = copy_ext->fit;
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_list) == false) {
lv_obj_set_style(new_list, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_list, lv_obj_get_style(copy));
lv_obj_iso_style(new_list, sizeof(lv_lists_t));
}
}
return new_list;

View File

@@ -62,13 +62,13 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
/*Allocate the message box type specific extended data*/
lv_mbox_ext_t * ext = lv_obj_alloc_ext(new_mbox, sizeof(lv_mbox_ext_t));
dm_assert(ext);
ext->txt = NULL;
ext->title = NULL;
ext->btnh = NULL;
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_f(new_mbox, lv_mbox_signal);
/* Let the design function of rect
lv_obj_set_design_f(new_mbox, lv_mbox_design); */
/*Init the new message box message box*/
if(copy == NULL) {
lv_rect_set_layout(new_mbox, LV_RECT_LAYOUT_COL_L);
@@ -85,15 +85,25 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
lv_rect_set_layout(ext->btnh, LV_RECT_LAYOUT_PRETTY);
lv_obj_set_style(new_mbox, lv_mboxs_get(LV_MBOXS_DEF, NULL));
lv_mbox_realign(new_mbox);
}
/*Copy an existing message box*/
else {
// lv_mbox_ext_t * copy_ext = lv_obj_get_ext(copy);
/*TODO*/
lv_mbox_ext_t * copy_ext = lv_obj_get_ext(copy);
ext->title = lv_label_create(new_mbox, copy_ext->title);
ext->txt = lv_label_create(new_mbox, copy_ext->txt);
ext->btnh = lv_rect_create(new_mbox, copy_ext->btnh);
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_mbox) == false) {
lv_obj_set_style(new_mbox, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_mbox, lv_obj_get_style(copy));
lv_obj_iso_style(new_mbox, sizeof(lv_mboxs_t));
}
}
lv_mbox_realign(new_mbox);
return new_mbox;
}

View File

@@ -67,10 +67,13 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_page_ext_t * ext = lv_obj_alloc_ext(new_page, sizeof(lv_page_ext_t));
dm_assert(ext);
ext->scrl = NULL;
ext->pr_action = NULL;
ext->rel_action = NULL;
ext->sbh_draw = 0;
ext->sbv_draw = 0;
if(ancestor_design_f == NULL) {
ancestor_design_f = lv_obj_get_design_f(new_page);
}
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_page);
/*Init the new page object*/
if(copy == NULL) {
@@ -96,7 +99,14 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
* because everything has to be ready before any signal is received*/
lv_obj_set_signal_f(new_page, lv_page_signal);
lv_obj_set_design_f(new_page, lv_page_design);
lv_obj_set_style(new_page, lv_obj_get_style(copy));
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_page) == false) {
lv_obj_set_style(new_page, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_page, lv_obj_get_style(copy));
lv_obj_iso_style(new_page, sizeof(lv_pages_t));
}
}
lv_page_sb_refresh(new_page);

View File

@@ -35,7 +35,7 @@ static void lv_pbs_init(void);
* STATIC VARIABLES
**********************/
static lv_pbs_t lv_pbs_def;
static lv_design_f_t ancestor_design_fp;
static lv_design_f_t ancestor_design_f;
/**********************
* MACROS
@@ -64,12 +64,15 @@ lv_obj_t * lv_pb_create(lv_obj_t * par, lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_pb_ext_t * ext = lv_obj_alloc_ext(new_pb, sizeof(lv_pb_ext_t));
dm_assert(ext);
ext->min_value = 0;
ext->max_value = 100;
ext->act_value = 0;
ext->format_str = NULL;
ext->label = NULL;
/* Save the rectangle design function.
* It will be used in the progress bar design function*/
if(ancestor_design_fp == NULL) {
ancestor_design_fp = lv_obj_get_design_f(new_pb);
}
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_pb);
lv_obj_set_signal_f(new_pb, lv_pb_signal);
lv_obj_set_design_f(new_pb, lv_pb_design);
@@ -78,9 +81,6 @@ lv_obj_t * lv_pb_create(lv_obj_t * par, lv_obj_t * copy)
if(copy == NULL) {
ext->format_str = dm_alloc(strlen(LV_PB_DEF_FORMAT) + 1);
strcpy(ext->format_str, LV_PB_DEF_FORMAT);
ext->min_value = 0;
ext->max_value = 100;
ext->act_value = 0;
ext->label = lv_label_create(new_pb, NULL);
@@ -95,10 +95,15 @@ lv_obj_t * lv_pb_create(lv_obj_t * par, lv_obj_t * copy)
ext->min_value = ext_copy->min_value;
ext->max_value = ext_copy->max_value;
ext->act_value = ext_copy->act_value;
ext->label = lv_label_create(new_pb, ext_copy->label);
lv_obj_set_style(new_pb, lv_obj_get_style(copy));
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_pb) == false) {
lv_obj_set_style(new_pb, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_pb, lv_obj_get_style(copy));
lv_obj_iso_style(new_pb, sizeof(lv_pbs_t));
}
lv_pb_set_value(new_pb, ext->act_value);
@@ -264,13 +269,13 @@ lv_pbs_t * lv_pbs_get(lv_pbs_builtin_t style, lv_pbs_t * copy)
*/
static bool lv_pb_design(lv_obj_t * pb, const area_t * mask, lv_design_mode_t mode)
{
if(ancestor_design_fp == NULL) return false;
if(ancestor_design_f == NULL) return false;
if(mode == LV_DESIGN_COVER_CHK) {
/*Return false if the object is not covers the mask_p area*/
return ancestor_design_fp(pb, mask, mode);
return ancestor_design_f(pb, mask, mode);
} else if(mode == LV_DESIGN_DRAW_MAIN) {
ancestor_design_fp(pb, mask, mode);
ancestor_design_f(pb, mask, mode);
lv_pb_ext_t * ext = lv_obj_get_ext(pb);
area_t bar_area;

View File

@@ -77,22 +77,34 @@ lv_obj_t * lv_rect_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_t * new_rect = lv_obj_create(par, copy);
dm_assert(new_rect);
lv_obj_alloc_ext(new_rect, sizeof(lv_rect_ext_t));
lv_rect_ext_t * rect_ext = lv_obj_get_ext(new_rect);
lv_rect_ext_t * ext = lv_obj_get_ext(new_rect);
dm_assert(ext);
ext->hfit_en = 0;
ext->vfit_en = 0;
ext->layout = LV_RECT_LAYOUT_OFF;
lv_obj_set_design_f(new_rect, lv_rect_design);
lv_obj_set_signal_f(new_rect, lv_rect_signal);
/*Init the new rectangle*/
if(copy == NULL) {
lv_obj_set_style(new_rect, lv_rects_get(LV_RECTS_DEF, NULL));
rect_ext->hfit_en = 0;
rect_ext->vfit_en = 0;
}
/*Copy an existing object*/
else {
lv_rect_ext_t * copy_ext = lv_obj_get_ext(copy);
rect_ext->hfit_en = copy_ext->hfit_en;
rect_ext->vfit_en = copy_ext->vfit_en;
rect_ext->layout = copy_ext->layout;
ext->hfit_en = copy_ext->hfit_en;
ext->vfit_en = copy_ext->vfit_en;
ext->layout = copy_ext->layout;
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_rect) == false) {
lv_obj_set_style(new_rect, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_rect, lv_obj_get_style(copy));
lv_obj_iso_style(new_rect, sizeof(lv_rects_t));
}
}
return new_rect;

View File

@@ -68,24 +68,20 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_ta_ext_t * ext = lv_obj_alloc_ext(new_ta, sizeof(lv_ta_ext_t));
dm_assert(ext);
ext->cur_hide = 0;
ext->cursor_pos = 0;
ext->cursor_valid_x = 0;
ext->label = NULL;
if(ancestor_design_f == NULL) {
ancestor_design_f = lv_obj_get_design_f(new_ta);
}
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_ta);
if(scrl_design_f == NULL) scrl_design_f = lv_obj_get_design_f(ext->page.scrl);
lv_obj_set_signal_f(new_ta, lv_ta_signal);
lv_obj_set_design_f(new_ta, lv_ta_design);
ext->cursor_valid_x = 0;
ext->cursor_pos = 0;
ext->cur_hide = 0;
/*Init the new text area object*/
if(copy == NULL) {
ext->label = lv_label_create(new_ta, NULL);
if(scrl_design_f == NULL) {
scrl_design_f = lv_obj_get_design_f(ext->page.scrl);
}
lv_obj_set_design_f(ext->page.scrl, lv_ta_scrling_design);
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
@@ -102,8 +98,13 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
ext->label = lv_label_create(new_ta, copy_ext->label);
lv_page_glue_obj(ext->label, true);
/*Refresh the style when everything is ready*/
lv_obj_set_style(new_ta, lv_obj_get_style(copy));
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_ta) == false) {
lv_obj_set_style(new_ta, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_ta, lv_obj_get_style(copy));
lv_obj_iso_style(new_ta, sizeof(lv_rects_t));
}
}
/*Create a cursor blinker animation*/

View File

@@ -63,13 +63,13 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_win_ext_t * ext = lv_obj_alloc_ext(new_win, sizeof(lv_win_ext_t));
dm_assert(ext);
ext->content = NULL;
ext->ctrl_holder = NULL;
ext->header = NULL;
ext->title = NULL;
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_f(new_win, lv_win_signal);
/* The design function is not changed
lv_obj_set_design_f(new_obj, lv_win_design); */
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
/*Init the new window object*/
if(copy == NULL) {
@@ -91,7 +91,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_style(new_win, lv_wins_get(LV_WINS_DEF, NULL));
lv_win_realign(new_win);
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
}
/*Copy an existing object*/
else {
@@ -112,11 +112,17 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
child = lv_obj_get_child(copy_ext->ctrl_holder, child);
}
lv_obj_set_style(new_win, lv_obj_get_style(copy));
lv_win_realign(new_win);
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_win) == false) {
lv_obj_set_style(new_win, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_win, lv_obj_get_style(copy));
lv_obj_iso_style(new_win, sizeof(lv_wins_t));
}
}
lv_win_realign(new_win);
return new_win;
}