diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_object.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/editconstraint.c | 46 | ||||
-rw-r--r-- | source/blender/editors/object/editgroup.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 16 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_ops.c | 133 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/space_buttons.c | 3 |
9 files changed, 202 insertions, 9 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index f7dcc7fd1a0..ab718aca81f 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -57,6 +57,7 @@ void ED_object_apply_obmat(struct Object *ob); /* single object duplicate, if dupflag==0, fully linked, else it uses U.dupflag */ struct Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int usedupflag); +void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr); /* bitflags for enter/exit editmode */ #define EM_FREEDATA 1 diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c index 7be4697d0c8..62bc5d13257 100644 --- a/source/blender/editors/object/editconstraint.c +++ b/source/blender/editors/object/editconstraint.c @@ -1008,12 +1008,11 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot) /************************ add constraint operator *********************/ -static int constraint_add_exec(bContext *C, wmOperator *op) +static int constraint_add_exec(bContext *C, wmOperator *op, ListBase *list) { Scene *scene= CTX_data_scene(C); Object *ob = CTX_data_active_object(C); bConstraint *con, *coniter; - ListBase *list= get_active_constraints(ob); bPoseChannel *pchan= get_active_posechannel(ob); int type= RNA_enum_get(op->ptr, "type"); @@ -1077,6 +1076,26 @@ static int constraint_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int object_constraint_add_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + + if(!ob) + return OPERATOR_CANCELLED; + + return constraint_add_exec(C, op, &ob->constraints); +} + +static int pose_constraint_add_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + + if(!ob) + return OPERATOR_CANCELLED;; + + return constraint_add_exec(C, op, get_active_constraints(ob)); +} + void OBJECT_OT_constraint_add(wmOperatorType *ot) { /* identifiers */ @@ -1086,13 +1105,32 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; - ot->exec= constraint_add_exec; - + ot->exec= object_constraint_add_exec; ot->poll= ED_operator_object_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + /* properties */ + RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); +} + +void POSE_OT_constraint_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Constraint"; + ot->description = "Add a constraint to the active bone."; + ot->idname= "POSE_OT_constraint_add"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= pose_constraint_add_exec; + ot->poll= ED_operator_posemode; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); } diff --git a/source/blender/editors/object/editgroup.c b/source/blender/editors/object/editgroup.c index 5943b36a6b0..9a184892e71 100644 --- a/source/blender/editors/object/editgroup.c +++ b/source/blender/editors/object/editgroup.c @@ -200,7 +200,7 @@ void GROUP_OT_objects_remove(wmOperatorType *ot) { /* identifiers */ - ot->name= "Remove from group"; + ot->name= "Remove From Groups"; ot->description = "Remove selected objects from all groups."; ot->idname= "GROUP_OT_objects_remove"; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0746fbaefb6..26a89999475 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2786,6 +2786,22 @@ static int test_parent_loop(Object *par, Object *ob) return test_parent_loop(par->parent, ob); } +void ED_object_parent(Object *ob, Object *par, int type, const char *substr) +{ + if(!par || test_parent_loop(par, ob)) { + ob->parent= NULL; + ob->partype= PAROBJECT; + ob->parsubstr[0]= 0; + return; + } + + /* this could use some more checks */ + + ob->parent= par; + ob->partype &= ~PARTYPE; + ob->partype |= type; + BLI_strncpy(ob->parsubstr, substr, sizeof(ob->parsubstr)); +} static int parent_set_exec(bContext *C, wmOperator *op) { diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 23a4b5773ff..5610a75d4d3 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -102,6 +102,7 @@ void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot); /* editconstraint.c */ void OBJECT_OT_constraint_add(struct wmOperatorType *ot); +void POSE_OT_constraint_add(struct wmOperatorType *ot); void CONSTRAINT_OT_delete(struct wmOperatorType *ot); void CONSTRAINT_OT_move_up(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index acfe2416d77..b73030226ef 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -112,6 +112,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_modifier_mdef_bind); WM_operatortype_append(OBJECT_OT_constraint_add); + WM_operatortype_append(POSE_OT_constraint_add); WM_operatortype_append(CONSTRAINT_OT_delete); WM_operatortype_append(CONSTRAINT_OT_move_up); WM_operatortype_append(CONSTRAINT_OT_move_down); @@ -147,16 +148,13 @@ void ED_keymap_object(wmWindowManager *wm) WM_keymap_add_item(keymap, "OBJECT_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_select_random", PADASTERKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_select_by_type", PADASTERKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_select_by_layer", PADASTERKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_verify_item(keymap, "OBJECT_OT_track_clear", TKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index f09f35589b9..20db9fce8f2 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -61,6 +61,9 @@ void buttons_context_draw(const struct bContext *C, struct uiLayout *layout); void buttons_context_register(struct ARegionType *art); /* buttons_ops.c */ +void OBJECT_OT_group_add(struct wmOperatorType *ot); +void OBJECT_OT_group_remove(struct wmOperatorType *ot); + void OBJECT_OT_material_slot_add(struct wmOperatorType *ot); void OBJECT_OT_material_slot_remove(struct wmOperatorType *ot); void OBJECT_OT_material_slot_assign(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index fb1e9d1214d..7dececd2679 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" #include "DNA_curve_types.h" +#include "DNA_group_types.h" #include "DNA_object_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" @@ -40,6 +41,7 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_group.h" #include "BKE_font.h" #include "BKE_library.h" #include "BKE_main.h" @@ -62,8 +64,139 @@ #include "ED_curve.h" #include "ED_mesh.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "buttons_intern.h" // own include + +/********************** group operators *********************/ + +static int group_add_exec(bContext *C, wmOperator *op) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Base *base; + Group *group; + int value= RNA_enum_get(op->ptr, "group"); + + if(!ob) + return OPERATOR_CANCELLED; + + base= object_in_scene(ob, scene); + if(!base) + return OPERATOR_CANCELLED; + + if(value == -1) + group= add_group( "Group" ); + else + group= BLI_findlink(&bmain->group, value); + + if(group) { + add_to_group(group, ob); + ob->flag |= OB_FROMGROUP; + base->flag |= OB_FROMGROUP; + } + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +static EnumPropertyItem group_items[]= { + {-1, "ADD_NEW", 0, "Add New Group", ""}, + {0, NULL, 0, NULL, NULL}}; + +static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem tmp = {0, "", 0, "", ""}; + EnumPropertyItem *item= NULL; + Main *bmain; + Group *group; + int a, totitem= 0; + + if(!C) /* needed for docs */ + return group_items; + + RNA_enum_items_add_value(&item, &totitem, group_items, -1); + + bmain= CTX_data_main(C); + if(bmain->group.first) + RNA_enum_item_add_separator(&item, &totitem); + + for(a=0, group=bmain->group.first; group; group=group->id.next, a++) { + tmp.value= a; + tmp.identifier= group->id.name+2; + tmp.name= group->id.name+2; + RNA_enum_item_add(&item, &totitem, &tmp); + } + + RNA_enum_item_end(&item, &totitem); + + *free= 1; + + return item; +} + +void OBJECT_OT_group_add(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Add Group"; + ot->idname= "OBJECT_OT_group_add"; + + /* api callbacks */ + ot->exec= group_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + prop= RNA_def_enum(ot->srna, "group", group_items, -1, "Group", "Group to add object to."); + RNA_def_enum_funcs(prop, group_itemf); +} + +static int group_remove_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Group *group= CTX_data_pointer_get_type(C, "group", &RNA_Group).data; + Base *base; + + if(!ob || !group) + return OPERATOR_CANCELLED; + + base= object_in_scene(ob, scene); + if(!base) + return OPERATOR_CANCELLED; + + rem_from_group(group, ob); + + if(find_group(ob, NULL) == NULL) { + ob->flag &= ~OB_FROMGROUP; + base->flag &= ~OB_FROMGROUP; + } + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_group_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Group"; + ot->idname= "OBJECT_OT_group_remove"; + + /* api callbacks */ + ot->exec= group_remove_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /********************** material slot operators *********************/ static int material_slot_add_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 17f55c9395e..65fbdeb4205 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -210,6 +210,9 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) void buttons_operatortypes(void) { + WM_operatortype_append(OBJECT_OT_group_add); + WM_operatortype_append(OBJECT_OT_group_remove); + WM_operatortype_append(OBJECT_OT_material_slot_add); WM_operatortype_append(OBJECT_OT_material_slot_remove); WM_operatortype_append(OBJECT_OT_material_slot_assign); |