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

fix(zoom): add lv_obj_get_style_transform_zoom_safe (#4204)

Signed-off-by: bjsylvia <bjsylvia@163.com>
This commit is contained in:
bjsylvia 2023-05-05 15:07:39 +08:00 committed by GitHub
parent 842cf80a48
commit 756c189519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 6 deletions

View File

@ -1173,7 +1173,8 @@ static void indev_proc_release(lv_indev_t * indev)
lv_obj_t * parent = scroll_obj;
while(parent) {
angle += lv_obj_get_style_transform_angle(parent, 0);
zoom *= (lv_obj_get_style_transform_zoom(parent, 0) / 256);
int32_t zoom_act = lv_obj_get_style_transform_zoom_safe(parent, 0);
zoom = (zoom * zoom_act) >> 8;
parent = lv_obj_get_parent(parent);
}

View File

@ -68,7 +68,8 @@ void _lv_indev_scroll_handler(lv_indev_t * indev)
lv_obj_t * parent = scroll_obj;
while(parent) {
angle += lv_obj_get_style_transform_angle(parent, 0);
zoom *= (lv_obj_get_style_transform_zoom(parent, 0) / 256);
int32_t zoom_act = lv_obj_get_style_transform_zoom_safe(parent, 0);
zoom = (zoom * zoom_act) >> 8;
parent = lv_obj_get_parent(parent);
}
@ -293,7 +294,7 @@ static lv_obj_t * find_scroll_obj(lv_indev_t * indev)
lv_obj_t * parent = obj_act;
while(parent) {
angle += lv_obj_get_style_transform_angle(parent, 0);
int32_t zoom_act = lv_obj_get_style_transform_zoom(parent, 0);
int32_t zoom_act = lv_obj_get_style_transform_zoom_safe(parent, 0);
zoom = (zoom * zoom_act) >> 8;
parent = lv_obj_get_parent(parent);
}

View File

@ -1141,7 +1141,7 @@ static void layout_update_core(lv_obj_t * obj)
static void transform_point(const lv_obj_t * obj, lv_point_t * p, bool inv)
{
int16_t angle = lv_obj_get_style_transform_angle(obj, 0);
int16_t zoom = lv_obj_get_style_transform_zoom(obj, 0);
int16_t zoom = lv_obj_get_style_transform_zoom_safe(obj, 0);
if(angle == 0 && zoom == LV_ZOOM_NONE) return;

View File

@ -309,7 +309,11 @@ static inline lv_coord_t lv_obj_get_style_space_bottom(const struct _lv_obj_t *
lv_text_align_t lv_obj_calculate_style_text_align(const struct _lv_obj_t * obj, lv_part_t part, const char * txt);
static inline lv_coord_t lv_obj_get_style_transform_zoom_safe(const struct _lv_obj_t * obj, uint32_t part)
{
int16_t zoom = lv_obj_get_style_transform_zoom(obj, part);
return zoom != 0 ? zoom : 1;
}
/**********************
* MACROS
**********************/

View File

@ -771,7 +771,7 @@ void refr_obj(lv_draw_ctx_t * draw_ctx, lv_obj_t * obj)
if(draw_dsc.angle > 3600) draw_dsc.angle -= 3600;
else if(draw_dsc.angle < 0) draw_dsc.angle += 3600;
draw_dsc.zoom = lv_obj_get_style_transform_zoom(obj, 0);
draw_dsc.zoom = lv_obj_get_style_transform_zoom_safe(obj, 0);
draw_dsc.blend_mode = lv_obj_get_style_blend_mode(obj, 0);
draw_dsc.antialias = disp_refr->antialiasing;