Fix #19389: add lamp had no submenu to choose the type.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 21 Sep 2009 10:54:15 +0000 (10:54 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 21 Sep 2009 10:54:15 +0000 (10:54 +0000)
release/ui/space_info.py
source/blender/editors/interface/interface_regions.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c

index 6e32cf9b0713baaecac4dd9fc55456fa79ac3826..539a6722cf059cd9bccc343110e0c2cd1aff6db6 100644 (file)
@@ -124,7 +124,7 @@ class INFO_MT_add(bpy.types.Menu):
                layout.item_menu_enumO("object.mesh_add", "type", text="Mesh", icon='ICON_OUTLINER_OB_MESH')
                layout.item_menu_enumO("object.curve_add", "type", text="Curve", icon='ICON_OUTLINER_OB_CURVE')
                layout.item_menu_enumO("object.surface_add", "type", text="Surface", icon='ICON_OUTLINER_OB_SURFACE')
-               layout.item_menu_enumO("object.metaball_add", "type", 'META', icon='ICON_OUTLINER_OB_META')
+               layout.item_menu_enumO("object.metaball_add", "type", 'META', text="Metaball", icon='ICON_OUTLINER_OB_META')
                layout.itemO("object.text_add", text="Text", icon='ICON_OUTLINER_OB_FONT')
 
                layout.itemS()
@@ -136,7 +136,7 @@ class INFO_MT_add(bpy.types.Menu):
                layout.itemS()
 
                layout.item_enumO("object.add", "type", 'CAMERA', icon='ICON_OUTLINER_OB_CAMERA')
-               layout.item_enumO("object.add", "type", 'LAMP', icon='ICON_OUTLINER_OB_LAMP')
+               layout.item_menu_enumO("object.lamp_add", "type", 'LAMP', text="Lamp", icon='ICON_OUTLINER_OB_LAMP')
 
 class INFO_MT_game(bpy.types.Menu):
        __space_type__ = 'INFO'
index 065d391e6d6d67f126da0c611b48ea3c516af3e2..0f04333c6c540cf6f9a90596697e1c424bdf68a4 100644 (file)
@@ -2226,7 +2226,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
                }
 
                block->minbounds= minwidth;
-               uiTextBoundsBlock(block, 40);
+               uiTextBoundsBlock(block, 50);
        }
 
        /* if menu slides out of other menu, override direction */
index ee9af61f516b604a7b60eca0219b09f725aae59f..d576f6e8bf68f9f7eb2aeb41bfd131c843ed5506 100644 (file)
@@ -32,6 +32,7 @@
 #include "DNA_action_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_group_types.h"
+#include "DNA_lamp_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meta_types.h"
@@ -165,7 +166,7 @@ static Object *object_add_type(bContext *C, int type)
 /* for object add operator */
 static int object_add_exec(bContext *C, wmOperator *op)
 {
-       object_add_type(C, RNA_int_get(op->ptr, "type"));
+       object_add_type(C, RNA_enum_get(op->ptr, "type"));
        
        return OPERATOR_FINISHED;
 }
