Cleanup: strip trailing space
[blender-addons.git] / space_view3d_pie_menus / pie_animation_menu.py
blob5b9ae6bf02b93330f6a27d3eedadb576651043a0
1 # SPDX-FileCopyrightText: 2016-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 bl_info = {
6 "name": "Hotkey: 'Shift Spacebar'",
7 "description": "Pie menu for Timeline controls",
8 "author": "pitiwazou, meta-androcto",
9 "version": (0, 1, 1),
10 "blender": (2, 80, 0),
11 "location": "3D View",
12 "warning": "",
13 "doc_url": "",
14 "category": "Animation Pie"
17 import bpy
18 from bpy.types import (
19 Menu,
20 Operator,
23 # Pie Animation
26 class PIE_MT_PieAnimation(Menu):
27 bl_idname = "PIE_MT_animation"
28 bl_label = "Pie Animation"
30 def draw(self, context):
31 layout = self.layout
32 pie = layout.menu_pie()
33 # 4 - LEFT
34 pie.operator("screen.frame_jump", text="Jump REW", icon='REW').end = False
35 # 6 - RIGHT
36 pie.operator("screen.frame_jump", text="Jump FF", icon='FF').end = True
37 # 2 - BOTTOM
38 pie.operator("screen.animation_play", text="Reverse", icon='PLAY_REVERSE').reverse = True
39 # 8 - TOP
40 if not context.screen.is_animation_playing: # Play / Pause
41 pie.operator("screen.animation_play", text="Play", icon='PLAY')
42 else:
43 pie.operator("screen.animation_play", text="Stop", icon='PAUSE')
44 # 7 - TOP - LEFT
45 pie.operator("screen.keyframe_jump", text="Previous FR", icon='PREV_KEYFRAME').next = False
46 # 9 - TOP - RIGHT
47 pie.operator("screen.keyframe_jump", text="Next FR", icon='NEXT_KEYFRAME').next = True
48 # 1 - BOTTOM - LEFT
49 pie.operator("insert.autokeyframe", text="Auto Keyframe", icon='REC')
50 # 3 - BOTTOM - RIGHT
51 pie.menu("VIEW3D_MT_object_animation", text="Keyframe Menu", icon="KEYINGSET")
54 # Insert Auto Keyframe
55 class PIE_OT_InsertAutoKeyframe(Operator):
56 bl_idname = "insert.autokeyframe"
57 bl_label = "Insert Auto Keyframe"
58 bl_description = "Toggle Insert Auto Keyframe"
59 bl_options = {'REGISTER', 'UNDO'}
61 def execute(self, context):
62 ts = context.tool_settings
64 ts.use_keyframe_insert_auto ^= 1
66 for area in context.screen.areas:
67 if area.type == 'TIMELINE':
68 area.tag_redraw()
70 return {'FINISHED'}
73 classes = (
74 PIE_MT_PieAnimation,
75 PIE_OT_InsertAutoKeyframe
78 addon_keymaps = []
81 def register():
82 for cls in classes:
83 bpy.utils.register_class(cls)
85 wm = bpy.context.window_manager
86 if wm.keyconfigs.addon:
87 # Animation
88 km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal')
89 kmi = km.keymap_items.new('wm.call_menu_pie', 'SPACE', 'PRESS', shift=True)
90 kmi.properties.name = "PIE_MT_animation"
91 addon_keymaps.append((km, kmi))
94 def unregister():
95 for cls in classes:
96 bpy.utils.unregister_class(cls)
98 wm = bpy.context.window_manager
99 kc = wm.keyconfigs.addon
100 if kc:
101 for km, kmi in addon_keymaps:
102 km.keymap_items.remove(kmi)
103 addon_keymaps.clear()
106 if __name__ == "__main__":
107 register()