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