-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeymaps.py
63 lines (48 loc) · 2.99 KB
/
keymaps.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
import bpy
addon_keymaps = []
# kmi_defs entry: (identifier, key, action, CTRL, SHIFT, ALT, OSKEY , props, nice name)
# props entry: ,((property name, property value), (property name, property value), ...),....
kmi_defs = (
# Brushes Popup [Image Paint] with: W.
(('Image Paint', 'EMPTY'), "view3d.brush_popup", 'W', 'PRESS', False, False, False, False, None, "Brushes Popup"),
# Convenience Palette Popup
(('Image Paint', 'EMPTY'), "d2p.palette_popup", 'P', 'PRESS', False, False, False, False, None, "Palette Popup"),
# 2D Editor Popup with Active Paint Slot with Shift + Alt + W
(('Image Paint', 'EMPTY'), "paint.display_active_slot", 'W', 'PRESS', False, True, True, False, None, "2D Editor Popup"),
# Slots Popup [Image Paint] with: Shift + W.
(('Image Paint', 'EMPTY'), "view3d.projectpaint", 'W', 'PRESS', False, True, False, False, None, "Slots Popup"),
# Textures Popup [Image Paint] with: Alt + W.
(('Image Paint', 'EMPTY'), "view3d.texture_popup", 'W', 'PRESS', False, False, True, False, None, "Textures Popup"),
# Toggle add/multily modes [Image Paint] with: D.
(('Image Paint', 'EMPTY'), "paint.toggle_add_multiply", 'D', 'PRESS', False, False, False, False, None, "Toggle add/multiply modes"),
# Toggle color/soft light modes [Image Paint] with: Ctrl + D
(('Image Paint', 'EMPTY'), "paint.toggle_color_soft_light_screen", 'D', 'PRESS', False, True, False, False, None, "Toggle color/soft light modes"),
# Toggle Alpha modes [Image Paint] with: A.
(('Image Paint', 'EMPTY'), "paint.toggle_alpha_mode", 'A', 'PRESS', False, False, False, False, None, "Toggle Alpha modes"),
# Re-init Mix mode [Image Paint] with: Alt + D.
(('Image Paint', 'EMPTY'), "paint.init_blend_mode", 'D', 'PRESS', False, False, True, False, None, "Re-init Mix mode"),
# Flip Brush Gradient in Brush [Image Paint] with: ,
(('Image Paint', 'EMPTY'), "brush.flip_gradient", 'K', 'PRESS', False, False, False, False, None, "Flip Brush Gradient")
)
def register():
global addon_keymaps
kc = bpy.context.window_manager.keyconfigs.addon
if kc:
for (spacetype, identifier, key, action, CTRL, SHIFT, ALT, OS_KEY, props, nicename) in kmi_defs:
if spacetype[0] in bpy.context.window_manager.keyconfigs.addon.keymaps.keys():
if spacetype[1] in kc.keymaps[spacetype[0]].space_type:
km = kc.keymaps[spacetype[0]]
else:
km = kc.keymaps.new(name=spacetype[0], space_type=spacetype[1])
kmi = km.keymap_items.new(identifier, key, action, ctrl=CTRL, shift=SHIFT, alt=ALT, oskey=OS_KEY)
if props:
for prop, value in props:
setattr(kmi.properties, prop, value)
addon_keymaps.append((km, kmi))
# keymaps
#Register_Shortcuts()
def unregister():
global addon_keymaps
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()