mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
ddlist: fiy scrollable width
This commit is contained in:
parent
755f68c87b
commit
b5898a750e
@ -43,6 +43,7 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void *
|
||||
static lv_res_t release_handler(lv_obj_t * ddlist);
|
||||
static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en);
|
||||
static void lv_ddlist_pos_current_option(lv_obj_t * ddlist);
|
||||
static void lv_ddlist_refr_width(lv_obj_t* ddlist);
|
||||
static void lv_ddlist_anim_cb(lv_obj_t * ddlist);
|
||||
static void lv_ddlist_adjust_height(lv_obj_t * ddlist, int32_t height);
|
||||
|
||||
@ -177,6 +178,8 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options)
|
||||
|
||||
lv_label_set_text(ext->label, options);
|
||||
|
||||
lv_ddlist_refr_width(ddlist);
|
||||
|
||||
switch(lv_label_get_align(ext->label)) {
|
||||
case LV_LABEL_ALIGN_LEFT:
|
||||
lv_obj_align(ext->label, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||
@ -292,7 +295,10 @@ void lv_ddlist_set_style(lv_obj_t * ddlist, lv_ddlist_style_t type, const lv_sty
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
switch(type) {
|
||||
case LV_DDLIST_STYLE_BG: lv_page_set_style(ddlist, LV_PAGE_STYLE_BG, style); break;
|
||||
case LV_DDLIST_STYLE_BG:
|
||||
lv_page_set_style(ddlist, LV_PAGE_STYLE_BG, style);
|
||||
lv_ddlist_refr_width(ddlist);
|
||||
break;
|
||||
case LV_DDLIST_STYLE_SB: lv_page_set_style(ddlist, LV_PAGE_STYLE_SB, style); break;
|
||||
case LV_DDLIST_STYLE_SEL:
|
||||
ext->sel_style = style;
|
||||
@ -937,4 +943,17 @@ static void lv_ddlist_pos_current_option(lv_obj_t * ddlist)
|
||||
lv_obj_set_y(scrl, -line_y1 + (h - font_h) / 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Be sure the width of the scrollable exactly fits the ddlist
|
||||
* @param ddlist pointer to a ddlist
|
||||
*/
|
||||
static void lv_ddlist_refr_width(lv_obj_t* ddlist)
|
||||
{
|
||||
/*Set the TIGHT fit horizontally the set the width to the content*/
|
||||
lv_page_set_scrl_fit2(ddlist, LV_FIT_TIGHT, LV_FIT_TIGHT);
|
||||
|
||||
/*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_FIT_TIGHT);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user