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