Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Improvements
- MeshSplit : Added `ignoreMissing` plug.
- Cycles : Added render-time translation of `UsdPreviewSurface` normal maps, these require a FaceVarying `uv` primitive variable to render correctly.
- Parent, Duplicate, Instancer, Group, MergeScenes : Improved performance when handling large numbers of sets.
- Viewer : Added a search field to the channels menu.
- RampPlug : Added ability to load `.gfr` files saved from Gaffer 1.8.

Fixes
Expand Down
4 changes: 4 additions & 0 deletions python/GafferImageUI/ImageViewUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def _menuDefinition( self ) :
"command" : functools.partial( Gaffer.WeakMethod( self.__setValue ), value = denoiseValue ),
"shortCut" : "D",
"active" : denoiseValue is not None and denoiseValue != currentValue,
"searchable" : False,
}
)

Expand All @@ -318,6 +319,7 @@ def _menuDefinition( self ) :
"command" : functools.partial( Gaffer.WeakMethod( self.__setValue ), value = previousValue ),
"shortCut" : "PgUp",
"active" : previousValue is not None and previousValue != currentValue,
"searchable" : False,
}
)

Expand All @@ -328,6 +330,7 @@ def _menuDefinition( self ) :
"command" : functools.partial( Gaffer.WeakMethod( self.__setValue ), value = nextValue ),
"shortCut" : "PgDown",
"active" : nextValue is not None and nextValue != currentValue,
"searchable" : False,
}
)

Expand All @@ -338,6 +341,7 @@ def _menuDefinition( self ) :
"command" : functools.partial( Gaffer.WeakMethod( self.__setValue ), value = firstValue ),
"shortCut" : "Ctrl+PgUp",
"active" : firstValue is not None and firstValue != currentValue,
"searchable" : False,
}
)

Expand Down
13 changes: 11 additions & 2 deletions python/GafferImageUI/RGBAChannelsPlugValueWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,19 @@
## Supported plug metadata :
#
# - "rgbaChannelsPlugValueWidget:allowNone" : Allows "None" to be chosen to assign an empty StringVectorData.
# - "rgbaChannelsPlugValueWidget:searchable" : Set to False to remove the search field from the menu. Defaults to True.
class RGBAChannelsPlugValueWidget( GafferUI.PlugValueWidget ) :

def __init__( self, plugs, **kw ) :

self.__menuButton = GafferUI.MenuButton( menu = GafferUI.Menu( Gaffer.WeakMethod( self._menuDefinition ) ) )
searchable = all(
Gaffer.Metadata.value( p, "rgbaChannelsPlugValueWidget:searchable" ) is not False
for p in ( { plugs } if isinstance( plugs, Gaffer.Plug ) else plugs )
)

self.__menuButton = GafferUI.MenuButton(
menu = GafferUI.Menu( Gaffer.WeakMethod( self._menuDefinition ), searchable = searchable )
)
self.__menuButton._qtWidget().setMinimumWidth( 150 )

GafferUI.PlugValueWidget.__init__( self, self.__menuButton, plugs, **kw )
Expand Down Expand Up @@ -161,7 +169,7 @@ def _menuDefinition( self ) :

result = IECore.MenuDefinition()
if not rgbaChannels :
result.append( "/No channels available", { "active" : False } )
result.append( "/No channels available", { "active" : False, "searchable" : False } )
return result

for text, value in rgbaChannels.items() :
Expand All @@ -171,6 +179,7 @@ def _menuDefinition( self ) :
{
"command" : functools.partial( Gaffer.WeakMethod( self.__setValue ), value = value ),
"checkBox" : value == self.__currentValue,
"searchText" : text,
}
)

Expand Down
31 changes: 31 additions & 0 deletions python/GafferImageUITest/ImageViewTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,34 @@ def testImageGadget( self ) :
view = GafferImageUI.ImageView( script )
self.assertIsInstance( view.imageGadget(), GafferImageUI.ImageGadget )
self.assertTrue( view.viewportGadget().isAncestorOf( view.imageGadget() ) )

def testChannelsMenuViewerOnlyItemsAreNotSearchable( self ) :

script = Gaffer.ScriptNode()
script["constant"] = GafferImage.Constant()
script["shuffle"] = GafferImage.Shuffle()
script["shuffle"]["in"].setInput( script["constant"]["out"] )
for channel in "RGBA" :
script["shuffle"]["shuffles"].addChild( Gaffer.ShufflePlug( channel, f"diffuse.{channel}" ) )

