Fix uilists showing data names translated (reported on bf-translations ML by Satoshi...
[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 class SCENE_UL_keying_set_paths(UIList):
30     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
31         # assert(isinstance(item, bpy.types.KeyingSetPath)
32         kspath = item
33         icon = layout.enum_item_icon(kspath, "id_type", kspath.id_type)
34         if self.layout_type in {'DEFAULT', 'COMPACT'}:
35             layout.label(text=kspath.data_path, translate=False, icon_value=icon)
36         elif self.layout_type in {'GRID'}:
37             layout.alignment = 'CENTER'
38             layout.label(text="", icon_value=icon)
39
40
41 class SceneButtonsPanel():
42     bl_space_type = 'PROPERTIES'
43     bl_region_type = 'WINDOW'
44     bl_context = "scene"
45
46     @classmethod
47     def poll(cls, context):
48         rd = context.scene.render
49         return context.scene and (rd.engine in cls.COMPAT_ENGINES)
50
51
52 class SCENE_PT_scene(SceneButtonsPanel, Panel):
53     bl_label = "Scene"
54     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
55
56     def draw(self, context):
57         layout = self.layout
58
59         scene = context.scene
60
61         layout.prop(scene, "camera")
62         layout.prop(scene, "background_set", text="Background")
63         layout.prop(scene, "active_clip", text="Active Clip")
64
65
66 class SCENE_PT_unit(SceneButtonsPanel, Panel):
67     bl_label = "Units"
68     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
69
70     def draw(self, context):
71         layout = self.layout
72
73         unit = context.scene.unit_settings
74
75         col = layout.column()
76         col.row().prop(unit, "system", expand=True)
77         col.row().prop(unit, "system_rotation", expand=True)
78
79         row = layout.row()
80         row.active = (unit.system != 'NONE')
81         row.prop(unit, "scale_length", text="Scale")
82         row.prop(unit, "use_separate")
83
84
85 class SCENE_PT_keying_sets(SceneButtonsPanel, Panel):
86     bl_label = "Keying Sets"
87     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
88
89     def draw(self, context):
90         layout = self.layout
91
92         scene = context.scene
93         row = layout.row()
94
95         col = row.column()
96         col.template_list("UI_UL_list", "", scene, "keying_sets", scene.keying_sets, "active_index", rows=2)
97
98         col = row.column(align=True)
99         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
100         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
101
102         ks = scene.keying_sets.active
103         if ks and ks.is_path_absolute:
104             row = layout.row()
105
106             col = row.column()
107             col.prop(ks, "bl_label")
108             col.prop(ks, "bl_description")
109
110             subcol = col.column()
111             subcol.operator_context = 'INVOKE_DEFAULT'
112             subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
113
114             col = row.column(align=True)
115             col.label(text="Keyframing Settings:")
116             col.prop(ks, "bl_options")
117
118
119 class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel):
120     bl_label = "Active Keying Set"
121     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
122
123     @classmethod
124     def poll(cls, context):
125         ks = context.scene.keying_sets.active
126         return (ks and ks.is_path_absolute)
127
128     def draw(self, context):
129         layout = self.layout
130
131         scene = context.scene
132         ks = scene.keying_sets.active
133
134         row = layout.row()
135         row.label(text="Paths:")
136
137         row = layout.row()
138
139         col = row.column()
140         col.template_list("SCENE_UL_keying_set_paths", "", ks, "paths", ks.paths, "active_index", rows=2)
141
142         col = row.column(align=True)
143         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
144         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
145
146         ksp = ks.paths.active
147         if ksp:
148             col = layout.column()
149             col.label(text="Target:")
150             col.template_any_ID(ksp, "id", "id_type")
151             col.template_path_builder(ksp, "data_path", ksp.id)
152
153             row = col.row(align=True)
154             row.label(text="Array Target:")
155             row.prop(ksp, "use_entire_array", text="All Items")
156             if ksp.use_entire_array:
157                 row.label(text=" ")  # padding
158             else:
159                 row.prop(ksp, "array_index", text="Index")
160
161             layout.separator()
162
163             row = layout.row()
164             col = row.column()
165             col.label(text="F-Curve Grouping:")
166             col.prop(ksp, "group_method", text="")
167             if ksp.group_method == 'NAMED':
168                 col.prop(ksp, "group")
169
170             col = row.column(align=True)
171             col.label(text="Keyframing Settings:")
172             col.prop(ksp, "bl_options")
173
174
175 class SCENE_PT_color_management(SceneButtonsPanel, Panel):
176     bl_label = "Color Management"
177     bl_options = {'DEFAULT_CLOSED'}
178     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
179
180     def draw(self, context):
181         layout = self.layout
182
183         scene = context.scene
184         rd = scene.render
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         layout.operator("sound.mixdown")
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, "num_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__)