From cfddd8df65c7f8289ad667a389c88c2eabce969f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 22 Oct 2019 06:01:48 +0200 Subject: [PATCH] ddlist: fix label alignment after style change --- src/lv_objx/lv_ddlist.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lv_objx/lv_ddlist.c b/src/lv_objx/lv_ddlist.c index 46fed43c5..65c5eeba0 100644 --- a/src/lv_objx/lv_ddlist.c +++ b/src/lv_objx/lv_ddlist.c @@ -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