remove type checks on drawing uiList's,
[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
25 class SCENE_UL_keying_set_paths(UIList):
26     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
27         # assert(isinstance(item, bpy.types.KeyingSetPath)
28         kspath = item
29         icon = layout.enum_item_icon(kspath, "id_type", kspath.id_type)
30         if self.layout_type in {'DEFAULT', 'COMPACT'}:
31             layout.label(kspath.data_path, icon_value=icon)
32         elif self.layout_type in {'GRID'}:
33             layout.alignment = 'CENTER'
34             layout.label("", icon_value=icon)
35
36
37 class SceneButtonsPanel():
38     bl_space_type = 'PROPERTIES'
39     bl_region_type = 'WINDOW'
40     bl_context = "scene"
41
42     @classmethod
43     def poll(cls, context):
44         rd = context.scene.render
45         return context.scene and (rd.engine in cls.COMPAT_ENGINES)
46
47
48 class SCENE_PT_scene(SceneButtonsPanel, Panel):
49     bl_label = "Scene"
50     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
51
52     def draw(self, context):
53         layout = self.layout
54
55         scene = context.scene
56
57         layout.prop(scene, "camera")
58         layout.prop(scene, "background_set", text="Background")
59         layout.prop(scene, "active_clip", text="Active Clip")
60
61
62 class SCENE_PT_audio(SceneButtonsPanel, Panel):
63     bl_label = "Audio"
64     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
65
66     def draw(self, context):
67         layout = self.layout
68
69         scene = context.scene
70         rd = context.scene.render
71         ffmpeg = rd.ffmpeg
72
73         layout.prop(scene, "audio_volume")
74         layout.operator("sound.bake_animation")
75
76         split = layout.split()
77
78         col = split.column()
79         col.label("Listener:")
80         col.prop(scene, "audio_distance_model", text="")
81         col.prop(scene, "audio_doppler_speed", text="Speed")
82         col.prop(scene, "audio_doppler_factor", text="Doppler")
83
84         col = split.column()
85         col.label("Format:")
86         col.prop(ffmpeg, "audio_channels", text="")
87         col.prop(ffmpeg, "audio_mixrate", text="Rate")
88
89         layout.operator("sound.mixdown")
90
91
92 class SCENE_PT_unit(SceneButtonsPanel, Panel):
93     bl_label = "Units"
94     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
95
96     def draw(self, context):
97         layout = self.layout
98
99         unit = context.scene.unit_settings
100
101         col = layout.column()
102         col.row().prop(unit, "system", expand=True)
103         col.row().prop(unit, "system_rotation", expand=True)
104
105         row = layout.row()
106         row.active = (unit.system != 'NONE')
107         row.prop(unit, "scale_length", text="Scale")
108         row.prop(unit, "use_separate")
109
110
111 class SCENE_PT_keying_sets(SceneButtonsPanel, Panel):
112     bl_label = "Keying Sets"
113     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
114
115     def draw(self, context):
116         layout = self.layout
117
118         scene = context.scene
119         row = layout.row()
120
121         col = row.column()
122         col.template_list("UI_UL_list", "", scene, "keying_sets", scene.keying_sets, "active_index", rows=2)
123
124         col = row.column(align=True)
125         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
126         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
127
128         ks = scene.keying_sets.active
129         if ks and ks.is_path_absolute:
130             row = layout.row()
131
132             col = row.column()
133             col.prop(ks, "bl_label")
134             col.prop(ks, "bl_description")
135
136             subcol = col.column()
137             subcol.operator_context = 'INVOKE_DEFAULT'
138             subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
139
140             col = row.column(align=True)
141             col.label(text="Keyframing Settings:")
142             col.prop(ks, "bl_options")
143
144
145 class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel):
146     bl_label = "Active Keying Set"
147     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
148
149     @classmethod
150     def poll(cls, context):
151         ks = context.scene.keying_sets.active
152         return (ks and ks.is_path_absolute)
153
154     def draw(self, context):
155         layout = self.layout
156
157         scene = context.scene
158         ks = scene.keying_sets.active
159
160         row = layout.row()
161         row.label(text="Paths:")
162
163         row = layout.row()
164
165         col = row.column()
166         col.template_list("SCENE_UL_keying_set_paths", "", ks, "paths", ks.paths, "active_index", rows=2)
167
168         col = row.column(align=True)
169         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
170         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
171
172         ksp = ks.paths.active
173         if ksp:
174             col = layout.column()
175             col.label(text="Target:")
176             col.template_any_ID(ksp, "id", "id_type")
177             col.template_path_builder(ksp, "data_path", ksp.id)
178
179             row = col.row(align=True)
180             row.label(text="Array Target:")
181             row.prop(ksp, "use_entire_array", text="All Items")
182             if ksp.use_entire_array:
183                 row.label(text=" ")  # padding
184             else:
185                 row.prop(ksp, "array_index", text="Index")
186
187             layout.separator()
188
189             row = layout.row()
190             col = row.column()
191             col.label(text="F-Curve Grouping:")
192             col.prop(ksp, "group_method", text="")
193             if ksp.group_method == 'NAMED':
194                 col.prop(ksp, "group")
195
196             col = row.column(align=True)
197             col.label(text="Keyframing Settings:")
198             col.prop(ksp, "bl_options")
199
200
201 class SCENE_PT_physics(SceneButtonsPanel, Panel):
202     bl_label = "Gravity"
203     COMPAT_ENGINES = {'BLENDER_RENDER'}
204
205     def draw_header(self, context):
206         self.layout.prop(context.scene, "use_gravity", text="")
207
208     def draw(self, context):
209         layout = self.layout
210
211         scene = context.scene
212
213         layout.active = scene.use_gravity
214
215         layout.prop(scene, "gravity", text="")
216
217
218 class SCENE_PT_simplify(SceneButtonsPanel, Panel):
219     bl_label = "Simplify"
220     COMPAT_ENGINES = {'BLENDER_RENDER'}
221
222     def draw_header(self, context):
223         rd = context.scene.render
224         self.layout.prop(rd, "use_simplify", text="")
225
226     def draw(self, context):
227         layout = self.layout
228
229         rd = context.scene.render
230
231         layout.active = rd.use_simplify
232
233         split = layout.split()
234
235         col = split.column()
236         col.prop(rd, "simplify_subdivision", text="Subdivision")
237         col.prop(rd, "simplify_child_particles", text="Child Particles")
238
239         col.prop(rd, "use_simplify_triangulate")
240
241         col = split.column()
242         col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
243         col.prop(rd, "simplify_ao_sss", text="AO and SSS")
244
245
246 class SCENE_PT_color_management(Panel):
247     bl_label = "Color Management"
248     bl_space_type = 'PROPERTIES'
249     bl_region_type = 'WINDOW'
250     bl_context = "scene"
251
252     def draw(self, context):
253         layout = self.layout
254
255         scene = context.scene
256         rd = scene.render
257
258         col = layout.column()
259         col.label(text="Display:")
260         col.prop(scene.display_settings, "display_device")
261
262         col = layout.column()
263         col.separator()
264         col.label(text="Render:")
265         col.template_colormanaged_view_settings(scene, "view_settings")
266         col.prop(rd, "use_color_unpremultiply")
267
268         col = layout.column()
269         col.separator()
270         col.label(text="Sequencer:")
271         col.prop(scene.sequencer_colorspace_settings, "name")
272
273
274 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
275     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
276     _context_path = "scene"
277     _property_type = bpy.types.Scene
278
279 if __name__ == "__main__":  # only for live edit.
280     bpy.utils.register_module(__name__)