Merged trunk up to rev41928
[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
22 from rna_prop_ui import PropertyPanel
23
24
25 class SceneButtonsPanel():
26     bl_space_type = 'PROPERTIES'
27     bl_region_type = 'WINDOW'
28     bl_context = "scene"
29
30     @classmethod
31     def poll(cls, context):
32         return context.scene
33
34
35 class SCENE_PT_scene(SceneButtonsPanel, Panel):
36     bl_label = "Scene"
37     COMPAT_ENGINES = {'BLENDER_RENDER'}
38
39     def draw(self, context):
40         layout = self.layout
41         scene = context.scene
42
43         layout.prop(scene, "camera")
44         layout.prop(scene, "background_set", text="Background")
45         layout.prop(scene, "active_clip", text="Active Clip")
46
47
48 class SCENE_PT_audio(SceneButtonsPanel, Panel):
49     bl_label = "Audio"
50     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
51
52     def draw(self, context):
53         layout = self.layout
54         scene = context.scene
55         rd = context.scene.render
56
57         layout.prop(scene, "audio_volume")
58         layout.operator("sound.bake_animation")
59
60         split = layout.split()
61
62         col = split.column()
63         col.label("Listener:")
64         col.prop(scene, "audio_distance_model", text="")
65         col.prop(scene, "audio_doppler_speed", text="Speed")
66         col.prop(scene, "audio_doppler_factor", text="Doppler")
67
68         col = split.column()
69         col.label("Format:")
70         col.prop(rd, "ffmpeg_audio_channels", text="")
71         col.prop(rd, "ffmpeg_audio_mixrate", text="Rate")
72
73         layout.operator("sound.mixdown")
74
75
76 class SCENE_PT_unit(SceneButtonsPanel, Panel):
77     bl_label = "Units"
78     COMPAT_ENGINES = {'BLENDER_RENDER'}
79
80     def draw(self, context):
81         layout = self.layout
82         unit = context.scene.unit_settings
83
84         col = layout.column()
85         col.row().prop(unit, "system", expand=True)
86         col.row().prop(unit, "system_rotation", expand=True)
87
88         row = layout.row()
89         row.active = (unit.system != 'NONE')
90         row.prop(unit, "scale_length", text="Scale")
91         row.prop(unit, "use_separate")
92
93
94 class SCENE_PT_keying_sets(SceneButtonsPanel, Panel):
95     bl_label = "Keying Sets"
96
97     def draw(self, context):
98         layout = self.layout
99
100         scene = context.scene
101         row = layout.row()
102
103         col = row.column()
104         col.template_list(scene, "keying_sets", scene.keying_sets, "active_index", rows=2)
105
106         col = row.column(align=True)
107         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
108         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
109
110         ks = scene.keying_sets.active
111         if ks and ks.is_path_absolute:
112             row = layout.row()
113
114             col = row.column()
115             col.prop(ks, "name")
116
117             subcol = col.column()
118             subcol.operator_context = 'INVOKE_DEFAULT'
119             subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
120
121             col = row.column()
122             col.label(text="Keyframing Settings:")
123             col.prop(ks, "bl_options")
124
125
126 class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel):
127     bl_label = "Active Keying Set"
128
129     @classmethod
130     def poll(cls, context):
131         ks = context.scene.keying_sets.active
132         return (ks and ks.is_path_absolute)
133
134     def draw(self, context):
135         layout = self.layout
136
137         scene = context.scene
138         ks = scene.keying_sets.active
139
140         row = layout.row()
141         row.label(text="Paths:")
142
143         row = layout.row()
144
145         col = row.column()
146         col.template_list(ks, "paths", ks.paths, "active_index", rows=2)
147
148         col = row.column(align=True)
149         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
150         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
151
152         ksp = ks.paths.active
153         if ksp:
154             col = layout.column()
155             col.label(text="Target:")
156             col.template_any_ID(ksp, "id", "id_type")
157             col.template_path_builder(ksp, "data_path", ksp.id)
158
159             row = layout.row()
160
161             col = row.column()
162             col.label(text="Array Target:")
163             col.prop(ksp, "use_entire_array")
164             if ksp.use_entire_array is False:
165                 col.prop(ksp, "array_index")
166
167             col = row.column()
168             col.label(text="F-Curve Grouping:")
169             col.prop(ksp, "group_method")
170             if ksp.group_method == 'NAMED':
171                 col.prop(ksp, "group")
172
173             col.prop(ksp, "bl_options")
174
175
176 class SCENE_PT_physics(SceneButtonsPanel, Panel):
177     bl_label = "Gravity"
178     COMPAT_ENGINES = {'BLENDER_RENDER'}
179
180     def draw_header(self, context):
181         self.layout.prop(context.scene, "use_gravity", text="")
182
183     def draw(self, context):
184         layout = self.layout
185
186         scene = context.scene
187
188         layout.active = scene.use_gravity
189
190         layout.prop(scene, "gravity", text="")
191
192
193 class SCENE_PT_simplify(SceneButtonsPanel, Panel):
194     bl_label = "Simplify"
195     COMPAT_ENGINES = {'BLENDER_RENDER'}
196
197     def draw_header(self, context):
198         scene = context.scene
199         rd = scene.render
200         self.layout.prop(rd, "use_simplify", text="")
201
202     def draw(self, context):
203         layout = self.layout
204         scene = context.scene
205         rd = scene.render
206
207         layout.active = rd.use_simplify
208
209         split = layout.split()
210
211         col = split.column()
212         col.prop(rd, "simplify_subdivision", text="Subdivision")
213         col.prop(rd, "simplify_child_particles", text="Child Particles")
214
215         col.prop(rd, "use_simplify_triangulate")
216
217         col = split.column()
218         col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
219         col.prop(rd, "simplify_ao_sss", text="AO and SSS")
220
221
222 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
223     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
224     _context_path = "scene"
225     _property_type = bpy.types.Scene
226
227 if __name__ == "__main__":  # only for live edit.
228     bpy.utils.register_module(__name__)