b7218e4ba47ccde8cf6af7461b12a9ec840c47c6
[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
58         layout.prop(scene, "audio_volume")
59         layout.operator("sound.bake_animation")
60
61         split = layout.split()
62
63         col = split.column()
64         col.label("Listener:")
65         col.prop(scene, "audio_distance_model", text="")
66         col.prop(scene, "audio_doppler_speed", text="Speed")
67         col.prop(scene, "audio_doppler_factor", text="Doppler")
68
69         col = split.column()
70         col.label("Format:")
71         col.prop(rd, "ffmpeg_audio_channels", text="")
72         col.prop(rd, "ffmpeg_audio_mixrate", text="Rate")
73
74         layout.operator("sound.mixdown")
75
76
77 class SCENE_PT_unit(SceneButtonsPanel, Panel):
78     bl_label = "Units"
79     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
80
81     def draw(self, context):
82         layout = self.layout
83         unit = context.scene.unit_settings
84
85         col = layout.column()
86         col.row().prop(unit, "system", expand=True)
87         col.row().prop(unit, "system_rotation", expand=True)
88
89         row = layout.row()
90         row.active = (unit.system != 'NONE')
91         row.prop(unit, "scale_length", text="Scale")
92         row.prop(unit, "use_separate")
93
94
95 class SCENE_PT_keying_sets(SceneButtonsPanel, Panel):
96     bl_label = "Keying Sets"
97     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
98
99     def draw(self, context):
100         layout = self.layout
101
102         scene = context.scene
103         row = layout.row()
104
105         col = row.column()
106         col.template_list(scene, "keying_sets", scene.keying_sets, "active_index", rows=2)
107
108         col = row.column(align=True)
109         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
110         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
111
112         ks = scene.keying_sets.active
113         if ks and ks.is_path_absolute:
114             row = layout.row()
115
116             col = row.column()
117             col.prop(ks, "name")
118
119             subcol = col.column()
120             subcol.operator_context = 'INVOKE_DEFAULT'
121             subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
122
123             col = row.column()
124             col.label(text="Keyframing Settings:")
125             col.prop(ks, "bl_options")
126
127
128 class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel):
129     bl_label = "Active Keying Set"
130     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
131
132     @classmethod
133     def poll(cls, context):
134         ks = context.scene.keying_sets.active
135         return (ks and ks.is_path_absolute)
136
137     def draw(self, context):
138         layout = self.layout
139
140         scene = context.scene
141         ks = scene.keying_sets.active
142
143         row = layout.row()
144         row.label(text="Paths:")
145
146         row = layout.row()
147
148         col = row.column()
149         col.template_list(ks, "paths", ks.paths, "active_index", rows=2)
150
151         col = row.column(align=True)
152         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
153         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
154
155         ksp = ks.paths.active
156         if ksp:
157             col = layout.column()
158             col.label(text="Target:")
159             col.template_any_ID(ksp, "id", "id_type")
160             col.template_path_builder(ksp, "data_path", ksp.id)
161
162             row = layout.row()
163
164             col = row.column()
165             col.label(text="Array Target:")
166             col.prop(ksp, "use_entire_array")
167             if ksp.use_entire_array is False:
168                 col.prop(ksp, "array_index")
169
170             col = row.column()
171             col.label(text="F-Curve Grouping:")
172             col.prop(ksp, "group_method")
173             if ksp.group_method == 'NAMED':
174                 col.prop(ksp, "group")
175
176             col.prop(ksp, "bl_options")
177
178
179 class SCENE_PT_physics(SceneButtonsPanel, Panel):
180     bl_label = "Gravity"
181     COMPAT_ENGINES = {'BLENDER_RENDER'}
182
183     def draw_header(self, context):
184         self.layout.prop(context.scene, "use_gravity", text="")
185
186     def draw(self, context):
187         layout = self.layout
188
189         scene = context.scene
190
191         layout.active = scene.use_gravity
192
193         layout.prop(scene, "gravity", text="")
194
195
196 class SCENE_PT_simplify(SceneButtonsPanel, Panel):
197     bl_label = "Simplify"
198     COMPAT_ENGINES = {'BLENDER_RENDER'}
199
200     def draw_header(self, context):
201         rd = context.scene.render
202         self.layout.prop(rd, "use_simplify", text="")
203
204     def draw(self, context):
205         layout = self.layout
206
207         rd = context.scene.render
208
209         layout.active = rd.use_simplify
210
211         split = layout.split()
212
213         col = split.column()
214         col.prop(rd, "simplify_subdivision", text="Subdivision")
215         col.prop(rd, "simplify_child_particles", text="Child Particles")
216
217         col.prop(rd, "use_simplify_triangulate")
218
219         col = split.column()
220         col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
221         col.prop(rd, "simplify_ao_sss", text="AO and SSS")
222
223
224 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
225     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
226     _context_path = "scene"
227     _property_type = bpy.types.Scene
228
229 if __name__ == "__main__":  # only for live edit.
230     bpy.utils.register_module(__name__)