Fix for T78211: Trackpad Zoom to Mouse Position Error

When using a trackpad Zoom to Mouse Position would always zoom to center of canvas.

Differential Revision: https://developer.blender.org/D8683

Reviewed by Brecht Van Lommel
This commit is contained in:
Yevgeny Makarov 2020-10-29 08:27:48 -07:00 committed by Harley Acheson
parent 962a0a6c66
commit c1b30e0ed1
Notes: blender-bot 2023-02-14 11:35:46 +01:00
Referenced by issue #78211, Zoom to Mouse Position is broken in Node Editor (with Trackpad, macOS)
1 changed files with 5 additions and 8 deletions

View File

@ -1232,6 +1232,11 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
v2d = vzd->v2d;
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
ARegion *region = CTX_wm_region(C);
/* Store initial mouse position (in view space). */
UI_view2d_region_to_view(
&region->v2d, event->mval[0], event->mval[1], &vzd->mx_2d, &vzd->my_2d);
vzd->zoom_to_mouse_pos = true;
}
@ -1278,14 +1283,6 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
/* for modal exit test */
vzd->invoke_event = event->type;
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
ARegion *region = CTX_wm_region(C);
/* store initial mouse position (in view space) */
UI_view2d_region_to_view(
&region->v2d, event->mval[0], event->mval[1], &vzd->mx_2d, &vzd->my_2d);
}
if (v2d->keepofs & V2D_LOCKOFS_X) {
WM_cursor_modal_set(window, WM_CURSOR_NS_SCROLL);
}