dm_get_size is back, move style isolation to lv_obj_create from obj_x

This commit is contained in:
Kiss-Vamosi Gabor
2017-01-08 13:06:41 +01:00
parent 895e446c8e
commit b3706b0130
22 changed files with 95 additions and 165 deletions

View File

@@ -93,13 +93,8 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_btn);
}
return new_btn;
@@ -511,9 +506,9 @@ static void lv_btns_init(void)
lv_btns_border.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_BLACK;
lv_btns_border.bcolor[LV_BTN_STATE_INA] = COLOR_GRAY;
lv_btns_border.flags[LV_BTN_STATE_REL].empty = 1;
lv_btns_border.flags[LV_BTN_STATE_PR].empty = 1;
lv_btns_border.flags[LV_BTN_STATE_TGL_REL].empty = 1;
lv_btns_border.flags[LV_BTN_STATE_TGL_PR].empty = 1;
lv_btns_border.flags[LV_BTN_STATE_PR].empty = 0;
lv_btns_border.flags[LV_BTN_STATE_TGL_REL].empty = 0;
lv_btns_border.flags[LV_BTN_STATE_TGL_PR].empty = 0;
lv_btns_border.flags[LV_BTN_STATE_INA].empty = 1;
lv_btns_border.flags[LV_BTN_STATE_REL].light_en = 0;
lv_btns_border.flags[LV_BTN_STATE_PR].light_en = 0;

View File

@@ -88,13 +88,6 @@ 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));
}

View File

@@ -82,13 +82,8 @@ 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);
/*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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_cb);
}
lv_obj_align_us(new_cb, NULL, LV_ALIGN_CENTER, 0, 0);

View File

@@ -96,13 +96,8 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_chart);
}
return new_chart;

View File

@@ -81,13 +81,8 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_img);
}
return new_img;

View File

@@ -90,13 +90,8 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * 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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_label);
}
return new_label;
}

View File

@@ -79,13 +79,8 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_led);
}
return new_led;

View File

@@ -86,7 +86,8 @@ 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));
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_line);
}
return new_line;

View File

@@ -75,13 +75,8 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_list);
}
return new_list;

View File

@@ -93,13 +93,8 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_mbox);
}
lv_mbox_realign(new_mbox);

View File

@@ -80,13 +80,8 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy)
else {
lv_templ_ext_t * copy_ext = lv_obj_get_ext(copy);
/*Set the style of 'copy' and isolate it if it is necessary*/
if(lv_obj_get_style_iso(new_templ) == false) {
lv_obj_set_style(new_templ, lv_obj_get_style(copy));
} else {
lv_obj_set_style(new_templ, lv_obj_get_style(copy));
lv_obj_iso_style(new_templ, sizeof(lv_templs_t));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_templ);
}
return new_templ;

View File

