diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-09-21 10:55:43 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-09-21 11:14:11 +0300 |
commit | c9d9bfa84ad5cb985e3feccffa702b2f3cc2adf8 (patch) | |
tree | 9cefe8d45141127b71d11812e4023ae185f06271 /release/scripts/startup/bl_ui | |
parent | 52bfa750e74952ddd4e8223d92d21140831902a7 (diff) |
Keymap: preference for fallback-tool with RMB select
Expose a key-map preference "Fallback Tool (RMB)",
disabled by default.
The right mouse button uses the fallback tool
(currently visible selection tool in the toolbar),
instead of always tweaking.
When any selection tool is active, right mouse always tweaks.
To enable fallback selection on RMB, set the "Right Mouse Select Action"
to "Selection Tool".
Internal changes:
- Add fall-back key-maps, separate key-maps needed for when the tool is
run as a fall-back. This is needed so RMB-select can support fall-back
tools, so left-mouse can be used when it's the active tool and RMB
can be used as a fall-back action when another tool is active.
- Add options field to tools so tools without gizmos can enable the
full-back tool keymap.
- Support multiple key-maps for keymap handlers.
- Fall-back keymaps now co-exist with the tool-keymaps.
So both keymaps may be active at once - using different mouse buttons.
When gizmos are in use, a highlighted gizmo prioritizes the
tool-keymap over the fall-back keymap.
Resolves T83690.
Reviewed By: JulienKaspar
Ref D12493
Diffstat (limited to 'release/scripts/startup/bl_ui')
-rw-r--r-- | release/scripts/startup/bl_ui/space_toolsystem_common.py | 14 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_toolsystem_toolbar.py | 15 |
2 files changed, 27 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 28549098e51..1c3dbded083 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -118,6 +118,8 @@ ToolDef = namedtuple( "draw_settings", # Optional draw cursor. "draw_cursor", + # Various options, see: `bpy.types.WorkSpaceTool.setup` options argument. + "options", ) ) del namedtuple @@ -133,6 +135,7 @@ def from_dict(kw_args): "description": None, "icon": None, "cursor": None, + "options": None, "widget": None, "widget_properties": None, "keymap": None, @@ -536,6 +539,7 @@ class ToolSelectPanelHelper: visited.add(km_name) yield (km_name, cls.bl_space_type, 'WINDOW', []) + yield (km_name + " (fallback)", cls.bl_space_type, 'WINDOW', []) # ------------------------------------------------------------------------- # Layout Generators @@ -988,16 +992,22 @@ def _activate_by_item(context, space_type, item, index, *, as_fallback=False): gizmo_group = item.widget or "" + idname_fallback = (item_fallback and item_fallback.idname) or "" + keymap_fallback = (item_fallback and item_fallback.keymap and item_fallback.keymap[0]) or "" + if keymap_fallback: + keymap_fallback = keymap_fallback + " (fallback)" + tool.setup( idname=item.idname, keymap=item.keymap[0] if item.keymap is not None else "", cursor=item.cursor or 'DEFAULT', + options=item.options or set(), gizmo_group=gizmo_group, data_block=item.data_block or "", operator=item.operator or "", index=index, - idname_fallback=(item_fallback and item_fallback.idname) or "", - keymap_fallback=(item_fallback and item_fallback.keymap and item_fallback.keymap[0]) or "", + idname_fallback=idname_fallback, + keymap_fallback=keymap_fallback, ) if ( diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index c5191e80aef..a513ab4b2d4 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -105,6 +105,7 @@ class _defs_view3d_generic: icon="ops.generic.cursor", keymap="3D View Tool: Cursor", draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @ToolDef.from_fn @@ -143,6 +144,7 @@ class _defs_view3d_generic: icon="ops.view3d.ruler", widget="VIEW3D_GGT_ruler", keymap="3D View Tool: Measure", + options={'KEYMAP_FALLBACK'}, ) @@ -237,6 +239,7 @@ class _defs_annotate: cursor='PAINT_BRUSH', keymap="Generic Tool: Annotate", draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @ToolDef.from_fn.with_args(draw_settings=draw_settings_common) @@ -248,6 +251,7 @@ class _defs_annotate: cursor='PAINT_BRUSH', keymap="Generic Tool: Annotate Line", draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @ToolDef.from_fn.with_args(draw_settings=draw_settings_common) @@ -259,6 +263,7 @@ class _defs_annotate: cursor='PAINT_BRUSH', keymap="Generic Tool: Annotate Polygon", draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @ToolDef.from_fn @@ -274,6 +279,7 @@ class _defs_annotate: cursor='ERASER', keymap="Generic Tool: Annotate Eraser", draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @@ -543,6 +549,7 @@ class _defs_view3d_add: widget="VIEW3D_GGT_placement", keymap="3D View Tool: Object, Add Primitive", draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @ToolDef.from_fn @@ -569,6 +576,7 @@ class _defs_view3d_add: widget="VIEW3D_GGT_placement", keymap="3D View Tool: Object, Add Primitive", draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @ToolDef.from_fn @@ -594,6 +602,7 @@ class _defs_view3d_add: widget="VIEW3D_GGT_placement", keymap="3D View Tool: Object, Add Primitive", draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @ToolDef.from_fn @@ -619,6 +628,7 @@ class _defs_view3d_add: widget="VIEW3D_GGT_placement", keymap="3D View Tool: Object, Add Primitive", draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @ToolDef.from_fn @@ -643,6 +653,7 @@ class _defs_view3d_add: widget="VIEW3D_GGT_placement", keymap="3D View Tool: Object, Add Primitive", draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @@ -1089,6 +1100,7 @@ class _defs_edit_mesh: widget=None, keymap=(), draw_settings=draw_settings, + options={'KEYMAP_FALLBACK'}, ) @ToolDef.from_fn @@ -1695,6 +1707,7 @@ class _defs_image_generic: ), icon="ops.generic.cursor", keymap=(), + options={'KEYMAP_FALLBACK'}, ) # Currently a place holder so we can switch away from the annotation tool. @@ -1846,6 +1859,7 @@ class _defs_image_uv_edit: # TODO: generic operator (UV version of `VIEW3D_GGT_tool_generic_handle_free`). widget=None, keymap=(), + options={'KEYMAP_FALLBACK'}, ) @@ -1879,6 +1893,7 @@ class _defs_image_uv_sculpt: operator="sculpt.uv_sculpt_stroke", keymap="Image Editor Tool: Uv, Sculpt Stroke", draw_cursor=draw_cursor, + options={'KEYMAP_FALLBACK'}, ), ) |