[Bf-blender-cvs] [0c8c1602029] master: WM: use different drag thresholds for mouse/tablet events

Campbell Barton noreply at git.blender.org
Thu May 30 07:29:44 CEST 2019


Commit: 0c8c1602029b5a0a34b7750c03b03fe990104c0e
Author: Campbell Barton
Date:   Thu May 30 14:47:24 2019 +1000
Branches: master
https://developer.blender.org/rB0c8c1602029b5a0a34b7750c03b03fe990104c0e

WM: use different drag thresholds for mouse/tablet events

Now a small threshold is used for mouse input,
avoiding delay when gizmos are activated on drag.

Tablet input threshold remains unchanged since
it's easier to make small movements when using a tablet.

A larger threshold for non-cursor input is now used (typically keyboard)
which improves usability when the "Pie Menu on Drag" key-map preference.

===================================================================

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenloader/intern/versioning_userdef.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index d1d65d7d238..79f7cdf6d5a 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1433,9 +1433,11 @@ class USERPREF_PT_input_mouse(PreferencePanel, Panel):
         flow.prop(inputs, "use_mouse_emulate_3_button")
         flow.prop(inputs, "use_mouse_continuous")
         flow.prop(inputs, "use_drag_immediately")
+        flow.prop(inputs, "mouse_double_click_time", text="Double Click Speed")
+        flow.prop(inputs, "drag_threshold_mouse")
+        flow.prop(inputs, "drag_threshold_tablet")
         flow.prop(inputs, "drag_threshold")
         flow.prop(inputs, "move_threshold")
-        flow.prop(inputs, "mouse_double_click_time", text="Double Click Speed")
 
 
 class USERPREF_PT_navigation_orbit(PreferencePanel, Panel):
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 7461a1b1051..887082a17a1 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -27,7 +27,7 @@
  * \note Use #STRINGIFY() rather than defining with quotes.
  */
 #define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 72
+#define BLENDER_SUBVERSION 73
 /** Several breakages with 280, e.g. collections vs layers. */
 #define BLENDER_MINVERSION 280
 #define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 89f4d86b1b8..7ff9dd70379 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -411,9 +411,6 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
         userdef->ndof_flag |= NDOF_TURNTABLE;
       }
     }
-    if (userdef->tweak_threshold == 0) {
-      userdef->tweak_threshold = 10;
-    }
   }
 
   /* NOTE!! from now on use userdef->versionfile and userdef->subversionfile */
@@ -604,6 +601,12 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
     userdef->pref_flag |= USER_PREF_FLAG_SAVE;
   }
 
+  if (!USER_VERSION_ATLEAST(280, 73)) {
+    userdef->drag_threshold = 30;
+    userdef->drag_threshold_mouse = 3;
+    userdef->drag_threshold_tablet = 10;
+  }
+
   /**
    * Include next version bump.
    */
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index fa12de56364..3fbdbbb6afa 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -735,7 +735,9 @@ typedef struct UserDef {
 
   /** Options for text rendering. */
   short text_render;
-  char _pad9[2];
+  char _pad9;
+
+  char navigation_mode;
 
   /** From texture.h. */
   struct ColorBand coba_weight;
@@ -744,9 +746,11 @@ typedef struct UserDef {
   /** Default color for newly created Grease Pencil layers. */
   float gpencil_new_layer_col[4];
 
-  short tweak_threshold;
+  /** Drag pixels (scaled by DPI). */
+  char drag_threshold_mouse;
+  char drag_threshold_tablet;
+  char drag_threshold;
   char move_threshold;
-  char navigation_mode;
 
   char font_path_ui[1024];
   char font_path_ui_mono[1024];
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index d06e938b262..f505e4d9e09 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -5201,23 +5201,37 @@ static void rna_def_userdef_input(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Walk Navigation", "Settings for walk navigation mode");
 
   /* tweak tablet & mouse preset */
+  prop = RNA_def_property(srna, "drag_threshold_mouse", PROP_INT, PROP_PIXEL);
+  RNA_def_property_range(prop, 3, 255);
+  RNA_def_property_ui_text(prop,
+                           "Mouse Drag Threshold",
+                           "Number of pixels to drag before a tweak/drag event is triggered "
+                           "for mouse/track-pad input "
+                           "(otherwise click events are detected)");
+
+  prop = RNA_def_property(srna, "drag_threshold_tablet", PROP_INT, PROP_PIXEL);
+  RNA_def_property_range(prop, 3, 255);
+  RNA_def_property_ui_text(prop,
+                           "Tablet Drag Threshold",
+                           "Number of pixels to drag before a tweak/drag event is triggered "
+                           "for tablet input "
+                           "(otherwise click events are detected)");
+
   prop = RNA_def_property(srna, "drag_threshold", PROP_INT, PROP_PIXEL);
-  RNA_def_property_int_sdna(prop, NULL, "tweak_threshold");
-  RNA_def_property_range(prop, 3, 1024);
-  RNA_def_property_ui_text(
-      prop,
-      "Drag Threshold",
-      "Number of pixels you have to drag before a tweak/drag event is triggered "
-      "(otherwise click events are detected)");
+  RNA_def_property_range(prop, 3, 255);
+  RNA_def_property_ui_text(prop,
+                           "Drag Threshold",
+                           "Number of pixels to drag before a drag event is triggered "
+                           "for keyboard and other non mouse/tablet input "
+                           "(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)");
+  RNA_def_property_ui_text(prop,
+                           "Motion Threshold",
+                           "Number of pixels 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);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 7aad89a4bdb..387bc949da8 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -5191,9 +5191,20 @@ bool WM_window_modal_keymap_status_draw(bContext *UNUSED(C), wmWindow *win, uiLa
  *
  * \{ */
 
-int WM_event_drag_threshold(const struct wmEvent *UNUSED(event))
+int WM_event_drag_threshold(const struct wmEvent *event)
 {
-  return (int)((float)U.tweak_threshold * U.dpi_fac);
+  int drag_threshold;
+  if (WM_event_is_tablet(event)) {
+    drag_threshold = U.drag_threshold_tablet;
+  }
+  else if (ISMOUSE(event->prevtype)) {
+    drag_threshold = U.drag_threshold_mouse;
+  }
+  else {
+    /* Typically keyboard, could be NDOF button or other less common types. */
+    drag_threshold = U.drag_threshold;
+  }
+  return drag_threshold * U.dpi_fac;
 }
 
 bool WM_event_drag_test_with_delta(const wmEvent *event, const int drag_delta[2])



More information about the Bf-blender-cvs mailing list