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