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