UI: Layout Engine
[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                 row = layout.row()
25                 row.itemR(lamp, "type", expand=True)
26                 
27                 split = layout.split()
28                 
29                 sub = split.column()
30                 sub.itemR(lamp, "energy")
31                 sub.itemR(lamp, "distance")
32                 sub.itemR(lamp, "negative")
33                 sub.itemR(lamp, "color")
34         
35                 sub = split.column()
36                 sub.itemR(lamp, "layer", text="This Layer Only")
37                 sub.itemR(lamp, "specular")
38                 sub.itemR(lamp, "diffuse")
39                 
40                 if lamp.type in ('POINT', 'SPOT'):
41                         sub.itemR(lamp, "falloff_type")
42                         sub.itemR(lamp, "sphere")
43                         
44                         if (lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED'):
45                                 sub.itemR(lamp, "linear_attenuation")
46                                 sub.itemR(lamp, "quadratic_attenuation")
47                         
48                 if lamp.type == 'AREA':
49                         sub.column()
50                         sub.itemR(lamp, "gamma")
51                         sub.itemR(lamp, "shape")
52                         if (lamp.shape == 'SQUARE'):
53                                 sub.itemR(lamp, "size")
54                         if (lamp.shape == 'RECTANGLE'):
55                                 sub.itemR(lamp, "size", text="Size X")
56                                 sub.itemR(lamp, "size_y")
57                                 
58 class DATA_PT_sunsky(DataButtonsPanel):
59         __idname__ = "DATA_PT_sunsky"
60         __label__ = "Sun/Sky"
61         
62         def poll(self, context):
63                 ob = context.active_object
64                 lamp = context.main.lamps[0]
65                 return (ob.type == 'LAMP' and lamp.type == 'SUN')
66
67         def draw(self, context):
68                 lamp = context.main.lamps[0].sky
69                 layout = self.layout
70
71                 if not lamp:
72                         return
73                 
74                 row = layout.row()
75                 row.itemR(lamp, "sky")
76                 row.itemR(lamp, "atmosphere")
77                 
78                 if lamp.sky or lamp.atmosphere:
79                         layout.itemR(lamp, "atmosphere_turbidity", text="Turbidity")
80                         
81                         split = layout.split()
82                         
83                         col = split.column()
84                         if lamp.sky:
85                                 sub = col.column()
86                                 sub.itemR(lamp, "sky_blend_type", text="Blend Type")
87                                 sub.itemR(lamp, "sky_blend")
88                                 sub.itemR(lamp, "sky_color_space", text="Color Space")
89                                 sub.itemR(lamp, "sky_exposure")
90                                 sub = col.column()
91                                 sub.itemR(lamp, "horizon_brightness", text="Hor Bright")
92                                 sub.itemR(lamp, "spread", text="Hor Spread")
93                                 sub.itemR(lamp, "sun_brightness", text="Sun Bright")
94                                 sub.itemR(lamp, "sun_size")
95                                 sub.itemR(lamp, "backscattered_light", text="Back Light")
96                                 
97                         sub = split.column()
98                         if lamp.atmosphere:
99                                 sub.itemR(lamp, "sun_intensity", text="Sun Intens")
100                                 sub.itemR(lamp, "atmosphere_inscattering", text="Inscattering")
101                                 sub.itemR(lamp, "atmosphere_extinction", text="Extinction")
102                                 sub.itemR(lamp, "atmosphere_distance_factor", text="Distance")
103                                 
104 class DATA_PT_shadow(DataButtonsPanel):
105         __idname__ = "DATA_PT_shadow"
106         __label__ = "Shadow"
107         
108         def poll(self, context):
109                 ob = context.active_object
110                 lamp = context.main.lamps[0]
111                 return (ob.type == 'LAMP' and lamp.type in ('POINT','SUN', 'SPOT', 'AREA'))
112
113         def draw(self, context):
114                 lamp = context.main.lamps[0]
115                 layout = self.layout
116
117                 if not lamp:
118                         return
119                 
120                 layout.itemR(lamp, "shadow_method", expand=True)
121                 
122                 if lamp.shadow_method in ('BUFFER_SHADOW', 'RAY_SHADOW'):
123                 
124                         split = layout.split()
125                         
126                         sub = split.column()
127                         sub.itemR(lamp, "only_shadow")
128                         sub.itemR(lamp, "shadow_layer")
129                         
130                         sub = split.column()
131                         sub.itemR(lamp, "shadow_color")
132                 
133                 if lamp.shadow_method == 'RAY_SHADOW':
134                 
135                         col = layout.column()
136                         col.itemL(text="Sampling:")
137                         col.row().itemR(lamp, "shadow_ray_sampling_method", expand=True)
138                                 
139                         if lamp.type in ('POINT', 'SUN', 'SPOT') and lamp.shadow_ray_sampling_method in ('CONSTANT_QMC', 'ADAPTIVE_QMC'):
140                                 flow = layout.column_flow()
141                                 flow.itemR(lamp, "shadow_soft_size", text="Soft Size")
142                                 flow.itemR(lamp, "shadow_ray_samples", text="Samples")
143                                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
144                                         flow.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
145                                                 
146                         if lamp.type == 'AREA':
147                                 flow = layout.column_flow()
148                                 flow.itemR(lamp, "shadow_ray_samples_x", text="Samples")
149                                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
150                                         flow.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
151                                 if lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
152                                         flow.itemR(lamp, "umbra")
153                                         flow.itemR(lamp, "dither")
154                                         flow.itemR(lamp, "jitter")      
155         
156                 if lamp.shadow_method == 'BUFFER_SHADOW':
157                         col = layout.column()
158                         col.itemL(text="Buffer Type:")
159                         col.row().itemR(lamp, "shadow_buffer_type", expand=True)
160
161                         if lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY'):
162                                 flow = layout.column_flow()
163                                 flow.itemL(text="Sample Buffers:")
164                                 flow.row().itemR(lamp, "shadow_sample_buffers", expand=True)
165                                 flow.itemL(text="Filter Type:")
166                                 flow.row().itemR(lamp, "shadow_filter_type", expand=True)
167                                 flow = layout.column_flow()
168                                 flow.itemR(lamp, "shadow_buffer_size", text="Size")
169                                 flow.itemR(lamp, "shadow_buffer_samples", text="Samples")
170                                 flow.itemR(lamp, "shadow_buffer_bias", text="Bias")
171                                 flow.itemR(lamp, "shadow_buffer_soft", text="Soft")
172                                 
173                         if (lamp.shadow_buffer_type == 'IRREGULAR'):
174                                 row = layout.row()
175                                 row.itemR(lamp, "shadow_buffer_bias", text="Bias")
176                         
177                         row = layout.row()
178                         row.itemR(lamp, "auto_clip_start", text="Autoclip Start")
179                         if not (lamp.auto_clip_start):
180                                 row.itemR(lamp, "shadow_buffer_clip_start", text="Clip Start")
181                         row = layout.row()
182                         row.itemR(lamp, "auto_clip_end", text="Autoclip End")
183                         if not (lamp.auto_clip_end):
184                                 row.itemR(lamp, "shadow_buffer_clip_end", text=" Clip End")
185
186 class DATA_PT_spot(DataButtonsPanel):
187         __idname__ = "DATA_PT_spot"
188         __label__ = "Spot"
189         
190         def poll(self, context):
191                 ob = context.active_object
192                 lamp = context.main.lamps[0]
193                 return (ob.type == 'LAMP' and lamp.type == 'SPOT')
194
195         def draw(self, context):
196                 lamp = context.main.lamps[0]
197                 layout = self.layout
198
199                 if not lamp:
200                         return
201                 
202                 split = layout.split()
203                 
204                 sub = split.column()
205                 sub.itemR(lamp, "square")
206                 sub.itemR(lamp, "spot_size")
207                 sub.itemR(lamp, "spot_blend")
208                 
209                 sub = split.column()
210                 sub.itemR(lamp, "halo")
211                 if lamp.halo:
212                         sub.itemR(lamp, "halo_intensity")
213                         if lamp.shadow_method == 'BUFFER_SHADOW':
214                                 sub.itemR(lamp, "halo_step")
215
216 bpy.types.register(DATA_PT_lamp)
217 bpy.types.register(DATA_PT_shadow)
218 bpy.types.register(DATA_PT_sunsky)
219 bpy.types.register(DATA_PT_spot)