Pose library: fix asset creation operator poll when no object active
[blender-addons.git] / space_view3d_pie_menus / pie_animation_menu.py
blob3d585ec15c36e66175188d38a17fe3757b24f288
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 bl_info = {
4 "name": "Hotkey: 'Shift Spacebar'",
5 "description": "Pie menu for Timeline controls",
6 "author": "pitiwazou, meta-androcto",
7 "version": (0, 1, 1),
8 "blender": (2, 80, 0),
9 "location": "3D View",
10 "warning": "",
11 "doc_url": "",
12 "category": "Animation Pie"
15 import bpy
16 from bpy.types import (
17 Menu,
18 Operator,
21 # Pie Animation
24 class PIE_MT_PieAnimation(Menu):
25 bl_idname = "PIE_MT_animation"
26 bl_label = "Pie Animation"
28 def draw(self, context):
29 layout = self.layout
30 pie = layout.menu_pie()
31 # 4 - LEFT
32 pie.operator("screen.frame_jump", text="Jump REW", icon='REW').end = False
33 # 6 - RIGHT
34 pie.operator("screen.frame_jump", text="Jump FF", icon='FF').end = True
35 # 2 - BOTTOM
36 pie.operator("screen.animation_play", text="Reverse", icon='PLAY_REVERSE').reverse = True
37 # 8 - TOP
38 if not context.screen.is_animation_playing: # Play / Pause
39 pie.operator("screen.animation_play", text="Play", icon='PLAY')
40 else:
41 pie.operator("screen.animation_play", text="Stop", icon='PAUSE')
42 # 7 - TOP - LEFT
43 pie.operator("screen.keyframe_jump", text="Previous FR", icon='PREV_KEYFRAME').next = False
44 # 9 - TOP - RIGHT
45 pie.operator("screen.keyframe_jump", text="Next FR", icon='NEXT_KEYFRAME').next = True
46 # 1 - BOTTOM - LEFT
47 pie.operator("insert.autokeyframe", text="Auto Keyframe", icon='REC')
48 # 3 - BOTTOM - RIGHT
49 pie.menu("VIEW3D_MT_object_animation", text="Keyframe Menu", icon="KEYINGSET")
52 # Insert Auto Keyframe
53 class PIE_OT_InsertAutoKeyframe(Operator):
54 bl_idname = "insert.autokeyframe"
55 bl_label = "Insert Auto Keyframe"
56 bl_description = "Toggle Insert Auto Keyframe"
57 bl_options = {'REGISTER', 'UNDO'}
59 def execute(self, context):
60 ts = context.tool_settings
62 ts.use_keyframe_insert_auto ^= 1
64 for area in context.screen.areas:
65 if area.type == 'TIMELINE':
66 area.tag_redraw()
68 return {'FINISHED'}
71 classes = (
72 PIE_MT_PieAnimation,
73 PIE_OT_InsertAutoKeyframe
76 addon_keymaps = []
79 def register():
80 for cls in classes:
81 bpy.utils.register_class(cls)
83 wm = bpy.context.window_manager
84 if wm.keyconfigs.addon:
85 # Animation
86 km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal')
87 kmi = km.keymap_items.new('wm.call_menu_pie', 'SPACE', 'PRESS', shift=True)
88 kmi.properties.name = "PIE_MT_animation"
89 addon_keymaps.append((km, kmi))
92 def unregister():
93 for cls in classes:
94 bpy.utils.unregister_class(cls)
96 wm = bpy.context.window_manager
97 kc = wm.keyconfigs.addon
98 if kc:
99 for km, kmi in addon_keymaps:
100 km.keymap_items.remove(kmi)
101 addon_keymaps.clear()
104 if __name__ == "__main__":
105 register()