1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

fix roller width if selected text is larger than the normal

This commit is contained in:
Gabor Kiss-Vamosi 2020-08-28 16:00:04 +02:00
parent adf65b6761
commit 9b9cd36dc9
2 changed files with 13 additions and 0 deletions

View File

@ -17,6 +17,7 @@
- Fix zooming and rotateing mosaic images
- Fix deleting tabview with LEFT/RIGHT tab position
- Fix btnmatrix to not send event when CLICK_TRIG = true and the cursor slid from a pressed button
- Fix roller width if selected text is larger than the normal
## v7.3.1 (18.08.2020)

View File

@ -966,6 +966,18 @@ static void refr_width(lv_obj_t * roller)
lv_style_int_t left = lv_obj_get_style_pad_left(roller, LV_ROLLER_PART_BG);
lv_style_int_t right = lv_obj_get_style_pad_right(roller, LV_ROLLER_PART_BG);
const lv_font_t * base_font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG);
const lv_font_t * sel_font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_SELECTED);
/*The selected text might be larger to get its size*/
if(base_font != sel_font) {
lv_coord_t letter_sp = lv_obj_get_style_text_letter_space(roller, LV_ROLLER_PART_SELECTED);
lv_coord_t line_sp = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_SELECTED);
lv_point_t p;
_lv_txt_get_size(&p, lv_label_get_text(label), sel_font, letter_sp, line_sp, LV_COORD_MAX, LV_TXT_FLAG_NONE);
if(label_w < p.x)label_w = p.x;
}
lv_obj_set_width(roller, label_w + left + right);
}