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>2020-01-21 15:50:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-01-21 15:50:24 +0300
commit79bd553f06283d7e30c76e3851c2444fa9a73ffb (patch)
treee0498cfac5a5691ec878a87cd678b5841f23c22d /release
parent40d71fc6428c462ca4d5eb35206baf334072497c (diff)
Industry Compatible Keymap: use MMB to access the active tool
Fallback tools are used on LMB, MMB accessed the active tool.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py49
1 files changed, 48 insertions, 1 deletions
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index 01db6994f37..ceca4687443 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -3669,7 +3669,7 @@ def km_generic_gizmo_maybe_drag(params):
# ------------------------------------------------------------------------------
# Full Configuration
-def generate_keymaps(params=None):
+def generate_keymaps_impl(params=None):
if params is None:
params = Params()
return [
@@ -3768,3 +3768,50 @@ def generate_keymaps(params=None):
km_3d_view_tool_scale(params),
]
+
+
+def keymap_transform_tool_mmb(keymap):
+ import re
+ # Any tool besides fallback tools.
+ re_fallback_tool = re.compile(
+ r".*\bTool:\s(?!"
+ r".*\bSelect Box$|"
+ r".*\bSelect Circle$|"
+ r".*\bSelect Lasso$|"
+ r".*\bTweak$)",
+ )
+ for km_name, km_args, km_content in keymap:
+ if re_fallback_tool.match(km_name):
+ km_items = km_content["items"]
+ km_items_new = []
+ for kmi in km_items:
+ ty = kmi[1]["type"]
+ if ty == 'LEFTMOUSE':
+ kmi = (kmi[0], kmi[1].copy(), kmi[2])
+ kmi[1]["type"] = 'MIDDLEMOUSE'
+ km_items_new.append(kmi)
+ elif ty == 'EVT_TWEAK_L':
+ kmi = (kmi[0], kmi[1].copy(), kmi[2])
+ kmi[1]["type"] = 'EVT_TWEAK_M'
+ km_items_new.append(kmi)
+ km_items.extend(km_items_new)
+
+
+def generate_keymaps(params=None):
+ import os
+ from bpy.utils import execfile
+ keymap = generate_keymaps_impl(params)
+
+ # Combine the key-map to support manipulating it, so we don't need to manually
+ # define key-map here just to manipulate them.
+ blender_default = execfile(
+ os.path.join(os.path.dirname(__file__), "blender_default.py"),
+ ).generate_keymaps()
+
+ keymap_existing_names = {km[0] for km in keymap}
+ keymap.extend([km for km in blender_default if km[0] not in keymap_existing_names])
+
+ # Manipulate the key-map.
+ keymap_transform_tool_mmb(keymap)
+
+ return keymap