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