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

ddlist: fix label alignment after style change

This commit is contained in:
Gabor Kiss-Vamosi 2019-10-22 06:01:48 +02:00
parent c241905d88
commit cfddd8df65

View File

@ -662,6 +662,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
if(sign == LV_SIGNAL_STYLE_CHG) {
lv_ddlist_refr_size(ddlist, 0);
} else if(sign == LV_SIGNAL_CLEANUP) {
ext->label = NULL;
} else if(sign == LV_SIGNAL_FOCUS) {
@ -980,11 +981,19 @@ static void lv_ddlist_pos_current_option(lv_obj_t * ddlist)
*/
static void lv_ddlist_refr_width(lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
/*Set the TIGHT fit horizontally the set the width to the content*/
lv_page_set_scrl_fit2(ddlist, LV_FIT_TIGHT, lv_page_get_scrl_fit_bottom(ddlist));
/*Revert FILL fit to fill the parent with the options area. It allows to RIGHT/CENTER align the text*/
lv_page_set_scrl_fit2(ddlist, LV_FIT_FILL, lv_page_get_scrl_fit_bottom(ddlist));
switch(lv_label_get_align(ext->label)) {
case LV_LABEL_ALIGN_LEFT: lv_obj_align(ext->label, NULL, LV_ALIGN_IN_LEFT_MID, 0, 0); break;
case LV_LABEL_ALIGN_CENTER: lv_obj_align(ext->label, NULL, LV_ALIGN_CENTER, 0, 0); break;
case LV_LABEL_ALIGN_RIGHT: lv_obj_align(ext->label, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0); break;
}
}
#endif