Merge branch 'master' into blender2.8
[blender.git] / release / scripts / startup / bl_ui / properties_data_lamp.py
index 00919d64ca53899dd25c3f7caeb570fc4af1d49a..30cd39d2e2f8e597c02b5bceaed9ab2c75de01a0 100644 (file)
 
 # <pep8 compliant>
 import bpy
+from bpy.types import Menu, Panel
 from rna_prop_ui import PropertyPanel
 
 
-class LAMP_MT_sunsky_presets(bpy.types.Menu):
+class LAMP_MT_sunsky_presets(Menu):
     bl_label = "Sun & Sky Presets"
     preset_subdir = "sunsky"
     preset_operator = "script.execute_preset"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-    draw = bpy.types.Menu.draw_preset
+    draw = Menu.draw_preset
 
 
-class DataButtonsPanel():
+class DataButtonsPanel:
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = "data"
@@ -40,7 +41,7 @@ class DataButtonsPanel():
         return context.lamp and (engine in cls.COMPAT_ENGINES)
 
 
-class DATA_PT_context_lamp(DataButtonsPanel, bpy.types.Panel):
+class DATA_PT_context_lamp(DataButtonsPanel, Panel):
     bl_label = ""
     bl_options = {'HIDE_HEADER'}
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -65,7 +66,7 @@ class DATA_PT_context_lamp(DataButtonsPanel, bpy.types.Panel):
             split.label(text=str(texture_count), icon='TEXTURE')
 
 
-class DATA_PT_preview(DataButtonsPanel, bpy.types.Panel):
+class DATA_PT_preview(DataButtonsPanel, Panel):
     bl_label = "Preview"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
@@ -73,7 +74,7 @@ class DATA_PT_preview(DataButtonsPanel, bpy.types.Panel):
         self.layout.template_preview(context.lamp)
 
 
-class DATA_PT_lamp(DataButtonsPanel, bpy.types.Panel):
+class DATA_PT_lamp(DataButtonsPanel, Panel):
     bl_label = "Lamp"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
@@ -102,6 +103,13 @@ class DATA_PT_lamp(DataButtonsPanel, bpy.types.Panel):
                 sub.prop(lamp, "linear_attenuation", slider=True, text="Linear")
                 sub.prop(lamp, "quadratic_attenuation", slider=True, text="Quadratic")
 
+            elif lamp.falloff_type == 'INVERSE_COEFFICIENTS':
+                col.label(text="Inverse Coefficients:")
+                sub = col.column(align=True)
+                sub.prop(lamp, "constant_coefficient", text="Constant")
+                sub.prop(lamp, "linear_coefficient", text="Linear")
+                sub.prop(lamp, "quadratic_coefficient", text="Quadratic")
+
             col.prop(lamp, "use_sphere")
 
         if lamp.type == 'AREA':
@@ -115,9 +123,9 @@ class DATA_PT_lamp(DataButtonsPanel, bpy.types.Panel):
         col.prop(lamp, "use_diffuse")
 
 
-class DATA_PT_sunsky(DataButtonsPanel, bpy.types.Panel):
+class DATA_PT_sunsky(DataButtonsPanel, Panel):
     bl_label = "Sky & Atmosphere"
-    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     @classmethod
     def poll(cls, context):
@@ -133,8 +141,8 @@ class DATA_PT_sunsky(DataButtonsPanel, bpy.types.Panel):
         row = layout.row(align=True)
         row.prop(lamp, "use_sky")
         row.menu("LAMP_MT_sunsky_presets", text=bpy.types.LAMP_MT_sunsky_presets.bl_label)
-        row.operator("lamp.sunsky_preset_add", text="", icon="ZOOMIN")
-        row.operator("lamp.sunsky_preset_add", text="", icon="ZOOMOUT").remove_active = True
+        row.operator("lamp.sunsky_preset_add", text="", icon='ZOOMIN')
+        row.operator("lamp.sunsky_preset_add", text="", icon='ZOOMOUT').remove_active = True
 
         row = layout.row()
         row.active = lamp.use_sky or lamp.use_atmosphere
@@ -187,9 +195,9 @@ class DATA_PT_sunsky(DataButtonsPanel, bpy.types.Panel):
         sub.prop(lamp, "atmosphere_extinction", slider=True, text="Extinction")
 
 
-class DATA_PT_shadow(DataButtonsPanel, bpy.types.Panel):
+class DATA_PT_shadow(DataButtonsPanel, Panel):
     bl_label = "Shadow"
-    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     @classmethod
     def poll(cls, context):
@@ -302,7 +310,7 @@ class DATA_PT_shadow(DataButtonsPanel, bpy.types.Panel):
             sub.prop(lamp, "shadow_buffer_clip_end", text=" Clip End")
 
 
-class DATA_PT_area(DataButtonsPanel, bpy.types.Panel):
+class DATA_PT_area(DataButtonsPanel, Panel):
     bl_label = "Area Shape"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
@@ -321,14 +329,14 @@ class DATA_PT_area(DataButtonsPanel, bpy.types.Panel):
         col.row().prop(lamp, "shape", expand=True)
         sub = col.row(align=True)
 
-        if (lamp.shape == 'SQUARE'):
+        if lamp.shape == 'SQUARE':
             sub.prop(lamp, "size")
-        elif (lamp.shape == 'RECTANGLE'):
+        elif lamp.shape == 'RECTANGLE':
             sub.prop(lamp, "size", text="Size X")
             sub.prop(lamp, "size_y", text="Size Y")
 
 
-class DATA_PT_spot(DataButtonsPanel, bpy.types.Panel):
+class DATA_PT_spot(DataButtonsPanel, Panel):
     bl_label = "Spot Shape"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
@@ -354,6 +362,7 @@ class DATA_PT_spot(DataButtonsPanel, bpy.types.Panel):
 
         col = split.column()
 
+        col.active = (lamp.shadow_method != 'BUFFER_SHADOW' or lamp.shadow_buffer_type != 'DEEP')
         col.prop(lamp, "use_halo")
         sub = col.column(align=True)
         sub.active = lamp.use_halo
@@ -362,7 +371,7 @@ class DATA_PT_spot(DataButtonsPanel, bpy.types.Panel):
             sub.prop(lamp, "halo_step", text="Step")
 
 
-class DATA_PT_falloff_curve(DataButtonsPanel, bpy.types.Panel):
+class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
     bl_label = "Falloff Curve"
     bl_options = {'DEFAULT_CLOSED'}
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -377,10 +386,13 @@ class DATA_PT_falloff_curve(DataButtonsPanel, bpy.types.Panel):
     def draw(self, context):
         lamp = context.lamp
 
-        self.layout.template_curve_mapping(lamp, "falloff_curve")
+        self.layout.template_curve_mapping(lamp, "falloff_curve", use_negative_slope=True)
 
 
-class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
+class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
     _context_path = "object.data"
     _property_type = bpy.types.Lamp
+
+if __name__ == "__main__":  # only for live edit.
+    bpy.utils.register_module(__name__)