Commit: 57395061042fe336dae7ee33e3ae11e53d068194 Author: Campbell Barton Date: Wed Mar 20 02:48:11 2019 +1100 Branches: master https://developer.blender.org/rB57395061042fe336dae7ee33e3ae11e53d068194
UI: scale cursor motion threshold by DPI This was using hard coded values of 2-3px. Move both drag and motion thresholds to defines. =================================================================== M source/blender/editors/armature/armature_select.c M source/blender/editors/interface/interface_handlers.c M source/blender/editors/screen/screen_ops.c M source/blender/editors/space_view3d/view3d_select.c M source/blender/windowmanager/WM_types.h M source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c M source/blender/windowmanager/intern/wm_event_system.c =================================================================== diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 658392f77aa..8e58f14ec99 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -421,7 +421,7 @@ static EditBone *get_nearest_editbonepoint( if (vc->v3d->shading.type > OB_WIRE) { do_nearest = true; - if (len_manhattan_v2v2_int(vc->mval, last_mval) < 3) { + if (len_manhattan_v2v2_int(vc->mval, last_mval) < WM_EVENT_CURSOR_MOTION_THRESHOLD) { do_nearest = false; } } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index a52a9633729..50ff2c1e7ff 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -8136,9 +8136,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) /* Drag on a hold button (used in the toolbar) now opens it immediately. */ if (data->hold_action_timer) { if (but->flag & UI_SELECT) { - if ((abs(event->x - event->prevx)) > 2 || - (abs(event->y - event->prevy)) > 2) - { + if (len_manhattan_v2v2_int(&event->x, &event->prevx) >= WM_EVENT_CURSOR_MOTION_THRESHOLD) { WM_event_remove_timer(data->wm, data->window, data->hold_action_timer); data->hold_action_timer = WM_event_add_timer(data->wm, data->window, TIMER, 0.0f); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index bb56d127b31..b4dfcf9ab66 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2511,8 +2511,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) } case LEFTMOUSE: if (event->val == KM_RELEASE) { - - if (ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { + if (len_manhattan_v2v2_int(&event->x, &rmd->origx) < WM_EVENT_CURSOR_MOTION_THRESHOLD) { if (rmd->ar->flag & RGN_FLAG_HIDDEN) { region_scale_toggle_hidden(C, rmd); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 6a42c06e59d..d7128b7d21a 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1410,7 +1410,7 @@ static int mixed_bones_object_selectbuffer_extended( if (use_cycle) { if (v3d->shading.type > OB_WIRE) { do_nearest = true; - if (len_manhattan_v2v2_int(mval, last_mval) < 3) { + if (len_manhattan_v2v2_int(mval, last_mval) < WM_EVENT_CURSOR_MOTION_THRESHOLD) { do_nearest = false; } } diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 0f799448561..8ad63cb92c0 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -490,6 +490,18 @@ typedef struct wmEvent { } wmEvent; +/** + * Values below are considered a click, above are considered a drag. + */ +#define WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD (U.tweak_threshold * U.dpi_fac) + +/** + * Values below are ignored when detecting if the user interntionally moved the cursor. + * Keep this very small since it's used for selection cycling for eg, + * where we want intended adjustments to pass this threshold and select new items. + */ +#define WM_EVENT_CURSOR_MOTION_THRESHOLD (3 * U.dpi_fac) + /* ************** custom wmEvent data ************** */ typedef struct wmTabletData { int Active; /* 0=EVT_TABLET_NONE, 1=EVT_TABLET_STYLUS, 2=EVT_TABLET_ERASER */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index e1eb735f074..42dd5e8f293 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -61,7 +61,6 @@ /* Allow gizmo part's to be single click only, * dragging falls back to activating their 'drag_part' action. */ #define USE_DRAG_DETECT -#define DRAG_THRESHOLD (U.tweak_threshold * U.dpi_fac) /* -------------------------------------------------------------------- */ /** \name wmGizmoGroup @@ -440,7 +439,7 @@ static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) wmGizmoMap *gzmap = mtweak->gzmap; if (mtweak->drag_state == DRAG_DETECT) { if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { - if (len_manhattan_v2v2_int(&event->x, gzmap->gzmap_context.event_xy) >= DRAG_THRESHOLD) { + if (len_manhattan_v2v2_int(&event->x, gzmap->gzmap_context.event_xy) >= WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD) { mtweak->drag_state = DRAG_IDLE; gz->highlight_part = gz->drag_part; } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 1ae3f7ffb79..a6e492e7449 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2729,8 +2729,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) if (wm_action_not_handled(action)) { if (event->check_drag) { wmWindow *win = CTX_wm_window(C); - 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) { int x = event->x; int y = event->y; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs