Skip to content

Commit

Permalink
GraphEditor : Add nodule label visibility menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl authored and johnhaddon committed Nov 22, 2024
1 parent c61e6cf commit 89154ca
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Improvements
- Increased menu item icon sizes.
- A lock icon is now displayed next to read-only nodes.
- RenderPassEditor : Changed the current render pass indicator to yellow to match other context-related UI elements.
- GraphEditor : Moved "Show Input Connections" and "Show Output Connections" to "Connections" sub-menu and added "Show Input Labels" and "Show Output Labels" items.

Fixes
-----
Expand Down
35 changes: 33 additions & 2 deletions python/GafferUI/GraphEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def plugDirectionsWalk( gadget ) :

if Gaffer.Plug.Direction.In in plugDirections :
menuDefinition.append(
"/Show Input Connections",
"/Connections/Show Input Connections",
{
"checkBox" : functools.partial( cls.__getNodeInputConnectionsVisible, graphEditor.graphGadget(), node ),
"command" : functools.partial( cls.__setNodeInputConnectionsVisible, graphEditor.graphGadget(), node ),
Expand All @@ -225,14 +225,34 @@ def plugDirectionsWalk( gadget ) :

if Gaffer.Plug.Direction.Out in plugDirections :
menuDefinition.append(
"/Show Output Connections",
"/Connections/Show Output Connections",
{
"checkBox" : functools.partial( cls.__getNodeOutputConnectionsVisible, graphEditor.graphGadget(), node ),
"command" : functools.partial( cls.__setNodeOutputConnectionsVisible, graphEditor.graphGadget(), node ),
"active" : not readOnly
}
)

if Gaffer.Plug.Direction.In in plugDirections :
menuDefinition.append(
"/Connections/Show Input Labels",
{
"checkBox" : functools.partial( cls.__getNoduleLabelsVisible, node, "input" ),
"command" : functools.partial( cls.__setNoduleLabelsVisible, node, "input" ),
"active" : not readOnly,
}
)

if Gaffer.Plug.Direction.Out in plugDirections :
menuDefinition.append(
"/Connections/Show Output Labels",
{
"checkBox" : functools.partial( cls.__getNoduleLabelsVisible, node, "output" ),
"command" : functools.partial( cls.__setNoduleLabelsVisible, node, "output" ),
"active" : not readOnly,
}
)

## May be used from a slot attached to nodeContextMenuSignal() to install a
# standard menu item for modifying the enabled state of a node.
@classmethod
Expand Down Expand Up @@ -729,6 +749,17 @@ def __setNodeInputConnectionsVisible( cls, graphGadget, node, value ) :
with Gaffer.UndoScope( node.ancestor( Gaffer.ScriptNode ) ) :
graphGadget.setNodeInputConnectionsMinimised( node, not value )

@classmethod
def __getNoduleLabelsVisible( cls, node, direction ) :

return Gaffer.Metadata.value( node, f"nodeGadget:{direction}NoduleLabelsVisible" ) or False

@classmethod
def __setNoduleLabelsVisible( cls, node, direction, value ) :

with Gaffer.UndoScope( node.ancestor( Gaffer.ScriptNode ) ) :
Gaffer.Metadata.registerValue( node, f"nodeGadget:{direction}NoduleLabelsVisible", value )

@classmethod
def __getNodeOutputConnectionsVisible( cls, graphGadget, node ) :

Expand Down

0 comments on commit 89154ca

Please sign in to comment.