@@ -82,7 +82,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_signal_f(ext->scrl, lv_scrl_signal);
lv_obj_set_drag(ext->scrl, true);
lv_obj_set_drag_throw(ext->scrl, true);
lv_obj_set_protect(ext->scrl, LV_OBJ_PROT_PARENT);
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT);
lv_rect_set_fit(ext->scrl, true, true);
lv_obj_set_style(ext->scrl, &pages->scrl_rects);
@@ -96,22 +96,16 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
ext->scrl = lv_rect_create(new_page, copy_ext->scrl);
lv_obj_set_signal_f(ext->scrl, lv_scrl_signal);
lv_page_set_pr_action(new_page, copy_ext->pr_action);
lv_page_set_rel_action(new_page, copy_ext->rel_action);
/* Add the signal function only if 'scrolling' is created
* 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_page_set_pr_action(new_page, copy_ext->pr_action);
lv_page_set_rel_action(new_page, copy_ext->rel_action);
/*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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_page);
}
lv_page_sb_refresh(new_page);
@@ -143,7 +137,7 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
case LV_SIGNAL_CHILD_CHG: /*Move children to the scrollable object*/
child = lv_obj_get_child(page, NULL);
while(child != NULL) {
if(lv_obj_is_protected(child, LV_OBJ_PROT_PARENT) == false) {
if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
lv_obj_t * tmp = child;
child = lv_obj_get_child(page, child); /*Get the next child before move this*/
lv_obj_set_parent(tmp, ext->scrl);

View File

@@ -97,13 +97,8 @@ lv_obj_t * lv_pb_create(lv_obj_t * par, lv_obj_t * copy)
ext->act_value = ext_copy->act_value;
ext->label = lv_label_create(new_pb, ext_copy->label);
/*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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_pb);
lv_pb_set_value(new_pb, ext->act_value);

View File

@@ -97,13 +97,8 @@ lv_obj_t * lv_rect_create(lv_obj_t * par, lv_obj_t * copy)
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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_rect);
}
@@ -430,17 +425,18 @@ static void lv_rect_layout_col(lv_obj_t * rect)
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
lv_obj_set_protect(rect, LV_OBJ_PROT_CHILD_CHG);
lv_obj_set_protect(rect, LV_PROTECT_CHILD_CHG);
/* Align the children */
cord_t last_cord = style->vpad;
LL_READ_BACK(rect->child_ll, child) {
if(lv_obj_get_hidden(child) != false) continue;
if(lv_obj_get_hidden(child) != false ||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
lv_obj_align(child, rect, align, hpad_corr , last_cord);
last_cord += lv_obj_get_height(child) + style->opad;
}
lv_obj_clr_protect(rect, LV_OBJ_PROT_CHILD_CHG);
lv_obj_clr_protect(rect, LV_PROTECT_CHILD_CHG);
}
/**
@@ -478,18 +474,19 @@ static void lv_rect_layout_row(lv_obj_t * rect)
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
lv_obj_set_protect(rect, LV_OBJ_PROT_CHILD_CHG);
lv_obj_set_protect(rect, LV_PROTECT_CHILD_CHG);
/* Align the children */
cord_t last_cord = style->hpad;
LL_READ_BACK(rect->child_ll, child) {
if(lv_obj_get_hidden(child) != false) continue;
if(lv_obj_get_hidden(child) != false ||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
lv_obj_align(child, rect, align, last_cord, vpad_corr);
last_cord += lv_obj_get_width(child) + style->opad;
}
lv_obj_clr_protect(rect, LV_OBJ_PROT_CHILD_CHG);
lv_obj_clr_protect(rect, LV_PROTECT_CHILD_CHG);
}
/**
@@ -514,18 +511,19 @@ static void lv_rect_layout_center(lv_obj_t * rect)
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
lv_obj_set_protect(rect, LV_OBJ_PROT_CHILD_CHG);
lv_obj_set_protect(rect, LV_PROTECT_CHILD_CHG);
/* Align the children */
cord_t last_cord = - (h_tot / 2);
LL_READ_BACK(rect->child_ll, child) {
if(lv_obj_get_hidden(child) != false) continue;
if(lv_obj_get_hidden(child) != false ||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
lv_obj_align(child, rect, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2);
last_cord += lv_obj_get_height(child) + style->opad;
}
lv_obj_clr_protect(rect, LV_OBJ_PROT_CHILD_CHG);
lv_obj_clr_protect(rect, LV_PROTECT_CHILD_CHG);
}
/**
@@ -547,7 +545,7 @@ static void lv_rect_layout_pretty(lv_obj_t * rect)
child_rs = ll_get_tail(&rect->child_ll); /*Set the row starter child*/
if(child_rs == NULL) return; /*Return if no child*/
lv_obj_set_protect(rect, LV_OBJ_PROT_CHILD_CHG);
lv_obj_set_protect(rect, LV_PROTECT_CHILD_CHG);
child_rc = child_rs; /*Initially the the row starter and closer is the same*/
while(child_rs != NULL) {
@@ -557,7 +555,8 @@ static void lv_rect_layout_pretty(lv_obj_t * rect)
/*Find the row closer object and collect some data*/
do {
if(lv_obj_get_hidden(child_rc) == false) {
if(lv_obj_get_hidden(child_rc) == false &&
lv_obj_is_protected(child_rc, LV_PROTECT_POS) == false) {
if(w_row + lv_obj_get_width(child_rc) > w_obj) break; /*If the next object is already not fit then break*/
w_row += lv_obj_get_width(child_rc) + style->opad; /*Add the object width + opad*/
h_row = max(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/
@@ -588,7 +587,8 @@ static void lv_rect_layout_pretty(lv_obj_t * rect)
cord_t act_x = style->hpad; /*x init*/
child_tmp = child_rs;
do{
if(lv_obj_get_hidden(child_tmp) == false) {
if(lv_obj_get_hidden(child_tmp) == false &&
lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) {
lv_obj_align(child_tmp, rect, LV_ALIGN_IN_TOP_LEFT, act_x, act_y);
act_x += lv_obj_get_width(child_tmp) + new_opad;
}
@@ -602,7 +602,7 @@ static void lv_rect_layout_pretty(lv_obj_t * rect)
child_rs = ll_get_prev(&rect->child_ll, child_rc); /*Go to the next object*/
child_rc = child_rs;
}
lv_obj_clr_protect(rect, LV_OBJ_PROT_CHILD_CHG);
lv_obj_clr_protect(rect, LV_PROTECT_CHILD_CHG);
}
/**
@@ -627,14 +627,15 @@ static void lv_rect_layout_grid(lv_obj_t * rect)
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
lv_obj_set_protect(rect, LV_OBJ_PROT_CHILD_CHG);
lv_obj_set_protect(rect, LV_PROTECT_CHILD_CHG);
/* Align the children */
cord_t act_x = style->hpad;
cord_t act_y = style->vpad;
uint16_t obj_cnt = 0;
LL_READ_BACK(rect->child_ll, child) {
if(lv_obj_get_hidden(child) != false) continue;
if(lv_obj_get_hidden(child) != false ||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
if(obj_row > 1) {
lv_obj_set_pos(child, act_x, act_y);
@@ -651,7 +652,7 @@ static void lv_rect_layout_grid(lv_obj_t * rect)
}
}
lv_obj_clr_protect(rect, LV_OBJ_PROT_CHILD_CHG);
lv_obj_clr_protect(rect, LV_PROTECT_CHILD_CHG);
}
/**

View File

@@ -100,13 +100,8 @@ 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);
/*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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_ta);
}
/*Create a cursor blinker animation*/

View File

@@ -79,7 +79,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
ext->header = lv_rect_create(new_win, NULL);
lv_rect_set_fit(ext->header, false, true);
/*Move back the header because it is automatically moved to the scrollable */
lv_obj_set_protect(ext->header, LV_OBJ_PROT_PARENT);
lv_obj_set_protect(ext->header, LV_PROTECT_PARENT);
lv_obj_set_parent(ext->header, new_win);
/*Create a title on the header*/
@@ -101,7 +101,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
/*Create the objects*/
ext->header = lv_rect_create(new_win, copy_ext->header);
/*Move back the header because it is automatically moved to the scrollable */
lv_obj_set_protect(ext->header, LV_OBJ_PROT_PARENT);
lv_obj_set_protect(ext->header, LV_PROTECT_PARENT);
lv_obj_set_parent(ext->header, new_win);
ext->title = lv_label_create(ext->header, copy_ext->title);
@@ -117,13 +117,8 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
child = lv_obj_get_child(copy_ext->ctrl_holder, child);
}
/*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));
}
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_win);
}
lv_win_realign(new_win);