svn merge -r 21041:21301 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
[blender.git] / release / ui / buttons_data_lamp.py
index f626eb45ed66360f4b94d1688e142e29c69d985f..a556aceb98dd67319fd1ded437ab7c990e5a35a6 100644 (file)
@@ -22,20 +22,24 @@ class DATA_PT_preview(DataButtonsPanel):
 class DATA_PT_lamp(DataButtonsPanel):
        __idname__ = "DATA_PT_lamp"
        __label__ = "Lamp"
+       
+       def poll(self, context):
+               return ((context.object and context.object.type == 'LAMP') or context.lamp)
 
        def draw(self, context):
+               layout = self.layout
+               
                ob = context.object
                lamp = context.lamp
                space = context.space_data
-               layout = self.layout
 
                split = layout.split(percentage=0.65)
 
                if ob:
-                       split.template_ID(context, ob, "data")
+                       split.template_ID(ob, "data")
                        split.itemS()
                elif lamp:
-                       split.template_ID(context, space, "pin_id")
+                       split.template_ID(space, "pin_id")
                        split.itemS()
 
                layout.itemS()
@@ -82,8 +86,8 @@ class DATA_PT_sunsky(DataButtonsPanel):
                return (lamp and lamp.type == 'SUN')
 
        def draw(self, context):
-               lamp = context.lamp.sky
                layout = self.layout
+               lamp = context.lamp.sky
 
                row = layout.row()
                row.itemR(lamp, "sky")
@@ -96,7 +100,6 @@ class DATA_PT_sunsky(DataButtonsPanel):
                split = layout.split()
 
                col = split.column()
-               
                sub = col.column()
                sub.active = lamp.sky
                sub.itemR(lamp, "sky_blend_type", text="Blend Type")
@@ -125,8 +128,8 @@ class DATA_PT_shadow(DataButtonsPanel):
                return (lamp and lamp.type in ('POINT','SUN', 'SPOT', 'AREA'))
 
        def draw(self, context):
-               lamp = context.lamp
                layout = self.layout
+               lamp = context.lamp
 
                layout.itemR(lamp, "shadow_method", expand=True)
                
@@ -204,8 +207,8 @@ class DATA_PT_spot(DataButtonsPanel):
                return (lamp and lamp.type == 'SPOT')
 
        def draw(self, context):
-               lamp = context.lamp
                layout = self.layout
+               lamp = context.lamp
 
                split = layout.split()
                
@@ -236,8 +239,8 @@ class DATA_PT_falloff_curve(DataButtonsPanel):
                return False
 
        def draw(self, context):
-               lamp = context.lamp
                layout = self.layout
+               lamp = context.lamp
 
                layout.template_curve_mapping(lamp.falloff_curve)
 
@@ -246,4 +249,4 @@ bpy.types.register(DATA_PT_lamp)
 bpy.types.register(DATA_PT_shadow)
 bpy.types.register(DATA_PT_sunsky)
 bpy.types.register(DATA_PT_spot)
-bpy.types.register(DATA_PT_falloff_curve)
\ No newline at end of file
+bpy.types.register(DATA_PT_falloff_curve)