view = GafferUI.View.create( script["shuffle"]["out"] )
widget = GafferImageUI.ImageViewUI._ChannelsPlugValueWidget( view["channels"] )
GafferUITest.PlugValueWidgetTest.waitForUpdate( widget )

searchable = {
path : getattr( item, "searchable", True )
for path, item in widget._menuDefinition().items()
if not item.divider
}

self.assertEqual(
searchable,
{
"/RGBA" : True,
"/diffuse" : True,
"/Denoised" : False,
"/Previous" : False,
"/Next" : False,
"/First" : False,
}
)
110 changes: 110 additions & 0 deletions python/GafferImageUITest/RGBAChannelsPlugValueWidgetTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
##########################################################################
#
# Copyright (c) 2026, Image Engine Design Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with
# the distribution.
#
# * Neither the name of John Haddon nor the names of
# any other contributors to this software may be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##########################################################################

import unittest

import Gaffer
import GafferUI
import GafferUITest
import GafferImage
import GafferImageUI

class RGBAChannelsPlugValueWidgetTest( GafferUITest.TestCase ) :

@staticmethod
def __script( layers ) :

script = Gaffer.ScriptNode()
script["constant"] = GafferImage.Constant()

script["shuffle"] = GafferImage.Shuffle()
script["shuffle"]["in"].setInput( script["constant"]["out"] )
for layer in layers :
for channel in "RGBA" :
script["shuffle"]["shuffles"].addChild( Gaffer.ShufflePlug( channel, f"{layer}.{channel}" ) )

script["stats"] = GafferImage.ImageStats()
script["stats"]["in"].setInput( script["shuffle"]["out"] )

return script

def testSearchable( self ) :

script = self.__script( [] )

widget = GafferImageUI.RGBAChannelsPlugValueWidget( script["stats"]["channels"] )
self.assertTrue( widget._RGBAChannelsPlugValueWidget__menuButton.getMenu().searchable() )

Gaffer.Metadata.registerValue( script["stats"]["channels"], "rgbaChannelsPlugValueWidget:searchable", False )
widget = GafferImageUI.RGBAChannelsPlugValueWidget( script["stats"]["channels"] )
self.assertFalse( widget._RGBAChannelsPlugValueWidget__menuButton.getMenu().searchable() )

def testSearchTextIsFullLayerName( self ) :

script = self.__script( [ "diffuse", "diffuse.direct", "specular.indirect" ] )

widget = GafferImageUI.RGBAChannelsPlugValueWidget( script["stats"]["channels"] )
GafferUITest.PlugValueWidgetTest.waitForUpdate( widget )

searchTexts = {
path : item.searchText
for path, item in widget._menuDefinition().items()
}

self.assertEqual(
searchTexts,
{
"/RGBA" : "RGBA",
"/diffuse" : "diffuse",
"/diffuse/direct" : "diffuse.direct",
"/specular/indirect" : "specular.indirect",
}
)

def testNoChannelsItemIsNotSearchable( self ) :

script = Gaffer.ScriptNode()
script["stats"] = GafferImage.ImageStats()

widget = GafferImageUI.RGBAChannelsPlugValueWidget( script["stats"]["channels"] )
GafferUITest.PlugValueWidgetTest.waitForUpdate( widget )

items = widget._menuDefinition().items()
self.assertEqual( [ path for path, item in items ], [ "/No channels available" ] )
self.assertIs( items[0][1].searchable, False )

if __name__ == "__main__":
unittest.main()
1 change: 1 addition & 0 deletions python/GafferImageUITest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

from .FormatPlugValueWidgetTest import FormatPlugValueWidgetTest
from .ImageViewTest import ImageViewTest
from .RGBAChannelsPlugValueWidgetTest import RGBAChannelsPlugValueWidgetTest
from .DocumentationTest import DocumentationTest
from .ImageGadgetTest import ImageGadgetTest
from .NodeUITest import NodeUITest
6 changes: 5 additions & 1 deletion python/GafferUITest/PlugValueWidgetTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#
##########################################################################

import itertools
import warnings
import weakref

Expand All @@ -57,7 +58,10 @@ def waitForUpdate( widget ) :

# And updates for computed values are done in the background, so we
# need to wait until they're done.
if any( isinstance( p, Gaffer.ValuePlug ) and Gaffer.PlugAlgo.dependsOnCompute( p ) for p in widget.getPlugs() ) :
if any(
isinstance( p, Gaffer.ValuePlug ) and Gaffer.PlugAlgo.dependsOnCompute( p )
for p in itertools.chain( widget.getPlugs(), *widget._PlugValueWidget__auxiliaryPlugs )
) :
handler.assertCalled()

def testContext( self ) :
Expand Down
Loading