2.5 Buttons:
[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                 layout.row()
25                 layout.itemR(lamp, "type", expand=True)
26                 
27                 layout.split(number=2)
28                 
29                 sub = layout.sub(0)
30                 sub.column()
31                 sub.itemL(text="LAMP DATABLOCKS")
32                 sub.itemR(lamp, "energy")
33                 sub.itemR(lamp, "distance")
34                 sub.itemR(lamp, "color")
35         
36                 sub = layout.sub(1)
37                 
38                 sub.column()
39                 sub.itemL(text="Illumination:")
40                 sub.itemR(lamp, "layer")
41                 sub.itemR(lamp, "negative")
42                 sub.itemR(lamp, "specular")
43                 sub.itemR(lamp, "diffuse")
44                 
45                 if (lamp.type in ('LOCAL', 'SPOT')):
46                         sub.column()
47                         sub.itemR(lamp, "falloff_type")
48                         sub.itemR(lamp, "sphere")
49                         
50                         if (lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED'):
51                                 sub.itemR(lamp, "linear_attenuation")
52                                 sub.itemR(lamp, "quadratic_attenuation")
53                         
54                 if (lamp.type == 'AREA'):
55                         sub.column()
56                         sub.itemR(lamp, "gamma")
57                         sub.itemR(lamp, "shape")
58                         if (lamp.shape == 'SQUARE'):
59                                 sub.itemR(lamp, "size")
60                         if (lamp.shape == 'RECTANGLE'):
61                                 sub.itemR(lamp, "size", text="Size X")
62                                 sub.itemR(lamp, "size_y")
63                                 
64 class DATA_PT_sunsky(DataButtonsPanel):
65         __idname__ = "DATA_PT_sunsky"
66         __label__ = "Sun/Sky"
67         
68         def poll(self, context):
69                 ob = context.active_object
70                 lamp = context.main.lamps[0]
71                 return (ob.type == 'LAMP' and lamp.type == 'SUN')
72
73         def draw(self, context):
74                 lamp = context.main.lamps[0].sky
75                 layout = self.layout
76
77                 if not lamp:
78                         return
79                 
80                 layout.row()
81                 layout.itemR(lamp, "sky")
82                 layout.itemR(lamp, "atmosphere")
83                 
84                 if (lamp.sky or lamp.atmosphere):
85                         layout.row()
86                         layout.itemR(lamp, "atmosphere_turbidity", text="Turbidity")
87                         
88                         layout.split(number=2)
89                         
90                         if (lamp.sky):
91                                 sub = layout.sub(0)
92                                 sub.column()
93                                 sub.itemR(lamp, "horizon_brightness", text="Hor Bright")
94                                 sub.itemR(lamp, "spread", text="Hor Spread")
95                                 sub.itemR(lamp, "sun_brightness", text="Sun Bright")
96                                 sub.itemR(lamp, "sun_size")
97                                 sub.itemR(lamp, "backscattered_light", text="Back Light")
98                                 sub.column()
99                                 sub.itemR(lamp, "sky_blend_type", text="Blend Type")
100                                 sub.itemR(lamp, "sky_blend")
101                                 sub.itemR(lamp, "sky_color_space", text="Color Space")
102                                 sub.itemR(lamp, "sky_exposure")
103                         
104                         if (lamp.atmosphere):
105                                 sub = layout.sub(1)
106                                 sub.column()
107                                 sub.itemR(lamp, "sun_intensity", text="Sun Intens")
108                                 sub.itemR(lamp, "atmosphere_inscattering", text="Inscattering")
109                                 sub.itemR(lamp, "atmosphere_extinction", text="Extinction")
110                                 sub.itemR(lamp, "atmosphere_distance_factor", text="Distance")
111
112 bpy.types.register(DATA_PT_lamp)
113 bpy.types.register(DATA_PT_sunsky)