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-30 07:17:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-30 08:02:53 +0300
commit82e8e5c871f86e65f332cdde3bd484a55e7e8572 (patch)
treeccbd4e45e339bd4c62231d12b3499bdfdeaed6e4 /source/blender/windowmanager/intern/wm_gesture.c
parent2437a8b6f02144d796829a32461878ff2160c791 (diff)
Cleanup: move click/drag events to functions
Simplifies future changes to dragging checks and avoids each check for drag using slightly different logic.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_gesture.c')
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index bc985087475..ea92409d528 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -128,15 +128,17 @@ bool WM_gesture_is_modal_first(const wmGesture *gesture)
}
/* tweak and line gestures */
-int wm_gesture_evaluate(wmGesture *gesture)
+int wm_gesture_evaluate(wmGesture *gesture, const wmEvent *event)
{
if (gesture->type == WM_GESTURE_TWEAK) {
rcti *rect = gesture->customdata;
- int dx = BLI_rcti_size_x(rect);
- int dy = BLI_rcti_size_y(rect);
- const int drag_threshold = WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD;
- if (abs(dx) >= drag_threshold || abs(dy) >= drag_threshold) {
- int theta = round_fl_to_int(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI);
+ const int delta[2] = {
+ BLI_rcti_size_x(rect),
+ BLI_rcti_size_y(rect),
+ };
+
+ if (WM_event_drag_test_with_delta(event, delta)) {
+ int theta = round_fl_to_int(4.0f * atan2f((float)delta[1], (float)delta[0]) / (float)M_PI);
int val = EVT_GESTURE_W;
if (theta == 0) {