UI: use matching distance checks & define for dragging
This commit is contained in:
parent
8949dfb7a6
commit
07d453dd9e
|
@ -1762,7 +1762,7 @@ static bool ui_but_drag_init(bContext *C,
|
|||
/* 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,
|
||||
WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD,
|
||||
(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) {
|
||||
|
|
|
@ -613,11 +613,11 @@ static int node_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
|
||||
const int dx = mval[0] - event->mval[0];
|
||||
const int dy = mval[1] - event->mval[1];
|
||||
const float tweak_threshold = U.tweak_threshold * U.dpi_fac;
|
||||
const int drag_threshold = WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD;
|
||||
/* If user moves mouse more than defined threshold, we consider select operator as
|
||||
* finished. Otherwise, it is still running until we get an 'release' event. In any
|
||||
* case, we pass through event, but select op is not finished yet. */
|
||||
if (abs(dx) + abs(dy) > tweak_threshold) {
|
||||
if (abs(dx) >= drag_threshold || abs(dy) >= drag_threshold) {
|
||||
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -87,10 +87,6 @@
|
|||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
/* Motion in pixels allowed before we don't consider single/double click,
|
||||
* or detect the start of a tweak event. */
|
||||
#define WM_EVENT_CLICK_TWEAK_THRESHOLD (U.tweak_threshold * U.dpi_fac)
|
||||
|
||||
static void wm_notifier_clear(wmNotifier *note);
|
||||
static void update_tablet_data(wmWindow *win, wmEvent *event);
|
||||
|
||||
|
@ -2932,8 +2928,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
|||
|
||||
if ((event->val == KM_RELEASE) && (win->eventstate->prevval == KM_PRESS) &&
|
||||
(win->eventstate->check_click == true)) {
|
||||
if ((abs(event->x - win->eventstate->prevclickx)) < WM_EVENT_CLICK_TWEAK_THRESHOLD &&
|
||||
(abs(event->y - win->eventstate->prevclicky)) < WM_EVENT_CLICK_TWEAK_THRESHOLD) {
|
||||
if ((abs(event->x - win->eventstate->prevclickx)) <
|
||||
WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD &&
|
||||
(abs(event->y - win->eventstate->prevclicky)) <
|
||||
WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD) {
|
||||
/* Position is where the actual click happens, for more
|
||||
* accurate selecting in case the mouse drifts a little. */
|
||||
int x = event->x;
|
||||
|
@ -4261,8 +4259,8 @@ static bool wm_event_is_double_click(wmEvent *event, const wmEvent *event_state)
|
|||
if ((event->type == event_state->prevtype) && (event_state->prevval == KM_RELEASE) &&
|
||||
(event->val == KM_PRESS)) {
|
||||
if ((ISMOUSE(event->type) == false) ||
|
||||
((abs(event->x - event_state->prevclickx)) < WM_EVENT_CLICK_TWEAK_THRESHOLD &&
|
||||
(abs(event->y - event_state->prevclicky)) < WM_EVENT_CLICK_TWEAK_THRESHOLD)) {
|
||||
((abs(event->x - event_state->prevclickx)) < WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD &&
|
||||
(abs(event->y - event_state->prevclicky)) < WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD)) {
|
||||
if ((PIL_check_seconds_timer() - event_state->prevclicktime) * 1000 < U.dbl_click_time) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -134,8 +134,8 @@ int wm_gesture_evaluate(wmGesture *gesture)
|
|||
rcti *rect = gesture->customdata;
|
||||
int dx = BLI_rcti_size_x(rect);
|
||||
int dy = BLI_rcti_size_y(rect);
|
||||
float tweak_threshold = U.tweak_threshold * U.dpi_fac;
|
||||
if (abs(dx) + abs(dy) > tweak_threshold) {
|
||||
const int drag_threshold = WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD;
|
||||
if (abs(dx) >= drag_threshold || abs(dy) >= drag_threshold) {
|
||||
int theta = round_fl_to_int(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI);
|
||||
int val = EVT_GESTURE_W;
|
||||
|
||||
|
|
Loading…
Reference in New Issue