From 52c61b115f15585d632494bb4f08063cb9d98d17 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 25 Aug 2020 11:54:12 +0200 Subject: [PATCH 1/2] minor image zoom fixes --- src/lv_draw/lv_img_buf.h | 8 ++++---- src/lv_widgets/lv_img.c | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lv_draw/lv_img_buf.h b/src/lv_draw/lv_img_buf.h index d549c8109..5b43456ac 100644 --- a/src/lv_draw/lv_img_buf.h +++ b/src/lv_draw/lv_img_buf.h @@ -308,14 +308,14 @@ static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_ ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256; } else if(dsc->cfg.angle == 0) { - xt = (xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; - yt = (yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; + xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; + yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; xs = xt + dsc->tmp.pivot_x_256; ys = yt + dsc->tmp.pivot_y_256; } else { - xt = (xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; - yt = (yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; + xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; + yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256; ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256; } diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 19223bb56..89ed3c864 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -672,7 +672,9 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area img_dsc.antialias = ext->antialias; lv_coord_t zoomed_src_w = (int32_t)((int32_t)ext->w * zoom_final) >> 8; + if(zoomed_src_w <= 0) return LV_DESIGN_RES_OK; lv_coord_t zoomed_src_h = (int32_t)((int32_t)ext->h * zoom_final) >> 8; + if(zoomed_src_h <= 0) return LV_DESIGN_RES_OK; lv_area_t zommed_coords; lv_obj_get_coords(img, &zommed_coords); @@ -697,10 +699,10 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area coords_tmp.y1 = zommed_coords.y1; coords_tmp.y2 = zommed_coords.y1 + ext->h - 1; - for(; coords_tmp.y1 <= zommed_coords.y2; coords_tmp.y1 += zoomed_src_h, coords_tmp.y2 += zoomed_src_h) { + for(; coords_tmp.y1 < zommed_coords.y2; coords_tmp.y1 += zoomed_src_h, coords_tmp.y2 += zoomed_src_h) { coords_tmp.x1 = zommed_coords.x1; coords_tmp.x2 = zommed_coords.x1 + ext->w - 1; - for(; coords_tmp.x1 <= zommed_coords.x2; coords_tmp.x1 += zoomed_src_w, coords_tmp.x2 += zoomed_src_w) { + for(; coords_tmp.x1 < zommed_coords.x2; coords_tmp.x1 += zoomed_src_w, coords_tmp.x2 += zoomed_src_w) { lv_draw_img(&coords_tmp, &clip_real, ext->src, &img_dsc); } } From 14a2a60bf936d2b072478a24e5f3e6f1a37b221b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 25 Aug 2020 15:18:45 +0200 Subject: [PATCH 2/2] Fix btnmatrix to not send event when CLICK_TRIG = true and the cursor slid from a pressed button Fixes: https://forum.lvgl.io/t/v7-3-register-button-in-button-matrix-only-after-touch-release-not-button-release/3117 --- src/lv_widgets/lv_btnmatrix.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 4acb82643..8855bddb3 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -904,12 +904,13 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa lv_indev_reset_long_press(param); /*Start the log press time again on the new button*/ if(btn_pr != LV_BTNMATRIX_BTN_NONE && button_is_inactive(ext->ctrl_bits[btn_pr]) == false && - button_is_hidden(ext->ctrl_bits[btn_pr]) == false) { + button_is_hidden(ext->ctrl_bits[btn_pr]) == false) + { + invalidate_button_area(btnm, btn_pr); /* Send VALUE_CHANGED for the newly pressed button */ - uint32_t b = btn_pr; - res = lv_event_send(btnm, LV_EVENT_VALUE_CHANGED, &b); - if(res == LV_RES_OK) { - invalidate_button_area(btnm, btn_pr); + if(button_is_click_trig(ext->ctrl_bits[btn_pr]) == false) { + uint32_t b = btn_pr; + lv_event_send(btnm, LV_EVENT_VALUE_CHANGED, &b); } } }