Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-05-27 18:19:02 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-27 18:36:31 +0300
commitdee7edffcf2a6c4a1ce35ab5d5ab35873d113c0f (patch)
treefc6337dd9314eb8d5d24b3a5cf4cfa2a37b5d306 /source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
parent58ce4061a83d03d601c3713d8df11252d182db07 (diff)
Fix tweak/drag event use with gizmos
It was possible to use a drag event for a gizmo that dragged away from the gizmo, changing the active gizmo. Now use gizmo located at the location that was clicked on.
Diffstat (limited to 'source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c')
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 9c18406b84d..56de2202731 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -683,6 +683,15 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
BLI_buffer_declare_static(wmGizmo *, visible_3d_gizmos, BLI_BUFFER_NOP, 128);
bool do_step[WM_GIZMOMAP_DRAWSTEP_MAX];
+ int mval[2] = {UNPACK2(event->mval)};
+
+ /* Ensure for drag events we use the location where the user clicked.
+ * Without this click-dragging on a gizmo can accidentally act on the wrong gizmo. */
+ if (ISTWEAK(event->type) || (event->val == KM_CLICK_DRAG)) {
+ mval[0] += event->x - event->prevclickx;
+ mval[1] += event->y - event->prevclicky;
+ }
+
for (int i = 0; i < ARRAY_SIZE(do_step); i++) {
do_step[i] = WM_gizmo_context_check_drawstep(C, i);
}
@@ -715,7 +724,7 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
wm_gizmogroup_intersectable_gizmos_to_list(gzgroup, &visible_3d_gizmos);
}
else if (step == WM_GIZMOMAP_DRAWSTEP_2D) {
- if ((gz = wm_gizmogroup_find_intersected_gizmo(gzgroup, C, event, r_part))) {
+ if ((gz = wm_gizmogroup_find_intersected_gizmo(gzgroup, C, mval, r_part))) {
break;
}
}
@@ -727,7 +736,7 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
/* 2D gizmos get priority. */
if (gz == NULL) {
gz = gizmo_find_intersected_3d(
- C, event->mval, visible_3d_gizmos.data, visible_3d_gizmos.count, r_part);
+ C, mval, visible_3d_gizmos.data, visible_3d_gizmos.count, r_part);
}
}
BLI_buffer_free(&visible_3d_gizmos);