[Bf-blender-cvs] [43156d83047] master: Preferences: remove tweak/drag threshold distinction

Campbell Barton noreply at git.blender.org
Mon Feb 11 05:49:51 CET 2019


Commit: 43156d830470fbbcd89bc1bd4b1f32d3348ba7a9
Author: Campbell Barton
Date:   Mon Feb 11 15:34:19 2019 +1100
Branches: master
https://developer.blender.org/rB43156d830470fbbcd89bc1bd4b1f32d3348ba7a9

Preferences: remove tweak/drag threshold distinction

Currently the preferences have both tweak and drag threshold,
this is confusing because most actions users would consider
dragging use the 'tweak' setting.

Now one drag threshold is used for both, with a maximum limit of half
the button unit-size in case of dragging UI elements.

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

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/blenloader/intern/versioning_userdef.c
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 2570930c457..c36a0f7a354 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1390,7 +1390,6 @@ class USERPREF_PT_input_mouse(PreferencePanel):
         flow.prop(inputs, "use_mouse_continuous")
         flow.prop(inputs, "use_drag_immediately")
         flow.prop(inputs, "drag_threshold")
-        flow.prop(inputs, "tweak_threshold")
         flow.prop(inputs, "mouse_double_click_time", text="Double Click Speed")
 
 
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 4db3fe76b0f..38c8808f818 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -314,8 +314,6 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
 		if (userdef->v2d_min_gridsize == 0) {
 			userdef->v2d_min_gridsize = 35;
 		}
-		if (userdef->dragthreshold == 0)
-			userdef->dragthreshold = 5;
 		if (userdef->widget_unit == 0)
 			userdef->widget_unit = 20;
 		if (userdef->anisotropic_filter <= 0)
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index f30d3c6ce25..47514f9f65c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -157,6 +157,16 @@ void ui_block_to_window_rctf(const ARegion *ar, uiBlock *block, rctf *rct_dst, c
 	ui_block_to_window_fl(ar, block, &rct_dst->xmax, &rct_dst->ymax);
 }
 
+float ui_block_to_window_scale(const ARegion *ar, uiBlock *block)
+{
+	/* We could have function for this to avoid dummy arg. */
+	float dummy_x;
+	float min_y = 0, max_y = 1;
+	ui_block_to_window_fl(ar, block, &dummy_x, &min_y);
+	ui_block_to_window_fl(ar, block, &dummy_x, &max_y);
+	return max_y - min_y;
+}
+
 /* for mouse cursor */
 void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y)
 {
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index f5649afbd28..92dac3f0257 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1734,8 +1734,13 @@ static bool ui_but_drag_init(
 	/* prevent other WM gestures to start while we try to drag */
 	WM_gestures_remove(C);
 
-	if (ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold * U.dpi_fac) {
+	/* 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,
+	        (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) {
 		button_activate_state(C, but, BUTTON_STATE_EXIT);
 		data->cancel = true;
 #ifdef USE_DRAG_TOGGLE
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 50ef9330762..2e5ed4ae14a 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -483,6 +483,7 @@ void ui_fontscale(short *points, float aspect);
 extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
 extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y);
 extern void ui_block_to_window_rctf(const struct ARegion *ar, uiBlock *block, rctf *rct_dst, const rctf *rct_src);
+extern float ui_block_to_window_scale(const struct ARegion *ar, uiBlock *block);
 extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
 extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y);
 extern void ui_window_to_region(const ARegion *ar, int *x, int *y);
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index b90a3d89603..b1d4145328b 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -641,7 +641,7 @@ typedef struct UserDef {
 	short edit_studio_light;
 	char _pad6[4];
 	short textimeout, texcollectrate;
-	short dragthreshold;
+	char _pad14[2];
 	int memcachelimit;
 	int prefetchframes;
 	/** Control the rotation step of the view when PAD2, PAD4, PAD6&PAD8 is use. */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index d11d1f7d515..38ce8a808a6 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -4671,16 +4671,11 @@ static void rna_def_userdef_input(BlenderRNA *brna)
 
 	/* tweak tablet & mouse preset */
 	prop = RNA_def_property(srna, "drag_threshold", PROP_INT, PROP_PIXEL);
-	RNA_def_property_int_sdna(prop, NULL, "dragthreshold");
-	RNA_def_property_range(prop, 3, 40);
-	RNA_def_property_ui_text(prop, "Drag Threshold",
-	                         "Amount of pixels you have to drag before dragging UI items happens");
-
-	prop = RNA_def_property(srna, "tweak_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, "Tweak Threshold",
-	                         "Number of pixels you have to drag before tweak event is triggered");
+	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)");
 
 	/* tablet pressure curve */
 	prop = RNA_def_property(srna, "pressure_threshold_max", PROP_FLOAT, PROP_FACTOR);



More information about the Bf-blender-cvs mailing list