[Bf-blender-cvs] [83975965a79] master: Keymap: RMB select option to place cursor on Alt-LMB

Campbell Barton noreply at git.blender.org
Thu Sep 23 14:11:09 CEST 2021


Commit: 83975965a797642eb0aece30c6a887061b34978d
Author: Campbell Barton
Date:   Thu Sep 23 22:06:51 2021 +1000
Branches: master
https://developer.blender.org/rB83975965a797642eb0aece30c6a887061b34978d

Keymap: RMB select option to place cursor on Alt-LMB

This allows most tools to activate on press, removing a small but
noticeable distance between the initial press and detection of a drag
event.

Gizmo tweak no longer actives when Alt is held, to avoid conflicting
with cursor placement.

This has the advantage that the gizmo doesn't get in the way when Alt
is used for activating tools or placing the cursor.

===================================================================

M	release/scripts/presets/keyconfig/Blender.py
M	release/scripts/presets/keyconfig/keymap_data/blender_default.py

===================================================================

diff --git a/release/scripts/presets/keyconfig/Blender.py b/release/scripts/presets/keyconfig/Blender.py
index 8a937b4d4b1..eb395dbc3b4 100644
--- a/release/scripts/presets/keyconfig/Blender.py
+++ b/release/scripts/presets/keyconfig/Blender.py
@@ -85,6 +85,8 @@ class Prefs(bpy.types.KeyConfigPreferences):
         default=False,
         update=update_fn,
     )
