5d822cef9afe61a9426ff5b0485537b3392b04c5
[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, UIList
22 from rna_prop_ui import PropertyPanel
23
24 from bl_ui.properties_physics_common import (
25     point_cache_ui,
26     effector_weights_ui,
27     )
28
29
30 class SCENE_UL_keying_set_paths(UIList):
31     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
32         # assert(isinstance(item, bpy.types.KeyingSetPath)
33         kspath = item
34         icon = layout.enum_item_icon(kspath, "id_type", kspath.id_type)
35         if self.layout_type in {'DEFAULT', 'COMPACT'}:
36             # Do not make this one editable in uiList for now...
37             layout.label(text=kspath.data_path, translate=False, icon_value=icon)
38         elif self.layout_type in {'GRID'}:
39             layout.alignment = 'CENTER'
40             layout.label(text="", icon_value=icon)
41
42
43 class SceneButtonsPanel():
44     bl_space_type = 'PROPERTIES'
45     bl_region_type = 'WINDOW'
46     bl_context = "scene"
47
48     @classmethod
49     def poll(cls, context):
50         rd = context.scene.render
51         return context.scene and (rd.engine in cls.COMPAT_ENGINES)
52
53
54 class SCENE_PT_scene(SceneButtonsPanel, Panel):
55     bl_label = "Scene"
56     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
57
58     def draw(self, context):
59         layout = self.layout
60
61         scene = context.scene
62
63         layout.prop(scene, "camera")
64         layout.prop(scene, "background_set", text="Background")
65         if context.scene.render.engine != 'BLENDER_GAME':
66             layout.prop(scene, "active_clip", text="Active Clip")
67
68
69 class SCENE_PT_unit(SceneButtonsPanel, Panel):
70     bl_label = "Units"
71     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
72
73     def draw(self, context):
74         layout = self.layout
75
76         unit = context.scene.unit_settings
77
78         col = layout.column()
79         col.row().prop(unit, "system", expand=True)
80         col.row().prop(unit, "system_rotation", expand=True)
81
82         if unit.system != 'NONE':
83             row = layout.row()
84             row.prop(unit, "scale_length", text="Scale")
85             row.prop(unit, "use_separate")
86
87
88 class SCENE_PT_keying_sets(SceneButtonsPanel, Panel):
89     bl_label = "Keying Sets"
90     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
91
92     def draw(self, context):
93         layout = self.layout
94
95         scene = context.scene
96         row = layout.row()
97
98         col = row.column()
99         col.template_list("UI_UL_list", "keying_sets", scene, "keying_sets", scene.keying_sets, "active_index", rows=1)
100
101         col = row.column(align=True)
102         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
103         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
104
105         ks = scene.keying_sets.active
106         if ks and ks.is_path_absolute:
107             row = layout.row()
108
109             col = row.column()
110             col.prop(ks, "bl_description")
111
112             subcol = col.column()
113             subcol.operator_context = 'INVOKE_DEFAULT'
114             subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
115
116             col = row.column()
117             col.label(text="Keyframing Settings:")
118             col.prop(ks, "use_insertkey_needed", text="Needed")
119             col.prop(ks, "use_insertkey_visual", text="Visual")
120             col.prop(ks, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
121
122
123 class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel):
124     bl_label = "Active Keying Set"
125     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
126
127     @classmethod
128     def poll(cls, context):
129         ks = context.scene.keying_sets.active
130         return (ks and ks.is_path_absolute)
131
132     def draw(self, context):
133         layout = self.layout
134
135         scene = context.scene
136         ks = scene.keying_sets.active
137
138         row = layout.row()
139         row.label(text="Paths:")
140
141         row = layout.row()
142
143         col = row.column()
144         col.template_list("SCENE_UL_keying_set_paths", "", ks, "paths", ks.paths, "active_index", rows=1)
145
146         col = row.column(align=True)
147         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
148         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
149
150         ksp = ks.paths.active
151         if ksp:
152             col = layout.column()
153             col.label(text="Target:")
154             col.template_any_ID(ksp, "id", "id_type")
155             col.template_path_builder(ksp, "data_path", ksp.id)
156
157             row = col.row(align=True)
158             row.label(text="Array Target:")
159             row.prop(ksp, "use_entire_array", text="All Items")
160             if ksp.use_entire_array:
161                 row.label(text=" ")  # padding
162             else:
163                 row.prop(ksp, "array_index", text="Index")
164
165             layout.separator()
166
167             row = layout.row()
168             col = row.column()
169             col.label(text="F-Curve Grouping:")
170             col.prop(ksp, "group_method", text="")
171             if ksp.group_method == 'NAMED':
172                 col.prop(ksp, "group")
173
174             col = row.column()
175             col.label(text="Keyframing Settings:")
176             col.prop(ksp, "use_insertkey_needed", text="Needed")
177             col.prop(ksp, "use_insertkey_visual", text="Visual")
178             col.prop(ksp, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
179
180
181 class SCENE_PT_color_management(SceneButtonsPanel, Panel):
182     bl_label = "Color Management"
183     bl_options = {'DEFAULT_CLOSED'}
184     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
185
186     def draw(self, context):
187         layout = self.layout
188
189         scene = context.scene
190
191         col = layout.column()
192         col.label(text="Display:")
193         col.prop(scene.display_settings, "display_device")
194
195         col = layout.column()
196         col.separator()
197         col.label(text="Render:")
198         col.template_colormanaged_view_settings(scene, "view_settings")
199
200         col = layout.column()
201         col.separator()
202         col.label(text="Sequencer:")
203         col.prop(scene.sequencer_colorspace_settings, "name")
204
205
206 class SCENE_PT_audio(SceneButtonsPanel, Panel):
207     bl_label = "Audio"
208     bl_options = {'DEFAULT_CLOSED'}
209     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
210
211     def draw(self, context):
212         layout = self.layout
213
214         scene = context.scene
215         rd = context.scene.render
216         ffmpeg = rd.ffmpeg
217
218         layout.prop(scene, "audio_volume")
219         layout.operator("sound.bake_animation")
220
221         split = layout.split()
222
223         col = split.column()
224         col.label("Listener:")
225         col.prop(scene, "audio_distance_model", text="")
226         col.prop(scene, "audio_doppler_speed", text="Speed")
227         col.prop(scene, "audio_doppler_factor", text="Doppler")
228
229         col = split.column()
230         col.label("Format:")
231         col.prop(ffmpeg, "audio_channels", text="")
232         col.prop(ffmpeg, "audio_mixrate", text="Rate")
233
234
235 class SCENE_PT_physics(SceneButtonsPanel, Panel):
236     bl_label = "Gravity"
237     COMPAT_ENGINES = {'BLENDER_RENDER'}
238
239     def draw_header(self, context):
240         self.layout.prop(context.scene, "use_gravity", text="")
241
242     def draw(self, context):
243         layout = self.layout
244
245         scene = context.scene
246
247         layout.active = scene.use_gravity
248
249         layout.prop(scene, "gravity", text="")
250
251
252 class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
253     bl_label = "Rigid Body World"
254     COMPAT_ENGINES = {'BLENDER_RENDER'}
255
256     @classmethod
257     def poll(cls, context):
258         scene = context.scene
259         rd = scene.render
260         return scene and (rd.engine in cls.COMPAT_ENGINES)
261
262     def draw_header(self, context):
263         scene = context.scene
264         rbw = scene.rigidbody_world
265         if rbw is not None:
266             self.layout.prop(rbw, "enabled", text="")
267
268     def draw(self, context):
269         layout = self.layout
270
271         scene = context.scene
272
273         rbw = scene.rigidbody_world
274
275         if rbw is None:
276             layout.operator("rigidbody.world_add")
277         else:
278             layout.operator("rigidbody.world_remove")
279
280             col = layout.column()
281             col.active = rbw.enabled
282
283             col = col.column()
284             col.prop(rbw, "group")
285             col.prop(rbw, "constraints")
286
287             split = col.split()
288
289             col = split.column()
290             col.prop(rbw, "time_scale", text="Speed")
291             col.prop(rbw, "use_split_impulse")
292
293             col = split.column()
294             col.prop(rbw, "steps_per_second", text="Steps Per Second")
295             col.prop(rbw, "solver_iterations", text="Solver Iterations")
296
297
298 class SCENE_PT_rigid_body_cache(SceneButtonsPanel, Panel):
299     bl_label = "Rigid Body Cache"
300     bl_options = {'DEFAULT_CLOSED'}
301     COMPAT_ENGINES = {'BLENDER_RENDER'}
302
303     @classmethod
304     def poll(cls, context):
305         rd = context.scene.render
306         scene = context.scene
307         return scene and scene.rigidbody_world and (rd.engine in cls.COMPAT_ENGINES)
308
309     def draw(self, context):
310         scene = context.scene
311         rbw = scene.rigidbody_world
312
313         point_cache_ui(self, context, rbw.point_cache, rbw.point_cache.is_baked is False and rbw.enabled, 'RIGID_BODY')
314
315
316 class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel):
317     bl_label = "Rigid Body Field Weights"
318     bl_options = {'DEFAULT_CLOSED'}
319     COMPAT_ENGINES = {'BLENDER_RENDER'}
320
321     @classmethod
322     def poll(cls, context):
323         rd = context.scene.render
324         scene = context.scene
325         return scene and scene.rigidbody_world and (rd.engine in cls.COMPAT_ENGINES)
326
327     def draw(self, context):
328         scene = context.scene
329         rbw = scene.rigidbody_world
330
331         effector_weights_ui(self, context, rbw.effector_weights, 'RIGID_BODY')
332
333
334 class SCENE_PT_simplify(SceneButtonsPanel, Panel):
335     bl_label = "Simplify"
336     COMPAT_ENGINES = {'BLENDER_RENDER'}
337
338     def draw_header(self, context):
339         rd = context.scene.render
340         self.layout.prop(rd, "use_simplify", text="")
341
342     def draw(self, context):
343         layout = self.layout
344
345         rd = context.scene.render
346
347         layout.active = rd.use_simplify
348
349         split = layout.split()
350
351         col = split.column()
352         col.prop(rd, "simplify_subdivision", text="Subdivision")
353         col.prop(rd, "simplify_child_particles", text="Child Particles")
354
355         col.prop(rd, "use_simplify_triangulate")
356
357         col = split.column()
358         col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
359         col.prop(rd, "simplify_ao_sss", text="AO and SSS")
360
361
362 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
363     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
364     _context_path = "scene"
365     _property_type = bpy.types.Scene
366
367 if __name__ == "__main__":  # only for live edit.
368     bpy.utils.register_module(__name__)