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="")
37 if not genericFiltersOnly:
38 row = layout.row(align=True)
39 row.prop(dopesheet, "show_transforms", text="")
42 row.prop(dopesheet, "show_missing_nla", text="")
44 row = layout.row(align=True)
45 row.prop(dopesheet, "show_scenes", text="")
46 row.prop(dopesheet, "show_worlds", text="")
47 row.prop(dopesheet, "show_nodes", text="")
50 row.prop(dopesheet, "show_meshes", text="")
51 if bpy.data.shape_keys:
52 row.prop(dopesheet, "show_shapekeys", text="")
53 if bpy.data.materials:
54 row.prop(dopesheet, "show_materials", text="")
56 row.prop(dopesheet, "show_lamps", text="")
58 row.prop(dopesheet, "show_textures", text="")
60 row.prop(dopesheet, "show_cameras", text="")
62 row.prop(dopesheet, "show_curves", text="")
63 if bpy.data.metaballs:
64 row.prop(dopesheet, "show_metaballs", text="")
66 row.prop(dopesheet, "show_lattices", text="")
67 if bpy.data.armatures:
68 row.prop(dopesheet, "show_armatures", text="")
69 if bpy.data.particles:
70 row.prop(dopesheet, "show_particles", text="")
73 row = layout.row(align=True)
74 row.prop(dopesheet, "show_only_group_objects", text="")
75 if dopesheet.show_only_group_objects:
76 row.prop(dopesheet, "filter_group", text="")
79 row = layout.row(align=True)
80 row.prop(dopesheet, "show_only_matching_fcurves", text="")
81 if dopesheet.show_only_matching_fcurves:
82 row.prop(dopesheet, "filter_fcurve_name", text="")
85 #######################################
86 # DopeSheet Editor - General/Standard UI
88 class DOPESHEET_HT_header(Header):
89 bl_space_type = 'DOPESHEET_EDITOR'
91 def draw(self, context):
94 st = context.space_data
96 row = layout.row(align=True)
99 if context.area.show_menus:
100 row.menu("DOPESHEET_MT_view")
101 row.menu("DOPESHEET_MT_select")
102 row.menu("DOPESHEET_MT_marker")
104 if st.mode == 'DOPESHEET' or (st.mode == 'ACTION' and st.action != None):
105 row.menu("DOPESHEET_MT_channel")
106 elif st.mode == 'GPENCIL':
107 row.menu("DOPESHEET_MT_gpencil_channel")
109 if st.mode != 'GPENCIL':
110 row.menu("DOPESHEET_MT_key")
112 row.menu("DOPESHEET_MT_gpencil_frame")
114 layout.prop(st, "mode", text="")
115 layout.prop(st.dopesheet, "show_summary", text="Summary")
117 if st.mode == 'DOPESHEET':
118 dopesheet_filter(layout, context)
119 elif st.mode == 'ACTION':
120 # 'genericFiltersOnly' limits the options to only the relevant 'generic' subset of
121 # filters which will work here and are useful (especially for character animation)
122 dopesheet_filter(layout, context, genericFiltersOnly=True)
124 if st.mode in {'ACTION', 'SHAPEKEY'}:
125 layout.template_ID(st, "action", new="action.new")
127 # Grease Pencil mode doesn't need snapping, as it's frame-aligned only
128 if st.mode != 'GPENCIL':
129 layout.prop(st, "auto_snap", text="")
131 row = layout.row(align=True)
132 row.operator("action.copy", text="", icon='COPYDOWN')
133 row.operator("action.paste", text="", icon='PASTEDOWN')
136 class DOPESHEET_MT_view(Menu):
139 def draw(self, context):
142 st = context.space_data
144 layout.prop(st, "use_realtime_update")
145 layout.prop(st, "show_frame_indicator")
146 layout.prop(st, "show_sliders")
147 layout.prop(st, "use_auto_merge_keyframes")
148 layout.prop(st, "use_marker_sync")
151 layout.operator("anim.time_toggle", text="Show Frames")
153 layout.operator("anim.time_toggle", text="Show Seconds")
156 layout.operator("anim.previewrange_set")
157 layout.operator("anim.previewrange_clear")
158 layout.operator("action.previewrange_set")
161 layout.operator("action.frame_jump")
162 layout.operator("action.view_all")
163 layout.operator("action.view_selected")
166 layout.operator("screen.area_dupli")
167 layout.operator("screen.screen_full_area")
170 class DOPESHEET_MT_select(Menu):
173 def draw(self, context):
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
181 layout.operator("action.select_border")
182 layout.operator("action.select_border", text="Border Axis Range").axis_range = True
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'
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'
192 layout.operator("action.select_leftright", text="Before Current Frame").mode = 'LEFT'
193 layout.operator("action.select_leftright", text="After Current Frame").mode = 'RIGHT'
195 # FIXME: grease pencil mode isn't supported for these yet, so skip for that mode only
196 if context.space_data.mode != 'GPENCIL':
198 layout.operator("action.select_more")
199 layout.operator("action.select_less")
202 layout.operator("action.select_linked")
205 class DOPESHEET_MT_marker(Menu):
208 def draw(self, context):
211 st = context.space_data
213 #layout.operator_context = 'EXEC_REGION_WIN'
215 layout.operator("marker.add", "Add Marker")
216 layout.operator("marker.duplicate", text="Duplicate Marker")
217 layout.operator("marker.delete", text="Delete Marker")
221 layout.operator("marker.rename", text="Rename Marker")
222 layout.operator("marker.move", text="Grab/Move Marker")
224 if st.mode in {'ACTION', 'SHAPEKEY'} and st.action:
226 layout.prop(st, "show_pose_markers")
228 if st.show_pose_markers is False:
229 layout.operator("action.markers_make_local")
232 #######################################
235 class DOPESHEET_MT_channel(Menu):
238 def draw(self, context):
241 layout.operator_context = 'INVOKE_REGION_CHANNELS'
243 layout.operator("anim.channels_delete")
246 layout.operator("anim.channels_setting_toggle")
247 layout.operator("anim.channels_setting_enable")
248 layout.operator("anim.channels_setting_disable")
251 layout.operator("anim.channels_editable_toggle")
252 layout.operator_menu_enum("action.extrapolation_type", "type", text="Extrapolation Mode")
255 layout.operator("anim.channels_expand")
256 layout.operator("anim.channels_collapse")
259 layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
262 layout.operator("anim.channels_fcurves_enable")
265 class DOPESHEET_MT_key(Menu):
268 def draw(self, context):
271 layout.menu("DOPESHEET_MT_key_transform", text="Transform")
273 layout.operator_menu_enum("action.snap", "type", text="Snap")
274 layout.operator_menu_enum("action.mirror", "type", text="Mirror")
277 layout.operator("action.keyframe_insert")
280 layout.operator("action.duplicate")
281 layout.operator("action.delete")
284 layout.operator_menu_enum("action.keyframe_type", "type", text="Keyframe Type")
285 layout.operator_menu_enum("action.handle_type", "type", text="Handle Type")
286 layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode")
289 layout.operator("action.clean")
290 layout.operator("action.sample")
293 layout.operator("action.copy")
294 layout.operator("action.paste")
297 class DOPESHEET_MT_key_transform(Menu):
298 bl_label = "Transform"
300 def draw(self, context):
303 layout.operator("transform.transform", text="Grab/Move").mode = 'TIME_TRANSLATE'
304 layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
305 layout.operator("transform.transform", text="Slide").mode = 'TIME_SLIDE'
306 layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE'
309 #######################################
310 # Grease Pencil Editing
312 class DOPESHEET_MT_gpencil_channel(Menu):
315 def draw(self, context):
318 layout.operator_context = 'INVOKE_REGION_CHANNELS'
320 layout.operator("anim.channels_delete")
323 layout.operator("anim.channels_setting_toggle")
324 layout.operator("anim.channels_setting_enable")
325 layout.operator("anim.channels_setting_disable")
328 layout.operator("anim.channels_editable_toggle")
330 # XXX: to be enabled when these are ready for use!
332 #layout.operator("anim.channels_expand")
333 #layout.operator("anim.channels_collapse")
336 #layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
339 class DOPESHEET_MT_gpencil_frame(Menu):
342 def draw(self, context):
345 layout.menu("DOPESHEET_MT_key_transform", text="Transform")
347 #layout.operator_menu_enum("action.snap", "type", text="Snap")
348 #layout.operator_menu_enum("action.mirror", "type", text="Mirror")
351 layout.operator("action.duplicate")
352 layout.operator("action.delete")
355 #layout.operator("action.copy")
356 #layout.operator("action.paste")
358 if __name__ == "__main__": # only for live edit.
359 bpy.utils.register_module(__name__)