From 9e2bb149e2774cab697e865ad83fd6bc89c8ddef Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 22 Jun 2023 17:48:43 -0400 Subject: [PATCH] fixup! ShaderUI : Add parameter filter --- python/GafferSceneUI/ShaderUI.py | 65 ++++++-------------------------- 1 file changed, 12 insertions(+), 53 deletions(-) diff --git a/python/GafferSceneUI/ShaderUI.py b/python/GafferSceneUI/ShaderUI.py index 9f8f280f536..38799b5bd33 100644 --- a/python/GafferSceneUI/ShaderUI.py +++ b/python/GafferSceneUI/ShaderUI.py @@ -637,7 +637,7 @@ def __init__( self, patterns, rootPath = None, propertyName = "name", userData = self.__pathMatcherDirty = True self.__pathMatcher = IECore.PathMatcher() - self.setRootPath( rootPath ) + rootPath.pathChangedSignal().connect( Gaffer.WeakMethod( self.__rootPathChanged ), scoped = False ) def setMatchPatterns( self, patterns ) : @@ -652,31 +652,6 @@ def getMatchPatterns( self ) : return self.__patterns - def setRootPath( self, rootPath ) : - - if rootPath is None : - self.__rootPathChangedConnection = None - self.__rootPath = rootPath - self.__paths = [] - self.__pathMatcherDirty = True - return - - if self.__rootPath == rootPath : - return - - self.__rootPath = rootPath - self.__updatePaths() - - self.__rootPathChangedConnection = self.__rootPath.pathChangedSignal().connect( - Gaffer.WeakMethod( self.__rootPathChanged ), - scoped = True - ) - self.__pathMatcherDirty = True - - def getRootPath( self ) : - - return self.__rootPath - def setPropertyName( self, propertyName ) : if( self.__propertyName == propertyName ) : @@ -710,8 +685,9 @@ def __updatePathMatcher( self ) : return newPathMatcher = IECore.PathMatcher() + self.__pathMatcherDirty = False - for p in self.__paths : + for p in self.__paths() : property = p.property( self.__propertyName ) if property is None : continue @@ -725,9 +701,8 @@ def __updatePathMatcher( self ) : return self.__pathMatcher = newPathMatcher - self.changedSignal()( self ) - def __updatePaths( self ) : + def __paths( self ) : def collectPaths( parentPath ) : result = [] @@ -737,11 +712,10 @@ def collectPaths( parentPath ) : return result - self.__paths = collectPaths( self.__rootPath ) + return collectPaths( self.__rootPath ) def __rootPathChanged( self, path ) : - self.__updatePaths() self.__pathMatcherDirty = True GafferUI.PathFilterWidget.registerType( _PathMatcherPathFilter, GafferUI.MatchPatternPathFilterWidget ) @@ -755,7 +729,11 @@ def __init__( self, shaderNetworks, title = None, **kw ) : GafferUI.Dialogue.__init__( self, title, **kw ) - self.__filter = _PathMatcherPathFilter( [ "" ] ) + self.__shaderNetworks = shaderNetworks + + self.__path = _ShaderPath( self.__shaderNetworks, path = "/" ) + + self.__filter = _PathMatcherPathFilter( [ "" ], self.__path.copy() ) self.__filter.setEnabled( False ) self.__filter.userData()["UI"] = { "editable" : True, @@ -763,14 +741,11 @@ def __init__( self, shaderNetworks, title = None, **kw ) : "propertyFilters" : { "name": "Name", "shader:type": "Type" } } - self.__shaderNetworks = shaderNetworks - self.__path = None - - tmpPath = Gaffer.DictPath( {}, "/" ) + self.__path.setFilter( self.__filter ) with GafferUI.ListContainer( spacing = 4 ) as mainColumn : self.__pathListingWidget = GafferUI.PathListingWidget( - tmpPath, + self.__path, columns = ( _DuplicateIconColumn( "Name", "name" ), GafferUI.PathListingWidget.StandardColumn( "Type", "shader:type" ), @@ -801,22 +776,6 @@ def __init__( self, shaderNetworks, title = None, **kw ) : self.__updateButtonState() - self.setPath( _ShaderPath( self.__shaderNetworks, path = "/", filter = self.__filter ) ) - - def getPath( self ) : - - return self.__path - - def setPath(self, path ) : - - if path.isSame( self.__path ) : - return - - self.__path = path - self.__filter.setRootPath( self.__path ) - - self.__pathListingWidget.setPath( self.__path ) - def parametersSelectedSignal( self ) : return self.__parametersSelectedSignal