minor fixes

This commit is contained in:
Gabor Kiss-Vamosi
2020-01-14 21:16:48 +01:00
parent 89c0ad468e
commit 3ba87cba48
5 changed files with 29 additions and 10 deletions

View File

@@ -1084,11 +1084,22 @@ static void draw_img(const lv_area_t * coords, const lv_area_t * clip, lv_draw_r
}
lv_draw_mask_remove_id(radius_mask_id);
} else {
coords_tmp.x1 = coords->x1 + lv_area_get_width(coords) / 2 - img_w / 2;
coords_tmp.y1 = coords->y1 + lv_area_get_height(coords) / 2 - img_h / 2;
lv_coord_t obj_w = lv_area_get_width(coords);
lv_coord_t obj_h = lv_area_get_height(coords);
coords_tmp.x1 = coords->x1 + (obj_w - img_w) / 2;
coords_tmp.y1 = coords->y1 + (obj_h - img_h) / 2;
coords_tmp.x2 = coords_tmp.x1 + img_w - 1;
coords_tmp.y2 = coords_tmp.y1 + img_h - 1;
/* If the (obj_h - img_h) is odd there is a rounding error when divided by 2.
* It's better round up in case of symbols because probably there is some extra space in the bottom
* due to the base line of font*/
if(src_type == LV_IMG_SRC_SYMBOL) {
lv_coord_t y_corr = (obj_h - img_h) & 0x1;
coords_tmp.y1 += y_corr;
coords_tmp.y2 += y_corr;
}
int16_t radius_mask_id = LV_MASK_ID_INV;
if(lv_area_is_in(&coords_tmp, coords, dsc->radius) == false) {
lv_draw_mask_radius_param_t radius_mask_param;

View File

@@ -70,12 +70,12 @@ typedef struct _lv_font_struct
const uint8_t * (*get_glyph_bitmap)(const struct _lv_font_struct *, uint32_t);
/*Pointer to the font in a font pack (must have the same line height)*/
lv_coord_t line_height; /**< The real line height where any text fits*/
lv_coord_t base_line; /**< Base line measured from the top of the line_height*/
uint8_t subpx :2; /**< An element of `lv_font_subpx_t`*/
void * dsc; /**< Store implementation specific or run_time data or caching here*/
lv_coord_t line_height; /**< The real line height where any text fits*/
lv_coord_t base_line; /**< Base line measured from the top of the line_height*/
uint8_t subpx :2; /**< An element of `lv_font_subpx_t`*/
void * dsc; /**< Store implementation specific or run_time data or caching here*/
#if LV_USE_USER_DATA
lv_font_user_data_t user_data; /**< Custom user data for font. */
lv_font_user_data_t user_data; /**< Custom user data for font. */
#endif

View File

@@ -693,10 +693,13 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
/*The state changes without re-caching the styles, disable the use of cache*/
// calendar->style_dsc.cache.enabled = 0;
lv_obj_state_t state_ori = calendar->state;
lv_obj_state_t prev_state_ori = calendar->prev_state;
if(ext->btn_pressing < 0) calendar->state |= LV_OBJ_STATE_PRESSED;
else calendar->state &= ~(LV_OBJ_STATE_PRESSED);
calendar->prev_state = calendar->state;
header_area.x1 += left;
lv_draw_label_dsc_init(&label_dsc);
@@ -704,11 +707,14 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
lv_draw_label(&header_area, mask, &label_dsc, LV_SYMBOL_LEFT, NULL);
calendar->state = state_ori; /*Restore the state*/
calendar->prev_state = prev_state_ori;
/*Add the right arrow*/
if(ext->btn_pressing > 0) calendar->state |= LV_OBJ_STATE_PRESSED;
else calendar->state &= ~(LV_OBJ_STATE_PRESSED);
calendar->prev_state = calendar->state;
header_area.x1 = header_area.x2 - right - lv_txt_get_width(LV_SYMBOL_RIGHT, (uint16_t)strlen(LV_SYMBOL_RIGHT), font, 0, LV_TXT_FLAG_NONE);
lv_draw_label_dsc_init(&label_dsc);
@@ -716,6 +722,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
lv_draw_label(&header_area, mask, &label_dsc, LV_SYMBOL_RIGHT, NULL);
calendar->state = state_ori; /*Restore the state*/
calendar->prev_state = prev_state_ori;
// calendar->style_dsc.cache.enabled = 1;
}

View File

@@ -49,7 +49,6 @@ static lv_signal_cb_t ancestor_signal;
*/
lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("check box create started");
/*Create the ancestor basic object*/
@@ -187,6 +186,7 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
lv_coord_t line_height = lv_font_get_line_height(font);
lv_obj_set_size(ext->bullet, line_height, line_height);
ext->bullet->state = cb->state;
ext->bullet->prev_state = cb->state;
lv_obj_refresh_style(ext->bullet);
} else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));

View File

@@ -107,6 +107,7 @@ static void basic_init(void)
lv_style_set_int(&panel, LV_STYLE_BG_GRAD_DIR, LV_GRAD_DIR_VER);
lv_style_set_color(&panel, LV_STYLE_BORDER_COLOR, LV_COLOR_GRAY);
lv_style_set_color(&panel, LV_STYLE_TEXT_COLOR, LV_COLOR_BLACK);
lv_style_set_ptr(&panel, LV_STYLE_FONT , &lv_font_roboto_16);
lv_style_init(&btn);
lv_style_set_int(&btn, LV_STYLE_PAD_LEFT, LV_DPI / 20);
@@ -134,8 +135,8 @@ static void basic_init(void)
lv_style_set_opa(&btn, LV_STYLE_BORDER_OPA, LV_OPA_70);
lv_style_set_opa(&btn, LV_STYLE_TEXT_OPA, LV_OPA_80);
lv_style_set_int(&btn, LV_STYLE_BORDER_WIDTH | LV_STYLE_STATE_FOCUS, 6);
lv_style_set_ptr(&btn, LV_STYLE_PATTERN_IMAGE | LV_STYLE_STATE_CHECKED, LV_SYMBOL_OK);
lv_style_set_int(&btn, LV_STYLE_PATTERN_REPEATE | LV_STYLE_STATE_CHECKED, 1);
lv_style_set_ptr(&btn, LV_STYLE_PATTERN_IMAGE | LV_STYLE_STATE_CHECKED, LV_SYMBOL_STOP);
// lv_style_set_int(&btn, LV_STYLE_PATTERN_REPEATE | LV_STYLE_STATE_CHECKED, 1);
lv_style_set_int(&btn, LV_STYLE_SHADOW_WIDTH, 5);
lv_style_set_int(&btn, LV_STYLE_SHADOW_OFFSET_Y, 3);
lv_style_set_int(&btn, LV_STYLE_TRANSITION_TIME, 200);