alternative to joe's commit r36451.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 4 May 2011 20:42:34 +0000 (20:42 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 4 May 2011 20:42:34 +0000 (20:42 +0000)
loopcut now follows 'Release confirms' user preference.

release/scripts/startup/bl_ui/space_userpref.py
source/blender/editors/mesh/loopcut.c
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_ops.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/makesrna/intern/rna_userdef.c
source/blender/windowmanager/intern/wm_operators.c

index 5c28f12..bf396e9 100644 (file)
@@ -795,9 +795,6 @@ class USERPREF_PT_input(InputKeyMapPanel):
 
         sub.separator()
 
-        sub.label(text="Loop Cut:")
-        sub.prop(inputs, "loopcut_finish_on_release")
-        
         sub.label(text="Orbit Style:")
         sub.row().prop(inputs, "view_rotate_method", expand=True)
 
index 2e06d83..0ec356a 100644 (file)
@@ -100,7 +100,6 @@ typedef struct tringselOpData {
 
        int extend;
        int do_cut;
-       wmTimer *timer;
 } tringselOpData;
 
 /* modal loop selection drawing callback */
@@ -316,13 +315,10 @@ static void ringsel_finish(bContext *C, wmOperator *op)
 }
 
 /* called when modal loop selection is done... */
-static void ringsel_exit(bContext *C, wmOperator *op)
+static void ringsel_exit(wmOperator *op)
 {
        tringselOpData *lcd= op->customdata;
 
-       if (lcd->timer)
-               WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), lcd->timer);
-
        /* deactivate the extra drawing stuff in 3D-View */
        ED_region_draw_cb_exit(lcd->ar->type, lcd->draw_handle);
        
@@ -358,10 +354,10 @@ static int ringsel_init (bContext *C, wmOperator *op, int do_cut)
        return 1;
 }
 
-static int ringcut_cancel (bContext *C, wmOperator *op)
+static int ringcut_cancel (bContext *UNUSED(C), wmOperator *op)
 {
        /* this is just a wrapper around exit() */
-       ringsel_exit(C, op);
+       ringsel_exit(op);
        return OPERATOR_CANCELLED;
 }
 
@@ -379,7 +375,7 @@ static int ringsel_invoke (bContext *C, wmOperator *op, wmEvent *evt)
        lcd = op->customdata;
        
        if (lcd->em->selectmode == SCE_SELECT_FACE) {
-               ringsel_exit(C, op);
+               ringsel_exit(op);
                WM_operator_name_call(C, "MESH_OT_loop_select", WM_OP_INVOKE_REGION_WIN, NULL);
                return OPERATOR_CANCELLED;
        }
@@ -389,7 +385,7 @@ static int ringsel_invoke (bContext *C, wmOperator *op, wmEvent *evt)
        
        edge = findnearestedge(&lcd->vc, &dist);
        if(!edge) {
-               ringsel_exit(C, op);
+               ringsel_exit(op);
                return OPERATOR_CANCELLED;
        }
 
@@ -397,7 +393,7 @@ static int ringsel_invoke (bContext *C, wmOperator *op, wmEvent *evt)
        ringsel_find_edge(lcd, 1);
 
        ringsel_finish(C, op);
-       ringsel_exit(C, op);
+       ringsel_exit(op);
 
        return OPERATOR_FINISHED;
 }
@@ -408,11 +404,7 @@ static int ringcut_invoke (bContext *C, wmOperator *op, wmEvent *evt)
        tringselOpData *lcd;
        EditEdge *edge;
        int dist = 75;
-       
-       /*if we're in the cut-n-slide macro, set release_confirm based on user pref*/
-       if (op->opm)
-               RNA_boolean_set(op->next->ptr, "release_confirm", U.loopcut_finish_on_release);
-       
+
        if(modifiers_isDeformedByLattice(obedit) || modifiers_isDeformedByArmature(obedit))
                BKE_report(op->reports, RPT_WARNING, "Loop cut doesn't work well on deformed edit mesh display");
        
@@ -445,34 +437,22 @@ static int ringcut_modal (bContext *C, wmOperator *op, wmEvent *event)
 
        view3d_operator_needs_opengl(C);
 
