[Bf-blender-cvs] [88692baacef] master: WM: gestures now activate immediately on mouse press
Campbell Barton
noreply at git.blender.org
Thu Sep 23 14:11:09 CEST 2021
Commit: 88692baacef170d90e55f6ab89392237a55b1bf3
Author: Campbell Barton
Date: Thu Sep 23 22:06:50 2021 +1000
Branches: master
https://developer.blender.org/rB88692baacef170d90e55f6ab89392237a55b1bf3
WM: gestures now activate immediately on mouse press
Some gestures were activating immediately on tweak events,
extend this to mouse-press and click-drag.
Without this change, box-select for example wouldn't be automatically
activated on mouse-press.
===================================================================
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_event_query.c
M source/blender/windowmanager/intern/wm_gesture_ops.c
===================================================================
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index c5482a729c3..577561017c4 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -906,6 +906,7 @@ int WM_event_modifier_flag(const struct wmEvent *event);
bool WM_event_is_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
bool WM_event_is_last_mousemove(const struct wmEvent *event);
bool WM_event_is_mouse_drag(const struct wmEvent *event);
+bool WM_event_is_mouse_drag_or_press(const wmEvent *event);
int WM_event_drag_threshold(const struct wmEvent *event);
bool WM_event_drag_test(const struct wmEvent *event, const int prev_xy[2]);
diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c
index e22285214f0..7b5691b99a0 100644
--- a/source/blender/windowmanager/intern/wm_event_query.c
+++ b/source/blender/windowmanager/intern/wm_event_query.c
@@ -270,6 +270,12 @@ bool WM_event_is_mouse_drag(const wmEvent *event)
return ISTWEAK(event->type) || (ISMOUSE_BUTTON(event->type) && (event->val == KM_CLICK_DRAG));
}
+bool WM_event_is_mouse_drag_or_press(const wmEvent *event)
+{
+ return WM_event_is_mouse_drag(event) ||
+ (ISMOUSE_BUTTON(event->type) && (event->val == KM_PRESS));
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index cc376d8f201..578699dda60 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -179,7 +179,8 @@ int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
wmWindow *win = CTX_wm_window(C);
const ARegion *region = CTX_wm_region(C);
- const bool wait_for_input = !ISTWEAK(event->type) && RNA_boolean_get(op->ptr, "wait_for_input");
+ const bool wait_for_input = !WM_event_is_mouse_drag_or_press(event) &&
+ RNA_boolean_get(op->ptr, "wait_for_input");
if (wait_for_input) {
op->customdata = WM_gesture_new(win, region, event, WM_GESTURE_CROSS_RECT);
@@ -300,7 +301,8 @@ static void gesture_circle_apply(bContext *C, wmOperator *op);
int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
wmWindow *win = CTX_wm_window(C);
- const bool wait_for_input = !ISTWEAK(event->type) && RNA_boolean_get(op->ptr, "wait_for_input");
+ const bool wait_for_input = !WM_event_is_mouse_drag_or_press(event) &&
+ RNA_boolean_get(op->ptr, "wait_for_input");
op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_CIRCLE);
wmGesture *gesture = op->customdata;
@@ -871,7 +873,7 @@ int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *e
op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_STRAIGHTLINE);
- if (ISTWEAK(event->type)) {
+ if (WM_event_is_mouse_drag_or_press(event)) {
wmGesture *gesture = op->customdata;
gesture->is_active = true;
}
More information about the Bf-blender-cvs
mailing list