Nodes: new operator to simplify adding named frames

Currently, the steps required to add a named frame in the node editor are quite
cumbersome:
* Press ctrl+J, which is hard to reach.
* Press F2, to rename.

This is bad, because frames are a key part of making node trees understandable.
Therefore, we should lower the barrier to adding them as much as possible.
Additionally, named frames help significantly more with readability. Therefore,
it's good to lower the barrier to adding those even more. Of course it's still
possible to click in empty space to avoid having to give a frame a name.

This patch adds a new operator to join nodes in a named frame. When triggered,
it adds the frame and automatically opens the rename menu to set the name.

Keymap changes:
* Remove `ctrl+J` which was creating a frame without label.
* Move existing functionality of `F` key to `J` key
  (including `shift+F -> shift+J`).
* Use `F` for this new operator to create a named frame.

Pull Request: https://projects.blender.org/blender/blender/pulls/138390
This commit is contained in:
Jacques Lucke
2025-05-15 20:51:54 +02:00
parent 760cf70d63
commit 8ec093a2d8
2 changed files with 13 additions and 3 deletions

View File

@@ -2206,9 +2206,9 @@ def km_node_editor(params):
{"properties": [("factor", 1.2)]}),
("node.backimage_fit", {"type": 'HOME', "value": 'PRESS', "alt": True}, None),
("node.backimage_sample", {"type": params.action_mouse, "value": 'PRESS', "alt": True}, None),
("node.link_make", {"type": 'F', "value": 'PRESS'},
("node.link_make", {"type": 'J', "value": 'PRESS'},
{"properties": [("replace", False)]}),
("node.link_make", {"type": 'F', "value": 'PRESS', "shift": True},
("node.link_make", {"type": 'J', "value": 'PRESS', "shift": True},
{"properties": [("replace", True)]}),
op_menu("NODE_MT_add", {"type": 'A', "value": 'PRESS', "shift": True}),
("node.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True},
@@ -2219,7 +2219,7 @@ def km_node_editor(params):
{"properties": [("NODE_OT_translate_attach", [("TRANSFORM_OT_translate", [("view2d_edge_pan", True)])])]}),
("node.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
("node.detach", {"type": 'P', "value": 'PRESS', "alt": True}, None),
("node.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
("node.join_named", {"type": 'F', "value": 'PRESS'}, None),
("node.hide_toggle", {"type": 'H', "value": 'PRESS'}, None),
("node.mute_toggle", {"type": 'M', "value": 'PRESS'}, None),
("node.preview_toggle", {"type": 'H', "value": 'PRESS', "shift": True}, None),

View File

@@ -147,6 +147,16 @@ void ED_operatormacros_node()
RNA_boolean_set(mot->ptr, "clear_viewer", true);
WM_operatortype_macro_define(ot, "NODE_OT_link_viewer");
ot = WM_operatortype_append_macro(
"NODE_OT_join_named",
"Join in Named Frame",
"Create a new frame node around the selected nodes and name it immediately",
OPTYPE_UNDO);
WM_operatortype_macro_define(ot, "NODE_OT_join");
mot = WM_operatortype_macro_define(ot, "WM_OT_call_panel");
RNA_string_set(mot->ptr, "name", "TOPBAR_PT_name");
RNA_boolean_set(mot->ptr, "keep_open", false);
ot = WM_operatortype_append_macro("NODE_OT_translate_attach",
"Move and Attach",
"Move nodes and attach to frame",