1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

ddlist label align fixes

This commit is contained in:
Gabor Kiss-Vamosi 2019-04-19 07:28:48 +02:00
parent 9fc1423ef7
commit 850693a840

View File

@ -177,11 +177,17 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options)
lv_label_set_text(ext->label, options); lv_label_set_text(ext->label, options);
/*Set the TIGHT fit horizontally the set the width the content*/ switch(lv_label_get_align(ext->label)) {
lv_page_set_scrl_fit2(ddlist, LV_FIT_TIGHT, LV_FIT_TIGHT); case LV_LABEL_ALIGN_LEFT:
lv_obj_align(ext->label, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
/*Revert FILL fit to fill the parent with the options area. It allows to RIGHT/CENTER align the text*/ break;
lv_page_set_scrl_fit2(ddlist, LV_FIT_FILL, LV_FIT_TIGHT); case LV_LABEL_ALIGN_CENTER:
lv_obj_align(ext->label, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
break;
case LV_LABEL_ALIGN_RIGHT:
lv_obj_align(ext->label, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
break;
}
lv_ddlist_refr_size(ddlist, false); lv_ddlist_refr_size(ddlist, false);
} }
@ -231,12 +237,6 @@ void lv_ddlist_set_fit(lv_obj_t * ddlist, lv_fit_t fit)
{ {
lv_cont_set_fit2(ddlist, fit, LV_FIT_NONE); lv_cont_set_fit2(ddlist, fit, LV_FIT_NONE);
if(fit == LV_FIT_NONE) {
lv_page_set_scrl_fit2(ddlist, LV_FIT_FLOOD, LV_FIT_NONE);
} else {
lv_page_set_scrl_fit2(ddlist, LV_FIT_TIGHT, LV_FIT_NONE);
}
lv_ddlist_refr_size(ddlist, false); lv_ddlist_refr_size(ddlist, false);
} }
@ -307,6 +307,18 @@ void lv_ddlist_set_align(lv_obj_t * ddlist, lv_label_align_t align)
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist); lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_label_set_align(ext->label, align); lv_label_set_align(ext->label, align);
switch(align) {
case LV_LABEL_ALIGN_LEFT:
lv_obj_align(ext->label, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
break;
case LV_LABEL_ALIGN_CENTER:
lv_obj_align(ext->label, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
break;
case LV_LABEL_ALIGN_RIGHT:
lv_obj_align(ext->label, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
break;
}
} }
/*===================== /*=====================
* Getter functions * Getter functions