Merge branch 'master' into blender2.8

This commit is contained in:
Campbell Barton 2017-10-16 22:28:24 +11:00
commit a2758152e2
43 changed files with 531 additions and 388 deletions

View File

@ -90,6 +90,9 @@ void DepsgraphNodeBuilder::build_ik_pose(Scene *scene,
/* Find the chain's root. */
bPoseChannel *rootchan = BKE_armature_ik_solver_find_root(pchan, data);
if (rootchan == NULL) {
return;
}
if (has_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name,
DEG_OPCODE_POSE_IK_SOLVER))

View File

@ -83,6 +83,9 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *ob,
* - see notes on direction of rel below...
*/
bPoseChannel *rootchan = BKE_armature_ik_solver_find_root(pchan, data);
if (rootchan == NULL) {
return;
}
OperationKey pchan_local_key(&ob->id, DEG_NODE_TYPE_BONE,
pchan->name, DEG_OPCODE_BONE_LOCAL);
OperationKey init_ik_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT_IK);

View File

@ -2457,8 +2457,8 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op)
bAnimContext ac;
rcti rect;
short selectmode = 0;
int gesture_mode;
bool extend;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
@ -2466,17 +2466,17 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op)
/* get settings from operator */
WM_operator_properties_border_to_rcti(op, &rect);
gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
extend = RNA_boolean_get(op->ptr, "extend");
if (!extend)
if (!extend) {
ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_CLEAR);
}
if (gesture_mode == GESTURE_MODAL_SELECT)
if (select) {
selectmode = ACHANNEL_SETFLAG_ADD;
else
}
else {
selectmode = ACHANNEL_SETFLAG_CLEAR;
}
/* apply borderselect animation channels */
borderselect_anim_channels(&ac, &rect, selectmode);
@ -2495,10 +2495,10 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot)
ot->description = "Select all animation channels within the specified region";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = animchannels_borderselect_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = animedit_poll_channels_nla_tweakmode_off;
@ -2506,7 +2506,7 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}
/* ******************* Rename Operator ***************************** */

View File

@ -1249,7 +1249,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
View2D *v2d = UI_view2d_fromcontext(C);
ListBase *markers = ED_context_get_markers(C);
TimeMarker *marker;
int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
bool select = !RNA_boolean_get(op->ptr, "deselect");
bool extend = RNA_boolean_get(op->ptr, "extend");
rctf rect;
@ -1262,13 +1262,11 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
/* XXX marker context */
for (marker = markers->first; marker; marker = marker->next) {
if (BLI_rctf_isect_x(&rect, marker->frame)) {
switch (gesture_mode) {
case GESTURE_MODAL_SELECT:
marker->flag |= SELECT;
break;
case GESTURE_MODAL_DESELECT:
marker->flag &= ~SELECT;
break;
if (select) {
marker->flag |= SELECT;
}
else {
marker->flag &= ~SELECT;
}
}
else if (!extend) {
@ -1284,7 +1282,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
static int ed_marker_select_border_invoke_wrapper(bContext *C, wmOperator *op, const wmEvent *event)
{
return ed_markers_opwrap_invoke_custom(C, op, event, WM_border_select_invoke);
return ed_markers_opwrap_invoke_custom(C, op, event, WM_gesture_border_invoke);
}
static void MARKER_OT_select_border(wmOperatorType *ot)
@ -1297,8 +1295,8 @@ static void MARKER_OT_select_border(wmOperatorType *ot)
/* api callbacks */
ot->exec = ed_marker_border_select_exec;
ot->invoke = ed_marker_select_border_invoke_wrapper;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ed_markers_poll_markers_exist;
@ -1306,7 +1304,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}
/* *********************** (de)select all ***************** */

View File

@ -318,10 +318,10 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot)
ot->description = "Interactively define frame range used for playback";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = previewrange_define_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ED_operator_animview_active;

View File

@ -1851,8 +1851,6 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
void GPENCIL_OT_brush_paint(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name = "Stroke Sculpt";
ot->idname = "GPENCIL_OT_brush_paint";
@ -1869,7 +1867,9 @@ void GPENCIL_OT_brush_paint(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* properties */
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input",
"Enter a mini 'sculpt-mode' if enabled, otherwise, exit after drawing a single stroke");

View File

@ -2784,8 +2784,10 @@ void GPENCIL_OT_draw(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
/* settings for drawing */
PropertyRNA *prop;
ot->prop = RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to interpret mouse movements");
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
/* NOTE: wait for input is enabled by default, so that all UI code can work properly without needing users to know about this */
RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "Wait for first click instead of painting immediately");

View File

@ -769,8 +769,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
const int my = RNA_int_get(op->ptr, "y");
const int radius = RNA_int_get(op->ptr, "radius");
const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const bool select = (gesture_mode == GESTURE_MODAL_SELECT);
bool select = !RNA_boolean_get(op->ptr, "deselect");
GP_SpaceConversion gsc = {NULL};
rcti rect = {0}; /* for bounding rect around circle (for quicky intersection testing) */
@ -830,10 +829,7 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX);
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
WM_operator_properties_gesture_circle_select(ot);
}
/* ********************************************** */
@ -843,8 +839,7 @@ static int gpencil_border_select_exec(bContext *C, wmOperator *op)
{
ScrArea *sa = CTX_wm_area(C);
const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const bool select = (gesture_mode == GESTURE_MODAL_SELECT);
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
GP_SpaceConversion gsc = {NULL};
@ -936,10 +931,10 @@ void GPENCIL_OT_select_border(wmOperatorType *ot)
ot->idname = "GPENCIL_OT_select_border";
/* callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = gpencil_border_select_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = gpencil_select_poll;
@ -947,7 +942,7 @@ void GPENCIL_OT_select_border(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}
/* ********************************************** */
@ -1056,9 +1051,8 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_UNDO;
RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first");
/* properties */
WM_operator_properties_gesture_lasso_select(ot);
}
/* ********************************************** */

View File

@ -1223,7 +1223,6 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
View2D *v2d = &ar->v2d;
rctf rect;
rctf cur_new = v2d->cur;
int gesture_mode;
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* convert coordinates of rect to 'tot' rect coordinates */
@ -1231,9 +1230,9 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
/* check if zooming in/out view */
gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out");
if (gesture_mode == GESTURE_MODAL_IN) {
if (zoom_in) {
/* zoom in:
* - 'cur' rect will be defined by the coordinates of the border region
* - just set the 'cur' rect to have the same coordinates as the border region
@ -1248,8 +1247,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
cur_new.ymax = rect.ymax;
}
}
else { /* if (gesture_mode == GESTURE_MODAL_OUT) */
else {
/* zoom out:
* - the current 'cur' rect coordinates are going to end up where the 'rect' ones are,
* but the 'cur' rect coordinates will need to be adjusted to take in more of the view
@ -1289,15 +1287,15 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
ot->idname = "VIEW2D_OT_zoom_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = view_borderzoom_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = view_zoom_poll;
/* rna */
WM_operator_properties_gesture_border(ot, false);
WM_operator_properties_gesture_border_zoom(ot);
}
#ifdef WITH_INPUT_NDOF
@ -1545,7 +1543,7 @@ static void VIEW2D_OT_smoothview(wmOperatorType *ot)
ot->flag = OPTYPE_INTERNAL;
/* rna */
WM_operator_properties_gesture_border(ot, false);
WM_operator_properties_gesture_border(ot);
}
/* ********************************************************* */

View File

@ -408,8 +408,9 @@ static int border_select_exec(bContext *C, wmOperator *op)
rcti rect;
rctf rectf;
int mode;
bool changed = false, extend;
bool changed = false;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
/* get rectangle from operator */
WM_operator_properties_border_to_rcti(op, &rect);
@ -417,9 +418,6 @@ static int border_select_exec(bContext *C, wmOperator *op)
ED_mask_point_pos(sa, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
ED_mask_point_pos(sa, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
mode = RNA_int_get(op->ptr, "gesture_mode");
extend = RNA_boolean_get(op->ptr, "extend");
/* do actual selection */
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
MaskSpline *spline;
@ -439,8 +437,8 @@ static int border_select_exec(bContext *C, wmOperator *op)
/* TODO: uw? */
if (BLI_rctf_isect_pt_v(&rectf, point_deform->bezt.vec[1])) {
BKE_mask_point_select_set(point, mode == GESTURE_MODAL_SELECT);
BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, mode == GESTURE_MODAL_SELECT);
BKE_mask_point_select_set(point, select);
BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, select);
}
else if (!extend) {
BKE_mask_point_select_set(point, false);
@ -471,16 +469,16 @@ void MASK_OT_select_border(wmOperatorType *ot)
ot->idname = "MASK_OT_select_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = border_select_exec;
ot->modal = WM_border_select_modal;
ot->modal = WM_gesture_border_modal;
ot->poll = ED_maskedit_mask_poll;
/* flags */
ot->flag = OPTYPE_UNDO;
/* properties */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}
static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves, short select)
@ -580,9 +578,7 @@ void MASK_OT_select_lasso(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first");
WM_operator_properties_gesture_lasso_select(ot);
}
/********************** circle select operator *********************/
@ -608,15 +604,15 @@ static int circle_select_exec(bContext *C, wmOperator *op)
int i;
float zoomx, zoomy, offset[2], ellipse[2];
int x, y, radius, width, height, mode;
int width, height;
bool changed = false;
/* get operator properties */
x = RNA_int_get(op->ptr, "x");
y = RNA_int_get(op->ptr, "y");
radius = RNA_int_get(op->ptr, "radius");
const int x = RNA_int_get(op->ptr, "x");
const int y = RNA_int_get(op->ptr, "y");
const int radius = RNA_int_get(op->ptr, "radius");
mode = RNA_int_get(op->ptr, "gesture_mode");
const bool select = !RNA_boolean_get(op->ptr, "deselect");
/* compute ellipse and position in unified coordinates */
ED_mask_get_size(sa, &width, &height);
@ -644,8 +640,8 @@ static int circle_select_exec(bContext *C, wmOperator *op)
MaskSplinePoint *point_deform = &points_array[i];
if (mask_spline_point_inside_ellipse(&point_deform->bezt, offset, ellipse)) {
BKE_mask_point_select_set(point, mode == GESTURE_MODAL_SELECT);
BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, mode == GESTURE_MODAL_SELECT);
BKE_mask_point_select_set(point, select);
BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, select);
changed = true;
}
@ -681,10 +677,7 @@ void MASK_OT_select_circle(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX);
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
WM_operator_properties_gesture_circle_select(ot);
}
static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)

View File

@ -2981,8 +2981,6 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
void MESH_OT_knife_cut(wmOperatorType *ot)
{
PropertyRNA *prop;
ot->name = "Knife Cut";
ot->description = "Cut selected edges and faces into parts";
ot->idname = "MESH_OT_knife_cut";
@ -2995,10 +2993,13 @@ void MESH_OT_knife_cut(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
RNA_def_enum(ot->srna, "type", knife_items, KNIFE_EXACT, "Type", "");
prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
/* internal */
RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, BC_NUMCURSORS, "Cursor", "", 0, BC_NUMCURSORS);

View File

@ -4127,7 +4127,9 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
/* properties */
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
/*********************** cut shape ***************************/

View File

@ -3804,9 +3804,9 @@ static void SCREEN_OT_border_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = border_select_exec;
ot->invoke = WM_border_select_invoke;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->invoke = WM_gesture_border_invoke;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ED_operator_areaactive;

View File

@ -436,7 +436,7 @@ static int hide_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
PartialVisArea area = RNA_enum_get(op->ptr, "area");
if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED))
return WM_border_select_invoke(C, op, event);
return WM_gesture_border_invoke(C, op, event);
else
return op->type->exec(C, op);
}
@ -464,7 +464,7 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot)
/* api callbacks */
ot->invoke = hide_show_invoke;
ot->modal = WM_border_select_modal;
ot->modal = WM_gesture_border_modal;
ot->exec = hide_show_exec;
/* sculpt-only for now */
ot->poll = sculpt_mode_poll_view3d;

View File

@ -511,8 +511,6 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
{
PropertyRNA *prop;
ot->name = "Mask Lasso Gesture";
ot->idname = "PAINT_OT_mask_lasso_gesture";
ot->description = "Add mask within the lasso as you move the brush";
@ -525,8 +523,8 @@ void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
/* properties */
WM_operator_properties_gesture_lasso(ot);
RNA_def_enum(ot->srna, "mode", mode_items, PAINT_MASK_FLOOD_VALUE, "Mode", NULL);
RNA_def_float(ot->srna, "value", 1.0, 0, 1.0, "Value",

View File

@ -214,7 +214,10 @@ void paint_stroke_operator_properties(wmOperatorType *ot)
{0}
};
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL,
"Stroke Mode",

View File

@ -309,26 +309,27 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op)
bAnimContext ac;
rcti rect;
short mode = 0, selectmode = 0;
int gesture_mode;
bool extend;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
/* clear all selection if not extending selection */
extend = RNA_boolean_get(op->ptr, "extend");
if (!extend)
if (!extend) {
deselect_action_keys(&ac, 1, SELECT_SUBTRACT);
}
/* get settings from operator */
WM_operator_properties_border_to_rcti(op, &rect);
gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
if (gesture_mode == GESTURE_MODAL_SELECT)
if (select) {
selectmode = SELECT_ADD;
else
}
else {
selectmode = SELECT_SUBTRACT;
}
/* selection 'mode' depends on whether borderselect region only matters on one axis */
if (RNA_boolean_get(op->ptr, "axis_range")) {
@ -362,10 +363,10 @@ void ACTION_OT_select_border(wmOperatorType *ot)
ot->description = "Select all keyframes within the specified region";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = actkeys_borderselect_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ED_operator_action_active;
@ -373,7 +374,7 @@ void ACTION_OT_select_border(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
}
@ -572,9 +573,7 @@ void ACTION_OT_select_lasso(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items");
RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection instead of deselecting everything first");
WM_operator_properties_gesture_lasso_select(ot);
}
/* ------------------- */
@ -582,8 +581,8 @@ void ACTION_OT_select_lasso(wmOperatorType *ot)
static int action_circle_select_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const short selectmode = (gesture_mode == GESTURE_MODAL_SELECT) ? SELECT_ADD : SELECT_SUBTRACT;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT;
KeyframeEdit_CircleData data = {0};
rctf rect_fl;
@ -629,11 +628,9 @@ void ACTION_OT_select_circle(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_UNDO;
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX);
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX);
/* properties */
WM_operator_properties_gesture_circle_select(ot);
}
/* ******************** Column Select Operator **************************** */

View File

@ -332,8 +332,7 @@ void CLIP_OT_graph_select(wmOperatorType *ot)
typedef struct BorderSelectuserData {
rctf rect;
int mode;
bool changed, extend;
bool select, extend, changed;
} BorderSelectuserData;
static void border_select_cb(void *userdata, MovieTrackingTrack *UNUSED(track),
@ -349,11 +348,12 @@ static void border_select_cb(void *userdata, MovieTrackingTrack *UNUSED(track),
else
flag = MARKER_GRAPH_SEL_Y;
if (data->mode == GESTURE_MODAL_SELECT)
if (data->select) {
marker->flag |= flag;
else
}
else {
marker->flag &= ~flag;
}
data->changed = true;
}
else if (!data->extend) {
@ -381,7 +381,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view_rctf(&ar->v2d, &rect, &userdata.rect);
userdata.changed = false;
userdata.mode = RNA_int_get(op->ptr, "gesture_mode");
userdata.select = !RNA_boolean_get(op->ptr, "deselect");
userdata.extend = RNA_boolean_get(op->ptr, "extend");
clip_graph_tracking_values_iterate_track(sc, act_track, &userdata, border_select_cb, NULL, NULL);
@ -403,16 +403,16 @@ void CLIP_OT_graph_select_border(wmOperatorType *ot)
ot->idname = "CLIP_OT_graph_select_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = border_select_graph_exec;
ot->modal = WM_border_select_modal;
ot->modal = WM_gesture_border_modal;
ot->poll = clip_graph_knots_poll;
/* flags */
ot->flag = OPTYPE_UNDO;
/* properties */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}
/********************** select all operator *********************/

View File

@ -438,7 +438,6 @@ static int border_select_exec(bContext *C, wmOperator *op)
rcti rect;
rctf rectf;
bool changed = false;
int mode, extend;
int framenr = ED_space_clip_get_clip_frame_number(sc);
/* get rectangle from operator */
@ -447,8 +446,8 @@ static int border_select_exec(bContext *C, wmOperator *op)
ED_clip_point_stable_pos(sc, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
ED_clip_point_stable_pos(sc, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
mode = RNA_int_get(op->ptr, "gesture_mode");
extend = RNA_boolean_get(op->ptr, "extend");
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
/* do actual selection */
track = tracksbase->first;
@ -458,10 +457,12 @@ static int border_select_exec(bContext *C, wmOperator *op)
if (MARKER_VISIBLE(sc, track, marker)) {
if (BLI_rctf_isect_pt_v(&rectf, marker->pos)) {
if (mode == GESTURE_MODAL_SELECT)
if (select) {
BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
else
}
else {
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
}
}
else if (!extend) {
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
@ -485,7 +486,7 @@ static int border_select_exec(bContext *C, wmOperator *op)
for (i = 0; i < 4; i++) {
if (BLI_rctf_isect_pt_v(&rectf, plane_marker->corners[i])) {
if (mode == GESTURE_MODAL_SELECT) {
if (select) {
plane_track->flag |= SELECT;
}
else {
@ -520,16 +521,16 @@ void CLIP_OT_select_border(wmOperatorType *ot)
ot->idname = "CLIP_OT_select_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = border_select_exec;
ot->modal = WM_border_select_modal;
ot->modal = WM_gesture_border_modal;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_UNDO;
/* properties */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}
/********************** lasso select operator *********************/
@ -656,9 +657,7 @@ void CLIP_OT_select_lasso(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first");
WM_operator_properties_gesture_lasso_select(ot);
}
/********************** circle select operator *********************/
@ -690,17 +689,17 @@ static int circle_select_exec(bContext *C, wmOperator *op)
MovieTrackingPlaneTrack *plane_track;
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
int x, y, radius, width, height, mode;
int width, height;
bool changed = false;
float zoomx, zoomy, offset[2], ellipse[2];
int framenr = ED_space_clip_get_clip_frame_number(sc);
/* get operator properties */
x = RNA_int_get(op->ptr, "x");
y = RNA_int_get(op->ptr, "y");
radius = RNA_int_get(op->ptr, "radius");
const int x = RNA_int_get(op->ptr, "x");
const int y = RNA_int_get(op->ptr, "y");
const int radius = RNA_int_get(op->ptr, "radius");
mode = RNA_int_get(op->ptr, "gesture_mode");
const bool select = !RNA_boolean_get(op->ptr, "deselect");
/* compute ellipse and position in unified coordinates */
ED_space_clip_get_size(sc, &width, &height);
@ -718,11 +717,12 @@ static int circle_select_exec(bContext *C, wmOperator *op)
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if (MARKER_VISIBLE(sc, track, marker) && marker_inside_ellipse(marker, offset, ellipse)) {
if (mode == GESTURE_MODAL_SELECT)
if (select) {
BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
else
}
else {
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
}
changed = true;
}
}
@ -741,7 +741,7 @@ static int circle_select_exec(bContext *C, wmOperator *op)
for (i = 0; i < 4; i++) {
if (point_inside_ellipse(plane_marker->corners[i], offset, ellipse)) {
if (mode == GESTURE_MODAL_SELECT) {
if (select) {
plane_track->flag |= SELECT;
}
else {
@ -782,10 +782,7 @@ void CLIP_OT_select_circle(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX);
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
WM_operator_properties_gesture_circle_select(ot);
}
/********************** select all operator *********************/

View File

@ -370,7 +370,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent *
int result;
result = WM_border_select_modal(C, op, event);
result = WM_gesture_border_modal(C, op, event);
if (result == OPERATOR_RUNNING_MODAL) {
WM_operator_properties_border_to_rcti(op, &rect);
@ -419,7 +419,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op)
SpaceFile *sfile = CTX_wm_space_file(C);
rcti rect;
FileSelect ret;
const bool select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
WM_operator_properties_border_to_rcti(op, &rect);
@ -452,14 +452,14 @@ void FILE_OT_select_border(wmOperatorType *ot)
ot->idname = "FILE_OT_select_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = file_border_select_exec;
ot->modal = file_border_select_modal;
ot->poll = ED_operator_file_active;
ot->cancel = WM_border_select_cancel;
ot->cancel = WM_gesture_border_cancel;
/* properties */
WM_operator_properties_gesture_border(ot, 1);
WM_operator_properties_gesture_border_select(ot);
}
static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)

View File

@ -332,25 +332,27 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
rctf rect_fl;
short mode = 0, selectmode = 0;
bool incl_handles;
bool extend;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
/* clear all selection if not extending selection */
extend = RNA_boolean_get(op->ptr, "extend");
if (!extend)
deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, true);
/* get select mode
* - 'gesture_mode' from the operator specifies how to select
* - 'include_handles' from the operator specifies whether to include handles in the selection
*/
if (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT)
if (select) {
selectmode = SELECT_ADD;
else
}
else {
selectmode = SELECT_SUBTRACT;
}
incl_handles = RNA_boolean_get(op->ptr, "include_handles");
@ -391,10 +393,10 @@ void GRAPH_OT_select_border(wmOperatorType *ot)
ot->description = "Select all keyframes within the specified region";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = graphkeys_borderselect_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = graphop_visible_keyframes_poll;
@ -402,7 +404,7 @@ void GRAPH_OT_select_border(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
RNA_def_boolean(ot->srna, "include_handles", 0, "Include Handles", "Are handles tested individually against the selection criteria");
@ -486,9 +488,7 @@ void GRAPH_OT_select_lasso(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items");
RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection instead of deselecting everything first");
WM_operator_properties_gesture_lasso_select(ot);
}
/* ------------------- */
@ -496,8 +496,8 @@ void GRAPH_OT_select_lasso(wmOperatorType *ot)
static int graph_circle_select_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const short selectmode = (gesture_mode == GESTURE_MODAL_SELECT) ? SELECT_ADD : SELECT_SUBTRACT;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT;
bool incl_handles = false;
KeyframeEdit_CircleData data = {0};
@ -555,11 +555,9 @@ void GRAPH_OT_select_circle(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_UNDO;
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX);
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX);
/* properties */
WM_operator_properties_gesture_circle_select(ot);
}
/* ******************** Column Select Operator **************************** */

View File

@ -1003,7 +1003,7 @@ static int image_view_zoom_border_exec(bContext *C, wmOperator *op)
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
rctf bounds;
const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out");
WM_operator_properties_border_to_rctf(op, &bounds);
@ -1022,7 +1022,7 @@ static int image_view_zoom_border_exec(bContext *C, wmOperator *op)
sima_zoom_set_from_bounds(sima, ar, &bounds);
/* zoom out */
if (gesture_mode == GESTURE_MODAL_OUT) {
if (!zoom_in) {
sima->xof = sima_view_prev.xof + (sima->xof - sima_view_prev.xof);
sima->yof = sima_view_prev.yof + (sima->yof - sima_view_prev.yof);
sima->zoom = sima_view_prev.zoom * (sima_view_prev.zoom / sima->zoom);
@ -1041,15 +1041,15 @@ void IMAGE_OT_view_zoom_border(wmOperatorType *ot)
ot->idname = "IMAGE_OT_view_zoom_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = image_view_zoom_border_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = space_image_main_region_poll;
/* rna */
WM_operator_properties_gesture_border(ot, false);
WM_operator_properties_gesture_border_zoom(ot);
}
/**************** load/replace/save callbacks ******************/
@ -3691,10 +3691,10 @@ void IMAGE_OT_render_border(wmOperatorType *ot)
ot->idname = "IMAGE_OT_render_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = render_border_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = image_cycle_render_slot_poll;
/* flags */

View File

@ -230,7 +230,7 @@ static int borderselect_exec(bContext *C, wmOperator *op)
rcti rect;
//rctf rectf, rq;
const bool select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
const bool select = !RNA_boolean_get(op->ptr, "deselect");
//int mval[2];
WM_operator_properties_border_to_rcti(op, &rect);
@ -298,10 +298,10 @@ void INFO_OT_select_border(wmOperatorType *ot)
ot->idname = "INFO_OT_select_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = borderselect_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ED_operator_info_active;
@ -309,7 +309,7 @@ void INFO_OT_select_border(wmOperatorType *ot)
/* ot->flag = OPTYPE_REGISTER; */
/* rna */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}

View File

@ -142,8 +142,6 @@ static int cut_links_exec(bContext *C, wmOperator *op)
void LOGIC_OT_links_cut(wmOperatorType *ot)
{
PropertyRNA *prop;
ot->name = "Cut Links";
ot->idname = "LOGIC_OT_links_cut";
ot->description = "Remove logic brick connections";
@ -158,8 +156,10 @@ void LOGIC_OT_links_cut(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
/* properties */
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
/* internal */
RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
}

View File

@ -278,25 +278,28 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op)
bAnimContext ac;
rcti rect;
short mode = 0, selectmode = 0;
int extend;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
/* clear all selection if not extending selection */
extend = RNA_boolean_get(op->ptr, "extend");
if (!extend)
if (!extend) {
deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_SUBTRACT);
}
/* get settings from operator */
WM_operator_properties_border_to_rcti(op, &rect);
if (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT)
if (select) {
selectmode = SELECT_ADD;
else
}
else {
selectmode = SELECT_SUBTRACT;
}
/* selection 'mode' depends on whether borderselect region only matters on one axis */
if (RNA_boolean_get(op->ptr, "axis_range")) {
/* mode depends on which axis of the range is larger to determine which axis to use
@ -329,10 +332,10 @@ void NLA_OT_select_border(wmOperatorType *ot)
ot->description = "Use box selection to grab NLA-Strips";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = nlaedit_borderselect_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = nlaop_poll_tweakmode_off;
@ -340,7 +343,7 @@ void NLA_OT_select_border(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
WM_operator_properties_gesture_border(ot, 1);
WM_operator_properties_gesture_border_select(ot);
RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
}

View File

@ -277,8 +277,6 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
void NODE_OT_add_reroute(wmOperatorType *ot)
{
PropertyRNA *prop;
ot->name = "Add Reroute";
ot->idname = "NODE_OT_add_reroute";
ot->description = "Add a reroute node";
@ -293,8 +291,10 @@ void NODE_OT_add_reroute(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
/* properties */
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
/* internal */
RNA_def_int(ot->srna, "cursor", BC_CROSSCURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
}

View File

@ -2568,17 +2568,17 @@ void NODE_OT_viewer_border(wmOperatorType *ot)
ot->idname = "NODE_OT_viewer_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = viewer_border_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = composite_node_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}
static int clear_viewer_border_exec(bContext *C, wmOperator *UNUSED(op))

View File

@ -1007,8 +1007,6 @@ static int cut_links_exec(bContext *C, wmOperator *op)
void NODE_OT_links_cut(wmOperatorType *ot)
{
PropertyRNA *prop;
ot->name = "Cut Links";
ot->idname = "NODE_OT_links_cut";
ot->description = "Use the mouse to cut (remove) some links";
@ -1023,8 +1021,11 @@ void NODE_OT_links_cut(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
/* properties */
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
/* internal */
RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
}

View File

@ -524,23 +524,23 @@ static int node_borderselect_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
bNode *node;
rctf rectf;
int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
WM_operator_properties_border_to_rctf(op, &rectf);
UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf);
for (node = snode->edittree->nodes.first; node; node = node->next) {
bool select;
bool is_inside;
if (node->type == NODE_FRAME) {
select = BLI_rctf_inside_rctf(&rectf, &node->totr);
is_inside = BLI_rctf_inside_rctf(&rectf, &node->totr);
}
else {
select = BLI_rctf_isect(&rectf, &node->totr, NULL);
is_inside = BLI_rctf_isect(&rectf, &node->totr, NULL);
}
if (select) {
nodeSetSelected(node, (gesture_mode == GESTURE_MODAL_SELECT));
if (is_inside) {
nodeSetSelected(node, select);
}
else if (!extend) {
nodeSetSelected(node, false);
@ -571,7 +571,7 @@ static int node_border_select_invoke(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
return WM_border_select_invoke(C, op, event);
return WM_gesture_border_invoke(C, op, event);
}
void NODE_OT_select_border(wmOperatorType *ot)
@ -584,8 +584,8 @@ void NODE_OT_select_border(wmOperatorType *ot)
/* api callbacks */
ot->invoke = node_border_select_invoke;
ot->exec = node_borderselect_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ED_operator_node_active;
@ -593,7 +593,7 @@ void NODE_OT_select_border(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
RNA_def_boolean(ot->srna, "tweak", 0, "Tweak", "Only activate when mouse is not over a node - useful for tweak gesture");
}
@ -605,12 +605,12 @@ static int node_circleselect_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
bNode *node;
int x, y, radius, gesture_mode;
int x, y, radius;
float offset[2];
float zoom = (float)(BLI_rcti_size_x(&ar->winrct)) / (float)(BLI_rctf_size_x(&ar->v2d.cur));
gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const bool select = !RNA_boolean_get(op->ptr, "deselect");
/* get operator properties */
x = RNA_int_get(op->ptr, "x");
@ -621,7 +621,7 @@ static int node_circleselect_exec(bContext *C, wmOperator *op)
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) {
nodeSetSelected(node, (gesture_mode == GESTURE_MODAL_SELECT));
nodeSetSelected(node, select);
}
}
@ -647,11 +647,8 @@ void NODE_OT_select_circle(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX);
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
/* properties */
WM_operator_properties_gesture_circle_select(ot);
}
/* ****** Lasso Select ****** */
@ -728,9 +725,7 @@ void NODE_OT_select_lasso(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first");
WM_operator_properties_gesture_lasso_select(ot);
}
/* ****** Select/Deselect All ****** */

View File

@ -1059,12 +1059,12 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
/* ****************************************************** */
/* **************** Border Select Tool ****************** */
static void outliner_item_border_select(Scene *scene, rctf *rectf, TreeElement *te, int gesture_mode)
static void outliner_item_border_select(Scene *scene, rctf *rectf, TreeElement *te, bool select)
{
TreeStoreElem *tselem = TREESTORE(te);
if (te->ys <= rectf->ymax && te->ys + UI_UNIT_Y >= rectf->ymin) {
if (gesture_mode == GESTURE_MODAL_SELECT) {
if (select) {
tselem->flag |= TSE_SELECTED;
}
else {
@ -1075,7 +1075,7 @@ static void outliner_item_border_select(Scene *scene, rctf *rectf, TreeElement *
/* Look at its children. */
if ((tselem->flag & TSE_CLOSED) == 0) {
for (te = te->subtree.first; te; te = te->next) {
outliner_item_border_select(scene, rectf, te, gesture_mode);
outliner_item_border_select(scene, rectf, te, select);
}
}
}
@ -1087,13 +1087,13 @@ static int outliner_border_select_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
TreeElement *te;
rctf rectf;
int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
bool select = !RNA_boolean_get(op->ptr, "deselect");
WM_operator_properties_border_to_rctf(op, &rectf);
UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf);
for (te = soops->tree.first; te; te = te->next) {
outliner_item_border_select(scene, &rectf, te, gesture_mode);
outliner_item_border_select(scene, &rectf, te, select);
}
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
@ -1110,10 +1110,10 @@ void OUTLINER_OT_select_border(wmOperatorType *ot)
ot->description = "Use box selection to select tree elements";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = outliner_border_select_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ED_operator_outliner_active;
@ -1121,7 +1121,7 @@ void OUTLINER_OT_select_border(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
WM_operator_properties_gesture_border(ot, false);
WM_operator_properties_gesture_border_ex(ot, true, false);
}
/* ****************************************************** */

View File

@ -3398,17 +3398,17 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot)
ot->description = "Set the boundaries of the border used for offset-view";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = view_ghost_border_exec;
ot->modal = WM_border_select_modal;
ot->modal = WM_gesture_border_modal;
ot->poll = sequencer_view_preview_poll;
ot->cancel = WM_border_select_cancel;
ot->cancel = WM_gesture_border_cancel;
/* flags */
ot->flag = 0;
/* rna */
WM_operator_properties_gesture_border(ot, false);
WM_operator_properties_gesture_border(ot);
}
/* rebuild_proxy operator */

View File

@ -889,7 +889,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op)
Sequence *seq;
rctf rectf, rq;
const bool select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool extend = RNA_boolean_get(op->ptr, "extend");
if (ed == NULL)
@ -927,10 +927,10 @@ void SEQUENCER_OT_select_border(wmOperatorType *ot)
ot->description = "Select strips using border selection";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = sequencer_borderselect_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ED_operator_sequencer_active;
@ -938,7 +938,7 @@ void SEQUENCER_OT_select_border(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}
/* ****** Selected Grouped ****** */

View File

@ -3524,10 +3524,10 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
ot->idname = "VIEW3D_OT_render_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = render_border_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ED_operator_view3d_active;
@ -3597,7 +3597,6 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
int gesture_mode;
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* Zooms in on a border drawn by the user */
@ -3622,7 +3621,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rcti(op, &rect);
/* check if zooming in/out view */
gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out");
ED_view3d_dist_range_get(v3d, dist_range);
@ -3705,7 +3704,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
new_dist *= max_ff(xscale, yscale);
}
if (gesture_mode == GESTURE_MODAL_OUT) {
if (!zoom_in) {
sub_v3_v3v3(dvec, new_ofs, rv3d->ofs);
new_dist = rv3d->dist * (rv3d->dist / new_dist);
add_v3_v3v3(new_ofs, rv3d->ofs, dvec);
@ -3731,7 +3730,7 @@ static int view3d_zoom_border_invoke(bContext *C, wmOperator *op, const wmEvent
/* if in camera view do not exec the operator so we do not conflict with set render border*/
if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d))
return WM_border_select_invoke(C, op, event);
return WM_gesture_border_invoke(C, op, event);
else
return OPERATOR_PASS_THROUGH;
}
@ -3746,8 +3745,8 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot)
/* api callbacks */
ot->invoke = view3d_zoom_border_invoke;
ot->exec = view3d_zoom_border_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ED_operator_region_view3d_active;
@ -3755,7 +3754,7 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot)
ot->flag = 0;
/* rna */
WM_operator_properties_gesture_border(ot, false);
WM_operator_properties_gesture_border_zoom(ot);
}
/* sets the view to 1:1 camera/render-pixel */
@ -4671,7 +4670,7 @@ static int view3d_clipping_invoke(bContext *C, wmOperator *op, const wmEvent *ev
return OPERATOR_FINISHED;
}
else {
return WM_border_select_invoke(C, op, event);
return WM_gesture_border_invoke(C, op, event);
}
}
@ -4687,8 +4686,8 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot)
/* api callbacks */
ot->invoke = view3d_clipping_invoke;
ot->exec = view3d_clipping_exec;
ot->modal = WM_border_select_modal;
ot->cancel = WM_border_select_cancel;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
ot->poll = ED_operator_region_view3d_active;

