A bunch of fixes for macro-type operators - Armatures + Objects
authorJoshua Leung <aligorith@gmail.com>
Tue, 27 Oct 2009 11:10:30 +0000 (11:10 +0000)
committerJoshua Leung <aligorith@gmail.com>
Tue, 27 Oct 2009 11:10:30 +0000 (11:10 +0000)
* Extrude and Duplicate for Armatures now use proper macros instead of manually calling transform themselves. This means that repeating these operators now works properly.
** NOTE: there's a bug with macros now which prevents the 'forked' extrude operator working correctly. Bug report filed for this.

* Included the proper operators for extrude and duplicate in the toolbar + menus. The operators used there did not activate transform, which meant that users often could not tell that the operation had occurred at all.

release/scripts/ui/space_view3d.py
release/scripts/ui/space_view3d_toolbar.py
source/blender/editors/armature/armature_ops.c
source/blender/editors/armature/editarmature.c
source/blender/editors/include/ED_armature.h
source/blender/editors/space_api/spacetypes.c

index ad2597d6c243d2d9a716d04d48e7cee45baf87c6..144944e6452175ecfa759f1e7653e458fb839d2b 100644 (file)
@@ -765,8 +765,8 @@ class VIEW3D_MT_edit_mesh(bpy.types.Menu):
                
                layout.itemS()
                
-               layout.itemO("mesh.extrude")
-               layout.itemO("mesh.duplicate")
+               layout.itemO("mesh.extrude_move")
+               layout.itemO("mesh.duplicate_move")
                layout.itemO("mesh.delete", text="Delete...")
                
                layout.itemS()
@@ -1129,12 +1129,12 @@ class VIEW3D_MT_edit_armature(bpy.types.Menu):
                                
                layout.itemS()
                
-               layout.itemO("armature.extrude")
+               layout.itemO("armature.extrude_move")
                
                if arm.x_axis_mirror:
-                       layout.item_booleanO("armature.extrude", "forked", True, text="Extrude Forked")
+                       layout.item_booleanO("armature.extrude_move", "forked", True, text="Extrude Forked")
                
-               layout.itemO("armature.duplicate")
+               layout.itemO("armature.duplicate_move")
                layout.itemO("armature.merge")
                layout.itemO("armature.fill")
                layout.itemO("armature.delete")
index 65802744034ec315329a4a6e6ac2649288a0bae5..b0a3508097e0ba48b65098004530af545e256db4 100644 (file)
@@ -67,12 +67,12 @@ class VIEW3D_PT_tools_meshedit(View3DPanel):
                
                col = layout.column(align=True)
                col.itemL(text="Mesh:")
-               col.itemO("mesh.duplicate")
+               col.itemO("mesh.duplicate_move")
                col.itemO("mesh.delete")
                
                col = layout.column(align=True)
                col.itemL(text="Modeling:")
-               col.itemO("mesh.extrude")
+               col.itemO("mesh.extrude_move")
                col.itemO("mesh.subdivide")
                col.itemO("mesh.loopcut")
                col.itemO("mesh.spin")
@@ -245,12 +245,12 @@ class VIEW3D_PT_tools_armatureedit(View3DPanel):
                col = layout.column(align=True)
                col.itemL(text="Bones:")
                col.itemO("armature.bone_primitive_add", text="Add")
-               col.itemO("armature.duplicate", text="Duplicate")
+               col.itemO("armature.duplicate_move", text="Duplicate")
                col.itemO("armature.delete", text="Delete")
                
                col = layout.column(align=True)
                col.itemL(text="Modeling:")
-               col.itemO("armature.extrude")
+               col.itemO("armature.extrude_move")
                
                col = layout.column(align=True)
                col.itemL(text="Grease Pencil:")
index 3a7ad8fc5ec78b93a18a4774144d9a5efcb6fc3e..71b54871be9146ea237bbb0771a8db0f224f27da 100644 (file)
 
 #include "armature_intern.h"
 
-/* ************************** quick tests **********************************/
-
-/*  XXX This is a quick test operator to print names of all EditBones in context
- *             that should be removed once tool coding starts...
- */
-
-static int armature_test_exec (bContext *C, wmOperator *op)
-{
-       printf("EditMode Armature Test: \n");
-       
-       printf("\tSelected Bones \n");
-       CTX_DATA_BEGIN(C, EditBone*, ebone, selected_bones)
-       {
-               printf("\t\tEditBone '%s' \n", ebone->name);
-       }
-       CTX_DATA_END;
-       
-       printf("\tEditable Bones \n");
-       CTX_DATA_BEGIN(C, EditBone*, ebone, selected_editable_bones) 
-       {
-               printf("\t\tEditBone '%s' \n", ebone->name);
-       }
-       CTX_DATA_END;
-       
-       printf("\tActive Bone \n");
-       {
-               EditBone *ebone= CTX_data_active_bone(C);
-               if (ebone) printf("\t\tEditBone '%s' \n", ebone->name);
-               else printf("\t\t<None> \n");
-       }
-       
-       return OPERATOR_FINISHED;
-}
-
-void ARMATURE_OT_test(wmOperatorType *ot)
-{
-       /* identifiers */
-       ot->name= "Test Context";
-       ot->idname= "ARMATURE_OT_test";
-       
-       /* api callbacks */
-       ot->exec= armature_test_exec;
-}
-
 /* ************************** registration **********************************/
 
 /* Both operators ARMATURE_OT_xxx and POSE_OT_xxx here */
