rename user interface operator properties from 'op' to 'props'
[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
46
47 class SCENE_PT_audio(SceneButtonsPanel, Panel):
48     bl_label = "Audio"
49     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
50
51     def draw(self, context):
52         layout = self.layout
53         scene = context.scene
54         rd = context.scene.render
55
56         layout.prop(scene, "audio_volume")
57         layout.operator("sound.bake_animation")
58
59         split = layout.split()
60
61         col = split.column()
62         col.label("Listener:")
63         col.prop(scene, "audio_distance_model", text="")
64         col.prop(scene, "audio_doppler_speed", text="Speed")
65         col.prop(scene, "audio_doppler_factor", text="Doppler")
66
67         col = split.column()
68         col.label("Format:")
69         col.prop(rd, "ffmpeg_audio_channels", text="")
70         col.prop(rd, "ffmpeg_audio_mixrate", text="Rate")
71
72         layout.operator("sound.mixdown")
73
74
75 class SCENE_PT_unit(SceneButtonsPanel, Panel):
76     bl_label = "Units"
77     COMPAT_ENGINES = {'BLENDER_RENDER'}
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     COMPAT_ENGINES = {'BLENDER_RENDER'}
195
196     def draw_header(self, context):
197         scene = context.scene
198         rd = scene.render
199         self.layout.prop(rd, "use_simplify", text="")
200
201     def draw(self, context):
202         layout = self.layout
203         scene = context.scene
204         rd = scene.render
205
206         layout.active = rd.use_simplify
207
208         split = layout.split()
209
210         col = split.column()
211         col.prop(rd, "simplify_subdivision", text="Subdivision")
212         col.prop(rd, "simplify_child_particles", text="Child Particles")
213
214         col.prop(rd, "use_simplify_triangulate")
215
216         col = split.column()
217         col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
218         col.prop(rd, "simplify_ao_sss", text="AO and SSS")
219
220
221 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
222     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
223     _context_path = "scene"
224     _property_type = bpy.types.Scene
225
226 if __name__ == "__main__":  # only for live edit.
227     bpy.utils.register_module(__name__)