Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-02-11 07:34:19 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-11 07:48:46 +0300
commit43156d830470fbbcd89bc1bd4b1f32d3348ba7a9 (patch)
tree605c05ee3b73459c8acf594024073e148dbfa5cb
parent1daaa74b089875562117b3978e5fe9783c21bbf5 (diff)
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.
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py1
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c2
-rw-r--r--source/blender/editors/interface/interface.c10
-rw-r--r--source/blender/editors/interface/interface_handlers.c7
-rw-r--r--source/blender/editors/interface/interface_intern.h1
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c11
7 files changed, 21 insertions, 13 deletions
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);