@@ -200,9 +156,23 @@ void ED_operatortypes_armature(void)
        WM_operatortype_append(POSE_OT_push);
        WM_operatortype_append(POSE_OT_relax);
        WM_operatortype_append(POSE_OT_breakdown);
+}
+
+void ED_operatormacros_armature(void)
+{
+       wmOperatorType *ot;
+       wmOperatorTypeMacro *otmacro;
        
-       /* TESTS */
-       WM_operatortype_append(ARMATURE_OT_test); // XXX temp test for context iterators... to be removed
+       ot= WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
+       WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
+       otmacro= WM_operatortype_macro_define(ot, "TFM_OT_translate");
+       RNA_enum_set(otmacro->ptr, "proportional", 0);
+
+       ot= WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", OPTYPE_UNDO|OPTYPE_REGISTER);
+       otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
+       RNA_enum_set(otmacro->ptr, "forked", 0);
+       otmacro= WM_operatortype_macro_define(ot, "TFM_OT_translate");
+       RNA_enum_set(otmacro->ptr, "proportional", 0);
 }
 
 void ED_keymap_armature(wmKeyConfig *keyconf)
@@ -247,8 +217,6 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "ARMATURE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "ARMATURE_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
        
-       WM_keymap_add_item(keymap, "ARMATURE_OT_test", TKEY, KM_PRESS, 0, 0);  // XXX temp test for context iterators... to be removed
-
        kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
                RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
        kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
@@ -266,9 +234,9 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "ARMATURE_OT_delete", XKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "ARMATURE_OT_delete", DELKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "ARMATURE_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
-       WM_keymap_add_item(keymap, "ARMATURE_OT_extrude", EKEY, KM_PRESS, 0, 0);
-       kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_extrude", EKEY, KM_PRESS, KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "forked", 1);
+       WM_keymap_add_item(keymap, "ARMATURE_OT_extrude_move", EKEY, KM_PRESS, 0, 0);
+       kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_extrude_move", EKEY, KM_PRESS, KM_SHIFT, 0);
+               RNA_boolean_set(kmi->ptr, "forked", 1); // XXX this doesn't work ok for macros it seems...
        WM_keymap_add_item(keymap, "ARMATURE_OT_click_extrude", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "ARMATURE_OT_fill", FKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "ARMATURE_OT_merge", MKEY, KM_PRESS, KM_ALT, 0);
index f379ff6c39555baf4d2d111508b5743912d15641..266e4fbdbb4b780981276dc4eb4c7d37f043253f 100644 (file)
@@ -2713,17 +2713,6 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-static int armature_duplicate_selected_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       int retv= armature_duplicate_selected_exec(C, op);
-
-       if (retv == OPERATOR_FINISHED) {
-               RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
-               WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
-       }
-
-       return retv;
-}
 
 void ARMATURE_OT_duplicate(wmOperatorType *ot)
 {
@@ -2732,15 +2721,11 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot)
        ot->idname= "ARMATURE_OT_duplicate";
        
        /* api callbacks */
-       ot->invoke = armature_duplicate_selected_invoke;
        ot->exec = armature_duplicate_selected_exec;
        ot->poll = ED_operator_editarmature;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
-       /* to give to transform */
-       RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX);
 }
 
 
@@ -3385,17 +3370,6 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-static int armature_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       if (OPERATOR_CANCELLED == armature_extrude_exec(C, op))
-               return OPERATOR_CANCELLED;
-
-       RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
-       WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
-
-       return OPERATOR_FINISHED;
-}
-
 void ARMATURE_OT_extrude(wmOperatorType *ot)
 {
        /* identifiers */
@@ -3403,7 +3377,6 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
        ot->idname= "ARMATURE_OT_extrude";
        
        /* api callbacks */
-       ot->invoke= armature_extrude_invoke;
        ot->exec= armature_extrude_exec;
        ot->poll= ED_operator_editarmature;
        
@@ -3412,8 +3385,6 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
        
        /* props */
        RNA_def_boolean(ot->srna, "forked", 0, "Forked", "");
-       /* to give to transform */
-       RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX);
 }
 /* ********************** Bone Add ********************/
 
index 6479030bcd1472b4ae158fc3eab891ef95dfe69c..f360fd7a657f99d2846d98177a7d6f617b02ac0d 100644 (file)
@@ -92,6 +92,7 @@ typedef struct EditBone
 
 /* armature_ops.c */
 void ED_operatortypes_armature(void);
+void ED_operatormacros_armature(void);
 void ED_keymap_armature(struct wmKeyConfig *keyconf);
 
 /* editarmature.c */
index f3db414099f26dcf46fd186dedae2d3a5fea7e3f..da92e450ed5974cf1d915e71eec5ebd0a9c8da31 100644 (file)
@@ -109,6 +109,7 @@ void ED_spacetypes_init(void)
 
        /* Macros's must go last since they reference other operators
         * maybe we'll need to have them go after python operators too? */
+       ED_operatormacros_armature();
        ED_operatormacros_mesh();
        ED_operatormacros_object();
 }