Expose keymaps
1.7.6 - ui: expose (almost) all keymap added by the addon to allow user for customize/disable as needed - ui: changed some namesgpv2
parent
44ccb3d146
commit
204553ed47
|
@ -1,5 +1,10 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
1.7.6
|
||||||
|
|
||||||
|
- ui: expose (almost) all keymap added by the addon to allow user for customize/disable as needed
|
||||||
|
- ui: changed some names
|
||||||
|
|
||||||
1.7.5
|
1.7.5
|
||||||
|
|
||||||
- feat: Select/set by color and by prefix now works on every displayed dopesheet layer (and react correctly to filters)
|
- feat: Select/set by color and by prefix now works on every displayed dopesheet layer (and react correctly to filters)
|
||||||
|
|
|
@ -4,6 +4,8 @@ from bpy.types import Operator
|
||||||
|
|
||||||
def get_layer_list(self, context):
|
def get_layer_list(self, context):
|
||||||
'''return (identifier, name, description) of enum content'''
|
'''return (identifier, name, description) of enum content'''
|
||||||
|
if not context.object:
|
||||||
|
return
|
||||||
return [(l.info, l.info, '') for l in context.object.data.layers if l != context.object.data.layers.active]
|
return [(l.info, l.info, '') for l in context.object.data.layers if l != context.object.data.layers.active]
|
||||||
# try:
|
# try:
|
||||||
# except:
|
# except:
|
||||||
|
|
|
@ -171,13 +171,14 @@ def register_keymaps():
|
||||||
addon = bpy.context.window_manager.keyconfigs.addon
|
addon = bpy.context.window_manager.keyconfigs.addon
|
||||||
km = addon.keymaps.new(name = "Screen", space_type = "EMPTY")
|
km = addon.keymaps.new(name = "Screen", space_type = "EMPTY")
|
||||||
|
|
||||||
kmi = km.keymap_items.new('screen.gp_keyframe_jump', type=pref.kfj_next_keycode, value="PRESS", alt=pref.kfj_next_alt, ctrl=pref.kfj_next_ctrl, shift=pref.kfj_next_shift, any=False)
|
|
||||||
kmi.properties.next = True
|
|
||||||
addon_keymaps.append((km, kmi))
|
|
||||||
kmi = km.keymap_items.new('screen.gp_keyframe_jump', type=pref.kfj_prev_keycode, value="PRESS", alt=pref.kfj_prev_alt, ctrl=pref.kfj_prev_ctrl, shift=pref.kfj_prev_shift, any=False)
|
kmi = km.keymap_items.new('screen.gp_keyframe_jump', type=pref.kfj_prev_keycode, value="PRESS", alt=pref.kfj_prev_alt, ctrl=pref.kfj_prev_ctrl, shift=pref.kfj_prev_shift, any=False)
|
||||||
kmi.properties.next = False
|
kmi.properties.next = False
|
||||||
addon_keymaps.append((km, kmi))
|
addon_keymaps.append((km, kmi))
|
||||||
|
|
||||||
|
kmi = km.keymap_items.new('screen.gp_keyframe_jump', type=pref.kfj_next_keycode, value="PRESS", alt=pref.kfj_next_alt, ctrl=pref.kfj_next_ctrl, shift=pref.kfj_next_shift, any=False)
|
||||||
|
kmi.properties.next = True
|
||||||
|
addon_keymaps.append((km, kmi))
|
||||||
|
|
||||||
def unregister_keymaps():
|
def unregister_keymaps():
|
||||||
# print('UNBIND CANVAS ROTATE KEYMAPS')#Dbg
|
# print('UNBIND CANVAS ROTATE KEYMAPS')#Dbg
|
||||||
for km, kmi in addon_keymaps:
|
for km, kmi in addon_keymaps:
|
||||||
|
|
|
@ -8,7 +8,7 @@ from .utils import get_gp_draw_plane, location_to_region, region_to_location
|
||||||
|
|
||||||
class GP_OT_pick_closest_layer(Operator):
|
class GP_OT_pick_closest_layer(Operator):
|
||||||
bl_idname = "gp.pick_closest_layer"
|
bl_idname = "gp.pick_closest_layer"
|
||||||
bl_label = "Active Closest Stroke Layer"
|
bl_label = "Get Closest Stroke Layer"
|
||||||
bl_description = "Pick closest stroke layer"
|
bl_description = "Pick closest stroke layer"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
|
|
@ -151,10 +151,6 @@ def register():
|
||||||
bpy.utils.register_class(GPTB_OT_sticky_cutter)
|
bpy.utils.register_class(GPTB_OT_sticky_cutter)
|
||||||
# register_keymaps()
|
# register_keymaps()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
if not bpy.app.background:
|
if not bpy.app.background:
|
||||||
# unregister_keymaps()
|
# unregister_keymaps()
|
||||||
|
|
123
__init__.py
123
__init__.py
|
@ -15,7 +15,7 @@ bl_info = {
|
||||||
"name": "GP toolbox",
|
"name": "GP toolbox",
|
||||||
"description": "Set of tools for Grease Pencil in animation production",
|
"description": "Set of tools for Grease Pencil in animation production",
|
||||||
"author": "Samuel Bernou, Christophe Seux",
|
"author": "Samuel Bernou, Christophe Seux",
|
||||||
"version": (1, 7, 5),
|
"version": (1, 7, 6),
|
||||||
"blender": (2, 91, 0),
|
"blender": (2, 91, 0),
|
||||||
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
|
@ -125,7 +125,8 @@ class GPTB_prefs(bpy.types.AddonPreferences):
|
||||||
|
|
||||||
pref_tabs : EnumProperty(
|
pref_tabs : EnumProperty(
|
||||||
items=(('PREF', "Preferences", "Change some preferences of the modal"),
|
items=(('PREF', "Preferences", "Change some preferences of the modal"),
|
||||||
('MAN_OPS', "Operator", "Operator to add Manually"),
|
('KEYS', "Shortcuts", "Customize addon shortcuts"),
|
||||||
|
('MAN_OPS', "Operators", "Operator to add Manually"),
|
||||||
('CHECKS', "Check List", "Customise what should happend when hitting 'check fix' button"),
|
('CHECKS', "Check List", "Customise what should happend when hitting 'check fix' button"),
|
||||||
# ('UPDATE', "Update", "Check and apply updates"),
|
# ('UPDATE', "Update", "Check and apply updates"),
|
||||||
# ('TUTO', "Tutorial", "How to use the tool"),
|
# ('TUTO', "Tutorial", "How to use the tool"),
|
||||||
|
@ -375,44 +376,102 @@ class GPTB_prefs(bpy.types.AddonPreferences):
|
||||||
box.prop(self, 'playblast_auto_open_folder')
|
box.prop(self, 'playblast_auto_open_folder')
|
||||||
|
|
||||||
# box.separator()## Keyframe jumper
|
# box.separator()## Keyframe jumper
|
||||||
box = layout.box()
|
|
||||||
box.label(text='Keyframe Jump options:')
|
|
||||||
|
|
||||||
box.prop(self, "kfj_use_shortcut", text='Bind shortcuts')
|
## Keyframe jump now displayed in Shortcut Tab
|
||||||
if self.kfj_use_shortcut:
|
# box = layout.box()
|
||||||
prompt = '[TYPE SHORTCUT TO USE (can be with modifiers)]'
|
# box.label(text='Keyframe Jump options:')
|
||||||
if self.kfj_prev_keycode:
|
|
||||||
mods = '+'.join([m for m, b in [('Ctrl', self.kfj_prev_ctrl), ('Shift', self.kfj_prev_shift), ('Alt', self.kfj_prev_alt)] if b])
|
|
||||||
text = f'{mods}+{self.kfj_prev_keycode}' if mods else self.kfj_prev_keycode
|
|
||||||
text = f'Jump Keyframe Prev: {text} (Click to change)'
|
|
||||||
else:
|
|
||||||
text = prompt
|
|
||||||
ops = box.operator('prefs.shortcut_rebinder', text=text, icon='FILE_REFRESH')
|
|
||||||
ops.s_keycode = 'kfj_prev_keycode'
|
|
||||||
ops.s_ctrl = 'kfj_prev_ctrl'
|
|
||||||
ops.s_shift = 'kfj_prev_shift'
|
|
||||||
ops.s_alt = 'kfj_prev_alt'
|
|
||||||
|
|
||||||
if self.kfj_next_keycode:
|
# box.prop(self, "kfj_use_shortcut", text='Bind shortcuts')
|
||||||
mods = '+'.join([m for m, b in [('Ctrl', self.kfj_next_ctrl), ('Shift', self.kfj_next_shift), ('Alt', self.kfj_next_alt)] if b])
|
# if self.kfj_use_shortcut:
|
||||||
text = f'{mods}+{self.kfj_next_keycode}' if mods else self.kfj_next_keycode
|
# prompt = '[TYPE SHORTCUT TO USE (can be with modifiers)]'
|
||||||
text = f'Jump Keyframe Next: {text} (Click to change)'
|
# if self.kfj_prev_keycode:
|
||||||
else:
|
# mods = '+'.join([m for m, b in [('Ctrl', self.kfj_prev_ctrl), ('Shift', self.kfj_prev_shift), ('Alt', self.kfj_prev_alt)] if b])
|
||||||
text = prompt
|
# text = f'{mods}+{self.kfj_prev_keycode}' if mods else self.kfj_prev_keycode
|
||||||
ops = box.operator('prefs.shortcut_rebinder', text=text, icon='FILE_REFRESH')
|
# text = f'Jump Keyframe Prev: {text} (Click to change)'
|
||||||
ops.s_keycode = 'kfj_next_keycode'
|
# else:
|
||||||
ops.s_ctrl = 'kfj_next_ctrl'
|
# text = prompt
|
||||||
ops.s_shift = 'kfj_next_shift'
|
# ops = box.operator('prefs.shortcut_rebinder', text=text, icon='FILE_REFRESH')
|
||||||
ops.s_alt = 'kfj_next_alt'
|
# ops.s_keycode = 'kfj_prev_keycode'
|
||||||
|
# ops.s_ctrl = 'kfj_prev_ctrl'
|
||||||
|
# ops.s_shift = 'kfj_prev_shift'
|
||||||
|
# ops.s_alt = 'kfj_prev_alt'
|
||||||
|
|
||||||
|
# if self.kfj_next_keycode:
|
||||||
|
# mods = '+'.join([m for m, b in [('Ctrl', self.kfj_next_ctrl), ('Shift', self.kfj_next_shift), ('Alt', self.kfj_next_alt)] if b])
|
||||||
|
# text = f'{mods}+{self.kfj_next_keycode}' if mods else self.kfj_next_keycode
|
||||||
|
# text = f'Jump Keyframe Next: {text} (Click to change)'
|
||||||
|
# else:
|
||||||
|
# text = prompt
|
||||||
|
# ops = box.operator('prefs.shortcut_rebinder', text=text, icon='FILE_REFRESH')
|
||||||
|
# ops.s_keycode = 'kfj_next_keycode'
|
||||||
|
# ops.s_ctrl = 'kfj_next_ctrl'
|
||||||
|
# ops.s_shift = 'kfj_next_shift'
|
||||||
|
# ops.s_alt = 'kfj_next_alt'
|
||||||
|
|
||||||
else:
|
# else:
|
||||||
box.label(text="No Jump hotkey auto set. Following operators needs to be set manually", icon="ERROR")
|
# box.label(text="No Jump hotkey auto set. Following operators needs to be set manually", icon="ERROR")
|
||||||
box.label(text="screen.gp_keyframe_jump - preferably in 'screen' category to jump from any editor")
|
# box.label(text="screen.gp_keyframe_jump - preferably in 'screen' category to jump from any editor")
|
||||||
|
|
||||||
box = layout.box()
|
box = layout.box()
|
||||||
box.label(text='Tools options:')
|
box.label(text='Tools options:')
|
||||||
box.prop(self, 'use_precise_eraser')
|
box.prop(self, 'use_precise_eraser')
|
||||||
|
|
||||||
|
if self.pref_tabs == 'KEYS':
|
||||||
|
# layout.label(text='Shortcuts :')
|
||||||
|
box = layout.box()
|
||||||
|
box.label(text='Shortcuts added by GP toolbox with context scope:')
|
||||||
|
## not available directly :
|
||||||
|
## keymaps.addon_keymaps <<- one two three on sculpt, not exposed
|
||||||
|
## OP_temp_cutter # not active by defaut
|
||||||
|
## TOOL_eraser_brush.addon_keymaps # has a checkbox in
|
||||||
|
|
||||||
|
prev_key_category = ''
|
||||||
|
kmi_see_list = []
|
||||||
|
for kms in [
|
||||||
|
OP_keyframe_jump.addon_keymaps,
|
||||||
|
OP_copy_paste.addon_keymaps,
|
||||||
|
OP_breakdowner.breakdowner_addon_keymaps,
|
||||||
|
OP_key_duplicate_send.addon_keymaps,
|
||||||
|
OP_layer_picker.addon_keymaps,
|
||||||
|
OP_material_picker.addon_keymaps,
|
||||||
|
]:
|
||||||
|
|
||||||
|
ct = 0
|
||||||
|
for akm, akmi in kms:
|
||||||
|
km = bpy.context.window_manager.keyconfigs.user.keymaps.get(akm.name)
|
||||||
|
if not km:
|
||||||
|
continue
|
||||||
|
key_category = km.name
|
||||||
|
# kmi = km.keymap_items.get(akmi.idname) # get only first idname when multiple entry
|
||||||
|
kmi = None
|
||||||
|
|
||||||
|
## numbering hack, need a better way to find multi idname user keymaps
|
||||||
|
id_ct = 0
|
||||||
|
for km_item in km.keymap_items:
|
||||||
|
if km_item.idname == akmi.idname:
|
||||||
|
if ct > id_ct:
|
||||||
|
id_ct +=1
|
||||||
|
continue
|
||||||
|
|
||||||
|
kmi = km_item
|
||||||
|
ct += 1
|
||||||
|
break
|
||||||
|
|
||||||
|
if not kmi:
|
||||||
|
continue
|
||||||
|
|
||||||
|
## show keymap category (ideally grouped by category)
|
||||||
|
if not prev_key_category:
|
||||||
|
if key_category:
|
||||||
|
box.label(text=key_category)
|
||||||
|
elif key_category and key_category != prev_key_category: # check if has changed singe
|
||||||
|
box.label(text=key_category)
|
||||||
|
|
||||||
|
draw_kmi(km, kmi, box)
|
||||||
|
prev_key_category = key_category
|
||||||
|
|
||||||
|
box.separator()
|
||||||
|
|
||||||
if self.pref_tabs == 'MAN_OPS':
|
if self.pref_tabs == 'MAN_OPS':
|
||||||
# layout.separator()## notes
|
# layout.separator()## notes
|
||||||
# layout.label(text='Notes:')
|
# layout.label(text='Notes:')
|
||||||
|
|
7
utils.py
7
utils.py
|
@ -756,7 +756,9 @@ def show_message_box(_message = "", _title = "Message Box", _icon = 'INFO'):
|
||||||
def draw_kmi(km, kmi, layout):
|
def draw_kmi(km, kmi, layout):
|
||||||
map_type = kmi.map_type
|
map_type = kmi.map_type
|
||||||
|
|
||||||
# col = _indented_layout(layout)
|
## col = _indented_layout(layout)
|
||||||
|
# layout.label(text=f'{km.name} - {km.space_type} - {km.region_type}') # debug
|
||||||
|
# layout.label(text=f'{km.name}')
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
if kmi.show_expanded:
|
if kmi.show_expanded:
|
||||||
col = col.column(align=True)
|
col = col.column(align=True)
|
||||||
|
@ -799,7 +801,7 @@ def draw_kmi(km, kmi, layout):
|
||||||
if (not kmi.is_user_defined) and kmi.is_user_modified:
|
if (not kmi.is_user_defined) and kmi.is_user_modified:
|
||||||
row.operator("preferences.keyitem_restore", text="", icon='BACK').item_id = kmi.id
|
row.operator("preferences.keyitem_restore", text="", icon='BACK').item_id = kmi.id
|
||||||
else:
|
else:
|
||||||
pass ### NO REMOVB
|
pass ### NO REMOVE
|
||||||
# row.operator(
|
# row.operator(
|
||||||
# "preferences.keyitem_remove",
|
# "preferences.keyitem_remove",
|
||||||
# text="",
|
# text="",
|
||||||
|
@ -848,7 +850,6 @@ def draw_kmi(km, kmi, layout):
|
||||||
# Operator properties
|
# Operator properties
|
||||||
box.template_keymap_item_properties(kmi)
|
box.template_keymap_item_properties(kmi)
|
||||||
|
|
||||||
|
|
||||||
## Modal key maps attached to this operator
|
## Modal key maps attached to this operator
|
||||||
# if not km.is_modal:
|
# if not km.is_modal:
|
||||||
# kmm = kc.keymaps.find_modal(kmi.idname)
|
# kmm = kc.keymaps.find_modal(kmi.idname)
|
||||||
|
|
Loading…
Reference in New Issue