Cleanup: rename gesture mode to is_active
authorCampbell Barton <ideasman42@gmail.com>
Mon, 16 Oct 2017 02:01:09 +0000 (13:01 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 16 Oct 2017 03:27:10 +0000 (14:27 +1100)
Wasn't obvious what this did at a glance.

source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_gesture.c
source/blender/windowmanager/intern/wm_operators.c

index 9483a12aa6a1931ca68c69893caf680f714ef3e8..3af1da3edce9b3c4c70d60c6f07b3deb52ecd5cd 100644 (file)
@@ -817,7 +817,7 @@ static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, const wmEve
                        /* TODO, hardcoded, extend WM_gesture_straightline_ */
                        if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
                                wmGesture *gesture = op->customdata;
-                               gesture->mode = 1;
+                               gesture->is_active = true;
                        }
                }
        }
index f6049f103786c0f15876f10ef1d0484ea665fc8c..1c8d12973c6a7c58b36eb25ceaddb39cbc5f0bf4 100644 (file)
@@ -409,11 +409,14 @@ typedef struct wmNotifier {
 typedef struct wmGesture {
        struct wmGesture *next, *prev;
        int event_type; /* event->type */
-       int mode;               /* for modal callback */
        int type;               /* gesture type define */
        int swinid;             /* initial subwindow id where it started */
        int points;             /* optional, amount of points stored */
        int size;               /* optional, maximum amount of points stored */
+
+       /* 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;
        
        void *customdata;
        /* customdata for border is a recti */
index cc48b162352a4bb261f834a18228c07b07f67dba..311b501a1791a5799837763121e81b4e4d5f2183 100644 (file)
@@ -377,10 +377,12 @@ void wm_gesture_draw(wmWindow *win)
                else if (gt->type == WM_GESTURE_CIRCLE)
                        wm_gesture_draw_circle(gt);
                else if (gt->type == WM_GESTURE_CROSS_RECT) {
-                       if (gt->mode == 1)
+                       if (gt->is_active) {
                                wm_gesture_draw_rect(gt);
-                       else
+                       }
+                       else {
                                wm_gesture_draw_cross(win, gt);
+                       }
                }
                else if (gt->type == WM_GESTURE_LINES)
                        wm_gesture_draw_lasso(win, gt, false);
index ae5a8319b0072abdab6fbafa081e07d6cf56811f..330a18eeda53f26f946299e78045aa62dc640463 100644 (file)
@@ -2336,7 +2336,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
        if (event->type == MOUSEMOVE) {
                wm_subwindow_origin_get(CTX_wm_window(C), gesture->swinid, &sx, &sy);
 
-               if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->mode == 0) {
+               if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->is_active == false) {
                        rect->xmin = rect->xmax = event->x - sx;
                        rect->ymin = rect->ymax = event->y - sy;
                }
@@ -2351,8 +2351,8 @@ int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
        else if (event->type == EVT_MODAL_MAP) {
                switch (event->val) {
                        case GESTURE_MODAL_BEGIN:
-                               if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->mode == 0) {
-                                       gesture->mode = 1;
+                               if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->is_active == false) {
+                                       gesture->is_active = true;
                                        wm_gesture_tag_redraw(C);
                                }
                                break;
@@ -2447,8 +2447,9 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
                wm_gesture_tag_redraw(C);
 
-               if (gesture->mode)
+               if (gesture->is_active) {
                        gesture_circle_apply(C, op);
+               }
        }
        else if (event->type == EVT_MODAL_MAP) {
                float fac;
@@ -2481,7 +2482,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
                                if (event->val != GESTURE_MODAL_NOP) {
                                        /* apply first click */
                                        gesture_circle_apply(C, op);
-                                       gesture->mode = 1;
+                                       gesture->is_active = true;
                                        wm_gesture_tag_redraw(C);
                                }
                                break;
@@ -2881,7 +2882,7 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
        if (event->type == MOUSEMOVE) {
                wm_subwindow_origin_get(CTX_wm_window(C), gesture->swinid, &sx, &sy);
                
-               if (gesture->mode == 0) {
+               if (gesture->is_active == false) {
                        rect->xmin = rect->xmax = event->x - sx;
                        rect->ymin = rect->ymax = event->y - sy;
                }
@@ -2896,8 +2897,8 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
        else if (event->type == EVT_MODAL_MAP) {
                switch (event->val) {
                        case GESTURE_MODAL_BEGIN:
-                               if (gesture->mode == 0) {
-                                       gesture->mode = 1;
+                               if (gesture->is_active == false) {
+                                       gesture->is_active = true;
                                        wm_gesture_tag_redraw(C);
                                }
                                break;