WM: add gesture variable to detect first execution

Needed for circle select to replace the current selection.
This commit is contained in:
2019-03-01 23:00:11 +11:00
parent 9f77c20286
commit 3982d3c171
2 changed files with 8 additions and 2 deletions

View File

@@ -427,6 +427,8 @@ typedef struct wmGesture {
/* For modal operators which may be running idle, waiting for an event to activate the gesture.
* Typically this is set when the user is click-dragging the gesture (border and circle select for eg). */
uint is_active : 1;
/* Previous value of is-active (use to detect first run & edge cases). */
uint is_active_prev : 1;
/* Use for gestures that support both immediate or delayed activation. */
uint wait_for_input : 1;

View File

@@ -251,6 +251,7 @@ int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
#endif
gesture->is_active_prev = gesture->is_active;
return OPERATOR_RUNNING_MODAL;
}
@@ -383,8 +384,8 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
/* apply first click */
gesture_circle_apply(C, op);
gesture->is_active = true;
gesture_circle_apply(C, op);
wm_gesture_tag_redraw(C);
}
break;
@@ -422,7 +423,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
#endif
gesture->is_active_prev = gesture->is_active;
return OPERATOR_RUNNING_MODAL;
}
@@ -655,6 +656,8 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
gesture_modal_end(C, op);
return OPERATOR_CANCELLED;
}
gesture->is_active_prev = gesture->is_active;
return OPERATOR_RUNNING_MODAL;
}
@@ -841,6 +844,7 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
}
}
gesture->is_active_prev = gesture->is_active;
return OPERATOR_RUNNING_MODAL;
}