1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

lv_page: refresh size according to vpad/hpad on STYLE_CHANGE

This commit is contained in:
Gabor Kiss-Vamosi 2017-10-09 16:11:54 +02:00
parent aea3154b3b
commit 577fc7b528
3 changed files with 28 additions and 22 deletions

View File

@ -116,24 +116,18 @@ bool lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
switch(sign) {
case LV_SIGNAL_STYLE_CHG: /*Recalculate the padding if the style changed*/
if(sign == LV_SIGNAL_STYLE_CHG) { /*Recalculate the padding if the style changed*/
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
break;
case LV_SIGNAL_CHILD_CHG:
} else if(sign == LV_SIGNAL_CHILD_CHG) {
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
break;
case LV_SIGNAL_CORD_CHG:
if(lv_obj_get_width(cont) != area_get_width(param) ||
lv_obj_get_height(cont) != area_get_height(param)) {
} else if(sign == LV_SIGNAL_CORD_CHG) {
if(lv_obj_get_width(cont) != area_get_width(param) ||
lv_obj_get_height(cont) != area_get_height(param)) {
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
}
break;
default:
break;
}
}

View File

@ -157,6 +157,8 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
lv_style_t * style = lv_obj_get_style(page);
if(lv_cont_get_hfit(ext->scrl) == false) {
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->hpad);
} else {
ext->scrl->signal_f(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->cords);
}
if(ext->sb_mode == LV_PAGE_SB_MODE_ON) {
@ -172,8 +174,8 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
lv_style_t * style = lv_obj_get_style(page);
/*Refresh the scrollbar and notify the scrl if the size is changed*/
if(ext->scrl != NULL &&
(lv_obj_get_width(page) != area_get_width(param) ||
lv_obj_get_height(page) != area_get_height(param))) {
(lv_obj_get_width(page) != area_get_width(param) ||
lv_obj_get_height(page) != area_get_height(param))) {
if(lv_cont_get_hfit(ext->scrl) == false) {
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->hpad);
@ -181,9 +183,9 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
ext->scrl->signal_f(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->cords);
/*The scrollbars are important olny if they are visible now*/
/*The scrollbars are important only if they are visible now*/
if(ext->sbh_draw != 0 || ext->sbv_draw != 0)
lv_page_sb_refresh(page);
lv_page_sb_refresh(page);
}
} else if(sign == LV_SIGNAL_PRESSED) {
@ -224,6 +226,12 @@ bool lv_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
lv_page_ext_t * page_ext = lv_obj_get_ext(page);
if(sign == LV_SIGNAL_CORD_CHG) {
/*Be sure the width of the scrollable is correct*/
if(lv_cont_get_hfit(scrl) == false) {
lv_obj_set_width(scrl, lv_obj_get_width(page) - 2 * page_style->hpad);
}
cord_t new_x;
cord_t new_y;
bool refr_x = false;
@ -278,10 +286,6 @@ bool lv_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
}
lv_page_sb_refresh(page);
} else if(sign == LV_SIGNAL_CORD_CHG) {
if(lv_cont_get_hfit(scrl) == false) {
lv_obj_set_width(scrl, lv_obj_get_width(page) - 2 * page_style->hpad);
}
} else if(sign == LV_SIGNAL_DRAG_BEGIN) {
if(page_ext->sb_mode == LV_PAGE_SB_MODE_DRAG ) {
cord_t sbh_pad = MATH_MAX(page_ext->sb_width, page_style->hpad);

View File

@ -172,9 +172,16 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
} else if(sign == LV_SIGNAL_STYLE_CHG) {
if(ext->label) {
lv_obj_t * scrl = lv_page_get_scrl(ta);
lv_style_t * style_ta = lv_obj_get_style(ta);
lv_style_t * style_scrl = lv_obj_get_style(scrl);
lv_obj_set_width(ext->label, lv_obj_get_width(scrl) - 2 * style_scrl->hpad);
lv_obj_set_pos(ext->label, style_scrl->hpad, style_scrl->vpad);
if(ext->one_line) { /*In one line mode refresh the Text Area height because 'vpad' can modify it*/
lv_style_t * style_label = lv_obj_get_style(ext->label);
cord_t font_h = font_get_height(style_label->font) >> FONT_ANTIALIAS;
lv_obj_set_height(ta, font_h + (style_ta->vpad + style_scrl->vpad) * 2);
} else { /*In not one line mode refresh the Label width because 'hpad' can modify it*/
lv_obj_set_width(ext->label, lv_obj_get_width(scrl) - 2 * style_scrl->hpad);
lv_obj_set_pos(ext->label, style_scrl->hpad, style_scrl->vpad); /*Be sure the Label is in the correct position*/
}
lv_label_set_text(ext->label, NULL);
lv_obj_refr_ext_size(lv_page_get_scrl(ta));
@ -669,12 +676,13 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
if(en != false) {
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
lv_style_t * style_ta = lv_obj_get_style(ta);
lv_style_t * style_scrl = lv_obj_get_style(lv_page_get_scrl(ta));
lv_style_t * style_label = lv_obj_get_style(ext->label);
cord_t font_h = font_get_height(style_label->font) >> FONT_ANTIALIAS;
ext->one_line = 1;
lv_cont_set_fit(lv_page_get_scrl(ta), true, true);
lv_obj_set_height(ta, font_h + style_ta->vpad * 2);
lv_obj_set_height(ta, font_h + (style_ta->vpad + style_scrl->vpad) * 2);
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_EXPAND);
lv_label_set_no_break(ext->label, true);
lv_obj_set_pos(lv_page_get_scrl(ta), style_ta->hpad, style_ta->vpad);