Merge with 2.5 -r 21619:21756.
[blender.git] / release / ui / buttons_world.py
1
2 import bpy
3
4 class WorldButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "world"
8
9         def poll(self, context):
10                 return (context.world != None)
11
12 class WORLD_PT_preview(WorldButtonsPanel):
13         __label__ = "Preview"
14
15         def draw(self, context):
16                 layout = self.layout
17                 world = context.world
18                 
19                 layout.template_preview(world)
20         
21 class WORLD_PT_context_world(WorldButtonsPanel):
22         __no_header__ = True
23
24         def poll(self, context):
25                 return (context.scene != None)
26
27         def draw(self, context):
28                 layout = self.layout
29                 
30                 scene = context.scene
31                 world = context.world
32                 space = context.space_data
33
34                 split = layout.split(percentage=0.65)
35
36                 if scene:
37                         split.template_ID(scene, "world", new="world.new")
38                 elif world:
39                         split.template_ID(space, "pin_id")
40
41 class WORLD_PT_world(WorldButtonsPanel):
42         __label__ = "World"
43
44         def draw(self, context):
45                 layout = self.layout
46
47                 world = context.world
48
49                 if world:
50                 
51                         row = layout.row()
52                         row.itemR(world, "blend_sky")
53                         row.itemR(world, "paper_sky")
54                         row.itemR(world, "real_sky")
55                         
56                         row = layout.row()
57                         row.column().itemR(world, "horizon_color")
58                         col = row.column()
59                         col.itemR(world, "zenith_color")
60                         col.active = world.blend_sky
61                         row.column().itemR(world, "ambient_color")
62                 
63 class WORLD_PT_color_correction(WorldButtonsPanel):
64         __label__ = "Color Correction"
65
66         def draw(self, context):
67                 layout = self.layout
68                 world = context.world
69
70                 row = layout.row()
71                 row.itemR(world, "exposure")
72                 row.itemR(world, "range")
73         
74 class WORLD_PT_mist(WorldButtonsPanel):
75         __label__ = "Mist"
76
77         def draw_header(self, context):
78                 layout = self.layout
79                 world = context.world
80
81                 layout.itemR(world.mist, "enabled", text="")
82
83         def draw(self, context):
84                 layout = self.layout
85                 world = context.world
86
87                 layout.active = world.mist.enabled
88
89                 flow = layout.column_flow()
90                 flow.itemR(world.mist, "start")
91                 flow.itemR(world.mist, "depth")
92                 flow.itemR(world.mist, "height")
93                 flow.itemR(world.mist, "intensity")
94                 col = layout.column()
95                 col.itemL(text="Fallof:")
96                 col.row().itemR(world.mist, "falloff", expand=True)
97                 
98 class WORLD_PT_stars(WorldButtonsPanel):
99         __label__ = "Stars"
100
101         def draw_header(self, context):
102                 layout = self.layout
103                 world = context.world
104
105                 layout.itemR(world.stars, "enabled", text="")
106
107         def draw(self, context):
108                 layout = self.layout
109                 world = context.world
110
111                 layout.active = world.stars.enabled
112
113                 flow = layout.column_flow()
114                 flow.itemR(world.stars, "size")
115                 flow.itemR(world.stars, "min_distance", text="Min. Dist")
116                 flow.itemR(world.stars, "average_separation", text="Separation")
117                 flow.itemR(world.stars, "color_randomization", text="Random")
118                 
119 class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
120         __label__ = "Ambient Occlusion"
121
122         def draw_header(self, context):
123                 layout = self.layout
124                 world = context.world
125
126                 layout.itemR(world.ambient_occlusion, "enabled", text="")
127
128         def draw(self, context):
129                 layout = self.layout
130                 ao = context.world.ambient_occlusion
131                 
132                 layout.active = ao.enabled
133                 
134                 layout.itemR(ao, "gather_method", expand=True)
135                 
136                 if ao.gather_method == 'RAYTRACE':
137                         split = layout.split()
138                         
139                         col = split.column()
140                         col.itemR(ao, "samples")
141                         col.itemR(ao, "distance")
142                         
143                         col = split.column()
144                         col.itemR(ao, "falloff")
145                         colsub = col.column()
146                         colsub.active = ao.falloff
147                         colsub.itemR(ao, "strength")
148                         
149                         layout.itemR(ao, "sample_method")
150                         if ao.sample_method == 'ADAPTIVE_QMC':
151                                 row = layout.row()
152                                 row.itemR(ao, "threshold")
153                                 row.itemR(ao, "adapt_to_speed")
154                                 
155                         if ao.sample_method == 'CONSTANT_JITTERED':
156                                 row = layout.row()
157                                 row.itemR(ao, "bias")
158                                                 
159                 if ao.gather_method == 'APPROXIMATE':
160                         split = layout.split()
161                         
162                         col = split.column()
163                         col.itemR(ao, "passes")
164                         col.itemR(ao, "error_tolerance", text="Error")
165                         col.itemR(ao, "correction")
166                         
167                         col = split.column() 
168                         col.itemR(ao, "falloff")
169                         colsub = col.column()
170                         colsub.active = ao.falloff
171                         colsub.itemR(ao, "strength")
172                         col.itemR(ao, "pixel_cache")
173
174                 col = layout.column()
175                 col.row().itemR(ao, "blend_mode", expand=True)
176                 col.row().itemR(ao, "color", expand=True)
177                 col.itemR(ao, "energy")
178
179 bpy.types.register(WORLD_PT_context_world)      
180 bpy.types.register(WORLD_PT_preview)
181 bpy.types.register(WORLD_PT_world)
182 bpy.types.register(WORLD_PT_ambient_occlusion)
183 bpy.types.register(WORLD_PT_mist)
184 bpy.types.register(WORLD_PT_stars)
185 bpy.types.register(WORLD_PT_color_correction)