@@ -467,7 +468,7 @@ static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *even
 void OBJECT_OT_metaball_add(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Metaball";
+       ot->name= "Add Metaball";
        ot->description= "Add an metaball object to the scene.";
        ot->idname= "OBJECT_OT_metaball_add";
 
@@ -559,6 +560,45 @@ void OBJECT_OT_armature_add(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+static int object_lamp_add_exec(bContext *C, wmOperator *op)
+{
+       Object *ob;
+       int type= RNA_enum_get(op->ptr, "type");
+
+       ob= object_add_type(C, OB_LAMP);
+       if(ob && ob->data)
+               ((Lamp*)ob->data)->type= type;
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_lamp_add(wmOperatorType *ot)
+{      
+       static EnumPropertyItem lamp_type_items[] = {
+               {LA_LOCAL, "POINT", ICON_LAMP_POINT, "Point", "Omnidirectional point light source."},
+               {LA_SUN, "SUN", ICON_LAMP_SUN, "Sun", "Constant direction parallel ray light source."},
+               {LA_SPOT, "SPOT", ICON_LAMP_SPOT, "Spot", "Directional cone light source."},
+               {LA_HEMI, "HEMI", ICON_LAMP_HEMI, "Hemi", "180 degree constant light source."},
+               {LA_AREA, "AREA", ICON_LAMP_AREA, "Area", "Directional area light source."},
+               {0, NULL, 0, NULL, NULL}};
+
+       /* identifiers */
+       ot->name= "Add Lamp";
+       ot->description = "Add a lamp object to the scene.";
+       ot->idname= "OBJECT_OT_lamp_add";
+       
+       /* api callbacks */
+       ot->invoke= WM_menu_invoke;
+       ot->exec= object_lamp_add_exec;
+       ot->poll= ED_operator_scene_editable;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       /* properties */
+       RNA_def_enum(ot->srna, "type", lamp_type_items, 0, "Type", "");
+}
+
 static int object_primitive_add_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        uiPopupMenu *pup= uiPupMenuBegin(C, "Add Object", 0);
@@ -567,7 +607,7 @@ static int object_primitive_add_invoke(bContext *C, wmOperator *op, wmEvent *eve
        uiItemMenuEnumO(layout, "Mesh", ICON_OUTLINER_OB_MESH, "OBJECT_OT_mesh_add", "type");
        uiItemMenuEnumO(layout, "Curve", ICON_OUTLINER_OB_CURVE, "OBJECT_OT_curve_add", "type");
        uiItemMenuEnumO(layout, "Surface", ICON_OUTLINER_OB_SURFACE, "OBJECT_OT_surface_add", "type");
-       uiItemMenuEnumO(layout, NULL, ICON_OUTLINER_OB_META, "OBJECT_OT_metaball_add", "type");
+       uiItemMenuEnumO(layout, "Metaball", ICON_OUTLINER_OB_META, "OBJECT_OT_metaball_add", "type");
        uiItemO(layout, "Text", ICON_OUTLINER_OB_FONT, "OBJECT_OT_text_add");
        uiItemS(layout);
        uiItemO(layout, "Armature", ICON_OUTLINER_OB_ARMATURE, "OBJECT_OT_armature_add");
@@ -575,7 +615,7 @@ static int object_primitive_add_invoke(bContext *C, wmOperator *op, wmEvent *eve
        uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_EMPTY, "OBJECT_OT_add", "type", OB_EMPTY);
        uiItemS(layout);
        uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_CAMERA, "OBJECT_OT_add", "type", OB_CAMERA);
-       uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_LAMP, "OBJECT_OT_add", "type", OB_LAMP);
+       uiItemMenuEnumO(layout, "Lamp", ICON_OUTLINER_OB_LAMP, "OBJECT_OT_lamp_add", "type");
        
        uiPupMenuEnd(C, pup);
        
index 315b663205129c3e9e2b84690200d2247629ccc2..87c4560916d425913316fe61e76f6806ed7e9b18 100644 (file)
@@ -89,6 +89,7 @@ void OBJECT_OT_surface_add(struct wmOperatorType *ot);
 void OBJECT_OT_metaball_add(struct wmOperatorType *ot);
 void OBJECT_OT_text_add(struct wmOperatorType *ot);
 void OBJECT_OT_armature_add(struct wmOperatorType *ot);
+void OBJECT_OT_lamp_add(struct wmOperatorType *ot);
 void OBJECT_OT_primitive_add(struct wmOperatorType *ot); /* only used as menu */
 
 void OBJECT_OT_duplicates_make_real(struct wmOperatorType *ot);
index fdfe6ed501c2165bb7401993f2bfea19648bf408..a9b4bfe68dd8f0b1b25a6c0fa0341cafcf6ef072 100644 (file)
@@ -115,6 +115,7 @@ void ED_operatortypes_object(void)
        WM_operatortype_append(OBJECT_OT_text_add);
        WM_operatortype_append(OBJECT_OT_surface_add);
        WM_operatortype_append(OBJECT_OT_armature_add);
+       WM_operatortype_append(OBJECT_OT_lamp_add);
        WM_operatortype_append(OBJECT_OT_add);
        WM_operatortype_append(OBJECT_OT_primitive_add);
        WM_operatortype_append(OBJECT_OT_mesh_add);