Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / release / ui / buttons_data_lamp.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = "PROPERTIES"
6         __region_type__ = "WINDOW"
7         __context__ = "data"
8         
9         def poll(self, context):
10                 return (context.lamp)
11                 
12 class DATA_PT_preview(DataButtonsPanel):
13         __label__ = "Preview"
14
15         def draw(self, context):
16                 layout = self.layout
17
18                 layout.template_preview(context.lamp)
19         
20 class DATA_PT_context_lamp(DataButtonsPanel):
21         __show_header__ = False
22         
23         def draw(self, context):
24                 layout = self.layout
25                 
26                 ob = context.object
27                 lamp = context.lamp
28                 space = context.space_data
29
30                 split = layout.split(percentage=0.65)
31
32                 if ob:
33                         split.template_ID(ob, "data")
34                         split.itemS()
35                 elif lamp:
36                         split.template_ID(space, "pin_id")
37                         split.itemS()
38
39 class DATA_PT_lamp(DataButtonsPanel):
40         __label__ = "Lamp"
41
42         def draw(self, context):
43                 layout = self.layout
44                 
45                 lamp = context.lamp
46                 
47                 layout.itemR(lamp, "type", expand=True)
48                 
49                 split = layout.split()
50                 
51                 col = split.column()
52                 sub = col.column()
53                 sub.itemR(lamp, "color", text="")
54                 sub.itemR(lamp, "energy")
55
56                 if lamp.type in ('POINT', 'SPOT'):
57                         sub.itemL(text="Falloff:")
58                         sub.itemR(lamp, "falloff_type", text="")
59                         sub.itemR(lamp, "distance")
60
61                         if lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED':
62                                 col.itemL(text="Attenuation Factors:")
63                                 sub = col.column(align=True)
64                                 sub.itemR(lamp, "linear_attenuation", slider=True, text="Linear")
65                                 sub.itemR(lamp, "quadratic_attenuation", slider=True, text="Quadratic")
66                         
67                         col.itemR(lamp, "sphere")
68                         
69                 if lamp.type == 'AREA':
70                         col.itemR(lamp, "distance")
71                         col.itemR(lamp, "gamma")
72
73                         
74                 col = split.column()
75                 col.itemR(lamp, "negative")
76                 col.itemR(lamp, "layer", text="This Layer Only")
77                 col.itemR(lamp, "specular")
78                 col.itemR(lamp, "diffuse")      
79
80 class DATA_PT_sunsky(DataButtonsPanel):
81         __label__ = "Sun/Sky"
82         
83         def poll(self, context):
84                 lamp = context.lamp
85                 return (lamp and lamp.type == 'SUN')
86
87         def draw(self, context):
88                 layout = self.layout
89                 
90                 lamp = context.lamp.sky
91
92                 row = layout.row()
93                 row.itemR(lamp, "sky")
94                 row.itemR(lamp, "atmosphere")
95                 
96                 row = layout.row()
97                 row.active = lamp.sky or lamp.atmosphere
98                 row.itemR(lamp, "atmosphere_turbidity", text="Turbidity")
99                         
100                 split = layout.split()
101                 
102                 col = split.column()
103                 col.active = lamp.sky
104                 col.itemL(text="Blend Mode:")
105                 sub = col.column(align=True)
106                 sub.itemR(lamp, "sky_blend_type", text="")
107                 sub.itemR(lamp, "sky_blend", text="Factor")
108                 
109                 col.itemL(text="Color Space:")
110                 sub = col.column(align=True)
111                 sub.itemR(lamp, "sky_color_space", text="")
112                 sub.itemR(lamp, "sky_exposure", text="Exposure")
113                         
114                 col = split.column()
115                 col.active = lamp.sky
116                 col.itemL(text="Horizon:")
117                 sub = col.column(align=True)
118                 sub.itemR(lamp, "horizon_brightness", text="Brightness")
119                 sub.itemR(lamp, "spread", text="Spread")
120                 
121                 col.itemL(text="Sun:")
122                 sub = col.column(align=True)
123                 sub.itemR(lamp, "sun_brightness", text="Brightness")
124                 sub.itemR(lamp, "sun_size", text="Size")
125                 sub.itemR(lamp, "backscattered_light", slider=True,text="Back Light")
126                 
127                 layout.itemS()
128                 
129                 split = layout.split()
130                 
131                 col = split.column()
132                 col.active = lamp.atmosphere
133                 col.itemL(text="Sun:")
134                 col.itemR(lamp, "sun_intensity", text="Intensity")
135                 col.itemL(text="Scale Distance:")
136                 col.itemR(lamp, "atmosphere_distance_factor", text="Distance")
137                         
138                 col = split.column()
139                 col.active = lamp.atmosphere
140                 col.itemL(text="Scattering:")
141                 sub = col.column(align=True)
142                 sub.itemR(lamp, "atmosphere_inscattering", slider=True, text="Inscattering")
143                 sub.itemR(lamp, "atmosphere_extinction", slider=True ,text="Extinction")
144                 
145 class DATA_PT_shadow(DataButtonsPanel):
146         __label__ = "Shadow"
147         
148         def poll(self, context):
149                 lamp = context.lamp
150                 return (lamp and lamp.type in ('POINT','SUN', 'SPOT', 'AREA'))
151
152         def draw(self, context):
153                 layout = self.layout
154                 
155                 lamp = context.lamp
156
157                 layout.itemR(lamp, "shadow_method", expand=True)
158                 
159                 if lamp.shadow_method != 'NOSHADOW':
160                         split = layout.split()
161                         
162                         col = split.column()
163                         col.itemR(lamp, "shadow_color", text="")
164                         
165                         col = split.column()
166                         col.itemR(lamp, "shadow_layer", text="This Layer Only")
167                         col.itemR(lamp, "only_shadow")
168                 
169                 if lamp.shadow_method == 'RAY_SHADOW':
170                         col = layout.column()
171                         col.itemL(text="Sampling:")
172                         col.row().itemR(lamp, "shadow_ray_sampling_method", expand=True)
173                                 
174                         if lamp.type in ('POINT', 'SUN', 'SPOT'):
175                                 split = layout.split()
176                                 
177                                 col = split.column()
178                                 col.itemR(lamp, "shadow_soft_size", text="Soft Size")
179                                 
180                                 col.itemR(lamp, "shadow_ray_samples", text="Samples")
181                                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
182                                         col.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
183                                 col = split.column()
184                                                 
185                         elif lamp.type == 'AREA':
186                                 split = layout.split()
187                                 
188                                 col = split.column()
189                                 sub = split.column(align=True)
190                                 if lamp.shape == 'SQUARE':
191                                         col.itemR(lamp, "shadow_ray_samples_x", text="Samples")
192                                 elif lamp.shape == 'RECTANGLE':
193                                         col.itemR(lamp, "shadow_ray_samples_x", text="Samples X")
194                                         col.itemR(lamp, "shadow_ray_samples_y", text="Samples Y")
195                                         
196                                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
197                                         col.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
198                                         
199                                 elif lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
200                                         sub.itemR(lamp, "umbra")
201                                         sub.itemR(lamp, "dither")
202                                         sub.itemR(lamp, "jitter")       
203
204                 if lamp.shadow_method == 'BUFFER_SHADOW':
205                         col = layout.column()
206                         col.itemL(text="Buffer Type:")
207                         col.row().itemR(lamp, "shadow_buffer_type", expand=True)
208
209                         if lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY'):
210                                 split = layout.split()
211                                 
212                                 col = split.column()
213                                 col.itemL(text="Filter Type:")
214                                 col.itemR(lamp, "shadow_filter_type", text="")
215                                 sub = col.column(align=True)
216                                 sub.itemR(lamp, "shadow_buffer_soft", text="Soft")
217                                 sub.itemR(lamp, "shadow_buffer_bias", text="Bias")
218                                 
219                                 col = split.column()
220                                 col.itemL(text="Sample Buffers:")
221                                 col.itemR(lamp, "shadow_sample_buffers", text="")
222                                 sub = col.column(align=True)
223                                 sub.itemR(lamp, "shadow_buffer_size", text="Size")
224                                 sub.itemR(lamp, "shadow_buffer_samples", text="Samples")
225                                 
226                         elif lamp.shadow_buffer_type == 'IRREGULAR':
227                                 layout.itemR(lamp, "shadow_buffer_bias", text="Bias")
228                         
229                         row = layout.row()
230                         row.itemR(lamp, "auto_clip_start", text="Autoclip Start")
231                         sub = row.row()
232                         sub.active = not lamp.auto_clip_start
233                         sub.itemR(lamp, "shadow_buffer_clip_start", text="Clip Start")
234
235                         row = layout.row()
236                         row.itemR(lamp, "auto_clip_end", text="Autoclip End")
237                         sub = row.row()
238                         sub.active = not lamp.auto_clip_end
239                         sub.itemR(lamp, "shadow_buffer_clip_end", text=" Clip End")
240
241 class DATA_PT_area(DataButtonsPanel):
242         __label__ = "Area Shape"
243         
244         def poll(self, context):
245                 lamp = context.lamp
246                 return (lamp and lamp.type == 'AREA')
247
248         def draw(self, context):
249                 layout = self.layout
250                 
251                 lamp = context.lamp
252
253                 split = layout.split()
254                 
255                 col = split.column()
256                 col.itemR(lamp, "shape", text="")
257                 
258                 sub = col.column(align=True)
259                 if (lamp.shape == 'SQUARE'):
260                         sub.itemR(lamp, "size")
261                 elif (lamp.shape == 'RECTANGLE'):
262                         sub.itemR(lamp, "size", text="Size X")
263                         sub.itemR(lamp, "size_y", text="Size Y")
264                 
265                 col = split.column()
266
267 class DATA_PT_spot(DataButtonsPanel):
268         __label__ = "Spot Shape"
269         
270         def poll(self, context):
271                 lamp = context.lamp
272                 return (lamp and lamp.type == 'SPOT')
273
274         def draw(self, context):
275                 layout = self.layout
276                 
277                 lamp = context.lamp
278
279                 split = layout.split()
280                 
281                 col = split.column()
282                 sub = col.column(align=True)
283                 sub.itemR(lamp, "spot_size", text="Size")
284                 sub.itemR(lamp, "spot_blend", text="Blend")
285                 col.itemR(lamp, "square")
286                 
287                 col = split.column()
288                 col.itemR(lamp, "halo")
289                 sub = col.column(align=True)
290                 sub.active = lamp.halo
291                 sub.itemR(lamp, "halo_intensity", text="Intensity")
292                 if lamp.shadow_method == 'BUFFER_SHADOW':
293                         sub.itemR(lamp, "halo_step", text="Step")
294
295 class DATA_PT_falloff_curve(DataButtonsPanel):
296         __label__ = "Falloff Curve"
297         __default_closed__ = True
298         
299         def poll(self, context):
300                 lamp = context.lamp
301
302                 if lamp and lamp.type in ('POINT', 'SPOT'):
303                         if lamp.falloff_type == 'CUSTOM_CURVE':
304                                 return True
305
306                 return False
307
308         def draw(self, context):
309                 layout = self.layout
310                 
311                 lamp = context.lamp
312
313                 layout.template_curve_mapping(lamp.falloff_curve)
314
315 bpy.types.register(DATA_PT_context_lamp)
316 bpy.types.register(DATA_PT_preview)
317 bpy.types.register(DATA_PT_lamp)
318 bpy.types.register(DATA_PT_falloff_curve)
319 bpy.types.register(DATA_PT_area)
320 bpy.types.register(DATA_PT_spot)
321 bpy.types.register(DATA_PT_shadow)
322 bpy.types.register(DATA_PT_sunsky)