macro's can set options for the operators they execute
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -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! */
|
||||
|
||||
@@ -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? */
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -57,17 +57,7 @@
|
||||
|
||||
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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user