Page MenuHome

Fix Zooming out a lot faster than zooming in (T73575) (Trackpad, Mouse) [5/5]
ClosedPublic

Authored by Yevgeny Makarov (jenkm) on Aug 23 2020, 12:40 PM.

Details

Summary

Fix T73575: View2D zooming out a lot faster than zooming in.

  • Zooming out a lot faster than zooming in, it had the wrong aspect ratio, make all the preparations with the factors instead of deltas.
  • Improved following the zoom_invert (should not apply to MOUSEZOOM) and "trackpad natural scroll" preferences.
  • zoomfac adjustment, same as in view_zoomdrag_modal.

Diff Detail

Repository
rB Blender

Event Timeline

Yevgeny Makarov (jenkm) retitled this revision from Trackpad: View2D Zoom improvements and fixes (5) to Fix Zooming out a lot faster than zooming in (T73575) (Trackpad, Mouse) [5/5].Oct 6 2020, 6:12 PM
Yevgeny Makarov (jenkm) edited the summary of this revision. (Show Details)
Yevgeny Makarov (jenkm) edited the summary of this revision. (Show Details)
Yevgeny Makarov (jenkm) edited the summary of this revision. (Show Details)
Campbell Barton (campbellbarton) requested changes to this revision.EditedJan 13 2021, 4:45 AM

Tested with "Scale" zoom style, which still has the issue of zooming out much faster than it zooms in.

This revision now requires changes to proceed.Jan 13 2021, 4:45 AM

Checking further, this improves behavior, but it's still not perfect.

diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 8ee8ff7b185..520324a8102 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1345,16 +1345,16 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
       len_old[0] = fabsf(vzd->lastx - vzd->region->winrct.xmin - dist);
       len_new[0] = fabsf(event->x - vzd->region->winrct.xmin - dist);
 
-      len_old[0] *= zoomfac * BLI_rctf_size_x(&v2d->cur);
-      len_new[0] *= zoomfac * BLI_rctf_size_x(&v2d->cur);
+      len_old[0] *= zoomfac;
+      len_new[0] *= zoomfac;
 
       /* y-axis transform */
       dist = BLI_rcti_size_y(&v2d->mask) / 2.0f;
       len_old[1] = fabsf(vzd->lasty - vzd->region->winrct.ymin - dist);
       len_new[1] = fabsf(event->y - vzd->region->winrct.ymin - dist);
 
-      len_old[1] *= zoomfac * BLI_rctf_size_y(&v2d->cur);
-      len_new[1] *= zoomfac * BLI_rctf_size_y(&v2d->cur);
+      len_old[1] *= zoomfac;
+      len_new[1] *= zoomfac;
 
       /* Calculate distance */
       if (v2d->keepzoom & V2D_KEEPASPECT) {
@@ -1365,6 +1365,9 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
         dx = len_new[0] - len_old[0];
         dy = len_new[1] - len_old[1];
       }
+
+      dx *= BLI_rctf_size_x(&v2d->cur);
+      dy *= BLI_rctf_size_y(&v2d->cur);
     }
     else { /* USER_ZOOM_CONT or USER_ZOOM_DOLLY */
       float facx = zoomfac * (event->x - vzd->lastx);

Also, this patch doesn't work quite right with dolly either.

It's probably simplest to store the zoom level when the operator starts running, then rescale that based on cursor input, so moving the cursor back to the same place always gives the same scale level.

Added a fix to the "Scale" zoom style.

@Campbell Barton (campbellbarton) Actually, my goal is to fix trackpad support, so I can leave here only the changes to view_zoomdrag_invoke if you prefer a better solution for view_zoomdrag_modal, "to store the zoom level when the operator starts running" - this will not be a solution for the trackpad anyway, I guess.

This revision is now accepted and ready to land.Jan 20 2021, 12:59 PM