Preferences: add threshold for cursor motion
authorCampbell Barton <ideasman42@gmail.com>
Wed, 20 Mar 2019 11:14:13 +0000 (22:14 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 20 Mar 2019 11:19:16 +0000 (22:19 +1100)
A hard coded threshold was used to ignore cursor motion,
make this a preference since tablet users may want to increase it
since a pen hovering isn't as easy to keep still as a mouse.

Resolves T56278

release/scripts/startup/bl_ui/space_userpref.py
source/blender/blenkernel/BKE_blender_version.h
source/blender/blenloader/intern/versioning_userdef.c
source/blender/editors/armature/armature_select.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c
source/blender/windowmanager/WM_types.h

index fadc4f4..1740731 100644 (file)
@@ -1384,6 +1384,7 @@ class USERPREF_PT_input_mouse(PreferencePanel, Panel):
         flow.prop(inputs, "use_mouse_continuous")
         flow.prop(inputs, "use_drag_immediately")
         flow.prop(inputs, "drag_threshold")
+        flow.prop(inputs, "move_threshold")
         flow.prop(inputs, "mouse_double_click_time", text="Double Click Speed")
 
 
index cad733f..62934b7 100644 (file)
@@ -24,7 +24,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         280
-#define BLENDER_SUBVERSION      50
+#define BLENDER_SUBVERSION      51
 /* Several breakages with 280, e.g. collections vs layers */
 #define BLENDER_MINVERSION      280
 #define BLENDER_MINSUBVERSION   0
index 14d10bb..ee6b0ab 100644 (file)
@@ -481,6 +481,10 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
                BKE_addon_remove_safe(&userdef->addons, "io_scene_3ds");
        }
 
+       if (!USER_VERSION_ATLEAST(280, 51)) {
+               userdef->move_threshold = 2;
+       }
+
        /**
         * Include next version bump.
         */
index 8e58f14..b10db51 100644 (file)
@@ -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) < WM_EVENT_CURSOR_MOTION_THRESHOLD) {
+                       if (len_manhattan_v2v2_int(vc->mval, last_mval) <= WM_EVENT_CURSOR_MOTION_THRESHOLD) {
                                do_nearest = false;
                        }
                }
index 50ff2c1..f31e903 100644 (file)
@@ -8136,7 +8136,10 @@ 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 (len_manhattan_v2v2_int(&event->x, &event->prevx) >= WM_EVENT_CURSOR_MOTION_THRESHOLD) {
+                                                       if (len_manhattan_v2v2_int(&event->x, &event->prevx) <= WM_EVENT_CURSOR_MOTION_THRESHOLD) {
+                                                               /* pass */
+                                                       }
+                                                       else {
                                                                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);
                                                        }
index b4dfcf9..4ce2101 100644 (file)
@@ -2511,7 +2511,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
                }
                case LEFTMOUSE:
                        if (event->val == KM_RELEASE) {
-                               if (len_manhattan_v2v2_int(&event->x, &rmd->origx) < WM_EVENT_CURSOR_MOTION_THRESHOLD) {
+                               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);
                                        }
index d7128b7..78a33a0 100644 (file)
@@ -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) < WM_EVENT_CURSOR_MOTION_THRESHOLD) {
+                       if (len_manhattan_v2v2_int(mval, last_mval) <= WM_EVENT_CURSOR_MOTION_THRESHOLD) {
                                do_nearest = false;
                        }
                }
index 1da28b4..d44b149 100644 (file)
@@ -723,8 +723,8 @@ typedef struct UserDef {
        float gpencil_new_layer_col[4];
 
        short tweak_threshold;
+       char move_threshold;
        char navigation_mode;
-       char _pad10;
 
        char font_path_ui[1024];
        char font_path_ui_mono[1024];
index f8908cb..a2de171 100644 (file)
@@ -4713,6 +4713,13 @@ static void rna_def_userdef_input(BlenderRNA *brna)
                                 "Number of pixels you have to drag before a tweak/drag event is triggered "
                                 "(otherwise click events are detected)");
 
+       prop = RNA_def_property(srna, "move_threshold", PROP_INT, PROP_PIXEL);
+       RNA_def_property_range(prop, 0, 255);
+       RNA_def_property_ui_range(prop, 0, 10, 1, -1);
+       RNA_def_property_ui_text(prop, "Motion Threshold",
+                                "Number of pixels you have to before the cursor is considered to have moved "
+                                "(used for cycling selected items on successive clicks)");
+
        /* tablet pressure curve */
        prop = RNA_def_property(srna, "pressure_threshold_max", PROP_FLOAT, PROP_FACTOR);
        RNA_def_property_range(prop, 0.0f, 1.0f);
index 8ad63cb..96560b4 100644 (file)
@@ -499,8 +499,10 @@ typedef struct wmEvent {
  * 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.
+ *
+ * Always check for <= this value since it may be zero.
  */
-#define WM_EVENT_CURSOR_MOTION_THRESHOLD (3 * U.dpi_fac)
+#define WM_EVENT_CURSOR_MOTION_THRESHOLD ((float)U.move_threshold * U.dpi_fac)
 
 /* ************** custom wmEvent data ************** */
 typedef struct wmTabletData {