From e848f3376423013a0db0891ad508e9b5582c0e4c Mon Sep 17 00:00:00 2001 From: John Haddon Date: Fri, 19 Jul 2024 17:01:07 +0100 Subject: [PATCH] strike-through wip : we can't remove plugDirtied stuff though --- include/GafferUI/StandardNodeGadget.h | 2 +- src/GafferUI/StandardNodeGadget.cpp | 56 ++++++--------------------- 2 files changed, 13 insertions(+), 45 deletions(-) diff --git a/include/GafferUI/StandardNodeGadget.h b/include/GafferUI/StandardNodeGadget.h index 5a43ff6b90..d05ce1f68c 100644 --- a/include/GafferUI/StandardNodeGadget.h +++ b/include/GafferUI/StandardNodeGadget.h @@ -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 diff --git a/src/GafferUI/StandardNodeGadget.cpp b/src/GafferUI/StandardNodeGadget.cpp index e8795e8615..5bd35937dc 100644 --- a/src/GafferUI/StandardNodeGadget.cpp +++ b/src/GafferUI/StandardNodeGadget.cpp @@ -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 ), @@ -659,7 +659,6 @@ StandardNodeGadget::StandardNodeGadget( Gaffer::NodePtr node, bool auxiliary ) updateUserColor(); updateMinWidth(); updatePadding(); - updateNodeEnabled(); updateIcon(); updateShape(); updateFocusGadgetVisibility(); @@ -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. @@ -776,6 +775,16 @@ void StandardNodeGadget::updateFromContextTracker( const ContextTracker *context { NodeGadget::updateFromContextTracker( contextTracker ); updateTextDimming(); + + if( auto dependencyNode = IECore::runTimeCast( node() ) ) + { + const bool alwaysDisabled = contextTracker->isAlwaysDisabled( dependencyNode ); + if( alwaysDisabled != m_nodeAlwaysDisabled ) + { + m_nodeAlwaysDisabled = alwaysDisabled; + dirty( DirtyType::Render ); + } + } } void StandardNodeGadget::updateTextDimming() @@ -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 ); @@ -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( node() ); - if( !dependencyNode ) - { - return; - } - - const Gaffer::BoolPlug *enabledPlug = dependencyNode->enabledPlug(); - if( !enabledPlug ) - { - return; - } - - if( dirtiedPlug && dirtiedPlug != enabledPlug ) - { - return; - } - - const ValuePlug *source = enabledPlug->source(); - bool enabled = true; - if( source->direction() != Plug::Out || !IECore::runTimeCast( 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;