Merging r44227 through r45619 from trunk into soc-2011-tomato
[blender.git] / release / scripts / startup / bl_ui / properties_scene.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Panel
22 from rna_prop_ui import PropertyPanel
23
24
25 class SceneButtonsPanel():
26     bl_space_type = 'PROPERTIES'
27     bl_region_type = 'WINDOW'
28     bl_context = "scene"
29
30     @classmethod
31     def poll(cls, context):
32         rd = context.scene.render
33         return context.scene and (rd.engine in cls.COMPAT_ENGINES)
34
35
36 class SCENE_PT_scene(SceneButtonsPanel, Panel):
37     bl_label = "Scene"
38     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
39
40     def draw(self, context):
41         layout = self.layout
42         scene = context.scene
43
44         layout.prop(scene, "camera")
45         layout.prop(scene, "background_set", text="Background")
46         layout.prop(scene, "active_clip", text="Active Clip")
47
48
49 class SCENE_PT_audio(SceneButtonsPanel, Panel):
50     bl_label = "Audio"
51     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
52
53     def draw(self, context):
54         layout = self.layout
55         scene = context.scene
56         rd = context.scene.render
57         ffmpeg = rd.ffmpeg
58
59         layout.prop(scene, "audio_volume")
60         layout.operator("sound.bake_animation")
61
62         split = layout.split()
63
64         col = split.column()
65         col.label("Listener:")
66         col.prop(scene, "audio_distance_model", text="")
67         col.prop(scene, "audio_doppler_speed", text="Speed")
68         col.prop(scene, "audio_doppler_factor", text="Doppler")
69
70         col = split.column()
71         col.label("Format:")
72         col.prop(ffmpeg, "audio_channels", text="")
73         col.prop(ffmpeg, "audio_mixrate", text="Rate")
74
75         layout.operator("sound.mixdown")
76
77
78 class SCENE_PT_unit(SceneButtonsPanel, Panel):
79     bl_label = "Units"
80     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
81
82     def draw(self, context):
83         layout = self.layout
84         unit = context.scene.unit_settings
85
86         col = layout.column()
87         col.row().prop(unit, "system", expand=True)
88         col.row().prop(unit, "system_rotation", expand=True)
89
90         row = layout.row()
91         row.active = (unit.system != 'NONE')
92         row.prop(unit, "scale_length", text="Scale")
93         row.prop(unit, "use_separate")
94
95
96 class SCENE_PT_keying_sets(SceneButtonsPanel, Panel):
97     bl_label = "Keying Sets"
98     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
99
100     def draw(self, context):
101         layout = self.layout
102
103         scene = context.scene
104         row = layout.row()
105
106         col = row.column()
107         col.template_list(scene, "keying_sets", scene.keying_sets, "active_index", rows=2)
108
109         col = row.column(align=True)
110         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
111         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
112
113         ks = scene.keying_sets.active
114         if ks and ks.is_path_absolute:
115             row = layout.row()
116
117             col = row.column()
118             col.prop(ks, "bl_label")
119             col.prop(ks, "bl_description")
120
121             subcol = col.column()
122             subcol.operator_context = 'INVOKE_DEFAULT'
123             subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
124
125             col = row.column()
126             col.label(text="Keyframing Settings:")
127             col.prop(ks, "bl_options")
128
129
130 class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel):
131     bl_label = "Active Keying Set"
132     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
133
134     @classmethod
135     def poll(cls, context):
136         ks = context.scene.keying_sets.active
137         return (ks and ks.is_path_absolute)
138
139     def draw(self, context):
140         layout = self.layout
141
142         scene = context.scene
143         ks = scene.keying_sets.active
144
145         row = layout.row()
146         row.label(text="Paths:")
147
148         row = layout.row()
149
150         col = row.column()
151         col.template_list(ks, "paths", ks.paths, "active_index", rows=2)
152
153         col = row.column(align=True)
154         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
155         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
156
157         ksp = ks.paths.active
158         if ksp:
159             col = layout.column()
160             col.label(text="Target:")
161             col.template_any_ID(ksp, "id", "id_type")
162             col.template_path_builder(ksp, "data_path", ksp.id)
163
164             row = layout.row()
165
166             col = row.column()
167             col.label(text="Array Target:")
168             col.prop(ksp, "use_entire_array")
169             if ksp.use_entire_array is False:
170                 col.prop(ksp, "array_index")
171
172             col = row.column()
173             col.label(text="F-Curve Grouping:")
174             col.prop(ksp, "group_method")
175             if ksp.group_method == 'NAMED':
176                 col.prop(ksp, "group")
177
178             col.prop(ksp, "bl_options")
179
180
181 class SCENE_PT_physics(SceneButtonsPanel, Panel):
182     bl_label = "Gravity"
183     COMPAT_ENGINES = {'BLENDER_RENDER'}
184
185     def draw_header(self, context):
186         self.layout.prop(context.scene, "use_gravity", text="")
187
188     def draw(self, context):
189         layout = self.layout
190
191         scene = context.scene
192
193         layout.active = scene.use_gravity
194
195         layout.prop(scene, "gravity", text="")
196
197
198 class SCENE_PT_simplify(SceneButtonsPanel, Panel):
199     bl_label = "Simplify"
200     COMPAT_ENGINES = {'BLENDER_RENDER'}
201
202     def draw_header(self, context):
203         rd = context.scene.render
204         self.layout.prop(rd, "use_simplify", text="")
205
206     def draw(self, context):
207         layout = self.layout
208
209         rd = context.scene.render
210
211         layout.active = rd.use_simplify
212
213         split = layout.split()
214
215         col = split.column()
216         col.prop(rd, "simplify_subdivision", text="Subdivision")
217         col.prop(rd, "simplify_child_particles", text="Child Particles")
218
219         col.prop(rd, "use_simplify_triangulate")
220
221         col = split.column()
222         col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
223         col.prop(rd, "simplify_ao_sss", text="AO and SSS")
224
225
226 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
227     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
228     _context_path = "scene"
229     _property_type = bpy.types.Scene
230
231 if __name__ == "__main__":  # only for live edit.
232     bpy.utils.register_module(__name__)