Nodes: Node Wrangler: Remove "Frame Selected" operator

This operator was duplicating feature that already exists in core
Blender (`node.join`), and was not working great as well. So there is
no need to maintain this python operator, but to keep consistency for
users I kept the keymap and UI entry but assigned it to `node.join`
operator instead, so that users don't notice change.

I assigned keymap inside add-on and not in Blender core because people
who didn't use Node Wrangler have that key free, or have something else
assigned (and `node.join` is already mapped to Ctrl+J), so only Node
Wrangler users should have this keymap. We can change it and rename
built-in operator to Parent, instead of Join, and remap it to Shift+P,
but that's separate discussion.

Resolves #129404.

Pull Request: https://projects.blender.org/blender/blender/pulls/132758
This commit is contained in:
Nika Kutsniashvili 2025-01-15 02:19:33 +01:00 committed by Hans Goudey
parent 716fda7df1
commit 89f829f736
3 changed files with 2 additions and 55 deletions

View file

@ -59,7 +59,7 @@ def drawlayout(context, layout, mode='non-panel'):
col.separator()
col = layout.column(align=True)
col.operator(operators.NWFrameSelected.bl_idname, icon='STICKY_UVS_LOC')
col.operator('node.join', icon='STICKY_UVS_LOC')
col.separator()
col = layout.column(align=True)

View file

@ -493,58 +493,6 @@ class NWAddAttrNode(Operator, NWBase):
return {'FINISHED'}
class NWFrameSelected(Operator, NWBase):
bl_idname = "node.nw_frame_selected"
bl_label = "Frame Selected"
bl_translation_context = i18n_contexts.id_nodetree
bl_description = "Add a frame node and parent the selected nodes to it"
bl_options = {'REGISTER', 'UNDO'}
label_prop: StringProperty(
name='Label',
description='The visual name of the frame node',
default=' '
)
use_custom_color_prop: BoolProperty(
name="Custom Color",
description="Use custom color for the frame node",
default=False
)
color_prop: FloatVectorProperty(
name="Color",
description="The color of the frame node",
default=(0.604, 0.604, 0.604),
min=0, max=1, step=1, precision=3,
subtype='COLOR_GAMMA', size=3
)
def draw(self, context):
layout = self.layout
layout.prop(self, 'label_prop')
layout.prop(self, 'use_custom_color_prop')
col = layout.column()
col.active = self.use_custom_color_prop
col.prop(self, 'color_prop', text="")
def execute(self, context):
nodes, links = get_nodes_links(context)
selected = []
for node in nodes:
if node.select:
selected.append(node)
bpy.ops.node.add_node(type='NodeFrame')
frm = nodes.active
frm.label = self.label_prop
frm.use_custom_color = self.use_custom_color_prop
frm.color = self.color_prop
for node in selected:
node.parent = frm
return {'FINISHED'}
class NWReloadImages(Operator):
bl_idname = "node.nw_reload_images"
bl_label = "Reload Images"
@ -2450,7 +2398,6 @@ classes = (
NWSwapLinks,
NWResetBG,
NWAddAttrNode,
NWFrameSelected,
NWReloadImages,
NWMergeNodes,
NWBatchChangeNodes,

View file

@ -329,7 +329,7 @@ kmi_defs = (
# Delete unused
(operators.NWDeleteUnused.bl_idname, 'X', 'PRESS', False, False, True, None, "Delete unused nodes"),
# Frame Selected
(operators.NWFrameSelected.bl_idname, 'P', 'PRESS', False, True, False, None, "Frame selected nodes"),
('node.join', 'P', 'PRESS', False, True, False, None, "Frame selected nodes"),
# Swap Links
(operators.NWSwapLinks.bl_idname, 'S', 'PRESS', False, False, True, None, "Swap Links"),
# Reload Images