+
        switch (event->type) {
                case LEFTMOUSE: /* confirm */ // XXX hardcoded
-                       if (event->val == KM_RELEASE) {
+                       if (event->val == KM_PRESS) {
                                /* finish */
                                ED_region_tag_redraw(lcd->ar);
                                
                                ringsel_finish(C, op);
-                               ringsel_exit(C, op);
+                               ringsel_exit(op);
                                ED_area_headerprint(CTX_wm_area(C), NULL);
                                
-                               return OPERATOR_FINISHED|OPERATOR_ABORT_MACRO;
-                       }else {
-                               lcd->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER2, 0.12);
+                               return OPERATOR_FINISHED;
                        }
                        
                        ED_region_tag_redraw(lcd->ar);
                        break;
-                       
-               case TIMER2: 
-                       /* finish */
-                       ED_region_tag_redraw(lcd->ar);
-                       
-                       ringsel_finish(C, op);
-                       ringsel_exit(C, op);
-                       
-                       ED_area_headerprint(CTX_wm_area(C), NULL);
-
-                       return OPERATOR_FINISHED;
                case RIGHTMOUSE: /* abort */ // XXX hardcoded
                case ESCKEY:
                        if (event->val == KM_RELEASE) {
index 6d8dd4e..282eeef 100644 (file)
@@ -176,9 +176,8 @@ void ED_operatormacros_mesh(void)
        ot->description = "Cut mesh loop and slide it";
        WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
        otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
-       RNA_boolean_set(otmacro->ptr, "release_confirm", 1);
-       RNA_int_set(otmacro->ptr, "launch_event", LEFTMOUSE);
-       
+       RNA_struct_idprops_unset(otmacro->ptr, "release_confirm");
+
        ot= WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
        ot->description = "Duplicate mesh and move";
        WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
index 701b8af..614b048 100644 (file)
@@ -1521,9 +1521,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
        t->mode = mode;
 
        t->launch_event = event ? event->type : -1;
-       if (RNA_property_is_set(op->ptr, "launch_event"))
-               t->launch_event = RNA_int_get(op->ptr, "launch_event");
-       
+
        if (t->launch_event == EVT_TWEAK_R)
        {
                t->launch_event = RIGHTMOUSE;
index 565ff76..4edaabb 100644 (file)
@@ -495,11 +495,10 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
        {
                RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Object data texture space", "");
        }
-       
+
        // Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit
        /*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
        //RNA_def_property_flag(prop, PROP_HIDDEN);
-       RNA_def_int(ot->srna, "launch_event", 0, 0, INT_MAX, "Launch Event", "", 0, INT_MAX);
 }
 
 void TRANSFORM_OT_translate(struct wmOperatorType *ot)
@@ -743,7 +742,7 @@ void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
        ot->poll   = ED_operator_editmesh;
 
        RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
-       
+
        Transform_Properties(ot, P_MIRROR|P_SNAP);
 }
 
index f91c0ac..1be67a4 100644 (file)
@@ -383,13 +383,13 @@ typedef struct UserDef {
        short autokey_mode;             /* autokeying mode */
        short autokey_flag;             /* flags for autokeying */
        
-       short text_render, dsm_maxmem;          /*options for text rendering*/
+       short text_render, pad9;                /*options for text rendering*/
        float pad10;
 
        struct ColorBand coba_weight;   /* from texture.h */
 
        float sculpt_paint_overlay_col[3];
-       int loopcut_finish_on_release;
+       int pad3;
 
        char author[80];        /* author name for file formats supporting it */
 } UserDef;
index 48e5854..3072c2c 100644 (file)
@@ -312,7 +312,6 @@ typedef struct wmOperator {
 #define OPERATOR_PASS_THROUGH  8
 /* in case operator got executed outside WM code... like via fileselect */
 #define OPERATOR_HANDLED               16
-#define OPERATOR_ABORT_MACRO   32
 
 /* wmOperator flag */
 #define OP_GRAB_POINTER                        1
index 421a48e..a914d87 100644 (file)
@@ -2676,10 +2676,6 @@ static void rna_def_userdef_input(BlenderRNA *brna)
        RNA_def_property_enum_items(prop, view_zoom_axes);
        RNA_def_property_ui_text(prop, "Zoom Axis", "Axis of mouse movement to zoom in or out on");
        
-       prop= RNA_def_property(srna, "loopcut_finish_on_release", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "loopcut_finish_on_release", 1);
-       RNA_def_property_ui_text(prop, "End Loopcut Slide On Release", "End Loopcut Slide On Mouse Release, a 'click-drag-and-hold' workflow");
-
        prop= RNA_def_property(srna, "invert_mouse_zoom", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_INVERT);
        RNA_def_property_ui_text(prop, "Invert Zoom Direction", "Invert the axis of mouse movement for zooming");
index 7148c16..63a8ecc 100644 (file)
@@ -214,9 +214,6 @@ static int wm_macro_exec(bContext *C, wmOperator *op)
                        } else {
                                break; /* operator didn't finish, end macro */
                        }
-                       
-                       if (retval & OPERATOR_ABORT_MACRO)
-                               break;
                }
        }
        
