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

checkbox: set bullet size with padding

This commit is contained in:
Gabor Kiss-Vamosi 2020-05-14 11:29:49 +02:00
parent f252edb5c1
commit af312fd2ba
2 changed files with 10 additions and 1 deletions

View File

@ -601,6 +601,10 @@ static void checkbox_init(void)
lv_style_set_pattern_image(&cb_bullet, LV_STATE_CHECKED, LV_SYMBOL_OK); lv_style_set_pattern_image(&cb_bullet, LV_STATE_CHECKED, LV_SYMBOL_OK);
lv_style_set_pattern_recolor(&cb_bullet, LV_STATE_CHECKED, LV_COLOR_WHITE); lv_style_set_pattern_recolor(&cb_bullet, LV_STATE_CHECKED, LV_COLOR_WHITE);
lv_style_set_text_font(&cb_bullet, LV_STATE_CHECKED, theme.font_small); lv_style_set_text_font(&cb_bullet, LV_STATE_CHECKED, theme.font_small);
lv_style_set_pad_left(&cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
lv_style_set_pad_right(&cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
lv_style_set_pad_top(&cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
lv_style_set_pad_bottom(&cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
#endif #endif
} }

View File

@ -180,7 +180,12 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * cb, lv_signal_t sign, void * param
if(sign == LV_SIGNAL_STYLE_CHG) { if(sign == LV_SIGNAL_STYLE_CHG) {
const lv_font_t * font = lv_obj_get_style_text_font(ext->label, LV_LABEL_PART_MAIN); const lv_font_t * font = lv_obj_get_style_text_font(ext->label, LV_LABEL_PART_MAIN);
lv_coord_t line_height = lv_font_get_line_height(font); lv_coord_t line_height = lv_font_get_line_height(font);
lv_obj_set_size(ext->bullet, line_height, line_height); lv_coord_t leftp = lv_obj_get_style_pad_left(cb, LV_CHECKBOX_PART_BULLET);
lv_coord_t rightp = lv_obj_get_style_pad_right(cb, LV_CHECKBOX_PART_BULLET);
lv_coord_t topp = lv_obj_get_style_pad_top(cb, LV_CHECKBOX_PART_BULLET);
lv_coord_t bottomp = lv_obj_get_style_pad_bottom(cb, LV_CHECKBOX_PART_BULLET);
lv_obj_set_size(ext->bullet, line_height + leftp + rightp, line_height + topp + bottomp);
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG)); lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
} }
else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST || else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST ||