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