BigW Consortium Gitlab

Commit b23b9866 by Gabor

Compatibility with malloc/free/realloc wrappers

parent 3d399ad8
......@@ -83,7 +83,9 @@ static uint8_t mem_pct[LV_APP_SYSMON_PNUM];
static uint8_t cpu_pct[LV_APP_SYSMON_PNUM];
static lv_pbs_t cpu_pbs;
static lv_pbs_t mem_pbs;
#if USE_DYN_MEM != 0
static dm_mon_t mem_mon;
#endif
/**********************
* MACROS
......@@ -281,16 +283,21 @@ static void sysmon_task(void)
cpu_busy = 100 - idle_get();
#endif
uint8_t mem_used_pct = 0;
#if USE_DYN_MEM != 0
dm_monitor(&mem_mon);
uint8_t mem_free_pct = (uint32_t) ((DM_MEM_SIZE - mem_mon.size_free) * 100 ) / DM_MEM_SIZE;
mem_used_pct = (uint32_t) ((DM_MEM_SIZE - mem_mon.size_free) * 100 ) / DM_MEM_SIZE;
#endif
/*Add the CPU and memory data*/
cpu_pct[LV_APP_SYSMON_PNUM - 1] = cpu_busy;
mem_pct[LV_APP_SYSMON_PNUM - 1] = mem_free_pct;
mem_pct[LV_APP_SYSMON_PNUM - 1] = mem_used_pct;
/*Refresh the shortcuts and windows*/
lv_app_sysmon_refr();
#if USE_DYN_MEM != 0
/*Handle periodic defrag. if enabled*/
#if LV_APP_SYSMON_DEFRAG_PERIOD != 0
static uint32_t last_defrag = 0;
......@@ -320,6 +327,7 @@ static void sysmon_task(void)
}
if(mem_mon.pct_frag < LV_APP_SYSMON_FRAG_WARN) frag_warn_report = false;
#endif
}
/**
......@@ -327,19 +335,30 @@ static void sysmon_task(void)
*/
static void lv_app_sysmon_refr(void)
{
/*Create a long detailed string*/
char buf_long[256];
sprintf(buf_long, "CPU: %d %%\n\nMEMORY: %d %%\nTotal: %d bytes\nUsed: %d bytes\nFree: %d bytes\nFrag: %d %%",
cpu_pct[LV_APP_SYSMON_PNUM - 1],
char buf_short[128];
#if USE_IDLE != 0
sprintf(buf_long, "CPU: %d %%\n\n", cpu_pct[LV_APP_SYSMON_PNUM - 1]);
sprintf(buf_short, "CPU: %d %%\n", cpu_pct[LV_APP_SYSMON_PNUM - 1]);
#else
strcpy(buf_long, "CPU: N/A\n\n");
strcpy(buf_short, "CPU: N/A\n");
#endif
#if USE_DYN_MEM != 0
sprintf(buf_long, "%sMEMORY: %d %%\nTotal: %d bytes\nUsed: %d bytes\nFree: %d bytes\nFrag: %d %%",
buf_long,
mem_pct[LV_APP_SYSMON_PNUM - 1],
DM_MEM_SIZE,
DM_MEM_SIZE - mem_mon.size_free, mem_mon.size_free, mem_mon.pct_frag);
/*Create a short string*/
char buf_short[128];
sprintf(buf_short, "CPU: %d %%\nMem: %d %%\nFrag: %d %%",
cpu_pct[LV_APP_SYSMON_PNUM - 1], mem_pct[LV_APP_SYSMON_PNUM - 1], mem_mon.pct_frag);
sprintf(buf_short, "%sMem: %d %%\nFrag: %d %%",
buf_short, mem_pct[LV_APP_SYSMON_PNUM - 1], mem_mon.pct_frag);
#else
sprintf(buf_long, "%sMEMORY: N/A", buf_long);
sprintf(buf_short, "%sMem: N/A\nFrag: N/A", buf_short);
#endif
lv_app_style_t * app_style = lv_app_style_get();
cord_t opad = app_style->win_style.content.scrl_rects.opad;
lv_app_inst_t * app;
......
......@@ -129,6 +129,7 @@ static void my_app_run(lv_app_inst_t * app, const char * cstr, void * conf)
/*Initialize the application*/
my_app_data_t * app_data = app->app_data;
app_data->com_type = LV_APP_COM_TYPE_CHAR;
memset(app_data->txt, 0, sizeof(app_data->txt));;
}
/**
......
......@@ -261,9 +261,9 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
if(p1->x == p2->x && p1->y == p2->y) return;
cord_t dx = abs(p2->x - p1->x);
cord_t dx = MATH_ABS(p2->x - p1->x);
cord_t sx = p1->x < p2->x ? 1 : -1;
cord_t dy = abs(p2->y - p1->y);
cord_t dy = MATH_ABS(p2->y - p1->y);
cord_t sy = p1->y < p2->y ? 1 : -1;
cord_t err = (dx > dy ? dx : -dy) / 2;
cord_t e2;
......
......@@ -125,7 +125,7 @@ bool anim_del(void * var, anim_fp_t fp)
*/
uint16_t anim_speed_to_time(uint16_t speed, int32_t start, int32_t end)
{
int32_t d = abs((int32_t) start - end);
int32_t d = MATH_ABS((int32_t) start - end);
uint16_t time = (int32_t)((int32_t)(d * 1000) / speed);
if(time == 0) {
......
......@@ -376,8 +376,8 @@ static void dispi_drag(lv_dispi_t * dispi_p)
dispi_p->vect_sum.y += dispi_p->vect.y;
/*If a move is greater then LV_DRAG_LIMIT then begin the drag*/
if(abs(dispi_p->vect_sum.x) >= LV_DISPI_DRAG_LIMIT ||
abs(dispi_p->vect_sum.y) >= LV_DISPI_DRAG_LIMIT)
if(MATH_ABS(dispi_p->vect_sum.x) >= LV_DISPI_DRAG_LIMIT ||
MATH_ABS(dispi_p->vect_sum.y) >= LV_DISPI_DRAG_LIMIT)
{
dispi_p->drag_in_prog = 1;
drag_obj->signal_f(drag_obj,
......
......@@ -138,7 +138,7 @@ void lv_obj_inv(lv_obj_t * obj)
}
/**
* Notify an object if its style is modified
* Notify an object about its style is modified
* @param obj pointer to an object
*/
void lv_obj_refr_style(lv_obj_t * obj)
......@@ -206,6 +206,9 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
new_obj->style_iso = 0;
new_obj->hidden = 0;
new_obj->top_en = 0;
new_obj->child_chg_off = 0;
new_obj->opa_protect = 0;
new_obj->ext = NULL;
}
/*parent != NULL create normal obj. on a parent*/
......@@ -241,6 +244,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
new_obj->style_iso = 0;
new_obj->hidden = 0;
new_obj->top_en = 0;
new_obj->child_chg_off = 0;
new_obj->opa_protect = 0;
new_obj->ext = NULL;
......@@ -249,23 +254,27 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
if(copy != NULL) {
area_cpy(&new_obj->cords, &copy->cords);
new_obj->ext_size = copy->ext_size;
/*Set attributes*/
new_obj->opa = copy->opa;
/*Set attributes*/
new_obj->click_en = copy->click_en;
new_obj->drag_en = copy->drag_en;
new_obj->drag_throw_en = copy->drag_throw_en;
new_obj->drag_parent = copy->drag_parent;
new_obj->hidden = copy->hidden;
new_obj->style_iso = copy->style_iso;
new_obj->top_en = copy->top_en;
new_obj->opa_protect = copy->opa_protect;
new_obj->style_p = copy->style_p;
if(copy->style_iso != 0) {
lv_obj_iso_style(new_obj, dm_get_size(copy->style_p));
if(copy->style_iso == 0) {
new_obj->style_p = copy->style_p;
} else {
new_obj->style_p = dm_alloc(sizeof(lv_objs_t));
memcpy(new_obj->style_p, copy->style_p, sizeof(lv_objs_t));
}
lv_obj_set_pos(new_obj, lv_obj_get_x(copy), lv_obj_get_y(copy));
new_obj->opa = copy->opa;
}
......@@ -814,7 +823,8 @@ void lv_obj_set_style(lv_obj_t * obj, void * style)
obj->style_p = style;
/*Send a style change signal to the object*/
obj->signal_f(obj, LV_SIGNAL_STYLE_CHG, NULL);
lv_obj_refr_style(obj);
lv_obj_inv(obj);
}
......@@ -1353,6 +1363,16 @@ bool lv_obj_get_drag_parent(lv_obj_t * obj)
}
/**
* Get the style isolation attribute of an object
* @param obj pointer to an object
* @return pointer to a style
*/
bool lv_obj_get_style_iso(lv_obj_t * obj)
{
return obj->style_iso == 0 ? false : true;
}
/**
* Get the opa_protect attribute of an object
* @param obj pointer to an object
* @return true: opa_protect is enabled
......
......@@ -241,6 +241,7 @@ bool lv_obj_get_top(lv_obj_t * obj);
bool lv_obj_get_drag(lv_obj_t * obj);
bool lv_obj_get_drag_throw(lv_obj_t * obj);
bool lv_obj_get_drag_parent(lv_obj_t * obj);
bool lv_obj_get_style_iso(lv_obj_t * obj);
bool lv_obj_get_opa_potect(lv_obj_t * obj);
/*Virtual functions get*/
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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*/
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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*/
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment