WM: refactor gestures for use as tools
authorCampbell Barton <ideasman42@gmail.com>
Mon, 16 Oct 2017 10:58:51 +0000 (21:58 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 16 Oct 2017 11:21:46 +0000 (22:21 +1100)
Border and circle select wait for input by default.
This commit uses bool properties on the operators instead of
magic number (called "gesture_mode").

Keymaps that define 'deselect' for border/circle select
begin immediately, exiting when on button release.

28 files changed:
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/gpencil/gpencil_select.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/mask/mask_select.c
source/blender/editors/sculpt_paint/paint_mask.c
source/blender/editors/space_action/action_select.c
source/blender/editors/space_clip/clip_graph_ops.c
source/blender/editors/space_clip/tracking_select.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_graph/graph_select.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_info/info_report.c
source/blender/editors/space_nla/nla_select.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_select.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_gesture.c
source/blender/windowmanager/intern/wm_operator_props.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/wm_event_types.h

index da7b6b085c06a1126e4b0621093180ddd59d8bf9..fc0c39e62950765fa9395d3e754176f274e7c85b 100644 (file)
@@ -2455,8 +2455,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)
@@ -2464,17 +2464,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);
@@ -2504,7 +2504,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 ***************************** */
index 926a41dd7ab4f2441501740b8bca761cbc43111f..30aaee8cbd9157ba25ee3c2b413dcfbf9ef9b29e 100644 (file)
@@ -1230,7 +1230,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;
        
@@ -1243,13 +1243,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) {
@@ -1287,7 +1285,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 ***************** */
index bea78156900036ff239ad7b1b3b84e91710a654f..3d9689ab54f4e3f620b5d26d91f41bf8d13e0a32 100644 (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,7 +829,7 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
        
        /* properties */
-       WM_operator_properties_gesture_circle(ot);
+       WM_operator_properties_gesture_circle_select(ot);
 }
 
 /* ********************************************** */
@@ -840,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};
@@ -944,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);
 }
 
 /* ********************************************** */
@@ -1054,7 +1052,7 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
        
        /* properties */
-       WM_operator_properties_gesture_lasso(ot);
+       WM_operator_properties_gesture_lasso_select(ot);
 }
 
 /* ********************************************** */
index ab8ec60696bc67bba593bcb06b983a7d6f23bb82..b271b0b5bc63ee6f02b9694a0b92ef6b8c9cc7da 100644 (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
@@ -1297,7 +1295,7 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
        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);
 }
 
 /* ********************************************************* */
index 543b005236a6f39f0db3bd812d033e74d33830d5..9f2f6de8a097c53a750c15859b5e9031f2e7f97b 100644 (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);
@@ -480,7 +478,7 @@ void MASK_OT_select_border(wmOperatorType *ot)
        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,7 +578,7 @@ void MASK_OT_select_lasso(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_lasso(ot);
+       WM_operator_properties_gesture_lasso_select(ot);
 }
 
 /********************** circle select operator *********************/
@@ -606,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);
@@ -642,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;
                                }
@@ -679,7 +677,7 @@ void MASK_OT_select_circle(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_circle(ot);
+       WM_operator_properties_gesture_circle_select(ot);
 }
 
 static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
index ed7030c01d11777889d8769b06bc9888a9e753ac..c92aaa8f9dbb68f987b381f055ce97221b9c3448 100644 (file)
@@ -519,7 +519,7 @@ void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_lasso_ex(ot, false, false);
+       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",
index 44b272af189492ef160e3c3eb66d6dc376d4b189..0cfd86f86f1ea8672d0af4a2fbe962a0fcfb738b 100644 (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")) {
@@ -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,7 +573,7 @@ void ACTION_OT_select_lasso(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
        
        /* properties */
-       WM_operator_properties_gesture_lasso(ot);
+       WM_operator_properties_gesture_lasso_select(ot);
 }
 
 /* ------------------- */
@@ -580,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,7 +630,7 @@ void ACTION_OT_select_circle(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_circle(ot);
+       WM_operator_properties_gesture_circle_select(ot);
 }
 
 /* ******************** Column Select Operator **************************** */
index 9c832ba052a0455ad6d6515be43e69e5eb1548c3..901f49042d9db672d5b6c7d56f58e2e0bce61da6 100644 (file)
@@ -331,8 +331,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),
@@ -348,11 +347,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) {
@@ -380,7 +380,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);
@@ -411,7 +411,7 @@ void CLIP_OT_graph_select_border(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_border(ot, true);
+       WM_operator_properties_gesture_border_select(ot);
 }
 
 /********************** select all operator *********************/
index c5947852c6db97da13bbdc7e97679faa8385e833..028b9c8a820d70da31d958302eabb3044ca61fda 100644 (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 {
@@ -529,7 +530,7 @@ void CLIP_OT_select_border(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_border(ot, true);
+       WM_operator_properties_gesture_border_select(ot);
 }
 
 /********************** lasso select operator *********************/
@@ -656,7 +657,7 @@ void CLIP_OT_select_lasso(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_lasso(ot);
+       WM_operator_properties_gesture_lasso_select(ot);
 }
 
 /********************** circle select operator *********************/
@@ -688,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);
@@ -716,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;
                        }
                }
@@ -739,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 {
@@ -780,7 +782,7 @@ void CLIP_OT_select_circle(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_circle(ot);
+       WM_operator_properties_gesture_circle_select(ot);
 }
 
 /********************** select all operator *********************/
index 20509a7157560932430c31604e99df5378094178..64c1e6f1d1d91dae11f7fa83c4b2594c344f4996 100644 (file)
@@ -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);
@@ -459,7 +459,7 @@ void FILE_OT_select_border(wmOperatorType *ot)
        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)
index 9ff5d7f3e7faa04af97c5cae5e9927cfcd3f8588..783f691f41a98e467ef1b8259ebdc8ed53830fae 100644 (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");
        
@@ -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,7 +488,7 @@ void GRAPH_OT_select_lasso(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
        
        /* properties */
-       WM_operator_properties_gesture_lasso(ot);
+       WM_operator_properties_gesture_lasso_select(ot);
 }
 
 /* ------------------- */
@@ -494,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,7 +557,7 @@ void GRAPH_OT_select_circle(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_circle(ot);
+       WM_operator_properties_gesture_circle_select(ot);
 }
 
 /* ******************** Column Select Operator **************************** */
index bedac0b878d6a153c54c4712f4d4f9f89c26a422..7644cb60ac72cc6a4a278d8d3588a3e2d441697d 100644 (file)
@@ -1000,7 +1000,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);
 
@@ -1019,7 +1019,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);
@@ -1046,7 +1046,7 @@ void IMAGE_OT_view_zoom_border(wmOperatorType *ot)
        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 ******************/
index 8c7b7b5014e290e4835736252d107775954a9070..31df9b199eaabe5001807ba71c200ce2ffb5d7c5 100644 (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);
@@ -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);
 }
 
 
index 6dde81162cf4c2f288de65e560bcf672019c98b9..32eca3140fc6f40ed0604aa0b003d28b899ca869 100644 (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 
@@ -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", "");
 }
index 9ed7e08dc62cca23e5e64b99194c2667de8c3981..b74735f8e02c911137ce4a6bc4d1a45163bc4ae1 100644 (file)
@@ -2573,7 +2573,7 @@ void NODE_OT_viewer_border(wmOperatorType *ot)
        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))
index 8a0c8e0ac95a47621ea8c4e18ffce8546f86abe7..0cff5f12dcaa4936b2591eba6b5f0d95e7ef8554 100644 (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);
@@ -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);
                }
        }
 
@@ -648,7 +648,7 @@ void NODE_OT_select_circle(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_circle(ot);
+       WM_operator_properties_gesture_circle_select(ot);
 }
 
 /* ****** Lasso Select ****** */
@@ -725,7 +725,7 @@ void NODE_OT_select_lasso(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_lasso(ot);
+       WM_operator_properties_gesture_lasso_select(ot);
 }
 
 /* ****** Select/Deselect All ****** */
index 4ed524a4fff1cc74ec569e849908e0cd008cb675..5cc83d3ee94c1002a4da8b86179f8b9ba9ea8179 100644 (file)
@@ -1068,12 +1068,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 {
@@ -1084,7 +1084,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);
                }
        }
 }
@@ -1096,13 +1096,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);
@@ -1130,7 +1130,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);
 }
 
 /* ****************************************************** */
index 2a77b85c1828fa8045897f47afcb50cfdbe533f6..d4732c93fe6d8d6d6776f6d088539eb5c20cb049 100644 (file)
@@ -3431,7 +3431,7 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot)
        ot->flag = 0;
 
        /* rna */
-       WM_operator_properties_gesture_border(ot, false);
+       WM_operator_properties_gesture_border(ot);
 }
 
 /* rebuild_proxy operator */
index ddd68a4c3d9d044eabc9327513d5a8bc2c6320fe..b24458a1cab581af4cd43d5945f4661933b025ec 100644 (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)
@@ -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 ****** */
index b6619f355f028c315665192d28bfbcfad3f94e07..77a3556db0a7c34a4707876273753386d8a00d81 100644 (file)
@@ -3580,7 +3580,6 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
        View3D *v3d = CTX_wm_view3d(C);
        RegionView3D *rv3d = CTX_wm_region_view3d(C);
        Scene *scene = CTX_data_scene(C);
-       int gesture_mode;
        const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
 
        /* Zooms in on a border drawn by the user */
@@ -3604,7 +3603,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);
 
@@ -3702,7 +3701,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);
@@ -3752,7 +3751,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 */
index 51af4c2dd5fffb464a4966fb2586393b387a7a15..bd19fe8f686f560e1b42c164f4fb611868e12611 100644 (file)
@@ -915,7 +915,7 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
        
        /* properties */
-       WM_operator_properties_gesture_lasso(ot);
+       WM_operator_properties_gesture_lasso_select(ot);
 }
 
 
@@ -2137,9 +2137,9 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
        /* setup view context for argument to callbacks */
        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) {
@@ -2224,7 +2224,7 @@ void VIEW3D_OT_select_border(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
        
        /* rna */
-       WM_operator_properties_gesture_border(ot, true);
+       WM_operator_properties_gesture_border_select(ot);
 }
 
 
@@ -2835,8 +2835,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")};
 
@@ -2897,5 +2896,5 @@ void VIEW3D_OT_select_circle(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_circle(ot);
+       WM_operator_properties_gesture_circle_select(ot);
 }
index faaf9ba23b28c9262890b60c951d19c1d25e5a47..45b1674e65d084b936eb503e67cfdde1c86c20df 100644 (file)
@@ -2875,9 +2875,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);
@@ -2968,7 +2968,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 **************** */
@@ -3009,8 +3009,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) :
@@ -3090,7 +3089,7 @@ static void UV_OT_circle_select(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_circle(ot);
+       WM_operator_properties_gesture_circle_select(ot);
 }
 
 
@@ -3222,7 +3221,7 @@ static void UV_OT_select_lasso(wmOperatorType *ot)
        ot->flag = OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_gesture_lasso(ot);
+       WM_operator_properties_gesture_lasso_select(ot);
 }
 
 
index aa52e7d224851d62084770028a0a870cd724815d..595050e12f7a3a4f0b7bcc68c0884bbbe9eb0ef5 100644 (file)
@@ -308,11 +308,17 @@ 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_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);
index d8ec26f55da4299b06fdb5710c2b8bab2e97e2fd..6c47d61c535538900c80de813a655c86959a9b50 100644 (file)
@@ -413,10 +413,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 */
index 11f39dc934ca50a6e3d3c7c6389b784f0fa37b23..b63962ffce2d46cf32bf15990441eb6dfb51871d 100644 (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);
        
index b8b527981756202207ba167e0b4e6e9ca62c1723..4873a6bbf8153edf20f43d842894782263b852a0 100644 (file)
@@ -227,17 +227,36 @@ void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect)
 /**
  * Use with #WM_gesture_border_invoke
  */
-void WM_operator_properties_gesture_border(wmOperatorType *ot, bool extend)
+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_gesture_border_select(wmOperatorType *ot)
+{
+       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
  */
@@ -256,6 +275,11 @@ void WM_operator_properties_gesture_lasso_ex(wmOperatorType *ot, bool deselect,
 }
 
 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);
 }
@@ -286,7 +310,7 @@ void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
 /**
  * Use with #WM_gesture_circle_invoke
  */
-void WM_operator_properties_gesture_circle(wmOperatorType *ot)
+void WM_operator_properties_gesture_circle_ex(wmOperatorType *ot, bool deselect)
 {
        PropertyRNA *prop;
        const int radius_default = 25;
@@ -296,8 +320,20 @@ void WM_operator_properties_gesture_circle(wmOperatorType *ot)
        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);
-       prop = RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
-       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");
+       }
+}
+
+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)
index 42f1325709574cbe8384354cf3fab300c8abfe45..9a1c01487b563ef7ffd9c7a4b44fc2ecbb206b3a 100644 (file)
@@ -2250,6 +2250,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 *************** */
 
 /**
@@ -2260,7 +2297,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;
@@ -2278,20 +2315,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);
 
@@ -2314,14 +2349,28 @@ static void wm_gesture_end(bContext *C, wmOperator *op)
 
 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;
@@ -2344,7 +2393,7 @@ int WM_gesture_border_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);
        }
@@ -2360,7 +2409,10 @@ int WM_gesture_border_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;
                                }
@@ -2394,8 +2446,12 @@ void WM_gesture_border_cancel(bContext *C, wmOperator *op)
 /* **************** circle gesture *************** */
 /* works now only for selection or modal paint stuff, calls exec while hold mouse, exit on release */
 
+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;
@@ -2403,6 +2459,16 @@ int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
        /* 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);
        
@@ -2415,15 +2481,18 @@ 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);
@@ -2451,6 +2520,7 @@ 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) {
@@ -2476,12 +2546,16 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
                        case GESTURE_MODAL_DESELECT:
                        case GESTURE_MODAL_NOP:
                        {
-                               PropertyRNA *prop = RNA_struct_find_property(op->ptr, "gesture_mode");
-                               if (prop != NULL) {
-                                       RNA_property_int_set(op->ptr, prop, event->val);
+                               if (gesture->wait_for_input) {
+                                       gesture->modal_state = event->val;
                                }
-
-                               if (event->val != GESTURE_MODAL_NOP) {
+                               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;
@@ -2491,8 +2565,12 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
                        }
                        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) {
@@ -4288,14 +4366,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);
index 3085f13884660b232d31fbdedb3fae48750621b9..090c8c90280bb1f8f337c0c72377b39a3430764c 100644 (file)
@@ -431,6 +431,7 @@ enum {
        GESTURE_MODAL_CANCEL      = 1,
        GESTURE_MODAL_CONFIRM     = 2,
 
+       /* Uses 'deselect' operator property. */
        GESTURE_MODAL_SELECT      = 3,
        GESTURE_MODAL_DESELECT    = 4,
 
@@ -441,6 +442,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,