View File

@ -896,9 +896,8 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_UNDO;
RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first");
/* properties */
WM_operator_properties_gesture_lasso_select(ot);
}
@ -2161,9 +2160,9 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
CTX_data_eval_ctx(C, &eval_ctx);
view3d_set_viewcontext(C, &vc);
select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
WM_operator_properties_border_to_rcti(op, &rect);
select = !RNA_boolean_get(op->ptr, "deselect");
extend = RNA_boolean_get(op->ptr, "extend");
WM_operator_properties_border_to_rcti(op, &rect);
if (vc.obedit) {
switch (vc.obedit->type) {
@ -2238,17 +2237,17 @@ void VIEW3D_OT_select_border(wmOperatorType *ot)
ot->idname = "VIEW3D_OT_select_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = view3d_borderselect_exec;
ot->modal = WM_border_select_modal;
ot->modal = WM_gesture_border_modal;
ot->poll = view3d_selectable_data;
ot->cancel = WM_border_select_cancel;
ot->cancel = WM_gesture_border_cancel;
/* flags */
ot->flag = OPTYPE_UNDO;
/* rna */
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}
@ -2860,8 +2859,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
const int radius = RNA_int_get(op->ptr, "radius");
const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const bool select = (gesture_mode == GESTURE_MODAL_SELECT);
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const int mval[2] = {RNA_int_get(op->ptr, "x"),
RNA_int_get(op->ptr, "y")};
@ -2922,9 +2920,7 @@ void VIEW3D_OT_select_circle(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_UNDO;
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX);
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX);
/* properties */
WM_operator_properties_gesture_circle_select(ot);
}

