forked from iBrushC/animextras
-
Notifications
You must be signed in to change notification settings - Fork 1
/
__init__.py
135 lines (103 loc) · 4.43 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Updated
# - Panel layout > updated to match 2.8 styling
# - Added cleaner eye toggles for past and future
# - Icons to some buttons
# Added
# - Option to work with linked rigs > needs work InBetween as we need to target Parent rig
# - In Front option > show mesh in front of onion skinning
# - Shortcuts > for easier and faster workflow
# - Addon preferences so shortcuts can be customized
# - Panel feedback when nothings is selected or wrong object
# Fixed
# - Possibly old onion skinning when another file is openened
# - Linked rigs and local object/mesh also show onion skinning
# Ideas
# - Auto update when working on posing > could be handy? > need fedback from real animators
# - Added option to do multiple objects > this would need merge of objects, not sure will still work properly
##################
## Initiation
##################
bl_info = {
"name": "AnimExtras",
"author": "Andrew Combs, Rombout Versluijs",
"version": (1, 1, 2),
"blender": (2, 80, 0),
"description": "True onion skinning",
"category": "Animation",
"wiki_url": "https://github.com/iBrushC/animextras",
"tracker_url": "https://github.com/iBrushC/animextras/issues"
}
import bpy
import rna_keymap_ui
from bpy.types import AddonPreferences
from .ons.gui import *
from .ons import ops
from .ons import registers
class ANMX_AddonPreferences(AddonPreferences):
""" Preference Settings Addon Panel"""
bl_idname = __name__
bl_label = "Addon Preferences"
bl_options = {'REGISTER', 'UNDO'}
def draw(self, context):
layout = self.layout
col = layout.column()
col.label(text = "Hotkeys:")
col.label(text = "Do NOT remove hotkeys, disable them instead!")
col.separator()
wm = bpy.context.window_manager
kc = wm.keyconfigs.user
col.separator()
km = kc.keymaps["3D View"]
kmi = registers.get_hotkey_entry_item(km, "anim_extras.update_onion","EXECUTE","tab")
if kmi:
col.context_pointer_set("keymap", km)
rna_keymap_ui.draw_kmi([], kc, km, kmi, col, 0)
else:
col.label(text = "Update Onion Object")
col.label(text = "restore hotkeys from interface tab")
col.separator()
kmi = registers.get_hotkey_entry_item(km, "anim_extras.toggle_onion","EXECUTE","tab")
if kmi:
col.context_pointer_set("keymap", km)
rna_keymap_ui.draw_kmi([], kc, km, kmi, col, 0)
else:
col.label(text = "Toggle Draw Onion")
col.label(text = "restore hotkeys from interface tab")
col.separator()
kmi = registers.get_hotkey_entry_item(km, "anim_extras.add_clear_onion","EXECUTE","tab")
if kmi:
col.context_pointer_set("keymap", km)
rna_keymap_ui.draw_kmi([], kc, km, kmi, col, 0)
else:
col.label(text = "Add / Clear Onion Object")
col.label(text = "restore hotkeys from interface tab")
col.separator()
addon_keymaps = []
classes = [ANMX_gui, ANMX_data, ANMX_set_onion, ANMX_draw_meshes, ANMX_clear_onion, ANMX_toggle_onion, ANMX_update_onion, ANMX_add_clear_onion, ANMX_AddonPreferences]
@persistent
def ANMX_clear_handler(scene):
ops.clear_active(clrRig=False)
# bpy.ops.anim_extras.draw_meshes('INVOKE_DEFAULT')
def register():
for c in classes:
bpy.utils.register_class(c)
bpy.types.Scene.anmx_data = bpy.props.PointerProperty(type=ANMX_data)
bpy.app.handlers.load_pre.append(ANMX_clear_handler)
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
km = kc.keymaps.new(name="3D View", space_type="VIEW_3D")
kmi = km.keymap_items.new("anim_extras.update_onion", "R", "PRESS", alt = True, shift = True)
addon_keymaps.append((km, kmi))
kmi = km.keymap_items.new("anim_extras.toggle_onion", "T", "PRESS", alt = True, shift = True)
addon_keymaps.append((km, kmi))
kmi = km.keymap_items.new("anim_extras.add_clear_onion", "C", "PRESS", alt = True, shift = True)
addon_keymaps.append((km, kmi))
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
bpy.app.handlers.load_pre.remove(ANMX_clear_handler)
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
if __name__ == "__main__":
register()