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.
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user