A bunch of fixes for macro-type operators - Armatures + Objects

* 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.
This commit is contained in:
Joshua Leung 2009-10-27 11:10:30 +00:00
parent 81c17a9fa3
commit 90957ed0dd
6 changed files with 30 additions and 89 deletions

@ -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")

@ -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:")

@ -59,50 +59,6 @@
#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);

@ -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 ********************/

@ -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 */

@ -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();
}