From b8960267dd51f9108b3b49e9b762e6b4d35ae1dc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Mar 2022 08:36:36 +1100 Subject: 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 --- source/blender/editors/interface/interface_handlers.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/interface') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 8262be163b7..f5fa710067b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -9394,7 +9394,9 @@ static int ui_list_activate_hovered_row(bContext *C, } } - const int *mouse_xy = (event->val == KM_CLICK_DRAG) ? event->prev_click_xy : event->xy; + int mouse_xy[2]; + WM_event_drag_start_xy(event, mouse_xy); + uiBut *listrow = ui_list_row_find_mouse_over(region, mouse_xy); if (listrow) { wmOperatorType *custom_activate_optype = ui_list->dyn_data->custom_activate_optype; @@ -9421,7 +9423,9 @@ static bool ui_list_is_hovering_draggable_but(bContext *C, const wmEvent *event) { /* On a tweak event, uses the coordinates from where tweaking was started. */ - const int *mouse_xy = (event->val == KM_CLICK_DRAG) ? event->prev_click_xy : event->xy; + int mouse_xy[2]; + WM_event_drag_start_xy(event, mouse_xy); + const uiBut *hovered_but = ui_but_find_mouse_over_ex(region, mouse_xy, false, NULL, NULL); if (list->dyn_data->custom_drag_optype) { -- cgit v1.2.3