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

fix(dropdown) fix showing the selected text if symbol=NULL

fixes #2235
This commit is contained in:
Gabor Kiss-Vamosi 2021-05-03 15:27:57 +02:00
parent 6b497dec3c
commit efc5bccbfd

View File

@ -747,10 +747,6 @@ static void draw_main(lv_event_t * e)
lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN); lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_dsc);
lv_draw_label_dsc_t symbol_dsc; lv_draw_label_dsc_t symbol_dsc;
lv_draw_label_dsc_init(&symbol_dsc); lv_draw_label_dsc_init(&symbol_dsc);
lv_obj_init_draw_label_dsc(obj, LV_PART_INDICATOR, &symbol_dsc); lv_obj_init_draw_label_dsc(obj, LV_PART_INDICATOR, &symbol_dsc);
@ -813,6 +809,11 @@ static void draw_main(lv_event_t * e)
img_dsc.angle = lv_obj_get_style_transform_angle(obj, LV_PART_INDICATOR); img_dsc.angle = lv_obj_get_style_transform_angle(obj, LV_PART_INDICATOR);
lv_draw_img(&symbol_area, clip_area, dropdown->symbol, &img_dsc); lv_draw_img(&symbol_area, clip_area, dropdown->symbol, &img_dsc);
} }
}
lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_dsc);
lv_point_t size; lv_point_t size;
lv_txt_get_size(&size, opt_txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, label_dsc.flag); lv_txt_get_size(&size, opt_txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, label_dsc.flag);
@ -836,7 +837,6 @@ static void draw_main(lv_event_t * e)
} }
} }
lv_draw_label(&txt_area, clip_area, &label_dsc, opt_txt, NULL); lv_draw_label(&txt_area, clip_area, &label_dsc, opt_txt, NULL);
}
if(dropdown->text == NULL) { if(dropdown->text == NULL) {
lv_mem_buf_release((char *)opt_txt); lv_mem_buf_release((char *)opt_txt);