@@ -242,9 +239,6 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, wmEvent *event,
                } else {
                        break; /* operator didn't finish, end macro */
                }
-               
-               if (retval & OPERATOR_ABORT_MACRO)
-                       break;
        }
 
        return wm_macro_end(op, retval);
@@ -271,45 +265,43 @@ static int wm_macro_modal(bContext *C, wmOperator *op, wmEvent *event)
                        MacroData *md = op->customdata;
 
                        md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
-                       
-                       if (!(retval & OPERATOR_ABORT_MACRO)) {
-                               retval = wm_macro_invoke_internal(C, op, event, opm->next);
-       
-                               /* if new operator is modal and also added its own handler */
-                               if (retval & OPERATOR_RUNNING_MODAL && op->opm != opm) {
-                                       wmWindow *win = CTX_wm_window(C);
-                                       wmEventHandler *handler = NULL;
-       
-                                       for (handler = win->modalhandlers.first; handler; handler = handler->next) {
-                                               /* first handler in list is the new one */
-                                               if (handler->op == op)
-                                                       break;
-                                       }
-       
-                                       if (handler) {
-                                               BLI_remlink(&win->modalhandlers, handler);
-                                               wm_event_free_handler(handler);
-                                       }
-       
-                                       /* if operator is blocking, grab cursor
-                                        * This may end up grabbing twice, but we don't care.
-                                        * */
-                                       if(op->opm->type->flag & OPTYPE_BLOCKING) {
-                                               int bounds[4] = {-1,-1,-1,-1};
-                                               int wrap = (U.uiflag & USER_CONTINUOUS_MOUSE) && ((op->opm->flag & OP_GRAB_POINTER) || (op->opm->type->flag & OPTYPE_GRAB_POINTER));
-       
-                                               if(wrap) {
-                                                       ARegion *ar= CTX_wm_region(C);
-                                                       if(ar) {
-                                                               bounds[0]= ar->winrct.xmin;
-                                                               bounds[1]= ar->winrct.ymax;
-                                                               bounds[2]= ar->winrct.xmax;
-                                                               bounds[3]= ar->winrct.ymin;
-                                                       }
+
+                       retval = wm_macro_invoke_internal(C, op, event, opm->next);
+
+                       /* if new operator is modal and also added its own handler */
+                       if (retval & OPERATOR_RUNNING_MODAL && op->opm != opm) {
+                               wmWindow *win = CTX_wm_window(C);
+                               wmEventHandler *handler = NULL;
+
+                               for (handler = win->modalhandlers.first; handler; handler = handler->next) {
+                                       /* first handler in list is the new one */
+                                       if (handler->op == op)
+                                               break;
+                               }
+
+                               if (handler) {
+                                       BLI_remlink(&win->modalhandlers, handler);
+                                       wm_event_free_handler(handler);
+                               }
+
+                               /* if operator is blocking, grab cursor
+                                * This may end up grabbing twice, but we don't care.
+                                * */
+                               if(op->opm->type->flag & OPTYPE_BLOCKING) {
+                                       int bounds[4] = {-1,-1,-1,-1};
+                                       int wrap = (U.uiflag & USER_CONTINUOUS_MOUSE) && ((op->opm->flag & OP_GRAB_POINTER) || (op->opm->type->flag & OPTYPE_GRAB_POINTER));
+
+                                       if(wrap) {
+                                               ARegion *ar= CTX_wm_region(C);
+                                               if(ar) {
+                                                       bounds[0]= ar->winrct.xmin;
+                                                       bounds[1]= ar->winrct.ymax;
+                                                       bounds[2]= ar->winrct.xmax;
+                                                       bounds[3]= ar->winrct.ymin;
                                                }
-       
-                                               WM_cursor_grab(CTX_wm_window(C), wrap, FALSE, bounds);
                                        }
+
+                                       WM_cursor_grab(CTX_wm_window(C), wrap, FALSE, bounds);
                                }
                        }
                }