poll() as a python '@staticmethod' was too limiting and didnt allow useful base class...
[blender.git] / release / scripts / ui / properties_data_lamp.py
index 709429c0ecced2cb9968c9a8d73c205ee24ed5c7..9a58622974e1dc8e470b8031a6f50f2a8e580508 100644 (file)
@@ -34,16 +34,16 @@ class DataButtonsPanel():
     bl_region_type = 'WINDOW'
     bl_context = "data"
 
+    @classmethod
+    def poll(cls, context):
+        engine = context.scene.render.engine
+        return context.lamp and (engine in cls.COMPAT_ENGINES)
+
 
 class DATA_PT_preview(DataButtonsPanel, bpy.types.Panel):
     bl_label = "Preview"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
-    @staticmethod
-    def poll(context):
-        engine = context.scene.render.engine
-        return context.lamp and (engine in __class__.COMPAT_ENGINES)
-
     def draw(self, context):
         self.layout.template_preview(context.lamp)
 
@@ -52,11 +52,6 @@ class DATA_PT_context_lamp(DataButtonsPanel, bpy.types.Panel):
     bl_show_header = False
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
-    @staticmethod
-    def poll(context):
-        engine = context.scene.render.engine
-        return context.lamp and (engine in __class__.COMPAT_ENGINES)
-
     def draw(self, context):
         layout = self.layout
 
@@ -65,6 +60,7 @@ class DATA_PT_context_lamp(DataButtonsPanel, bpy.types.Panel):
         space = context.space_data
 
         split = layout.split(percentage=0.65)
+
         if ob:
             split.template_ID(ob, "data")
             split.separator()
@@ -74,24 +70,14 @@ class DATA_PT_context_lamp(DataButtonsPanel, bpy.types.Panel):
 
 
 class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
-    _context_path = "object.data"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
-    @staticmethod
-    def poll(context):
-        engine = context.scene.render.engine
-        return context.lamp and (engine in __class__.COMPAT_ENGINES)
+    _context_path = "object.data"
 
 
 class DATA_PT_lamp(DataButtonsPanel, bpy.types.Panel):
     bl_label = "Lamp"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
-    @staticmethod
-    def poll(context):
-        engine = context.scene.render.engine
-        return context.lamp and (engine in __class__.COMPAT_ENGINES)
-
     def draw(self, context):
         layout = self.layout
 
@@ -134,11 +120,11 @@ class DATA_PT_sunsky(DataButtonsPanel, bpy.types.Panel):
     bl_label = "Sky & Atmosphere"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
-    @staticmethod
-    def poll(context):
+    @classmethod
+    def poll(cls, context):
         lamp = context.lamp
         engine = context.scene.render.engine
-        return (lamp and lamp.type == 'SUN') and (engine in __class__.COMPAT_ENGINES)
+        return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -205,11 +191,11 @@ class DATA_PT_shadow(DataButtonsPanel, bpy.types.Panel):
     bl_label = "Shadow"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
-    @staticmethod
-    def poll(context):
+    @classmethod
+    def poll(cls, context):
         lamp = context.lamp
         engine = context.scene.render.engine
-        return (lamp and lamp.type in ('POINT', 'SUN', 'SPOT', 'AREA')) and (engine in __class__.COMPAT_ENGINES)
+        return (lamp and lamp.type in ('POINT', 'SUN', 'SPOT', 'AREA')) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -218,6 +204,20 @@ class DATA_PT_shadow(DataButtonsPanel, bpy.types.Panel):
 
         layout.prop(lamp, "shadow_method", expand=True)
 
+        if lamp.shadow_method == 'NOSHADOW' and lamp.type == 'AREA':
+            split = layout.split()
+
+            col= split.column()
+            col.label(text="Form factor sampling:")
+            
+            sub=col.row(align=True)
+
+            if lamp.shape == 'SQUARE':
+                sub.prop(lamp, "shadow_ray_samples_x", text="Samples")
+            elif lamp.shape == 'RECTANGLE':
+                sub.prop(lamp, "shadow_ray_samples_x", text="Samples X")
+                sub.prop(lamp, "shadow_ray_samples_y", text="Samples Y")
+
         if lamp.shadow_method != 'NOSHADOW':
             split = layout.split()
 
@@ -229,45 +229,41 @@ class DATA_PT_shadow(DataButtonsPanel, bpy.types.Panel):
             col.prop(lamp, "only_shadow")
 
         if lamp.shadow_method == 'RAY_SHADOW':