+    # NOTE: expose `use_alt_tool` and `use_alt_cursor` as two options in the UI
+    # as the tool-tips and titles are different enough depending on RMB/LMB select.
     use_alt_tool: BoolProperty(
         name="Alt Tool Access",
         description=(
@@ -93,6 +95,16 @@ class Prefs(bpy.types.KeyConfigPreferences):
         default=False,
         update=update_fn,
     )
+    use_alt_cursor: BoolProperty(
+        name="Alt Cursor Access",
+        description=(
+            "Hold Alt-LMB to place the Cursor (instead of LMB), allows tools to activate on press instead of drag"
+        ),
+        default=False,
+        update=update_fn,
+    )
+    # end note.
+
     use_select_all_toggle: BoolProperty(
         name="Select All Toggles",
         description=(
@@ -219,6 +231,8 @@ class Prefs(bpy.types.KeyConfigPreferences):
         row.prop(self, "use_alt_click_leader")
         if is_select_left:
             row.prop(self, "use_alt_tool")
+        else:
+            row.prop(self, "use_alt_cursor")
         row = sub.row()
         row.prop(self, "use_select_all_toggle")
         row.prop(self, "use_key_activate_tools", text="Key Activates Tools")
@@ -269,7 +283,7 @@ def load():
             use_v3d_shade_ex_pie=kc_prefs.use_v3d_shade_ex_pie,
             use_gizmo_drag=(is_select_left and kc_prefs.gizmo_action == 'DRAG'),
             use_fallback_tool=(True if is_select_left else (kc_prefs.rmb_action == 'FALLBACK_TOOL')),
-            use_alt_tool=(kc_prefs.use_alt_tool and is_select_left),
+            use_alt_tool_or_cursor=kc_prefs.use_alt_tool if is_select_left else kc_prefs.use_alt_cursor,
             use_alt_click_leader=kc_prefs.use_alt_click_leader,
             use_pie_click_drag=kc_prefs.use_pie_click_drag,
         ),
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 5ecbe7715e3..4b15cdc25d3 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -31,6 +31,8 @@ class Params:
         "action_tweak",
         "tool_mouse",
         "tool_tweak",
+        "tool_maybe_tweak",
+        "tool_maybe_tweak_value",
         "context_menu_event",
         "cursor_set_event",
         "cursor_tweak_event",
@@ -74,6 +76,8 @@ class Params:
         "use_fallback_tool_rmb",
         # Convenience for: `'CLICK' if params.use_fallback_tool_rmb else params.select_mouse_value`.
         "select_mouse_value_fallback",
+        # Convenience for: `{"type": params.tool_maybe_tweak, "value": params.tool_maybe_tweak_value}`.
+        "tool_maybe_tweak_event",
     )
 
     def __init__(
@@ -92,7 +96,7 @@ class Params:
             use_v3d_tab_menu=False,
             use_v3d_shade_ex_pie=False,
             use_v3d_mmb_pan=False,
-            use_alt_tool=False,
+            use_alt_tool_or_cursor=False,
             use_alt_click_leader=False,
             use_pie_click_drag=False,
             v3d_tilde_action='VIEW',
@@ -111,8 +115,21 @@ class Params:
             self.action_tweak = 'EVT_TWEAK_L'
             self.tool_mouse = 'LEFTMOUSE'
             self.tool_tweak = 'EVT_TWEAK_L'
+            if use_alt_tool_or_cursor:
+                self.tool_maybe_tweak = 'LEFTMOUSE'
+                self.tool_maybe_tweak_value = 'PRESS'
+            else:
+                self.tool_maybe_tweak = 'EVT_TWEAK_L'
+                self.tool_maybe_tweak_value = 'ANY'
+
             self.context_menu_event = {"type": 'W', "value": 'PRESS'}
-            self.cursor_set_event = {"type": 'LEFTMOUSE', "value": 'CLICK'}
+
+            # Use the "cursor" functionality for RMB select.
+            if use_alt_tool_or_cursor:
+                self.cursor_set_event = {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True}
+            else:
+                self.cursor_set_event = {"type": 'LEFTMOUSE', "value": 'CLICK'}
+
             self.cursor_tweak_event = None
             self.use_fallback_tool = use_fallback_tool
             self.use_fallback_tool_rmb = use_fallback_tool
@@ -129,6 +146,8 @@ class Params:
             self.action_tweak = 'EVT_TWEAK_R'
             self.tool_mouse = 'LEFTMOUSE'
             self.tool_tweak = 'EVT_TWEAK_L'
+            self.tool_maybe_tweak = 'EVT_TWEAK_L'
+            self.tool_maybe_tweak_value = 'ANY'
 
             if self.legacy:
                 self.context_menu_event = {"type": 'W', "value": 'PRESS'}
@@ -141,7 +160,8 @@ class Params:
             self.use_fallback_tool_rmb = False
             self.select_mouse_value_fallback = self.select_mouse_value
 
-            if use_alt_tool:
+            # Use the "tool" functionality for LMB select.
+            if use_alt_tool_or_cursor:
                 # Allow `Alt` to be pressed or not.
                 self.tool_modifier = {"alt": -1}
             else:
@@ -168,6 +188,9 @@ class Params:
         else:
             self.pie_value = 'CLICK_DRAG'
 
+        # Convenience variables.
+        self.tool_maybe_tweak_event = {"type": self.tool_maybe_tweak, "value": self.tool_maybe_tweak_value}
+
 
 # ------------------------------------------------------------------------------
 # Constants
@@ -188,6 +211,13 @@ def _fallback_id(text, fallback):
     return text
 
 
+def any_except(*args):
+    mod = {"ctrl": -1, "alt": -1, "shift": -1, "oskey": -1}
+    for arg in args:
+        del mod[arg]
+    return mod
+
+
 # ------------------------------------------------------------------------------
 # Keymap Item Wrappers
 
@@ -300,20 +330,23 @@ def _template_items_object_subdivision_set():
 
 def _template_items_gizmo_tweak_value():
     return [
-        ("gizmogroup.gizmo_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+        ("gizmogroup.gizmo_tweak",
+         {"type": 'LEFTMOUSE', "value": 'PRESS', **any_except("alt")}, None),
     ]
 
 
 def _template_items_gizmo_tweak_value_click_drag():
     return [
-        ("gizmogroup.gizmo_tweak", {"type": 'LEFTMOUSE', "value": 'CLICK', "any": True}, None),
-        ("gizmogroup.gizmo_tweak", {"type": 'EVT_TWEAK_L', "value": 'ANY', "any": True}, None),
+        ("gizmogroup.gizmo_tweak",
+         {"type": 'LEFTMOUSE', "value": 'CLICK', **any_except("alt")}, None),
+        ("gizmogroup.gizmo_tweak",
+         {"type": 'EVT_TWEAK_L', "value": 'ANY', **any_except("alt")}, None),
     ]
 
 
 def _template_items_gizmo_tweak_value_drag():
     return [
-        ("gizmogroup.gizmo_tweak", {"type": 'EVT_TWEAK_L', "value": 'ANY', "any": True}, None),
+        ("gizmogroup.gizmo_tweak", {"type": 'EVT_TWEAK_L', "value": 'ANY', **any_except("alt")}, None),
     ]
 
 
@@ -6046,7 +6079,7 @@ def km_generic_tool_annotate_line(params):
         "Generic Tool: Annotate Line",
         {"space_type": 'EMPTY', "region_type": 'WINDOW'},
         {"items": [
-            ("gpencil.annotate", {"type": params.tool_tweak, "value": 'ANY'},
+            ("gpencil.annotate", params.tool_maybe_tweak_event,
              {"properties": [("mode", 'DRAW_STRAIGHT'), ("wait_for_input", False)]}),
             ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
              {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
@@ -6095,8 +6128,12 @@ def km_image_editor_tool_uv_cursor(params):
         "Image Editor Tool: Uv, Cursor",
         {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
         {"items": [
-            ("uv.cursor_set", {"type": params.tool_mouse, "value": 'PRESS'}, None),
-            ("transform.translate", {"type": params.tool_tweak, "value": 'ANY'},
+            ("uv.cursor_set",
+             {"type": params.tool_mouse, "value": 'PRESS'},
+             None),
+            # Don't use `tool_maybe_tweak_event` since it conflicts with `PRESS` that places the cursor.
+            ("transform.translate",
+             {"type": params.tool_tweak, "value": 'ANY'},
              {"properties": [("release_confirm", True), ("cursor_transform", True)]}),
         ]},
     )
@@ -6121,8 +6158,7 @@ def km_image_editor_tool_uv_select_box(params, *, fallback):
         {"items": [
             *([] if (fallback and not params.use_fallback_tool) else _template_items_tool_select_actions_simple(
                 "uv.select_box",
-                type=params.select_tweak if fallback else params.tool_tweak,
-                value='ANY')),
+                **({"type": params.select_tweak, "value": 'ANY'} if fallback else params.tool_maybe_tweak_event))),
             *_template_uv_select_for_fallback(params, fallback),
         ]},
     )
@@ -6151,9 +6187,7 @@ def km_image_editor_tool_uv_select_lasso(params, *, fallback):
         {"items": [
             *([] if (fallback and not params.use_fallback_tool) else _template_items_tool_select_actions_simple(
                 "uv.select_lasso",
-                type=params.select_tweak if fallback else params.tool_tweak,
-                value='ANY')
-              ),
+                **({"type": params.select_tweak, "value": 'ANY'} if fallback else params.tool_maybe_tweak_event))),
             *_template_uv_select_for_fallback(params, fallback),
         ]},
     )
@@ -6164,7 +6198,7 @@ def km_image_editor_tool_uv_rip_region(params):
         "Image Editor Tool: Uv, Rip Region",
         {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
         {"items": [
-            ("uv.rip_move", {"type": params.tool_tweak, "value": 'ANY', **params.tool_modifier},
+            ("uv.rip_move", {**params.tool_maybe_tweak_event, **params.tool_modifier},
              {"properties": [("TRANSFORM_OT_translate", [("release_confirm", True)])]}),
         ]},
     )
@@ -6194,7 +6228,7 @@ def km_image_editor_tool_uv_move(params):
         "Image Editor Tool: Uv, Move",
         {"space_type": 'IMAGE_EDITOR', "re

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list