Nodes: Swap Node Operator

Implement a native method to swap between different node and zone types.

This implementation repurposes the existing menu definitions as base
classes, from which both an "Add" and a "Swap" version would be generated
from. This allows both menus to have the same layout, but use their own
operators for handling the different node/zone types.

In this PR, support for all node editors has been implemented.

Invoking the menu is currently bound to `Shift + S`, same as the old
implementation in Node Wrangler. Since "Swap" is implemented as a
regular menu, features that menus already have such as type-to-search
and adding to Quick Favorites don't require any extra caveats to
consider.

Resolves #133452

Pull Request: https://projects.blender.org/blender/blender/pulls/143997
This commit is contained in:
quackarooni
2025-09-25 16:12:02 +02:00
committed by Hans Goudey
parent fc4fc2d16c
commit 2a1a658492
21 changed files with 2495 additions and 1292 deletions

View File

@@ -2231,6 +2231,7 @@ def km_node_editor(params):
("node.link_make", {"type": 'J', "value": 'PRESS', "shift": True},
{"properties": [("replace", True)]}),
op_menu("NODE_MT_add", {"type": 'A', "value": 'PRESS', "shift": True}),
op_menu("NODE_MT_swap", {"type": 'S', "value": 'PRESS', "shift": True}),
("node.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True},
{"properties": [("NODE_OT_translate_attach", [("TRANSFORM_OT_translate", [("view2d_edge_pan", True)])])]}),
("node.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True},