From 3504b4c9c324e001e461d1483275e25aa81dadb3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Aug 2019 22:08:10 +1000 Subject: Fix T68360: Zoom too sensitive with hi-dpi Scale pixel-input by pixel size for zoom operators. --- source/blender/editors/interface/view2d_ops.c | 4 ++-- source/blender/editors/space_clip/clip_ops.c | 2 ++ source/blender/editors/space_image/image_ops.c | 2 ++ source/blender/editors/space_view3d/view3d_edit.c | 18 ++++++++++-------- 4 files changed, 16 insertions(+), 10 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index b57d100127e..f32fcffabd4 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -940,8 +940,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) const bool zoom_to_pos = use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS); /* get amount to move view by */ - dx = RNA_float_get(op->ptr, "deltax"); - dy = RNA_float_get(op->ptr, "deltay"); + dx = RNA_float_get(op->ptr, "deltax") / U.pixelsize; + dy = RNA_float_get(op->ptr, "deltay") / U.pixelsize; if (U.uiflag & USER_ZOOM_INVERT) { dx *= -1; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index af998fda6f9..cf899773822 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -640,6 +640,8 @@ static void view_zoom_apply( delta = event->x - vpd->x + event->y - vpd->y; } + delta /= U.pixelsize; + if (U.uiflag & USER_ZOOM_INVERT) { delta = -delta; } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 1aa8c4c988b..05ba82b8bde 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -570,6 +570,8 @@ static void image_zoom_apply(ViewZoomData *vpd, delta = x - vpd->origx + y - vpd->origy; } + delta /= U.pixelsize; + if (zoom_invert) { delta = -delta; } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 2dffa8c5edc..ec7c1c0b3b9 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1959,6 +1959,8 @@ static float viewzoom_scale_value(const rcti *winrct, fac = (float)(xy_init[1] - xy_curr[1]); } + fac /= U.pixelsize; + if (zoom_invert != zoom_invert_force) { fac = -fac; } @@ -1974,8 +1976,8 @@ static float viewzoom_scale_value(const rcti *winrct, BLI_rcti_cent_x(winrct), BLI_rcti_cent_y(winrct), }; - float len_new = 5 + len_v2v2_int(ctr, xy_curr); - float len_old = 5 + len_v2v2_int(ctr, xy_init); + float len_new = (5 * U.pixelsize) + ((float)len_v2v2_int(ctr, xy_curr) / U.pixelsize); + float len_old = (5 * U.pixelsize) + ((float)len_v2v2_int(ctr, xy_init) / U.pixelsize); /* intentionally ignore 'zoom_invert' for scale */ if (zoom_invert_force) { @@ -1985,16 +1987,16 @@ static float viewzoom_scale_value(const rcti *winrct, zfac = val_orig * (len_old / max_ff(len_new, 1.0f)) / val; } else { /* USER_ZOOM_DOLLY */ - float len_new = 5; - float len_old = 5; + float len_new = 5 * U.pixelsize; + float len_old = 5 * U.pixelsize; if (U.uiflag & USER_ZOOM_HORIZ) { - len_new += (winrct->xmax - (xy_curr[0])); - len_old += (winrct->xmax - (xy_init[0])); + len_new += (winrct->xmax - (xy_curr[0])) / U.pixelsize; + len_old += (winrct->xmax - (xy_init[0])) / U.pixelsize; } else { - len_new += (winrct->ymax - (xy_curr[1])); - len_old += (winrct->ymax - (xy_init[1])); + len_new += (winrct->ymax - (xy_curr[1])) / U.pixelsize; + len_old += (winrct->ymax - (xy_init[1])) / U.pixelsize; } if (zoom_invert != zoom_invert_force) { -- cgit v1.2.3