Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-11-22 03:34:05 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-22 03:35:46 +0300
commit553307bec1c08be3e5ba5fa6b0139320de06604e (patch)
tree8e4994e021f63b186e120ddcd3a750543f4ff4e7
parent120be7740d3c5290e861d540a14e6999cfd74a62 (diff)
Tool System: auto-assign A-Z keys for toolbar popup
Assign keys based on tool name when they're free, allows: Space-T for Transform, Space-A for Annotate.
-rw-r--r--release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
index 6966152776e..bfd49d667e2 100644
--- a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
+++ b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
@@ -275,6 +275,29 @@ def generate(context, space_type):
# Map all unmapped keys to numbers,
# while this is a bit strange it means users will not confuse regular key bindings to ordered bindings.
+ # First map A-Z.
+ kmi_type_alpha_char = [chr(i) for i in range(65, 91)]
+ kmi_type_alpha_args = {c: {"type": c} for c in kmi_type_alpha_char}
+ kmi_type_alpha_args_tuple = {c: dict_as_tuple(kmi_type_alpha_args[c]) for c in kmi_type_alpha_char}
+ for item_container in items_all:
+ item, kmi_found, kmi_exist = item_container
+ if kmi_exist:
+ continue
+ kmi_type = item.text[0].upper()
+ kmi_tuple = kmi_type_alpha_args_tuple[kmi_type]
+ if kmi_tuple not in kmi_unique_args:
+ # print(kmi_tuple, item.text)
+ kmi_unique_args.add(kmi_tuple)
+ kmi = keymap.keymap_items.new(
+ idname="wm.tool_set_by_name",
+ value='PRESS',
+ **kmi_type_alpha_args[kmi_type],
+ )
+ kmi.properties.name = item.text
+ item_container[2] = kmi
+ kmi_unique_args.add(kmi_tuple)
+ del kmi_type_alpha_char, kmi_type_alpha_args, kmi_type_alpha_args_tuple
+
# Free events (last used first).
kmi_type_auto = ('ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE', 'ZERO')
# Map both numbers and num-pad.