diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-05-29 11:13:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-05-29 11:13:33 +0300 |
commit | 07d453dd9e0207ff74c0f85583ef9fcc8d54a218 (patch) | |
tree | 00af234ccda861f81cbf1b0035e081ae04129241 | |
parent | 8949dfb7a6e2cc9c24d43b0cac4342a1962e22d9 (diff) |
UI: use matching distance checks & define for dragging
4 files changed, 11 insertions, 13 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index f17e6370d09..f08829c6556 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1762,7 +1762,7 @@ static bool ui_but_drag_init(bContext *C, /* Clamp the maximum to half the UI unit size so a high user preference * doesn't require the user to drag more then half the default button height. */ const int drag_threshold = min_ii( - U.tweak_threshold * U.dpi_fac, + WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD, (int)((UI_UNIT_Y / 2) * ui_block_to_window_scale(data->region, but->block))); if (ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > drag_threshold) { diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index aab328249fe..11462358d88 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -613,11 +613,11 @@ static int node_select_modal(bContext *C, wmOperator *op, const wmEvent *event) else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { const int dx = mval[0] - event->mval[0]; const int dy = mval[1] - event->mval[1]; - const float tweak_threshold = U.tweak_threshold * U.dpi_fac; + const int drag_threshold = WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD; /* If user moves mouse more than defined threshold, we consider select operator as * finished. Otherwise, it is still running until we get an 'release' event. In any * case, we pass through event, but select op is not finished yet. */ - if (abs(dx) + abs(dy) > tweak_threshold) { + if (abs(dx) >= drag_threshold || abs(dy) >= drag_threshold) { return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } else { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 198e26aa465..04ff29b6fbf 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -87,10 +87,6 @@ #include "DEG_depsgraph.h" -/* Motion in pixels allowed before we don't consider single/double click, - * or detect the start of a tweak event. */ -#define WM_EVENT_CLICK_TWEAK_THRESHOLD (U.tweak_threshold * U.dpi_fac) - static void wm_notifier_clear(wmNotifier *note); static void update_tablet_data(wmWindow *win, wmEvent *event); @@ -2932,8 +2928,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) if ((event->val == KM_RELEASE) && (win->eventstate->prevval == KM_PRESS) && (win->eventstate->check_click == true)) { - if ((abs(event->x - win->eventstate->prevclickx)) < WM_EVENT_CLICK_TWEAK_THRESHOLD && - (abs(event->y - win->eventstate->prevclicky)) < WM_EVENT_CLICK_TWEAK_THRESHOLD) { + if ((abs(event->x - win->eventstate->prevclickx)) < + WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD && + (abs(event->y - win->eventstate->prevclicky)) < + WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD) { /* Position is where the actual click happens, for more * accurate selecting in case the mouse drifts a little. */ int x = event->x; @@ -4261,8 +4259,8 @@ static bool wm_event_is_double_click(wmEvent *event, const wmEvent *event_state) if ((event->type == event_state->prevtype) && (event_state->prevval == KM_RELEASE) && (event->val == KM_PRESS)) { if ((ISMOUSE(event->type) == false) || - ((abs(event->x - event_state->prevclickx)) < WM_EVENT_CLICK_TWEAK_THRESHOLD && - (abs(event->y - event_state->prevclicky)) < WM_EVENT_CLICK_TWEAK_THRESHOLD)) { + ((abs(event->x - event_state->prevclickx)) < WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD && + (abs(event->y - event_state->prevclicky)) < WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD)) { if ((PIL_check_seconds_timer() - event_state->prevclicktime) * 1000 < U.dbl_click_time) { return true; } diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index e117a1bcdfe..bc985087475 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -134,8 +134,8 @@ int wm_gesture_evaluate(wmGesture *gesture) rcti *rect = gesture->customdata; int dx = BLI_rcti_size_x(rect); int dy = BLI_rcti_size_y(rect); - float tweak_threshold = U.tweak_threshold * U.dpi_fac; - if (abs(dx) + abs(dy) > tweak_threshold) { + 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); int val = EVT_GESTURE_W; |