* projection paint options in the toolbar
[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                 rd = context.scene.render_data
11                 return (context.world != None) and (not rd.use_game_engine)
12
13 class WORLD_PT_preview(WorldButtonsPanel):
14         __label__ = "Preview"
15
16         def draw(self, context):
17                 layout = self.layout
18                 world = context.world
19                 
20                 layout.template_preview(world)
21         
22 class WORLD_PT_context_world(WorldButtonsPanel):
23         __show_header__ = False
24
25         def poll(self, context):
26                 rd = context.scene.render_data
27                 return (context.scene != None) and (not rd.use_game_engine)
28
29         def draw(self, context):
30                 layout = self.layout
31                 
32                 scene = context.scene
33                 world = context.world
34                 space = context.space_data
35
36                 split = layout.split(percentage=0.65)
37
38                 if scene:
39                         split.template_ID(scene, "world", new="world.new")
40                 elif world:
41                         split.template_ID(space, "pin_id")
42
43 class WORLD_PT_world(WorldButtonsPanel):
44         __label__ = "World"
45
46         def draw(self, context):
47                 layout = self.layout
48
49                 world = context.world
50
51                 if world:
52                 
53                         row = layout.row()
54                         row.itemR(world, "blend_sky")
55                         row.itemR(world, "paper_sky")
56                         row.itemR(world, "real_sky")
57                         
58                         row = layout.row()
59                         row.column().itemR(world, "horizon_color")
60                         col = row.column()
61                         col.itemR(world, "zenith_color")
62                         col.active = world.blend_sky
63                         row.column().itemR(world, "ambient_color")
64                 
65 class WORLD_PT_mist(WorldButtonsPanel):
66         __label__ = "Mist"
67
68         def draw_header(self, context):
69                 layout = self.layout
70                 world = context.world
71
72                 layout.itemR(world.mist, "enabled", text="")
73
74         def draw(self, context):
75                 layout = self.layout
76                 world = context.world
77
78                 layout.active = world.mist.enabled
79
80                 flow = layout.column_flow()
81                 flow.itemR(world.mist, "start")
82                 flow.itemR(world.mist, "depth")
83                 flow.itemR(world.mist, "height")
84                 flow.itemR(world.mist, "intensity")
85
86                 layout.itemR(world.mist, "falloff")
87                 
88 class WORLD_PT_stars(WorldButtonsPanel):
89         __label__ = "Stars"
90
91         def draw_header(self, context):
92                 layout = self.layout
93                 world = context.world
94
95                 layout.itemR(world.stars, "enabled", text="")
96
97         def draw(self, context):
98                 layout = self.layout
99                 world = context.world
100
101                 layout.active = world.stars.enabled
102
103                 flow = layout.column_flow()
104                 flow.itemR(world.stars, "size")
105                 flow.itemR(world.stars, "color_randomization", text="Colors")
106                 flow.itemR(world.stars, "min_distance", text="Min. Dist")
107                 flow.itemR(world.stars, "average_separation", text="Separation")
108                 
109 class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
110         __label__ = "Ambient Occlusion"
111
112         def draw_header(self, context):
113                 layout = self.layout
114                 world = context.world
115
116                 layout.itemR(world.ambient_occlusion, "enabled", text="")
117
118         def draw(self, context):
119                 layout = self.layout
120                 ao = context.world.ambient_occlusion
121                 
122                 layout.active = ao.enabled
123                 
124                 layout.itemR(ao, "gather_method", expand=True)
125
126                 split = layout.split()
127                 
128                 col = split.column()
129                 col.itemL(text="Attenuation:")
130                 col.itemR(ao, "distance")
131                 col.itemR(ao, "falloff")
132                 sub = col.row()
133                 sub.active = ao.falloff
134                 sub.itemR(ao, "falloff_strength", text="Strength")
135         
136                 if ao.gather_method == 'RAYTRACE':
137                         col = split.column()
138                         
139                         col.itemL(text="Sampling:")
140                         col.itemR(ao, "sample_method", text="")
141
142                         sub = col.column(align=True)
143                         sub.itemR(ao, "samples")
144
145                         if ao.sample_method == 'ADAPTIVE_QMC':
146                                 sub.itemR(ao, "threshold")
147                                 sub.itemR(ao, "adapt_to_speed")
148                         elif ao.sample_method == 'CONSTANT_JITTERED':
149                                 sub.itemR(ao, "bias")
150                                                 
151                 if ao.gather_method == 'APPROXIMATE':
152                         col = split.column()
153                         
154                         col.itemL(text="Sampling:")
155                         col.itemR(ao, "error_tolerance", text="Error")
156                         col.itemR(ao, "pixel_cache")
157                         col.itemR(ao, "correction")
158                         
159                 col = layout.column(align=True)
160                 col.itemL(text="Influence:")
161                 row = col.row()
162                 row.itemR(ao, "blend_mode", text="")
163                 row.itemR(ao, "color", text="")
164                 row.itemR(ao, "energy", text="")
165
166 bpy.types.register(WORLD_PT_context_world)      
167 bpy.types.register(WORLD_PT_preview)
168 bpy.types.register(WORLD_PT_world)
169 bpy.types.register(WORLD_PT_ambient_occlusion)
170 bpy.types.register(WORLD_PT_mist)
171 bpy.types.register(WORLD_PT_stars)
172