View File

@ -2760,9 +2760,9 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf);
/* figure out what to select/deselect */
select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
pinned = RNA_boolean_get(op->ptr, "pinned");
select = !RNA_boolean_get(op->ptr, "deselect");
extend = RNA_boolean_get(op->ptr, "extend");
pinned = RNA_boolean_get(op->ptr, "pinned");
if (!extend)
uv_select_all_perform(scene, ima, em, SEL_DESELECT);
@ -2839,11 +2839,11 @@ static void UV_OT_select_border(wmOperatorType *ot)
ot->idname = "UV_OT_select_border";
/* api callbacks */
ot->invoke = WM_border_select_invoke;
ot->invoke = WM_gesture_border_invoke;
ot->exec = uv_border_select_exec;
ot->modal = WM_border_select_modal;
ot->modal = WM_gesture_border_modal;
ot->poll = ED_operator_uvedit_space_image; /* requires space image */;
ot->cancel = WM_border_select_cancel;
ot->cancel = WM_gesture_border_cancel;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -2851,7 +2851,7 @@ static void UV_OT_select_border(wmOperatorType *ot)
/* properties */
RNA_def_boolean(ot->srna, "pinned", 0, "Pinned", "Border select pinned UVs only");
WM_operator_properties_gesture_border(ot, true);
WM_operator_properties_gesture_border_select(ot);
}
/* ******************** circle select operator **************** */
@ -2892,8 +2892,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
MLoopUV *luv;
int x, y, radius, width, height;
float zoomx, zoomy, offset[2], ellipse[2];
int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
const bool select = (gesture_mode == GESTURE_MODAL_SELECT);
const bool select = !RNA_boolean_get(op->ptr, "deselect");
bool changed = false;
const bool use_face_center = (ts->uv_flag & UV_SYNC_SELECTION) ?
(ts->selectmode == SCE_SELECT_FACE) :
@ -2971,12 +2970,9 @@ static void UV_OT_circle_select(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX);
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
WM_operator_properties_gesture_circle_select(ot);
}
@ -3104,9 +3100,8 @@ static void UV_OT_select_lasso(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_UNDO;
RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first");
/* properties */
WM_operator_properties_gesture_lasso_select(ot);
}

