Skip to content

Commit

Permalink
strike-through wip : we can't remove plugDirtied stuff though
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Jul 19, 2024
1 parent c2e5bcb commit e848f33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 45 deletions.
2 changes: 1 addition & 1 deletion include/GafferUI/StandardNodeGadget.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class GAFFERUI_API StandardNodeGadget : public NodeGadget
void error( const Gaffer::Plug *plug, const Gaffer::Plug *source, const std::string &message );
void displayError( Gaffer::ConstPlugPtr plug, const std::string &message );

bool m_nodeEnabled;
bool m_nodeAlwaysDisabled;
bool m_labelsVisibleOnHover;
// We accept drags onto the NodeGadget itself and
// use them to create a connection to the
Expand Down
56 changes: 12 additions & 44 deletions src/GafferUI/StandardNodeGadget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ StandardNodeGadget::StandardNodeGadget( Gaffer::NodePtr node )
// can optionally use it without needing to inherit from StandardNodeGadget
StandardNodeGadget::StandardNodeGadget( Gaffer::NodePtr node, bool auxiliary )
: NodeGadget( node ),
m_nodeEnabled( true ),
m_nodeAlwaysDisabled( false ),
m_labelsVisibleOnHover( true ),
m_dragDestination( nullptr ),
m_userColor( 0 ),
Expand Down Expand Up @@ -659,7 +659,6 @@ StandardNodeGadget::StandardNodeGadget( Gaffer::NodePtr node, bool auxiliary )
updateUserColor();
updateMinWidth();
updatePadding();
updateNodeEnabled();
updateIcon();
updateShape();
updateFocusGadgetVisibility();
Expand Down Expand Up @@ -715,7 +714,7 @@ void StandardNodeGadget::renderLayer( Layer layer, const Style *style, RenderRea
{
const Box3f b = bound();

if( !m_nodeEnabled && !isSelectionRender( reason ) )
if( m_nodeAlwaysDisabled && !isSelectionRender( reason ) )
{
/// \todo Replace renderLine() with a specific method (renderNodeStrikeThrough?) on the Style class
/// so that styles can do customised drawing based on knowledge of what is being drawn.
Expand Down Expand Up @@ -776,6 +775,16 @@ void StandardNodeGadget::updateFromContextTracker( const ContextTracker *context
{
NodeGadget::updateFromContextTracker( contextTracker );
updateTextDimming();

if( auto dependencyNode = IECore::runTimeCast<const DependencyNode>( node() ) )
{
const bool alwaysDisabled = contextTracker->isAlwaysDisabled( dependencyNode );
if( alwaysDisabled != m_nodeAlwaysDisabled )
{
m_nodeAlwaysDisabled = alwaysDisabled;
dirty( DirtyType::Render );
}
}
}

void StandardNodeGadget::updateTextDimming()
Expand Down Expand Up @@ -1035,7 +1044,6 @@ bool StandardNodeGadget::getLabelsVisibleOnHover() const

void StandardNodeGadget::plugDirtied( const Gaffer::Plug *plug )
{
updateNodeEnabled( plug );
if( ErrorGadget *e = errorGadget( /* createIfMissing = */ false ) )
{
e->removeError( plug );
Expand Down Expand Up @@ -1260,46 +1268,6 @@ void StandardNodeGadget::updatePadding()
paddingRow()->setPadding( Box3f( V3f( -padding ), V3f( padding ) ) );
}

void StandardNodeGadget::updateNodeEnabled( const Gaffer::Plug *dirtiedPlug )
{
DependencyNode *dependencyNode = IECore::runTimeCast<DependencyNode>( node() );
if( !dependencyNode )
{
return;
}

const Gaffer::BoolPlug *enabledPlug = dependencyNode->enabledPlug();
if( !enabledPlug )
{
return;
}

if( dirtiedPlug && dirtiedPlug != enabledPlug )
{
return;
}

const ValuePlug *source = enabledPlug->source<ValuePlug>();
bool enabled = true;
if( source->direction() != Plug::Out || !IECore::runTimeCast<const ComputeNode>( source->node() ) )
{
// Only evaluate `enabledPlug` if it won't trigger a compute.
// We don't want to hang the UI waiting, and we don't really
// know what context to perform the compute in anyway.
/// \todo We could consider doing this in the background, using
/// an upstream traversal from the focus node to determine context.
enabled = enabledPlug->getValue();
}

if( enabled == m_nodeEnabled )
{
return;
}

m_nodeEnabled = enabled;
dirty( DirtyType::Render );
}

void StandardNodeGadget::updateIcon()
{
float scale = 1.5f;
Expand Down

0 comments on commit e848f33

Please sign in to comment.