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

page: fix scrollbar visibility

This commit is contained in:
Gabor Kiss-Vamosi 2020-05-13 01:09:13 +02:00
parent d9ebf93836
commit d7940734b8
2 changed files with 12 additions and 9 deletions

View File

@ -604,14 +604,12 @@ void lv_dropdown_open(lv_obj_t * ddlist)
lv_obj_set_design_cb(ext->page, lv_dropdown_page_design); lv_obj_set_design_cb(ext->page, lv_dropdown_page_design);
lv_obj_set_signal_cb(ext->page, lv_dropdown_page_signal); lv_obj_set_signal_cb(ext->page, lv_dropdown_page_signal);
lv_obj_set_signal_cb(lv_page_get_scrllable(ext->page), lv_dropdown_page_scrl_signal); lv_obj_set_signal_cb(lv_page_get_scrllable(ext->page), lv_dropdown_page_scrl_signal);
lv_page_set_scrollbar_mode(ext->page, LV_SCROLLBAR_MODE_AUTO);
lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_BG), &ext->style_page); lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_BG), &ext->style_page);
lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCROLLBAR), &ext->style_scrlbar); lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCROLLBAR), &ext->style_scrlbar);
lv_obj_clean_style_list(ext->page, LV_PAGE_PART_SCROLLABLE); lv_obj_clean_style_list(ext->page, LV_PAGE_PART_SCROLLABLE);
lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL); lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL);
lv_obj_t * label = lv_label_create(ext->page, NULL); lv_obj_t * label = lv_label_create(ext->page, NULL);
lv_label_set_text_static(label, ext->options); lv_label_set_text_static(label, ext->options);
@ -627,8 +625,8 @@ void lv_dropdown_open(lv_obj_t * ddlist)
lv_style_int_t top = lv_obj_get_style_pad_top(ddlist, LV_DROPDOWN_PART_LIST); lv_style_int_t top = lv_obj_get_style_pad_top(ddlist, LV_DROPDOWN_PART_LIST);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(ddlist, LV_DROPDOWN_PART_LIST); lv_style_int_t bottom = lv_obj_get_style_pad_bottom(ddlist, LV_DROPDOWN_PART_LIST);
lv_coord_t list_h = label_h + top + bottom; lv_coord_t list_fit_h = label_h + top + bottom;
lv_coord_t list_h = list_fit_h;
if(list_h > ext->max_height) list_h = ext->max_height; if(list_h > ext->max_height) list_h = ext->max_height;
lv_dropdown_dir_t dir = ext->dir; lv_dropdown_dir_t dir = ext->dir;
@ -659,6 +657,7 @@ void lv_dropdown_open(lv_obj_t * ddlist)
} }
} }
if(list_h > list_fit_h) list_h = list_fit_h;
if(list_h > ext->max_height) list_h = ext->max_height; if(list_h > ext->max_height) list_h = ext->max_height;
lv_obj_set_height(ext->page, list_h); lv_obj_set_height(ext->page, list_h);

View File

@ -943,9 +943,18 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
} }
scrl_reposition(page); scrl_reposition(page);
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
/*The scrollbars are important only if they are visible now or the scrollable's size has changed*/
if((ext->scrlbar.hor_draw || ext->scrlbar.ver_draw) ||
(lv_obj_get_width(scrl) != lv_area_get_width(param) || lv_obj_get_height(scrl) != lv_area_get_height(param))) {
scrlbar_refresh(page);
}
} }
else if(sign == LV_SIGNAL_STYLE_CHG) { else if(sign == LV_SIGNAL_STYLE_CHG) {
scrl_reposition(page); scrl_reposition(page);
scrlbar_refresh(page);
} }
else if(sign == LV_SIGNAL_DRAG_BEGIN) { else if(sign == LV_SIGNAL_DRAG_BEGIN) {
if(page_ext->scrlbar.mode == LV_SCROLLBAR_MODE_DRAG) { if(page_ext->scrlbar.mode == LV_SCROLLBAR_MODE_DRAG) {
@ -1172,11 +1181,6 @@ static void scrl_reposition(lv_obj_t * page)
if(refr_x || refr_y) { if(refr_x || refr_y) {
lv_obj_set_pos(scrl, new_x, new_y); lv_obj_set_pos(scrl, new_x, new_y);
} }
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
/*The scrollbars are important only if they are visible now*/
if(ext->scrlbar.hor_draw || ext->scrlbar.ver_draw) scrlbar_refresh(page);
} }
/** /**