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/space_view3d/view3d_gizmo_ruler.c | |
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/space_view3d/view3d_gizmo_ruler.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_gizmo_ruler.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index 437c2a9a027..224c80bdd48 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -1082,7 +1082,8 @@ static int gizmo_ruler_invoke(bContext *C, wmGizmo *gz, const wmEvent *event) ARegion *region = ruler_info->region; - const float mval_fl[2] = {UNPACK2(event->mval)}; + float mval_fl[2]; + WM_event_drag_start_mval_fl(event, region, mval_fl); #ifdef USE_AXIS_CONSTRAINTS ruler_info->constrain_axis = CONSTRAIN_AXIS_NONE; @@ -1311,6 +1312,9 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e return OPERATOR_CANCELLED; } + int mval[2]; + WM_event_drag_start_mval(event, region, mval); + /* Create new line */ RulerItem *ruler_item; ruler_item = ruler_item_add(gzgroup); @@ -1329,7 +1333,7 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e depsgraph, ruler_info, ruler_item, - event->mval, + mval, false #ifndef USE_SNAP_DETECT_FROM_KEYMAP_HACK , @@ -1344,7 +1348,7 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e else { negate_v3_v3(inter->drag_start_co, rv3d->ofs); copy_v3_v3(ruler_item->co[0], inter->drag_start_co); - view3d_ruler_item_project(ruler_info, ruler_item->co[0], event->mval); + view3d_ruler_item_project(ruler_info, ruler_item->co[0], mval); } copy_v3_v3(ruler_item->co[2], ruler_item->co[0]); |