Merging r43501 through r43720 form 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, "name")
119
120             subcol = col.column()
121             subcol.operator_context = 'INVOKE_DEFAULT'
122             subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
123
124             col = row.column()
125             col.label(text="Keyframing Settings:")
126             col.prop(ks, "bl_options")
127
128
129 class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel):
130     bl_label = "Active Keying Set"
131     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
132
133     @classmethod
134     def poll(cls, context):
135         ks = context.scene.keying_sets.active
136         return (ks and ks.is_path_absolute)
137
138     def draw(self, context):
139         layout = self.layout
140
141         scene = context.scene
142         ks = scene.keying_sets.active
143
144         row = layout.row()
145         row.label(text="Paths:")
146
147         row = layout.row()
148
149         col = row.column()
150         col.template_list(ks, "paths", ks.paths, "active_index", rows=2)
151
152         col = row.column(align=True)
153         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
154         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
155
156         ksp = ks.paths.active
157         if ksp:
158             col = layout.column()
159             col.label(text="Target:")
160             col.template_any_ID(ksp, "id", "id_type")
161             col.template_path_builder(ksp, "data_path", ksp.id)
162
163             row = layout.row()
164
165             col = row.column()
166             col.label(text="Array Target:")
167             col.prop(ksp, "use_entire_array")
168             if ksp.use_entire_array is False:
169                 col.prop(ksp, "array_index")
170
171             col = row.column()
172             col.label(text="F-Curve Grouping:")
173             col.prop(ksp, "group_method")
174             if ksp.group_method == 'NAMED':
175                 col.prop(ksp, "group")
176
177             col.prop(ksp, "bl_options")
178
179
180 class SCENE_PT_physics(SceneButtonsPanel, Panel):
181     bl_label = "Gravity"
182     COMPAT_ENGINES = {'BLENDER_RENDER'}
183
184     def draw_header(self, context):
185         self.layout.prop(context.scene, "use_gravity", text="")
186
187     def draw(self, context):
188         layout = self.layout
189
190         scene = context.scene
191
192         layout.active = scene.use_gravity
193
194         layout.prop(scene, "gravity", text="")
195
196
197 class SCENE_PT_simplify(SceneButtonsPanel, Panel):
198     bl_label = "Simplify"
199     COMPAT_ENGINES = {'BLENDER_RENDER'}
200
201     def draw_header(self, context):
202         rd = context.scene.render
203         self.layout.prop(rd, "use_simplify", text="")
204
205     def draw(self, context):
206         layout = self.layout
207
208         rd = context.scene.render
209
210         layout.active = rd.use_simplify
211
212         split = layout.split()
213
214         col = split.column()
215         col.prop(rd, "simplify_subdivision", text="Subdivision")
216         col.prop(rd, "simplify_child_particles", text="Child Particles")
217
218         col.prop(rd, "use_simplify_triangulate")
219
220         col = split.column()
221         col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
222         col.prop(rd, "simplify_ao_sss", text="AO and SSS")
223
224
225 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
226     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
227     _context_path = "scene"
228     _property_type = bpy.types.Scene
229
230 if __name__ == "__main__":  # only for live edit.
231     bpy.utils.register_module(__name__)