Nodes: Node Wrangler: Use socket icons for Lazy Connect menu
Replace the icons for the "From Socket" and "To Socket" pop-up menus from `RADIOBUT_OFF` and `FORWARD`, to each socket type's corresponding icon. This makes it easier to pick out sockets in longer lists, as they could now be distinguished by their color. Video and images in PR Pull Request: https://projects.blender.org/blender/blender/pulls/145648
This commit is contained in:
committed by
Nika Kutsniashvili
parent
a80b4ce22b
commit
0545fba54f
@@ -13,6 +13,18 @@ from .utils.constants import blend_types, geo_combine_operations, operations
|
||||
from .utils.nodes import get_nodes_links, NWBaseMenu
|
||||
|
||||
|
||||
def socket_to_icon(socket):
|
||||
socket_type = socket.type
|
||||
|
||||
if socket_type == "CUSTOM":
|
||||
return "RADIOBUT_OFF"
|
||||
|
||||
if socket_type == "VALUE":
|
||||
socket_type = "FLOAT"
|
||||
|
||||
return "NODE_SOCKET_" + socket_type
|
||||
|
||||
|
||||
def drawlayout(context, layout, mode='non-panel'):
|
||||
tree_type = context.space_data.tree_type
|
||||
|
||||
@@ -163,12 +175,15 @@ class NWMergeMixMenu(Menu, NWBaseMenu):
|
||||
|
||||
class NWConnectionListOutputs(Menu, NWBaseMenu):
|
||||
bl_idname = "NODE_MT_nw_connection_list_out"
|
||||
bl_label = "From Socket"
|
||||
bl_label = ""
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
nodes, links = get_nodes_links(context)
|
||||
|
||||
layout.label(text="From Socket", icon='RADIOBUT_OFF')
|
||||
layout.separator()
|
||||
|
||||
n1 = nodes[context.scene.NWLazySource]
|
||||
for index, output in enumerate(n1.outputs):
|
||||
# Only show sockets that are exposed.
|
||||
@@ -177,18 +192,21 @@ class NWConnectionListOutputs(Menu, NWBaseMenu):
|
||||
operators.NWCallInputsMenu.bl_idname,
|
||||
text=output.name,
|
||||
text_ctxt=i18n_contexts.default,
|
||||
icon="RADIOBUT_OFF",
|
||||
icon=socket_to_icon(output),
|
||||
).from_socket = index
|
||||
|
||||
|
||||
class NWConnectionListInputs(Menu, NWBaseMenu):
|
||||
bl_idname = "NODE_MT_nw_connection_list_in"
|
||||
bl_label = "To Socket"
|
||||
bl_label = ""
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
nodes, links = get_nodes_links(context)
|
||||
|
||||
layout.label(text="To Socket", icon='FORWARD')
|
||||
layout.separator()
|
||||
|
||||
n2 = nodes[context.scene.NWLazyTarget]
|
||||
|
||||
for index, input in enumerate(n2.inputs):
|
||||
@@ -200,7 +218,7 @@ class NWConnectionListInputs(Menu, NWBaseMenu):
|
||||
op = layout.operator(
|
||||
operators.NWMakeLink.bl_idname, text=input.name,
|
||||
text_ctxt=i18n_contexts.default,
|
||||
icon="FORWARD",
|
||||
icon=socket_to_icon(input),
|
||||
)
|
||||
op.from_socket = context.scene.NWSourceSocket
|
||||
op.to_socket = index
|
||||
|
||||
Reference in New Issue
Block a user