KeyingSets UI - Improving button layout for legibility of buttons
[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     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
39
40     def draw(self, context):
41         layout = self.layout
42         scene = context.scene
43
44         layout.prop(scene, "camera")
45         layout.prop(scene, "background_set", text="Background")
46         layout.prop(scene, "active_clip", text="Active Clip")
47
48
49 class SCENE_PT_audio(SceneButtonsPanel, Panel):
50     bl_label = "Audio"
51     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
52
53     def draw(self, context):
54         layout = self.layout
55         scene = context.scene
56         rd = context.scene.render
57         ffmpeg = rd.ffmpeg
58
59         layout.prop(scene, "audio_volume")
60         layout.operator("sound.bake_animation")
61
62         split = layout.split()
63
64         col = split.column()
65         col.label("Listener:")
66         col.prop(scene, "audio_distance_model", text="")
67         col.prop(scene, "audio_doppler_speed", text="Speed")
68         col.prop(scene, "audio_doppler_factor", text="Doppler")
69
70         col = split.column()
71         col.label("Format:")
72         col.prop(ffmpeg, "audio_channels", text="")
73         col.prop(ffmpeg, "audio_mixrate", text="Rate")
74
75         layout.operator("sound.mixdown")
76
77
78 class SCENE_PT_unit(SceneButtonsPanel, Panel):
79     bl_label = "Units"
80     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
81
82     def draw(self, context):
83         layout = self.layout
84         unit = context.scene.unit_settings
85
86         col = layout.column()
87         col.row().prop(unit, "system", expand=True)
88         col.row().prop(unit, "system_rotation", expand=True)
89
90         row = layout.row()
91         row.active = (unit.system != 'NONE')
92         row.prop(unit, "scale_length", text="Scale")
93         row.prop(unit, "use_separate")
94
95
96 def draw_keyingset_options(data, layout):
97     # NOTE: keep in sync with rna_def_common_keying_flags() in rna_animation.c
98     # These are defined out like this because the standard names are too long
99     layout.prop_enum(data, "bl_options", text="Only Needed", value='INSERTKEY_NEEDED')
100     layout.prop_enum(data, "bl_options", text="Visual Keying", value='INSERTKEY_VISUAL')
101     layout.prop_enum(data, "bl_options", text="XYZ=RGB Coloring", value='INSERTKEY_XYZ_TO_RGB')
102
103
104 class SCENE_PT_keying_sets(SceneButtonsPanel, Panel):
105     bl_label = "Keying Sets"
106     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
107
108     def draw(self, context):
109         layout = self.layout
110
111         scene = context.scene
112         row = layout.row()
113
114         col = row.column()
115         col.template_list(scene, "keying_sets", scene.keying_sets, "active_index", rows=2)
116
117         col = row.column(align=True)
118         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
119         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
120
121         ks = scene.keying_sets.active
122         if ks and ks.is_path_absolute:
123             row = layout.row()
124
125             col = row.column()
126             col.prop(ks, "bl_label")
127             col.prop(ks, "bl_description")
128
129             subcol = col.column()
130             subcol.operator_context = 'INVOKE_DEFAULT'
131             subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
132
133             col = row.column(align=True)
134             col.label(text="Keyframing Settings:")
135             draw_keyingset_options(ks, col)
136
137
138 class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel):
139     bl_label = "Active Keying Set"
140     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
141
142     @classmethod
143     def poll(cls, context):
144         ks = context.scene.keying_sets.active
145         return (ks and ks.is_path_absolute)
146
147     def draw(self, context):
148         layout = self.layout
149
150         scene = context.scene
151         ks = scene.keying_sets.active
152
153         row = layout.row()
154         row.label(text="Paths:")
155
156         row = layout.row()
157
158         col = row.column()
159         col.template_list(ks, "paths", ks.paths, "active_index", rows=2)
160
161         col = row.column(align=True)
162         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
163         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
164
165         ksp = ks.paths.active
166         if ksp:
167             col = layout.column()
168             col.label(text="Target:")
169             col.template_any_ID(ksp, "id", "id_type")
170             col.template_path_builder(ksp, "data_path", ksp.id)
171
172             row = col.row(align=True)
173             row.label(text="Array Target:")
174             row.prop(ksp, "use_entire_array", text="All Items")
175             if ksp.use_entire_array:
176                 row.label(text=" ") # padding
177             else:
178                 row.prop(ksp, "array_index", text="Index")
179
180             layout.separator()
181
182             row = layout.row()
183             col = row.column()
184             col.label(text="F-Curve Grouping:")
185             col.prop(ksp, "group_method", text="")
186             if ksp.group_method == 'NAMED':
187                 col.prop(ksp, "group")
188             
189             col = row.column(align=True)
190             col.label(text="Keyframing Settings:")
191             draw_keyingset_options(ks, col)
192
193
194 class SCENE_PT_physics(SceneButtonsPanel, Panel):
195     bl_label = "Gravity"
196     COMPAT_ENGINES = {'BLENDER_RENDER'}
197
198     def draw_header(self, context):
199         self.layout.prop(context.scene, "use_gravity", text="")
200
201     def draw(self, context):
202         layout = self.layout
203
204         scene = context.scene
205
206         layout.active = scene.use_gravity
207
208         layout.prop(scene, "gravity", text="")
209
210
211 class SCENE_PT_simplify(SceneButtonsPanel, Panel):
212     bl_label = "Simplify"
213     COMPAT_ENGINES = {'BLENDER_RENDER'}
214
215     def draw_header(self, context):
216         rd = context.scene.render
217         self.layout.prop(rd, "use_simplify", text="")
218
219     def draw(self, context):
220         layout = self.layout
221
222         rd = context.scene.render
223
224         layout.active = rd.use_simplify
225
226         split = layout.split()
227
228         col = split.column()
229         col.prop(rd, "simplify_subdivision", text="Subdivision")
230         col.prop(rd, "simplify_child_particles", text="Child Particles")
231
232         col.prop(rd, "use_simplify_triangulate")
233
234         col = split.column()
235         col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
236         col.prop(rd, "simplify_ao_sss", text="AO and SSS")
237
238
239 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
240     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
241     _context_path = "scene"
242     _property_type = bpy.types.Scene
243
244 if __name__ == "__main__":  # only for live edit.
245     bpy.utils.register_module(__name__)