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
|
||||
|
||||
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
|
||||
|
||||
- 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):
|
||||
'''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]
|
||||
# try:
|
||||
# except:
|
||||
|
|
|
@ -171,13 +171,14 @@ def register_keymaps():
|
|||
addon = bpy.context.window_manager.keyconfigs.addon
|
||||
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.properties.next = False
|
||||
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():
|
||||
# print('UNBIND CANVAS ROTATE KEYMAPS')#Dbg
|
||||
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):
|
||||
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_options = {"REGISTER", "UNDO"}
|
||||
|
||||
|
|
|
@ -151,10 +151,6 @@ def register():
|
|||
bpy.utils.register_class(GPTB_OT_sticky_cutter)
|
||||
# register_keymaps()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def unregister():
|
||||
if not bpy.app.background:
|
||||
# unregister_keymaps()
|
||||
|
|
123
__init__.py
123
__init__.py
|
@ -15,7 +15,7 @@ bl_info = {
|
|||
"name": "GP toolbox",
|
||||
"description": "Set of tools for Grease Pencil in animation production",
|
||||
"author": "Samuel Bernou, Christophe Seux",
|
||||
"version": (1, 7, 5),
|
||||
"version": (1, 7, 6),
|
||||
"blender": (2, 91, 0),
|
||||
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
||||
"warning": "",
|
||||
|
@ -125,7 +125,8 @@ class GPTB_prefs(bpy.types.AddonPreferences):
|
|||
|
||||
pref_tabs : EnumProperty(
|
||||
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"),
|
||||
# ('UPDATE', "Update", "Check and apply updates"),
|
||||
# ('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.separator()## Keyframe jumper
|
||||
box = layout.box()
|
||||
box.label(text='Keyframe Jump options:')
|
||||
|
||||
box.prop(self, "kfj_use_shortcut", text='Bind shortcuts')
|
||||
if self.kfj_use_shortcut:
|
||||
prompt = '[TYPE SHORTCUT TO USE (can be with modifiers)]'
|
||||
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'
|
||||
## Keyframe jump now displayed in Shortcut Tab
|
||||
# box = layout.box()
|
||||
# box.label(text='Keyframe Jump options:')
|
||||
|
||||
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'
|
||||
# box.prop(self, "kfj_use_shortcut", text='Bind shortcuts')
|
||||
# if self.kfj_use_shortcut:
|
||||
# prompt = '[TYPE SHORTCUT TO USE (can be with modifiers)]'
|
||||
# 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'
|
||||
|
||||
else:
|
||||
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")
|
||||
# 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:
|
||||
# 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 = layout.box()
|
||||
box.label(text='Tools options:')
|
||||
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':
|
||||
# layout.separator()## 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):
|
||||
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()
|
||||
if kmi.show_expanded:
|
||||
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:
|
||||
row.operator("preferences.keyitem_restore", text="", icon='BACK').item_id = kmi.id
|
||||
else:
|
||||
pass ### NO REMOVB
|
||||
pass ### NO REMOVE
|
||||
# row.operator(
|
||||
# "preferences.keyitem_remove",
|
||||
# text="",
|
||||
|
@ -848,7 +850,6 @@ def draw_kmi(km, kmi, layout):
|
|||
# Operator properties
|
||||
box.template_keymap_item_properties(kmi)
|
||||
|
||||
|
||||
## Modal key maps attached to this operator
|
||||
# if not km.is_modal:
|
||||
# kmm = kc.keymaps.find_modal(kmi.idname)
|
||||
|
|
Loading…
Reference in New Issue