From 8ec093a2d85be700eff26991136c4f1cdecd01c2 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 15 May 2025 20:51:54 +0200 Subject: [PATCH] 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 --- .../presets/keyconfig/keymap_data/blender_default.py | 6 +++--- source/blender/editors/space_node/node_ops.cc | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/presets/keyconfig/keymap_data/blender_default.py b/scripts/presets/keyconfig/keymap_data/blender_default.py index d06ac87c214..04f829bbb73 100644 --- a/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -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), diff --git a/source/blender/editors/space_node/node_ops.cc b/source/blender/editors/space_node/node_ops.cc index 3f40a69e1c5..0a4229f197d 100644 --- a/source/blender/editors/space_node/node_ops.cc +++ b/source/blender/editors/space_node/node_ops.cc @@ -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",