Cucumber, first batch of merge - UI changes and custom exit key
[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         rd = context.scene.render
33         return context.scene and (rd.engine in cls.COMPAT_ENGINES)
34
35
36 class SCENE_PT_scene(SceneButtonsPanel, Panel):
37     bl_label = "Scene"
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
79     def draw(self, context):
80         layout = self.layout
81         unit = context.scene.unit_settings
82
83         col = layout.column()
84         col.row().prop(unit, "system", expand=True)
85         col.row().prop(unit, "system_rotation", expand=True)
86
87         row = layout.row()
88         row.active = (unit.system != 'NONE')
89         row.prop(unit, "scale_length", text="Scale")
90         row.prop(unit, "use_separate")
91
92
93 class SCENE_PT_keying_sets(SceneButtonsPanel, Panel):
94     bl_label = "Keying Sets"
95
96     def draw(self, context):
97         layout = self.layout
98
99         scene = context.scene
100         row = layout.row()
101
102         col = row.column()
103         col.template_list(scene, "keying_sets", scene.keying_sets, "active_index", rows=2)
104
105         col = row.column(align=True)
106         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
107         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
108
109         ks = scene.keying_sets.active
110         if ks and ks.is_path_absolute:
111             row = layout.row()
112
113             col = row.column()
114             col.prop(ks, "name")
115
116             subcol = col.column()
117             subcol.operator_context = 'INVOKE_DEFAULT'
118             subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
119
120             col = row.column()
121             col.label(text="Keyframing Settings:")
122             col.prop(ks, "bl_options")
123
124
125 class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel):
126     bl_label = "Active Keying Set"
127
128     @classmethod
129     def poll(cls, context):
130         ks = context.scene.keying_sets.active
131         return (ks and ks.is_path_absolute)
132
133     def draw(self, context):
134         layout = self.layout
135
136         scene = context.scene
137         ks = scene.keying_sets.active
138
139         row = layout.row()
140         row.label(text="Paths:")
141
142         row = layout.row()
143
144         col = row.column()
145         col.template_list(ks, "paths", ks.paths, "active_index", rows=2)
146
147         col = row.column(align=True)
148         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
149         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
150
151         ksp = ks.paths.active
152         if ksp:
153             col = layout.column()
154             col.label(text="Target:")
155             col.template_any_ID(ksp, "id", "id_type")
156             col.template_path_builder(ksp, "data_path", ksp.id)
157
158             row = layout.row()
159
160             col = row.column()
161             col.label(text="Array Target:")
162             col.prop(ksp, "use_entire_array")
163             if ksp.use_entire_array is False:
164                 col.prop(ksp, "array_index")
165
166             col = row.column()
167             col.label(text="F-Curve Grouping:")
168             col.prop(ksp, "group_method")
169             if ksp.group_method == 'NAMED':
170                 col.prop(ksp, "group")
171
172             col.prop(ksp, "bl_options")
173
174
175 class SCENE_PT_physics(SceneButtonsPanel, Panel):
176     bl_label = "Gravity"
177     COMPAT_ENGINES = {'BLENDER_RENDER'}
178
179     def draw_header(self, context):
180         self.layout.prop(context.scene, "use_gravity", text="")
181
182     def draw(self, context):
183         layout = self.layout
184
185         scene = context.scene
186
187         layout.active = scene.use_gravity
188
189         layout.prop(scene, "gravity", text="")
190
191
192 class SCENE_PT_simplify(SceneButtonsPanel, Panel):
193     bl_label = "Simplify"
194
195     def draw_header(self, context):
196         rd = context.scene.render
197         self.layout.prop(rd, "use_simplify", text="")
198
199     def draw(self, context):
200         layout = self.layout
201
202         rd = context.scene.render
203
204         layout.active = rd.use_simplify
205
206         split = layout.split()
207
208         col = split.column()
209         col.prop(rd, "simplify_subdivision", text="Subdivision")
210         col.prop(rd, "simplify_child_particles", text="Child Particles")
211
212         col.prop(rd, "use_simplify_triangulate")
213
214         col = split.column()
215         col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
216         col.prop(rd, "simplify_ao_sss", text="AO and SSS")
217
218
219 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
220     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
221     _context_path = "scene"
222     _property_type = bpy.types.Scene
223
224 if __name__ == "__main__":  # only for live edit.
225     bpy.utils.register_module(__name__)