1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
22 from bpy.types import Header, Menu
25 #######################################
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'
33 row = layout.row(align=True)
34 row.prop(dopesheet, "show_only_selected", text="")
35 row.prop(dopesheet, "show_hidden", text="")
38 row.prop(dopesheet, "show_missing_nla", text="")
40 if not genericFiltersOnly:
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="")
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="")
53 if not genericFiltersOnly:
54 row = layout.row(align=True)
55 row.prop(dopesheet, "show_datablock_filters", text="Filters")
57 if dopesheet.show_datablock_filters:
58 row.prop(dopesheet, "show_scenes", text="")
59 row.prop(dopesheet, "show_worlds", text="")
60 row.prop(dopesheet, "show_nodes", text="")
62 row.prop(dopesheet, "show_transforms", text="")
65 row.prop(dopesheet, "show_meshes", text="")
66 if bpy.data.shape_keys:
67 row.prop(dopesheet, "show_shapekeys", text="")
68 if bpy.data.materials:
69 row.prop(dopesheet, "show_materials", text="")
71 row.prop(dopesheet, "show_lamps", text="")
73 row.prop(dopesheet, "show_textures", text="")
75 row.prop(dopesheet, "show_cameras", text="")
77 row.prop(dopesheet, "show_curves", text="")
78 if bpy.data.metaballs:
79 row.prop(dopesheet, "show_metaballs", text="")
81 row.prop(dopesheet, "show_lattices", text="")
82 if bpy.data.armatures:
83 row.prop(dopesheet, "show_armatures", text="")
84 if bpy.data.particles:
85 row.prop(dopesheet, "show_particles", text="")
87 row.prop(dopesheet, "show_speakers", text="")
90 #######################################
91 # DopeSheet Editor - General/Standard UI
93 class DOPESHEET_HT_header(Header):
94 bl_space_type = 'DOPESHEET_EDITOR'
96 def draw(self, context):
99 st = context.space_data
101 row = layout.row(align=True)
102 row.template_header()
104 if context.area.show_menus:
105 row.menu("DOPESHEET_MT_view")
106 row.menu("DOPESHEET_MT_select")
107 row.menu("DOPESHEET_MT_marker")
109 if st.mode == 'DOPESHEET' or (st.mode == 'ACTION' and st.action != None):
110 row.menu("DOPESHEET_MT_channel")
111 elif st.mode == 'GPENCIL':
112 row.menu("DOPESHEET_MT_gpencil_channel")
114 if st.mode != 'GPENCIL':
115 row.menu("DOPESHEET_MT_key")
117 row.menu("DOPESHEET_MT_gpencil_frame")
119 layout.prop(st, "mode", text="")
120 layout.prop(st.dopesheet, "show_summary", text="Summary")
122 if st.mode == 'DOPESHEET':
123 dopesheet_filter(layout, context)
124 elif st.mode == 'ACTION':
125 # 'genericFiltersOnly' limits the options to only the relevant 'generic' subset of
126 # filters which will work here and are useful (especially for character animation)
127 dopesheet_filter(layout, context, genericFiltersOnly=True)
129 if st.mode in {'ACTION', 'SHAPEKEY'}:
130 layout.template_ID(st, "action", new="action.new")
132 # Grease Pencil mode doesn't need snapping, as it's frame-aligned only
133 if st.mode != 'GPENCIL':
134 layout.prop(st, "auto_snap", text="")
136 row = layout.row(align=True)
137 row.operator("action.copy", text="", icon='COPYDOWN')
138 row.operator("action.paste", text="", icon='PASTEDOWN')
141 class DOPESHEET_MT_view(Menu):
144 def draw(self, context):
147 st = context.space_data
149 layout.prop(st, "use_realtime_update")
150 layout.prop(st, "show_frame_indicator")
151 layout.prop(st, "show_sliders")
152 layout.prop(st, "use_auto_merge_keyframes")
153 layout.prop(st, "use_marker_sync")
156 layout.operator("anim.time_toggle", text="Show Frames")
158 layout.operator("anim.time_toggle", text="Show Seconds")
161 layout.operator("anim.previewrange_set")
162 layout.operator("anim.previewrange_clear")
163 layout.operator("action.previewrange_set")
166 layout.operator("action.frame_jump")
167 layout.operator("action.view_all")
168 layout.operator("action.view_selected")
171 layout.operator("screen.area_dupli")
172 layout.operator("screen.screen_full_area")
175 class DOPESHEET_MT_select(Menu):
178 def draw(self, context):
181 # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
182 layout.operator("action.select_all_toggle")
183 layout.operator("action.select_all_toggle", text="Invert Selection").invert = True
186 layout.operator("action.select_border")
187 layout.operator("action.select_border", text="Border Axis Range").axis_range = True
190 layout.operator("action.select_column", text="Columns on Selected Keys").mode = 'KEYS'
191 layout.operator("action.select_column", text="Column on Current Frame").mode = 'CFRA'
193 layout.operator("action.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
194 layout.operator("action.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
197 layout.operator("action.select_leftright", text="Before Current Frame").mode = 'LEFT'
198 layout.operator("action.select_leftright", text="After Current Frame").mode = 'RIGHT'
200 # FIXME: grease pencil mode isn't supported for these yet, so skip for that mode only
201 if context.space_data.mode != 'GPENCIL':
203 layout.operator("action.select_more")
204 layout.operator("action.select_less")
207 layout.operator("action.select_linked")
210 class DOPESHEET_MT_marker(Menu):
213 def draw(self, context):
216 st = context.space_data
218 #layout.operator_context = 'EXEC_REGION_WIN'
220 layout.operator("marker.add", "Add Marker")
221 layout.operator("marker.duplicate", text="Duplicate Marker")
222 layout.operator("marker.delete", text="Delete Marker")
226 layout.operator("marker.rename", text="Rename Marker")
227 layout.operator("marker.move", text="Grab/Move Marker")
229 if st.mode in {'ACTION', 'SHAPEKEY'} and st.action:
231 layout.prop(st, "show_pose_markers")
233 if st.show_pose_markers is False:
234 layout.operator("action.markers_make_local")
237 #######################################
240 class DOPESHEET_MT_channel(Menu):
243 def draw(self, context):
246 layout.operator_context = 'INVOKE_REGION_CHANNELS'
248 layout.operator("anim.channels_delete")
251 layout.operator("anim.channels_setting_toggle")
252 layout.operator("anim.channels_setting_enable")
253 layout.operator("anim.channels_setting_disable")
256 layout.operator("anim.channels_editable_toggle")
257 layout.operator_menu_enum("action.extrapolation_type", "type", text="Extrapolation Mode")
260 layout.operator("anim.channels_expand")
261 layout.operator("anim.channels_collapse")
264 layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
267 layout.operator("anim.channels_fcurves_enable")
270 class DOPESHEET_MT_key(Menu):
273 def draw(self, context):
276 layout.menu("DOPESHEET_MT_key_transform", text="Transform")
278 layout.operator_menu_enum("action.snap", "type", text="Snap")
279 layout.operator_menu_enum("action.mirror", "type", text="Mirror")
282 layout.operator("action.keyframe_insert")
285 layout.operator("action.duplicate_move")
286 layout.operator("action.delete")
289 layout.operator_menu_enum("action.keyframe_type", "type", text="Keyframe Type")
290 layout.operator_menu_enum("action.handle_type", "type", text="Handle Type")
291 layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode")
294 layout.operator("action.clean")
295 layout.operator("action.sample")
298 layout.operator("action.copy")
299 layout.operator("action.paste")
302 class DOPESHEET_MT_key_transform(Menu):
303 bl_label = "Transform"
305 def draw(self, context):
308 layout.operator("transform.transform", text="Grab/Move").mode = 'TIME_TRANSLATE'
309 layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
310 layout.operator("transform.transform", text="Slide").mode = 'TIME_SLIDE'
311 layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE'
314 #######################################
315 # Grease Pencil Editing
317 class DOPESHEET_MT_gpencil_channel(Menu):
320 def draw(self, context):
323 layout.operator_context = 'INVOKE_REGION_CHANNELS'
325 layout.operator("anim.channels_delete")
328 layout.operator("anim.channels_setting_toggle")
329 layout.operator("anim.channels_setting_enable")
330 layout.operator("anim.channels_setting_disable")
333 layout.operator("anim.channels_editable_toggle")
335 # XXX: to be enabled when these are ready for use!
337 #layout.operator("anim.channels_expand")
338 #layout.operator("anim.channels_collapse")
341 #layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
344 class DOPESHEET_MT_gpencil_frame(Menu):
347 def draw(self, context):
350 layout.menu("DOPESHEET_MT_key_transform", text="Transform")
352 #layout.operator_menu_enum("action.snap", "type", text="Snap")
353 #layout.operator_menu_enum("action.mirror", "type", text="Mirror")
356 layout.operator("action.duplicate")
357 layout.operator("action.delete")
360 #layout.operator("action.copy")
361 #layout.operator("action.paste")
363 if __name__ == "__main__": # only for live edit.
364 bpy.utils.register_module(__name__)