Skip to content

Commit

Permalink
fixup! ShaderUI : Add parameter filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Jun 26, 2023
1 parent 3b20368 commit 9e2bb14
Showing 1 changed file with 12 additions and 53 deletions.
65 changes: 12 additions & 53 deletions python/GafferSceneUI/ShaderUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) :

Expand All @@ -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 ) :
Expand Down Expand Up @@ -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
Expand All @@ -725,9 +701,8 @@ def __updatePathMatcher( self ) :
return

self.__pathMatcher = newPathMatcher
self.changedSignal()( self )

def __updatePaths( self ) :
def __paths( self ) :

def collectPaths( parentPath ) :
result = []
Expand All @@ -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 )
Expand All @@ -755,22 +729,23 @@ 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,
"label" : "Filter",
"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" ),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9e2bb14

Please sign in to comment.