Reshuffling DopeSheet filter icons so that they appear more obviously
[blender.git] / release / scripts / startup / bl_ui / space_dopesheet.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
21 import bpy
22 from bpy.types import Header, Menu
23
24
25 #######################################
26 # DopeSheet Filtering
27
28 # used for DopeSheet, NLA, and Graph Editors
29 def dopesheet_filter(layout, context, genericFiltersOnly=False):
30     dopesheet = context.space_data.dopesheet
31     is_nla = context.area.type == 'NLA_EDITOR'
32
33     row = layout.row(align=True)
34     row.prop(dopesheet, "show_only_selected", text="")
35     row.prop(dopesheet, "show_hidden", text="")
36
37     if is_nla:
38         row.prop(dopesheet, "show_missing_nla", text="")
39     
40     if not genericFiltersOnly:
41         if bpy.data.groups:
42             row = layout.row(align=True)
43             row.prop(dopesheet, "show_only_group_objects", text="")
44             if dopesheet.show_only_group_objects:
45                 row.prop(dopesheet, "filter_group", text="")
46
47     if not is_nla:
48         row = layout.row(align=True)
49         row.prop(dopesheet, "show_only_matching_fcurves", text="")
50         if dopesheet.show_only_matching_fcurves:
51             row.prop(dopesheet, "filter_fcurve_name", text="")
52
53     row = layout.row(align=True)
54     row.prop(dopesheet, "show_datablock_filters", text="Filters")
55
56     if (not genericFiltersOnly) and (dopesheet.show_datablock_filters):
57         row.prop(dopesheet, "show_scenes", text="")
58         row.prop(dopesheet, "show_worlds", text="")
59         row.prop(dopesheet, "show_nodes", text="")
60
61         row.prop(dopesheet, "show_transforms", text="")
62
63         if bpy.data.meshes:
64             row.prop(dopesheet, "show_meshes", text="")
65         if bpy.data.shape_keys:
66             row.prop(dopesheet, "show_shapekeys", text="")
67         if bpy.data.materials:
68             row.prop(dopesheet, "show_materials", text="")
69         if bpy.data.lamps:
70             row.prop(dopesheet, "show_lamps", text="")
71         if bpy.data.textures:
72             row.prop(dopesheet, "show_textures", text="")
73         if bpy.data.cameras:
74             row.prop(dopesheet, "show_cameras", text="")
75         if bpy.data.curves:
76             row.prop(dopesheet, "show_curves", text="")
77         if bpy.data.metaballs:
78             row.prop(dopesheet, "show_metaballs", text="")
79         if bpy.data.lattices:
80             row.prop(dopesheet, "show_lattices", text="")
81         if bpy.data.armatures:
82             row.prop(dopesheet, "show_armatures", text="")
83         if bpy.data.particles:
84             row.prop(dopesheet, "show_particles", text="")
85         if bpy.data.speakers:
86             row.prop(dopesheet, "show_speakers", text="")
87
88
89 #######################################
90 # DopeSheet Editor - General/Standard UI
91
92 class DOPESHEET_HT_header(Header):
93     bl_space_type = 'DOPESHEET_EDITOR'
94
95     def draw(self, context):
96         layout = self.layout
97
98         st = context.space_data
99
100         row = layout.row(align=True)
101         row.template_header()
102
103         if context.area.show_menus:
104             row.menu("DOPESHEET_MT_view")
105             row.menu("DOPESHEET_MT_select")
106             row.menu("DOPESHEET_MT_marker")
107
108             if st.mode == 'DOPESHEET' or (st.mode == 'ACTION' and st.action != None):
109                 row.menu("DOPESHEET_MT_channel")
110             elif st.mode == 'GPENCIL':
111                 row.menu("DOPESHEET_MT_gpencil_channel")
112
113             if st.mode != 'GPENCIL':
114                 row.menu("DOPESHEET_MT_key")
115             else:
116                 row.menu("DOPESHEET_MT_gpencil_frame")
117
118         layout.prop(st, "mode", text="")
119         layout.prop(st.dopesheet, "show_summary", text="Summary")
120
121         if st.mode == 'DOPESHEET':
122             dopesheet_filter(layout, context)
123         elif st.mode == 'ACTION':
124             # 'genericFiltersOnly' limits the options to only the relevant 'generic' subset of
125             # filters which will work here and are useful (especially for character animation)
126             dopesheet_filter(layout, context, genericFiltersOnly=True)
127
128         if st.mode in {'ACTION', 'SHAPEKEY'}:
129             layout.template_ID(st, "action", new="action.new")
130
131         # Grease Pencil mode doesn't need snapping, as it's frame-aligned only
132         if st.mode != 'GPENCIL':
133             layout.prop(st, "auto_snap", text="")
134
135         row = layout.row(align=True)
136         row.operator("action.copy", text="", icon='COPYDOWN')
137         row.operator("action.paste", text="", icon='PASTEDOWN')
138
139
140 class DOPESHEET_MT_view(Menu):
141     bl_label = "View"
142
143     def draw(self, context):
144         layout = self.layout
145
146         st = context.space_data
147
148         layout.prop(st, "use_realtime_update")
149         layout.prop(st, "show_frame_indicator")
150         layout.prop(st, "show_sliders")
151         layout.prop(st, "use_auto_merge_keyframes")
152         layout.prop(st, "use_marker_sync")
153
154         if st.show_seconds:
155             layout.operator("anim.time_toggle", text="Show Frames")
156         else:
157             layout.operator("anim.time_toggle", text="Show Seconds")
158
159         layout.separator()
160         layout.operator("anim.previewrange_set")
161         layout.operator("anim.previewrange_clear")
162         layout.operator("action.previewrange_set")
163
164         layout.separator()
165         layout.operator("action.frame_jump")
166         layout.operator("action.view_all")
167         layout.operator("action.view_selected")
168
169         layout.separator()
170         layout.operator("screen.area_dupli")
171         layout.operator("screen.screen_full_area")
172
173
174 class DOPESHEET_MT_select(Menu):
175     bl_label = "Select"
176
177     def draw(self, context):
178         layout = self.layout
179
180         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
181         layout.operator("action.select_all_toggle")
182         layout.operator("action.select_all_toggle", text="Invert Selection").invert = True
183
184         layout.separator()
185         layout.operator("action.select_border")
186         layout.operator("action.select_border", text="Border Axis Range").axis_range = True
187
188         layout.separator()
189         layout.operator("action.select_column", text="Columns on Selected Keys").mode = 'KEYS'
190         layout.operator("action.select_column", text="Column on Current Frame").mode = 'CFRA'
191
192         layout.operator("action.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
193         layout.operator("action.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
194
195         layout.separator()
196         layout.operator("action.select_leftright", text="Before Current Frame").mode = 'LEFT'
197         layout.operator("action.select_leftright", text="After Current Frame").mode = 'RIGHT'
198
199         # FIXME: grease pencil mode isn't supported for these yet, so skip for that mode only
200         if context.space_data.mode != 'GPENCIL':
201             layout.separator()
202             layout.operator("action.select_more")
203             layout.operator("action.select_less")
204
205             layout.separator()
206             layout.operator("action.select_linked")
207
208
209 class DOPESHEET_MT_marker(Menu):
210     bl_label = "Marker"
211
212     def draw(self, context):
213         layout = self.layout
214
215         st = context.space_data
216
217         #layout.operator_context = 'EXEC_REGION_WIN'
218
219         layout.operator("marker.add", "Add Marker")
220         layout.operator("marker.duplicate", text="Duplicate Marker")
221         layout.operator("marker.delete", text="Delete Marker")
222
223         layout.separator()
224
225         layout.operator("marker.rename", text="Rename Marker")
226         layout.operator("marker.move", text="Grab/Move Marker")
227
228         if st.mode in {'ACTION', 'SHAPEKEY'} and st.action:
229             layout.separator()
230             layout.prop(st, "show_pose_markers")
231
232             if st.show_pose_markers is False:
233                 layout.operator("action.markers_make_local")
234
235
236 #######################################
237 # Keyframe Editing
238
239 class DOPESHEET_MT_channel(Menu):
240     bl_label = "Channel"
241
242     def draw(self, context):
243         layout = self.layout
244
245         layout.operator_context = 'INVOKE_REGION_CHANNELS'
246
247         layout.operator("anim.channels_delete")
248
249         layout.separator()
250         layout.operator("anim.channels_setting_toggle")
251         layout.operator("anim.channels_setting_enable")
252         layout.operator("anim.channels_setting_disable")
253
254         layout.separator()
255         layout.operator("anim.channels_editable_toggle")
256         layout.operator_menu_enum("action.extrapolation_type", "type", text="Extrapolation Mode")
257
258         layout.separator()
259         layout.operator("anim.channels_expand")
260         layout.operator("anim.channels_collapse")
261
262         layout.separator()
263         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
264
265         layout.separator()
266         layout.operator("anim.channels_fcurves_enable")
267
268
269 class DOPESHEET_MT_key(Menu):
270     bl_label = "Key"
271
272     def draw(self, context):
273         layout = self.layout
274
275         layout.menu("DOPESHEET_MT_key_transform", text="Transform")
276
277         layout.operator_menu_enum("action.snap", "type", text="Snap")
278         layout.operator_menu_enum("action.mirror", "type", text="Mirror")
279
280         layout.separator()
281         layout.operator("action.keyframe_insert")
282
283         layout.separator()
284         layout.operator("action.duplicate_move")
285         layout.operator("action.delete")
286
287         layout.separator()
288         layout.operator_menu_enum("action.keyframe_type", "type", text="Keyframe Type")
289         layout.operator_menu_enum("action.handle_type", "type", text="Handle Type")
290         layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode")
291
292         layout.separator()
293         layout.operator("action.clean")
294         layout.operator("action.sample")
295
296         layout.separator()
297         layout.operator("action.copy")
298         layout.operator("action.paste")
299
300
301 class DOPESHEET_MT_key_transform(Menu):
302     bl_label = "Transform"
303
304     def draw(self, context):
305         layout = self.layout
306
307         layout.operator("transform.transform", text="Grab/Move").mode = 'TIME_TRANSLATE'
308         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
309         layout.operator("transform.transform", text="Slide").mode = 'TIME_SLIDE'
310         layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE'
311
312
313 #######################################
314 # Grease Pencil Editing
315
316 class DOPESHEET_MT_gpencil_channel(Menu):
317     bl_label = "Channel"
318
319     def draw(self, context):
320         layout = self.layout
321
322         layout.operator_context = 'INVOKE_REGION_CHANNELS'
323
324         layout.operator("anim.channels_delete")
325
326         layout.separator()
327         layout.operator("anim.channels_setting_toggle")
328         layout.operator("anim.channels_setting_enable")
329         layout.operator("anim.channels_setting_disable")
330
331         layout.separator()
332         layout.operator("anim.channels_editable_toggle")
333
334         # XXX: to be enabled when these are ready for use!
335         #layout.separator()
336         #layout.operator("anim.channels_expand")
337         #layout.operator("anim.channels_collapse")
338
339         #layout.separator()
340         #layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
341
342
343 class DOPESHEET_MT_gpencil_frame(Menu):
344     bl_label = "Frame"
345
346     def draw(self, context):
347         layout = self.layout
348
349         layout.menu("DOPESHEET_MT_key_transform", text="Transform")
350
351         #layout.operator_menu_enum("action.snap", "type", text="Snap")
352         #layout.operator_menu_enum("action.mirror", "type", text="Mirror")
353
354         layout.separator()
355         layout.operator("action.duplicate")
356         layout.operator("action.delete")
357
358         #layout.separator()
359         #layout.operator("action.copy")
360         #layout.operator("action.paste")
361
362 if __name__ == "__main__":  # only for live edit.
363     bpy.utils.register_module(__name__)