macro's can set options for the operators they execute
authorCampbell Barton <ideasman42@gmail.com>
Mon, 12 Oct 2009 12:54:08 +0000 (12:54 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 12 Oct 2009 12:54:08 +0000 (12:54 +0000)
changed extrude, rip and duplicate to disable proportional editing however this gives a different problem now.
Commented in transform.c
 // XXX If modal, save settings back in scene

this changes disables the option whenever the macro used used.

source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_object.h
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/object/object_ops.c
source/blender/editors/space_api/spacetypes.c
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c

index cf0e6eb01c3aa92f6e00f2d5c2af82d72e42d290..3bceeb9340e35cbf7e955109a85652450386d96a 100644 (file)
@@ -85,6 +85,7 @@ int                   join_mesh_exec(struct bContext *C, struct wmOperator *op);
 
 /* mesh_ops.c */
 void           ED_operatortypes_mesh(void);
+void           ED_operatormacros_mesh(void);
 void           ED_keymap_mesh(struct wmKeyConfig *keyconf);
 
 
index 7ea882b765b3c880582006f124ccd79c0423d9db..e19fc806404fb7dfbdda5c5addef97c9acde0e30 100644 (file)
@@ -44,6 +44,7 @@ struct ModifierData;
 
 /* object_edit.c */
 void ED_operatortypes_object(void);
+void ED_operatormacros_object(void);
 void ED_keymap_object(struct wmKeyConfig *keyconf);
 
        /* send your own notifier for select! */
index 0865455b3b9a19d08b32231cd462b0d8b8f822b3..9e74c5717c64753533d0869e9163479a23beac41 100644 (file)
@@ -235,8 +235,6 @@ static void MESH_OT_specials(wmOperatorType *ot)
 
 void ED_operatortypes_mesh(void)
 {
-       wmOperatorType *ot;
-       
        WM_operatortype_append(MESH_OT_select_all_toggle);
        WM_operatortype_append(MESH_OT_select_more);
        WM_operatortype_append(MESH_OT_select_less);
@@ -323,8 +321,12 @@ void ED_operatortypes_mesh(void)
        
        WM_operatortype_append(MESH_OT_edgering_select);
        WM_operatortype_append(MESH_OT_loopcut);
+}
 
-       /* macros */
+void ED_operatormacros_mesh(void)
+{
+       wmOperatorType *ot;
+       wmOperatorTypeMacro *otmacro;
 
        /*combining operators with invoke and exec portions doesn't work yet.
        
@@ -335,16 +337,18 @@ void ED_operatortypes_mesh(void)
 
        ot= WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
        WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
-       WM_operatortype_macro_define(ot, "TFM_OT_translate");
+       otmacro= WM_operatortype_macro_define(ot, "TFM_OT_translate");
+       RNA_enum_set(otmacro->ptr, "proportional", 0);
 
        ot= WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", OPTYPE_UNDO|OPTYPE_REGISTER);
        WM_operatortype_macro_define(ot, "MESH_OT_rip");
-       WM_operatortype_macro_define(ot, "TFM_OT_translate");
+       otmacro= WM_operatortype_macro_define(ot, "TFM_OT_translate");
+       RNA_enum_set(otmacro->ptr, "proportional", 0);
 
        ot= WM_operatortype_append_macro("MESH_OT_extrude_move", "Extrude", OPTYPE_UNDO|OPTYPE_REGISTER);
        WM_operatortype_macro_define(ot, "MESH_OT_extrude");
-       WM_operatortype_macro_define(ot, "TFM_OT_translate");
-
+       otmacro= WM_operatortype_macro_define(ot, "TFM_OT_translate");
+       RNA_enum_set(otmacro->ptr, "proportional", 0);
 }
 
 /* note mesh keymap also for other space? */
index 2b010f5b6bc28ecec89487b0d7749595c46b2b7b..9869d15a69c56502847aa43cd612ff006b457779 100644 (file)
@@ -178,8 +178,12 @@ void ED_operatortypes_object(void)
 
        WM_operatortype_append(OBJECT_OT_group_add);
        WM_operatortype_append(OBJECT_OT_group_remove);
+}
+
+void ED_operatormacros_object(void)
+{
+       wmOperatorType *ot;
        
-       /* macros */
        ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
        if(ot) {
                WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
index 397da005543f217bef9723d80a54a59b75c8d1e5..60b9c5a6da702b2c0ee1c54a0fc4daa33d56a809 100644 (file)
@@ -105,6 +105,12 @@ void ED_spacetypes_init(void)
        spacetypes = BKE_spacetypes_list();
        for(type=spacetypes->first; type; type=type->next)
                type->operatortypes();
+
+
+       /* Macros's must go last since they reference other operators
+        * maybe we'll need to have them go after python operators too? */
+       ED_operatormacros_mesh();
+       ED_operatormacros_object();
 }
 
 /* called in wm.c */
index 0292f01fd6d290acbabbced75ba6a9636b305428..7a024e35ff08b7a7525a39b8db617dc40ae7277b 100644 (file)
@@ -181,6 +181,7 @@ typedef struct wmOperatorTypeMacro {
        /* operator id */
        char idname[MAX_ID_NAME];
        /* rna pointer to access properties, like keymap */
+       struct IDProperty *properties;  /* operator properties, assigned to ptr->data and can be written to a file */
        struct PointerRNA *ptr; 
 
 } wmOperatorTypeMacro;
@@ -240,14 +241,14 @@ typedef struct wmKeyMapItem {
        
        /* operator */
        char idname[64];                                /* used to retrieve operator type pointer */
-       IDProperty *properties;                 /* operator properties */
+       IDProperty *properties;                 /* operator properties, assigned to ptr->data and can be written to a file */
        
        /* modal */
        short propvalue;                                /* if used, the item is from modal map */
 
        /* event */
        short type;                                             /* event code itself */
-       short val;                                              /* 0=any, 1=click, 2=release, or wheelvalue, or... */
+       short val;                                              /* KM_ANY, KM_PRESS, KM_NOTHING etc */
        short shift, ctrl, alt, oskey;  /* oskey is apple or windowskey, value denotes order of pressed */
        short keymodifier;                              /* rawkey modifier */
        
index 44e404524f561bb459c7a0f82af4a429c2a2e3b7..958b388f574997336163a14945b61ea014911c51 100644 (file)
@@ -181,6 +181,7 @@ int                 WM_operator_repeat              (struct bContext *C, struct wmOperator *op);
 int         WM_operator_name_call      (struct bContext *C, const char *opstring, int context, struct PointerRNA *properties);
 int                    WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports);
 
+void           WM_operator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *opstring); /* used for keymap and macro items */
 void           WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring);
 void           WM_operator_properties_free(struct PointerRNA *ptr);
 void           WM_operator_properties_filesel(struct wmOperatorType *ot, int filter, short type);
