Preferences: add threshold for cursor motion

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
This commit is contained in:
Campbell Barton 2019-03-20 22:14:13 +11:00
parent 454b90483d
commit ef09aff61c
Notes: blender-bot 2023-02-14 11:07:28 +01:00
Referenced by issue #56278, Blender 2.8 selection inconsistent between mouse and pen.
10 changed files with 24 additions and 7 deletions

View 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")

View 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

View 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.
*/

View 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;
}
}

View 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);
}

View 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);
}

View 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;
}
}

View 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];

View 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);

View 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 {