NLA-SoC: Merge from 2.5 branch 19863:20113
[blender.git] / release / ui / buttons_data_lamp.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "data"
8         
9         def poll(self, context):
10                 ob = context.active_object
11                 return (ob and ob.type == 'LAMP')
12         
13 class DATA_PT_lamp(DataButtonsPanel):
14         __idname__ = "DATA_PT_lamp"
15         __label__ = "Lamp"
16
17         def draw(self, context):
18                 lamp = context.main.lamps[0]
19                 layout = self.layout
20
21                 if not lamp:
22                         return
23                 
24                 layout.row()
25                 layout.itemR(lamp, "type", expand=True)
26                 
27                 layout.split(number=2)
28                 
29                 sub = layout.sub(0)
30                 sub.column()
31                 sub.itemL(text="LAMP DATABLOCKS")
32                 sub.itemR(lamp, "energy")
33                 sub.itemR(lamp, "distance")
34                 sub.itemR(lamp, "color")
35         
36                 sub = layout.sub(1)
37                 
38                 sub.column()
39                 sub.itemL(text="Illumination:")
40                 sub.itemR(lamp, "layer")
41                 sub.itemR(lamp, "negative")
42                 sub.itemR(lamp, "specular")
43                 sub.itemR(lamp, "diffuse")
44                 
45                 if (lamp.type in ('LOCAL', 'SPOT')):
46                         sub.column()
47                         sub.itemR(lamp, "falloff_type")
48                         sub.itemR(lamp, "sphere")
49                         
50                         if (lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED'):
51                                 sub.itemR(lamp, "linear_attenuation")
52                                 sub.itemR(lamp, "quadratic_attenuation")
53                         
54                 if (lamp.type == 'AREA'):
55                         sub.column()
56                         sub.itemR(lamp, "gamma")
57                         sub.itemR(lamp, "shape")
58                         if (lamp.shape == 'SQUARE'):
59                                 sub.itemR(lamp, "size")
60                         if (lamp.shape == 'RECTANGLE'):
61                                 sub.itemR(lamp, "size", text="Size X")
62                                 sub.itemR(lamp, "size_y")
63                                 
64 class DATA_PT_sunsky(DataButtonsPanel):
65         __idname__ = "DATA_PT_sunsky"
66         __label__ = "Sun/Sky"
67         
68         def poll(self, context):
69                 ob = context.active_object
70                 lamp = context.main.lamps[0]
71                 return (ob.type == 'LAMP' and lamp.type == 'SUN')
72
73         def draw(self, context):
74                 lamp = context.main.lamps[0].sky
75                 layout = self.layout
76
77                 if not lamp:
78                         return
79                 
80                 layout.row()
81                 layout.itemR(lamp, "sky")
82                 layout.itemR(lamp, "atmosphere")
83                 
84                 if (lamp.sky or lamp.atmosphere):
85                         layout.row()
86                         layout.itemR(lamp, "atmosphere_turbidity", text="Turbidity")
87                         
88                         layout.split(number=2)
89                         
90                         if (lamp.sky):
91                                 sub = layout.sub(0)
92                                 sub.column()
93                                 sub.itemR(lamp, "horizon_brightness", text="Hor Bright")
94                                 sub.itemR(lamp, "spread", text="Hor Spread")
95                                 sub.itemR(lamp, "sun_brightness", text="Sun Bright")
96                                 sub.itemR(lamp, "sun_size")
97                                 sub.itemR(lamp, "backscattered_light", text="Back Light")
98                                 sub.column()
99                                 sub.itemR(lamp, "sky_blend_type", text="Blend Type")
100                                 sub.itemR(lamp, "sky_blend")
101                                 sub.itemR(lamp, "sky_color_space", text="Color Space")
102                                 sub.itemR(lamp, "sky_exposure")
103                         
104                         if (lamp.atmosphere):
105                                 sub = layout.sub(1)
106                                 sub.column()
107                                 sub.itemR(lamp, "sun_intensity", text="Sun Intens")
108                                 sub.itemR(lamp, "atmosphere_inscattering", text="Inscattering")
109                                 sub.itemR(lamp, "atmosphere_extinction", text="Extinction")
110                                 sub.itemR(lamp, "atmosphere_distance_factor", text="Distance")
111                                 
112 class DATA_PT_shadow(DataButtonsPanel):
113         __idname__ = "DATA_PT_shadow"
114         __label__ = "Shadow"
115         
116         def poll(self, context):
117                 ob = context.active_object
118                 lamp = context.main.lamps[0]
119                 return (ob.type == 'LAMP' and lamp.type in ('LOCAL','SUN', 'SPOT', 'AREA'))
120
121         def draw(self, context):
122                 lamp = context.main.lamps[0]
123                 layout = self.layout
124
125                 if not lamp:
126                         return
127                 
128                 layout.row()
129                 layout.itemR(lamp, "shadow_method", expand=True)
130                 
131                 layout.row()
132                 layout.itemR(lamp, "only_shadow")
133                 layout.itemR(lamp, "shadow_layer", text="Layer")
134                 if (lamp.shadow_method == 'RAY_SHADOW'):
135                         if (lamp.type in ('LOCAL', 'SUN', 'SPOT', 'AREA')):
136
137                                 layout.split(number=2)
138
139                                 sub = layout.sub(0)
140                                 sub.column()
141                                 sub.itemL(text="Display:")
142                                 sub.itemR(lamp, "shadow_color")
143                 
144                                 sub = layout.sub(1)
145                                 sub.column()
146                                 sub.itemL(text="Sampling:")
147                                 sub.itemR(lamp, "shadow_ray_sampling_method", text="")
148                                 
149                                 if (lamp.type in ('LOCAL', 'SUN', 'SPOT') and lamp.shadow_ray_sampling_method in ('CONSTANT_QMC', 'ADAPTIVE_QMC')):
150                                         sub.itemR(lamp, "shadow_soft_size", text="Soft Size")
151                                         sub.itemR(lamp, "shadow_ray_samples", text="Samples")
152                                         if (lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC'):
153                                                 sub.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
154                                                 
155                                 if (lamp.type == 'AREA'):
156                                         sub.itemR(lamp, "shadow_ray_samples_x", text="Samples")
157                                         if (lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC'):
158                                                 sub.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
159                                         if (lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED'):
160                                                 sub.itemR(lamp, "umbra")
161                                                 sub.itemR(lamp, "dither")
162                                                 sub.itemR(lamp, "jitter")
163                                                 
164 class DATA_PT_spot(DataButtonsPanel):
165         __idname__ = "DATA_PT_spot"
166         __label__ = "Spot"
167         
168         def poll(self, context):
169                 ob = context.active_object
170                 lamp = context.main.lamps[0]
171                 return (ob.type == 'LAMP' and lamp.type == 'SPOT')
172
173         def draw(self, context):
174                 lamp = context.main.lamps[0]
175                 layout = self.layout
176
177                 if not lamp:
178                         return
179                 
180                 layout.split(number=2)
181                 
182                 sub = layout.sub(0)
183                 sub.column()
184                 sub.itemR(lamp, "square")
185                 sub.itemR(lamp, "halo")
186                 
187                 sub = layout.sub(1)
188                 sub.column()
189                 sub.itemR(lamp, "spot_size")
190                 sub.itemR(lamp, "spot_blend")
191                 sub.itemR(lamp, "halo_intensity")
192
193 bpy.types.register(DATA_PT_lamp)
194 bpy.types.register(DATA_PT_sunsky)
195 bpy.types.register(DATA_PT_shadow)
196 bpy.types.register(DATA_PT_spot)