-            col = layout.column()
+            split = layout.split()
+            
+            col = split.column()
             col.label(text="Sampling:")
-            col.row().prop(lamp, "shadow_ray_sampling_method", expand=True)
-
+            
             if lamp.type in ('POINT', 'SUN', 'SPOT'):
-                split = layout.split()
-
-                col = split.column()
-                col.prop(lamp, "shadow_soft_size", text="Soft Size")
-
-                col.prop(lamp, "shadow_ray_samples", text="Samples")
-                if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
-                    col.prop(lamp, "shadow_adaptive_threshold", text="Threshold")
-
-                col = split.column()
-
+                sub = col.row()
+                
+                sub.prop(lamp, "shadow_ray_samples", text="Samples")
+                sub.prop(lamp, "shadow_soft_size", text="Soft Size")
+                
             elif lamp.type == 'AREA':
-                split = layout.split()
-
-                col = split.column()
-
+                sub = col.row(align=True)
+                
                 if lamp.shape == 'SQUARE':
-                    col.prop(lamp, "shadow_ray_samples_x", text="Samples")
+                    sub.prop(lamp, "shadow_ray_samples_x", text="Samples")
                 elif lamp.shape == 'RECTANGLE':
-                    col.prop(lamp, "shadow_ray_samples_x", text="Samples X")
-                    col.prop(lamp, "shadow_ray_samples_y", text="Samples Y")
+                    sub.prop(lamp, "shadow_ray_samples_x", text="Samples X")
+                    sub.prop(lamp, "shadow_ray_samples_y", text="Samples Y")
 
-                if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
-                    col.prop(lamp, "shadow_adaptive_threshold", text="Threshold")
-                    col = split.column()
-
-                elif lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
-                    col = split.column()
-                    col.prop(lamp, "umbra")
-                    col.prop(lamp, "dither")
-                    col.prop(lamp, "jitter")
-                else:
-                    col = split.column()
+            col.row().prop(lamp, "shadow_ray_sampling_method", expand=True)
 
+            split = layout.split()
+            col = split.column()
+            
+            if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
+                col.prop(lamp, "shadow_adaptive_threshold", text="Threshold")
+                col = split.column()
+            
+            if lamp.type == 'AREA' and lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
+                col = split.column()
+                col = split.column()
+                col.prop(lamp, "umbra")
+                col.prop(lamp, "dither")
+                col.prop(lamp, "jitter")
 
         elif lamp.shadow_method == 'BUFFER_SHADOW':
             col = layout.column()
@@ -315,23 +311,23 @@ class DATA_PT_area(DataButtonsPanel, bpy.types.Panel):
     bl_label = "Area Shape"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
-    @staticmethod
-    def poll(context):
+    @classmethod
+    def poll(cls, context):
         lamp = context.lamp
         engine = context.scene.render.engine
-        return (lamp and lamp.type == 'AREA') and (engine in __class__.COMPAT_ENGINES)
+        return (lamp and lamp.type == 'AREA') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
-        layout = self.layout
-
         lamp = context.lamp
 
+        layout = self.layout
         split = layout.split()
 
         col = split.column()
+        
         col.row().prop(lamp, "shape", expand=True)
+        sub = col.row(align=True)
 
-        sub = col.column(align=True)
         if (lamp.shape == 'SQUARE'):
             sub.prop(lamp, "size")
         elif (lamp.shape == 'RECTANGLE'):
@@ -343,11 +339,11 @@ class DATA_PT_spot(DataButtonsPanel, bpy.types.Panel):
     bl_label = "Spot Shape"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
-    @staticmethod
-    def poll(context):
+    @classmethod
+    def poll(cls, context):
         lamp = context.lamp
         engine = context.scene.render.engine
-        return (lamp and lamp.type == 'SPOT') and (engine in __class__.COMPAT_ENGINES)
+        return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -378,12 +374,12 @@ class DATA_PT_falloff_curve(DataButtonsPanel, bpy.types.Panel):
     bl_default_closed = True
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
-    @staticmethod
-    def poll(context):
+    @classmethod
+    def poll(cls, context):
         lamp = context.lamp
         engine = context.scene.render.engine
 
-        return (lamp and lamp.type in ('POINT', 'SPOT') and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in __class__.COMPAT_ENGINES)
+        return (lamp and lamp.type in ('POINT', 'SPOT') and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         lamp = context.lamp