diff options
author | Ton Roosendaal <ton@blender.org> | 2009-01-15 19:07:39 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-01-15 19:07:39 +0300 |
commit | 004eacad0c3d6e63f825fa0561525deafb042470 (patch) | |
tree | 60db203f99e13190ad9cec91ec4298f32f95b798 /source | |
parent | 237cd7a7a747334109a742c89dd0a78d4bb35d47 (diff) |
2.5
SHIFT+A add object back, no primitives in it though... later!
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 107 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 4 |
4 files changed, 68 insertions, 51 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index b139ff622ed..f18fa63f848 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -266,55 +266,80 @@ void ED_object_base_init_from_view(Scene *scene, View3D *v3d, Base *base) } } +/* ******************* add object operator ****************** */ + +static EnumPropertyItem prop_object_types[] = { + {OB_EMPTY, "EMPTY", "Empty", ""}, + {OB_MESH, "MESH", "Mesh", ""}, + {OB_CURVE, "CURVE", "Curve", ""}, + {OB_SURF, "SURFACE", "Surface", ""}, + {OB_FONT, "TEXT", "Text", ""}, + {OB_MBALL, "META", "Meta", ""}, + {OB_LAMP, "LAMP", "Lamp", ""}, + {OB_CAMERA, "CAMERA", "Camera", ""}, + {OB_ARMATURE, "ARMATURE", "Armature", ""}, + {OB_LATTICE, "LATTICE", "Lattice", ""}, + {0, NULL, NULL, NULL} +}; + + void add_object_draw(Scene *scene, View3D *v3d, int type) /* for toolbox or menus, only non-editmode stuff */ { + /* keep here to get things compile, remove later */ +} + +static int object_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + ScrArea *sa= CTX_wm_area(C); Object *ob; + View3D *v3d= NULL; + int type= RNA_int_get(op->ptr, "type"); -// ED_view3d_exit_paint_modes(C); - -// XXX if (obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ + /* hrms, this is editor level operator */ + ED_view3d_exit_paint_modes(C); + + if (CTX_data_edit_object(C)) + ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ + + /* deselects all, sets scene->basact */ ob= add_object(scene, type); -// ED_base_object_activate(C, BASACT); - ED_object_base_init_from_view(scene, v3d, BASACT); + /* editor level activate, notifiers */ + ED_base_object_activate(C, BASACT); - /* only undo pushes on objects without editmode... */ - if(type==OB_EMPTY) BIF_undo_push("Add Empty"); - else if(type==OB_LAMP) { - BIF_undo_push("Add Lamp"); - reshadeall_displist(scene); /* only frees */ - } - else if(type==OB_LATTICE) BIF_undo_push("Add Lattice"); - else if(type==OB_CAMERA) BIF_undo_push("Add Camera"); - - allqueue(REDRAWVIEW3D, 0); - -// XXX redraw_test_buttons(OBACT); - - allqueue(REDRAWALL, 0); - -// XXX deselect_all_area_oops(); -// XXX set_select_flag_oops(); + /* more editor stuff */ + if(sa && sa->spacetype==SPACE_VIEW3D) + v3d= sa->spacedata.first; + ED_object_base_init_from_view(scene, v3d, BASACT); DAG_scene_sort(scene); - allqueue(REDRAWINFO, 1); /* 1, because header->win==0! */ + + return OPERATOR_FINISHED; } -void add_objectLamp(Scene *scene, View3D *v3d, short type) +void OBJECT_OT_object_add(wmOperatorType *ot) { - Lamp *la; - - if(scene->obedit==NULL) { // XXX get from context - add_object_draw(scene, v3d, OB_LAMP); - ED_object_base_init_from_view(scene, v3d, BASACT); - } + PropertyRNA *prop; - la = BASACT->object->data; - la->type = type; - - allqueue(REDRAWALL, 0); + /* identifiers */ + ot->name= "Add Object"; + ot->idname= "OBJECT_OT_object_add"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= object_add_exec; + + ot->poll= ED_operator_scene_editable; + ot->flag= OPTYPE_REGISTER; + + prop = RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_object_types); } + +/* ******************************* */ + /* remove base from a specific scene */ /* note: now unlinks constraints as well */ void ED_base_object_free_and_unlink(Scene *scene, Base *base) @@ -1138,18 +1163,6 @@ void OBJECT_OT_clear_track(wmOperatorType *ot) /* ***************************** */ /* ****** Select by Type ****** */ -static EnumPropertyItem prop_select_object_types[] = { - {OB_EMPTY, "EMPTY", "Empty", ""}, - {OB_MESH, "MESH", "Mesh", ""}, - {OB_CURVE, "CURVE", "Curve", ""}, - {OB_SURF, "SURFACE", "Surface", ""}, - {OB_FONT, "TEXT", "Text", ""}, - {OB_MBALL, "META", "Meta", ""}, - {OB_LAMP, "LAMP", "Lamp", ""}, - {OB_CAMERA, "CAMERA", "Camera", ""}, - {OB_LATTICE, "LATTICE", "Lattice", ""}, - {0, NULL, NULL, NULL} -}; static int object_select_by_type_exec(bContext *C, wmOperator *op) { @@ -1184,7 +1197,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) ot->poll= ED_operator_scene_editable; prop = RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_select_object_types); + RNA_def_property_enum_items(prop, prop_object_types); } /* ****** selection by links *******/ diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 389827a870b..8c1092ae0d7 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -63,7 +63,7 @@ void OBJECT_OT_set_slowparent(struct wmOperatorType *ot); void OBJECT_OT_clear_slowparent(struct wmOperatorType *ot); void OBJECT_OT_set_center(struct wmOperatorType *ot); void OBJECT_OT_make_dupli_real(struct wmOperatorType *ot); - +void OBJECT_OT_object_add(struct wmOperatorType *ot); /* editlattice.c */ void free_editLatt(Object *ob); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 5edc09eb4cf..2e1e9845701 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -84,6 +84,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_clear_slowparent); WM_operatortype_append(OBJECT_OT_set_center); WM_operatortype_append(OBJECT_OT_make_dupli_real); + WM_operatortype_append(OBJECT_OT_object_add); } void ED_keymap_object(wmWindowManager *wm) @@ -116,6 +117,9 @@ void ED_keymap_object(wmWindowManager *wm) WM_keymap_verify_item(keymap, "OBJECT_OT_clear_restrictview", HKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_set_restrictview", HKEY, KM_PRESS, 0, 0); -// RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_viewzoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); + + WM_keymap_verify_item(keymap, "OBJECT_OT_object_add", AKEY, KM_PRESS, KM_SHIFT, 0); + + } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 627c0e7a1fc..a895835d3f0 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -195,14 +195,14 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) { PropertyRNA *prop= RNA_struct_find_property(op->ptr, "type"); const EnumPropertyItem *item; - int totitem, i, len= strlen(op->type->name) + 5; + int totitem, i, len= strlen(op->type->name) + 8; char *menu, *p; if(prop) { RNA_property_enum_items(op->ptr, prop, &item, &totitem); for (i=0; i<totitem; i++) - len+= strlen(item[i].name) + 5; + len+= strlen(item[i].name) + 8; menu= MEM_callocN(len, "string"); |