index 3d3a6e46fb2091a71cedf806e5e40d4b1374ce83..eedacb056b700089fd33704e3ad77a6d4b364776 100644 (file)
 
 static void keymap_properties_set(wmKeyMapItem *kmi)
 {
-       if(!kmi->properties) {
-               IDPropertyTemplate val = {0};
-               kmi->properties= IDP_New(IDP_GROUP, val, "wmKeyMapItemProperties");
-       }
-
-       if(!kmi->ptr) {
-               kmi->ptr= MEM_callocN(sizeof(PointerRNA), "wmKeyMapItemPtr");
-               WM_operator_properties_create(kmi->ptr, kmi->idname);
-       }
-
-       kmi->ptr->data= kmi->properties;
+       WM_operator_properties_alloc(&(kmi->ptr), &(kmi->properties), kmi->idname);
 }
 
 wmKeyConfig *WM_keyconfig_add(wmWindowManager *wm, char *idname)
index 7db6669ca7419f52eb37ecbae5dd3877ee219676..99872f92f0f160aa5b92b5e7e43a5c6ad2cba87d 100644 (file)
@@ -270,8 +270,7 @@ wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char
        BLI_strncpy(otmacro->idname, idname, OP_MAX_TYPENAME);
 
        /* do this on first use, since operatordefinitions might have been not done yet */
-//     otmacro->ptr= MEM_callocN(sizeof(PointerRNA), "optype macro ItemPtr");
-//     WM_operator_properties_create(otmacro->ptr, idname);
+       WM_operator_properties_alloc(&(otmacro->ptr), &(otmacro->properties), idname);
        
        BLI_addtail(&ot->macro, otmacro);
        
@@ -441,6 +440,25 @@ void WM_operator_properties_create(PointerRNA *ptr, const char *opstring)
                RNA_pointer_create(NULL, &RNA_OperatorProperties, NULL, ptr);
 }
 
+/* similar to the function above except its uses ID properties
+ * used for keymaps and macros */
+void WM_operator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *opstring)
+{
+       if(*properties==NULL) {
+               IDPropertyTemplate val = {0};
+               *properties= IDP_New(IDP_GROUP, val, "wmOpItemProp");
+       }
+
+       if(*ptr==NULL) {
+               *ptr= MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
+               WM_operator_properties_create(*ptr, opstring);
+       }
+
+       (*ptr)->data= *properties;
+
+}
+
+
 void WM_operator_properties_free(PointerRNA *ptr)
 {
        IDProperty *properties= ptr->data;