diff options
author | Campbell Barton <campbell@blender.org> | 2022-03-09 00:36:36 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-03-09 00:38:42 +0300 |
commit | b8960267dd51f9108b3b49e9b762e6b4d35ae1dc (patch) | |
tree | 910b39958345ed78ebb8607e4d15341d88cd6359 /source/blender/editors/transform | |
parent | 156e07232e79d53fa3f43d4bcfc4b0c4061331e5 (diff) |
Event System: drag events no longer default to the drag start location
This avoids transform jumping which is a problem when tweaking values a
small amount. A fix for T40549 was made box-select used the location
when the key was pressed.
While it's important for box-select or any operator where it's expected
the drag-start location is used, this is only needed in some cases.
Since the event stores the click location and the current location,
no longer overwrite the events real location. Operators that depend on
using the drag-start can use this location if they need.
In some cases the region relative cursor location (Event.mval) now needs
to be calculated based on the click location.
- Added `WM_event_drag_start_mval` for convenient access to the region
relative drag-start location (for drag events).
- Added `WM_event_drag_start_xy` for window relative coordinates.
- Added Python property Event.mouse_prev_click_x/y
Resolves T93599.
Reviewed By: Severin
Ref D14213
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform.c | 16 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 7 |
3 files changed, 24 insertions, 2 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index fd01f708ed2..9810f1cb6ad 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1706,6 +1706,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->launch_event = LEFTMOUSE; } + if (options & CTX_CURSOR) { + /* Cursor should always use the drag start as the combination of click-drag to place & move + * doesn't work well if the click location isn't used when transforming. */ + t->flag |= T_EVENT_DRAG_START; + } + unit_m3(t->spacemtx); initTransInfo(C, t, op, event); @@ -1819,7 +1825,15 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve use_accurate = true; } } - initMouseInput(t, &t->mouse, t->center2d, event->mval, use_accurate); + + int mval[2]; + if (t->flag & T_EVENT_DRAG_START) { + WM_event_drag_start_mval(event, t->region, mval); + } + else { + copy_v2_v2_int(mval, event->mval); + } + initMouseInput(t, &t->mouse, t->center2d, mval, use_accurate); } transform_mode_init(t, op, mode); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 3ee5868d5be..21592032af2 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -137,6 +137,9 @@ typedef enum { /** Runs auto-merge & splits. */ T_AUTOSPLIT = 1 << 21, + /** Use drag-start position of the event, otherwise use the cursor coordinates (unmodified). */ + T_EVENT_DRAG_START = (1 << 22), + /** No cursor wrapping on region bounds */ T_NO_CURSOR_WRAP = 1 << 23, } eTFlag; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8987325145c..776229d66a0 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -216,7 +216,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve int mval[2]; if (event) { - copy_v2_v2_int(mval, event->mval); + if (t->flag & T_EVENT_DRAG_START) { + WM_event_drag_start_mval(event, region, mval); + } + else { + copy_v2_v2_int(mval, event->mval); + } } else { zero_v2_int(mval); |