View File

@ -333,9 +333,18 @@ void WM_operator_properties_filesel(
void WM_operator_properties_border(struct wmOperatorType *ot);
void WM_operator_properties_border_to_rcti(struct wmOperator *op, struct rcti *rect);
void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect);
void WM_operator_properties_gesture_border(struct wmOperatorType *ot, bool extend);
void WM_operator_properties_mouse_select(struct wmOperatorType *ot);
void WM_operator_properties_gesture_border_ex(struct wmOperatorType *ot, bool deselect, bool extend);
void WM_operator_properties_gesture_border(struct wmOperatorType *ot);
void WM_operator_properties_gesture_border_select(struct wmOperatorType *ot);
void WM_operator_properties_gesture_border_zoom(struct wmOperatorType *ot);
void WM_operator_properties_gesture_lasso_ex(struct wmOperatorType *ot, bool deselect, bool extend);
void WM_operator_properties_gesture_lasso(struct wmOperatorType *ot);
void WM_operator_properties_gesture_lasso_select(struct wmOperatorType *ot);
void WM_operator_properties_gesture_straightline(struct wmOperatorType *ot, int cursor);
void WM_operator_properties_gesture_circle_ex(struct wmOperatorType *ot, bool deselect);
void WM_operator_properties_gesture_circle(struct wmOperatorType *ot);
void WM_operator_properties_gesture_circle_select(struct wmOperatorType *ot);
void WM_operator_properties_mouse_select(struct wmOperatorType *ot);
void WM_operator_properties_select_all(struct wmOperatorType *ot);
void WM_operator_properties_select_action(struct wmOperatorType *ot, int default_action);
void WM_operator_properties_select_action_simple(struct wmOperatorType *ot, int default_action);
@ -396,9 +405,9 @@ void WM_menutype_freelink(struct MenuType *mt);
void WM_menutype_free(void);
/* default operator callbacks for border/circle/lasso */
int WM_border_select_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_border_select_modal (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
void WM_border_select_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_border_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_gesture_border_modal (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
void WM_gesture_border_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_circle_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_gesture_circle_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
void WM_gesture_circle_cancel(struct bContext *C, struct wmOperator *op);

View File

@ -418,10 +418,13 @@ typedef struct wmGesture {
int swinid; /* initial subwindow id where it started */
int points; /* optional, amount of points stored */
int points_alloc; /* optional, maximum amount of points stored */
int modal_state;
/* 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;
/* Use for gestures that support both immediate or delayed activation. */
uint wait_for_input : 1;
void *customdata;
/* customdata for border is a recti */

View File

@ -773,12 +773,16 @@ static bool wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot)
return wm && (wm->op_undo_depth == 0) && (ot->flag & (OPTYPE_REGISTER | OPTYPE_UNDO));
}
static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat)
static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat, const bool store)
{
wmWindowManager *wm = CTX_wm_manager(C);
op->customdata = NULL;
if (store) {
WM_operator_last_properties_store(op);
}
/* we don't want to do undo pushes for operators that are being
* called from operators that already do an undo push. usually
* this will happen for python operators that call C operators */
@ -841,12 +845,7 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons
wm_operator_reports(C, op, retval, false);
if (retval & OPERATOR_FINISHED) {
if (store) {
if (wm->op_undo_depth == 0) { /* not called by py script */
WM_operator_last_properties_store(op);
}
}
wm_operator_finished(C, op, repeat);
wm_operator_finished(C, op, repeat, store && wm->op_undo_depth == 0);
}
else if (repeat == 0) {
/* warning: modal from exec is bad practice, but avoid crashing. */
@ -1202,10 +1201,8 @@ static int wm_operator_invoke(
/* do nothing, wm_operator_exec() has been called somewhere */
}
else if (retval & OPERATOR_FINISHED) {
if (!is_nested_call) { /* not called by py script */
WM_operator_last_properties_store(op);
}
wm_operator_finished(C, op, 0);
const bool store = !is_nested_call;
wm_operator_finished(C, op, false, store);
}
else if (retval & OPERATOR_RUNNING_MODAL) {
/* take ownership of reports (in case python provided own) */
@ -1811,7 +1808,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
/* important to run 'wm_operator_finished' before NULLing the context members */
if (retval & OPERATOR_FINISHED) {
wm_operator_finished(C, op, 0);
wm_operator_finished(C, op, false, true);
handler->op = NULL;
}
else if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {

View File

@ -72,6 +72,7 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type)
gesture->event_type = event->type;
gesture->swinid = ar->swinid; /* means only in area-region context! */
gesture->userdata_free = true; /* Free if userdata is set. */
gesture->modal_state = GESTURE_MODAL_NOP;
wm_subwindow_origin_get(window, gesture->swinid, &sx, &sy);
@ -84,11 +85,7 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type)
rect->xmin = event->x - sx;
rect->ymin = event->y - sy;
if (type == WM_GESTURE_CIRCLE) {
#ifdef GESTURE_MEMORY
rect->xmax = circle_select_size;
#else
rect->xmax = 25; // XXX temp
#endif
/* caller is responsible for initializing 'xmax' to radius. */
}
else {
rect->xmax = event->x - sx;

View File

@ -224,30 +224,69 @@ void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect)
BLI_rctf_rcti_copy(rect, &rect_i);
}
void WM_operator_properties_gesture_border(wmOperatorType *ot, bool extend)
/**
* Use with #WM_gesture_border_invoke
*/
void WM_operator_properties_gesture_border_ex(wmOperatorType *ot, bool deselect, bool extend)
{
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
WM_operator_properties_border(ot);
if (deselect) {
RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items");
}
if (extend) {
RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection instead of deselecting everything first");
}
}
void WM_operator_properties_mouse_select(wmOperatorType *ot)
void WM_operator_properties_gesture_border_select(wmOperatorType *ot)
{
PropertyRNA *prop;
prop = RNA_def_boolean(ot->srna, "extend", false, "Extend",
"Extend selection instead of deselecting everything first");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Remove from selection");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Selection", "Toggle the selection");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
WM_operator_properties_gesture_border_ex(ot, true, true);
}
void WM_operator_properties_gesture_border(wmOperatorType *ot)
{
WM_operator_properties_gesture_border_ex(ot, false, false);
}
void WM_operator_properties_gesture_border_zoom(wmOperatorType *ot)
{
WM_operator_properties_border(ot);
PropertyRNA *prop;
prop = RNA_def_boolean(ot->srna, "zoom_out", false, "Zoom Out", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
/**
* Use with #WM_gesture_lasso_invoke
*/
void WM_operator_properties_gesture_lasso_ex(wmOperatorType *ot, bool deselect, bool extend)
{
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
if (deselect) {
RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items");
}
if (extend) {
RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection instead of deselecting everything first");
}
}
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
{
WM_operator_properties_gesture_lasso_ex(ot, false, false);
}
void WM_operator_properties_gesture_lasso_select(wmOperatorType *ot)
{
WM_operator_properties_gesture_lasso_ex(ot, true, true);
}
/**
* Use with #WM_gesture_straightline_invoke
*/
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
{
PropertyRNA *prop;
@ -268,6 +307,48 @@ void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
}
}
/**
* Use with #WM_gesture_circle_invoke
*/
void WM_operator_properties_gesture_circle_ex(wmOperatorType *ot, bool deselect)
{
PropertyRNA *prop;
const int radius_default = 25;
prop = RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
prop = RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
RNA_def_int(ot->srna, "radius", radius_default, 1, INT_MAX, "Radius", "", 1, INT_MAX);
if (deselect) {
RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items");
}
}
void WM_operator_properties_gesture_circle(wmOperatorType *ot)
{
WM_operator_properties_gesture_circle_ex(ot, false);
}
void WM_operator_properties_gesture_circle_select(wmOperatorType *ot)
{
WM_operator_properties_gesture_circle_ex(ot, true);
}
void WM_operator_properties_mouse_select(wmOperatorType *ot)
{
PropertyRNA *prop;
prop = RNA_def_boolean(ot->srna, "extend", false, "Extend",
"Extend selection instead of deselecting everything first");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Remove from selection");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Selection", "Toggle the selection");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/**
* \param nth_can_disable: Enable if we want to be able to select no interval at all.
*/

View File

@ -2303,6 +2303,43 @@ void WM_paint_cursor_end(wmWindowManager *wm, void *handle)
* These are default callbacks for use in operators requiring gesture input
*/
static void gesture_modal_state_to_operator(wmOperator *op, int modal_state)
{
PropertyRNA *prop;
switch (modal_state) {
case GESTURE_MODAL_SELECT:
case GESTURE_MODAL_DESELECT:
if ((prop = RNA_struct_find_property(op->ptr, "deselect"))) {
RNA_property_boolean_set(op->ptr, prop, (modal_state == GESTURE_MODAL_DESELECT));
}
break;
case GESTURE_MODAL_IN:
case GESTURE_MODAL_OUT:
if ((prop = RNA_struct_find_property(op->ptr, "zoom_out"))) {
RNA_property_boolean_set(op->ptr, prop, (modal_state == GESTURE_MODAL_OUT));
}
break;
}
}
static int gesture_modal_state_from_operator(wmOperator *op)
{
PropertyRNA *prop;
if ((prop = RNA_struct_find_property(op->ptr, "deselect"))) {
if (RNA_property_is_set(op->ptr, prop)) {
return RNA_property_boolean_get(op->ptr, prop) ? GESTURE_MODAL_DESELECT : GESTURE_MODAL_SELECT;
}
}
if ((prop = RNA_struct_find_property(op->ptr, "zoom_out"))) {
if (RNA_property_is_set(op->ptr, prop)) {
return RNA_property_boolean_get(op->ptr, prop) ? GESTURE_MODAL_OUT : GESTURE_MODAL_IN;
}
}
return GESTURE_MODAL_NOP;
}
/* **************** Border gesture *************** */
/**
@ -2313,7 +2350,7 @@ void WM_paint_cursor_end(wmWindowManager *wm, void *handle)
* It stores 4 values (xmin, xmax, ymin, ymax) and event it ended with (event_type)
*/
static int border_apply_rect(wmOperator *op)
static bool gesture_border_apply_rect(wmOperator *op)
{
wmGesture *gesture = op->customdata;
rcti *rect = gesture->customdata;
@ -2331,20 +2368,18 @@ static int border_apply_rect(wmOperator *op)
return 1;
}
static int border_apply(bContext *C, wmOperator *op, int gesture_mode)
static bool gesture_border_apply(bContext *C, wmOperator *op)
{
PropertyRNA *prop;
wmGesture *gesture = op->customdata;
int retval;
if (!border_apply_rect(op))
if (!gesture_border_apply_rect(op)) {
return 0;
/* XXX weak; border should be configured for this without reading event types */
if ((prop = RNA_struct_find_property(op->ptr, "gesture_mode"))) {
RNA_property_int_set(op->ptr, prop, gesture_mode);
}
gesture_modal_state_to_operator(op, gesture->modal_state);
retval = op->type->exec(C, op);
OPERATOR_RETVAL_CHECK(retval);
@ -2365,22 +2400,36 @@ static void wm_gesture_end(bContext *C, wmOperator *op)
}
}
int WM_border_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_border_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
if (ISTWEAK(event->type))
int modal_state = gesture_modal_state_from_operator(op);
if (ISTWEAK(event->type) || (modal_state != GESTURE_MODAL_NOP)) {
op->customdata = WM_gesture_new(C, event, WM_GESTURE_RECT);
else
}
else {
op->customdata = WM_gesture_new(C, event, WM_GESTURE_CROSS_RECT);
}
/* Starting with the mode starts immediately, like having 'wait_for_input' disabled (some tools use this). */
if (modal_state == GESTURE_MODAL_NOP) {
wmGesture *gesture = op->customdata;
gesture->wait_for_input = true;
}
else {
wmGesture *gesture = op->customdata;
gesture->modal_state = modal_state;
}
/* add modal handler */
WM_event_add_modal_handler(C, op);
wm_gesture_tag_redraw(C);
return OPERATOR_RUNNING_MODAL;
}
int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_border_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
wmGesture *gesture = op->customdata;
rcti *rect = gesture->customdata;
@ -2397,7 +2446,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
rect->xmax = event->x - sx;
rect->ymax = event->y - sy;
}
border_apply_rect(op);
gesture_border_apply_rect(op);
wm_gesture_tag_redraw(C);
}
@ -2413,7 +2462,10 @@ int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
case GESTURE_MODAL_DESELECT:
case GESTURE_MODAL_IN:
case GESTURE_MODAL_OUT:
if (border_apply(C, op, event->val)) {
if (gesture->wait_for_input) {
gesture->modal_state = event->val;
}
if (gesture_border_apply(C, op)) {
wm_gesture_end(C, op);
return OPERATOR_FINISHED;
}
@ -2439,7 +2491,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
void WM_border_select_cancel(bContext *C, wmOperator *op)
void WM_gesture_border_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
}
@ -2447,14 +2499,29 @@ void WM_border_select_cancel(bContext *C, wmOperator *op)
/* **************** circle gesture *************** */
/* works now only for selection or modal paint stuff, calls exec while hold mouse, exit on release */
#ifdef GESTURE_MEMORY
int circle_select_size = 25; /* XXX - need some operator memory thing! */
#endif
static void gesture_circle_apply(bContext *C, wmOperator *op);
int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
int modal_state = gesture_modal_state_from_operator(op);
op->customdata = WM_gesture_new(C, event, WM_GESTURE_CIRCLE);
wmGesture *gesture = op->customdata;
rcti *rect = gesture->customdata;
/* Default or previously stored value. */
rect->xmax = RNA_int_get(op->ptr, "radius");
/* Starting with the mode starts immediately, like having 'wait_for_input' disabled (some tools use this). */
if (modal_state == GESTURE_MODAL_NOP) {
gesture->wait_for_input = true;
}
else {
gesture->is_active = true;
gesture->modal_state = modal_state;
gesture_circle_apply(C, op);
}
/* add modal handler */
WM_event_add_modal_handler(C, op);
@ -2467,23 +2534,23 @@ static void gesture_circle_apply(bContext *C, wmOperator *op)
{
wmGesture *gesture = op->customdata;
rcti *rect = gesture->customdata;
if (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_NOP)
if (gesture->modal_state == GESTURE_MODAL_NOP) {
return;
}
/* operator arguments and storage. */
RNA_int_set(op->ptr, "x", rect->xmin);
RNA_int_set(op->ptr, "y", rect->ymin);
RNA_int_set(op->ptr, "radius", rect->xmax);
gesture_modal_state_to_operator(op, gesture->modal_state);
if (op->type->exec) {
int retval;
retval = op->type->exec(C, op);
OPERATOR_RETVAL_CHECK(retval);
}
#ifdef GESTURE_MEMORY
circle_select_size = rect->xmax;
#endif
}
int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
@ -2505,6 +2572,8 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
else if (event->type == EVT_MODAL_MAP) {
bool is_circle_size = false;
bool is_finished = false;
float fac;
switch (event->val) {
@ -2515,35 +2584,53 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
else
rect->xmax += floor(fac);
if (rect->xmax < 1) rect->xmax = 1;
wm_gesture_tag_redraw(C);
is_circle_size = true;
break;
case GESTURE_MODAL_CIRCLE_ADD:
rect->xmax += 2 + rect->xmax / 10;
wm_gesture_tag_redraw(C);
is_circle_size = true;
break;
case GESTURE_MODAL_CIRCLE_SUB:
rect->xmax -= 2 + rect->xmax / 10;
if (rect->xmax < 1) rect->xmax = 1;
wm_gesture_tag_redraw(C);
is_circle_size = true;
break;
case GESTURE_MODAL_SELECT:
case GESTURE_MODAL_DESELECT:
case GESTURE_MODAL_NOP:
if (RNA_struct_find_property(op->ptr, "gesture_mode"))
RNA_int_set(op->ptr, "gesture_mode", event->val);
if (event->val != GESTURE_MODAL_NOP) {
{
if (gesture->wait_for_input) {
gesture->modal_state = event->val;
}
if (event->val == GESTURE_MODAL_NOP) {
/* Single action, click-drag & release to exit. */
if (gesture->wait_for_input == false) {
is_finished = true;
}
}
else {
/* apply first click */
gesture_circle_apply(C, op);
gesture->is_active = true;
wm_gesture_tag_redraw(C);
}
break;
}
case GESTURE_MODAL_CANCEL:
case GESTURE_MODAL_CONFIRM:
wm_gesture_end(C, op);
return OPERATOR_FINISHED; /* use finish or we don't get an undo */
is_finished = true;
}
if (is_finished) {
wm_gesture_end(C, op);
return OPERATOR_FINISHED; /* use finish or we don't get an undo */
}
if (is_circle_size) {
wm_gesture_tag_redraw(C);
/* So next use remembers last seen size, even if we didn't apply it. */
RNA_int_set(op->ptr, "radius", rect->xmax);
}
}
#ifdef WITH_INPUT_NDOF
@ -2575,12 +2662,10 @@ void WM_OT_circle_gesture(wmOperatorType *ot)
ot->invoke = WM_gesture_circle_invoke;
ot->modal = WM_gesture_circle_modal;
ot->poll = WM_operator_winactive;
RNA_def_property(ot->srna, "x", PROP_INT, PROP_NONE);
RNA_def_property(ot->srna, "y", PROP_INT, PROP_NONE);
RNA_def_property(ot->srna, "radius", PROP_INT, PROP_NONE);
/* properties */
WM_operator_properties_gesture_circle(ot);
}
#endif
@ -4353,14 +4438,15 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_SELECT);
/* Note: use 'KM_ANY' for release, so the circle exits on any mouse release,
* this is needed when circle select is activated as a tool. */
/* left mouse shift for deselect too */
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_SHIFT, 0, GESTURE_MODAL_DESELECT);
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_SHIFT, 0, GESTURE_MODAL_NOP);
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_NOP);
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_DESELECT); // default 2.4x
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_NOP); // default 2.4x
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_NOP);
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_NOP); // default 2.4x
WM_modalkeymap_add_item(keymap, WHEELUPMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_SUB);
WM_modalkeymap_add_item(keymap, PADMINUS, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_SUB);

View File

@ -90,12 +90,4 @@ void wm_stereo3d_set_cancel(bContext *C, wmOperator *op);
void wm_open_init_load_ui(wmOperator *op, bool use_prefs);
void wm_open_init_use_scripts(wmOperator *op, bool use_prefs);
/* hack to store circle select size - campbell, must replace with nice operator memory */
#define GESTURE_MEMORY
#ifdef GESTURE_MEMORY
extern int circle_select_size;
#endif
#endif /* __WM_H__ */

View File

@ -433,6 +433,7 @@ enum {
GESTURE_MODAL_CANCEL = 1,
GESTURE_MODAL_CONFIRM = 2,
/* Uses 'deselect' operator property. */
GESTURE_MODAL_SELECT = 3,
GESTURE_MODAL_DESELECT = 4,
@ -443,6 +444,7 @@ enum {
GESTURE_MODAL_BEGIN = 8, /* border select/straight line, activate, use release to detect which button */
/* Uses 'zoom_out' operator property. */
GESTURE_MODAL_IN = 9,
GESTURE_MODAL_OUT = 10,