<s> import functools <EOL> import IECore <EOL> import Gaffer <EOL> import GafferUI <EOL> import GafferScene <EOL> import GafferSceneUI <EOL> Gaffer . Metadata . registerNode ( <EOL> GafferSceneUI . SceneView , <EOL> plugs = { <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT>" , <NUM_LIT:2> , <EOL> "<STR_LIT>" , True , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , True , <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , True , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT:description>" , <EOL> """<STR_LIT>""" , <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT:description>" , <EOL> """<STR_LIT>""" , <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> ] , <EOL> } <EOL> ) <EOL> class _ShadingModePlugValueWidget ( GafferUI . PlugValueWidget ) : <EOL> def __init__ ( self , plug , parenting = None ) : <EOL> menuButton = GafferUI . MenuButton ( <EOL> image = "<STR_LIT>" , <EOL> menu = GafferUI . Menu ( Gaffer . WeakMethod ( self . __menuDefinition ) ) , <EOL> hasFrame = False , <EOL> ) <EOL> GafferUI . PlugValueWidget . __init__ ( self , menuButton , plug , parenting = parenting ) <EOL> def hasLabel ( self ) : <EOL> return True <EOL> def _updateFromPlug ( self ) : <EOL> pass <EOL> def __menuDefinition ( self ) : <EOL> m = IECore . MenuDefinition ( ) <EOL> currentName = self . getPlug ( ) . getValue ( ) <EOL> for name in [ "<STR_LIT>" ] + GafferSceneUI . SceneView . registeredShadingModes ( ) : <EOL> m . append ( <EOL> "<STR_LIT:/>" + name if name else "<STR_LIT>" , <EOL> { <EOL> "<STR_LIT>" : name == currentName , <EOL> "<STR_LIT>" : functools . partial ( Gaffer . WeakMethod ( self . __setValue ) , name if name != currentName else "<STR_LIT>" ) , <EOL> } <EOL> ) <EOL> if not name : <EOL> m . append ( "<STR_LIT>" , { "<STR_LIT>" : True } ) <EOL> return m <EOL> def __setValue ( self , value , * unused ) : <EOL> self . getPlug ( ) . setValue ( value ) <EOL> class _ExpansionPlugValueWidget ( GafferUI . PlugValueWidget ) : <EOL> def __init__ ( self , plug , parenting = None ) : <EOL> menu = GafferUI . Menu ( Gaffer . WeakMethod ( self . __menuDefinition ) ) <EOL> menuButton = GafferUI . MenuButton ( menu = menu , image = "<STR_LIT>" , hasFrame = False ) <EOL> GafferUI . PlugValueWidget . __init__ ( self , menuButton , plug , parenting = parenting ) <EOL> def hasLabel ( self ) : <EOL> return True <EOL> def _updateFromPlug ( self ) : <EOL> pass <EOL> def __menuDefinition ( self ) : <EOL> expandAll = bool ( self . getPlug ( ) . getValue ( ) ) <EOL> m = IECore . MenuDefinition ( ) <EOL> m . append ( "<STR_LIT>" , { "<STR_LIT>" : self . getPlug ( ) . node ( ) . expandSelection , "<STR_LIT>" : not expandAll , "<STR_LIT>" : "<STR_LIT>" } ) <EOL> m . append ( "<STR_LIT>" , { "<STR_LIT>" : IECore . curry ( self . getPlug ( ) . node ( ) . expandSelection , depth = <NUM_LIT> ) , "<STR_LIT>" : not expandAll , "<STR_LIT>" : "<STR_LIT>" } ) <EOL> m . append ( "<STR_LIT>" , { "<STR_LIT>" : self . getPlug ( ) . node ( ) . collapseSelection , "<STR_LIT>" : not expandAll , "<STR_LIT>" : "<STR_LIT>" } ) <EOL> m . append ( "<STR_LIT>" , { "<STR_LIT>" : True } ) <EOL> m . append ( "<STR_LIT>" , { "<STR_LIT>" : expandAll , "<STR_LIT>" : Gaffer . WeakMethod ( self . __toggleMinimumExpansionDepth ) } ) <EOL> return m <EOL> def __toggleMinimumExpansionDepth ( self , * unused ) : <EOL> self . getPlug ( ) . setValue ( <NUM_LIT:0> if self . getPlug ( ) . getValue ( ) else <NUM_LIT> ) <EOL> class _LookThroughPlugValueWidget ( GafferUI . PlugValueWidget ) : <EOL> def __init__ ( self , plug , parenting = None ) : <EOL> row = GafferUI . ListContainer ( GafferUI . ListContainer . Orientation . Horizontal ) <EOL> GafferUI . PlugValueWidget . __init__ ( self , row , plug , parenting = parenting ) <EOL> with row : <EOL> self . __enabledWidget = GafferUI . BoolPlugValueWidget ( plug [ "<STR_LIT>" ] , displayMode = GafferUI . BoolWidget . DisplayMode . Switch ) <EOL> self . __cameraWidget = GafferSceneUI . ScenePathPlugValueWidget ( <EOL> plug [ "<STR_LIT>" ] , <EOL> path = GafferScene . ScenePath ( <EOL> plug . node ( ) [ "<STR_LIT>" ] , <EOL> plug . node ( ) . getContext ( ) , <EOL> "<STR_LIT:/>" , <EOL> filter = GafferScene . ScenePath . createStandardFilter ( [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> ) , <EOL> ) <EOL> self . __cameraWidget . pathWidget ( ) . setFixedCharacterWidth ( <NUM_LIT> ) <EOL> if hasattr ( self . __cameraWidget . pathWidget ( ) . _qtWidget ( ) , "<STR_LIT>" ) : <EOL> self . __cameraWidget . pathWidget ( ) . _qtWidget ( ) . setPlaceholderText ( "<STR_LIT>" ) <EOL> self . _updateFromPlug ( ) <EOL> def _updateFromPlug ( self ) : <EOL> with self . getContext ( ) : <EOL> self . __cameraWidget . setEnabled ( self . getPlug ( ) [ "<STR_LIT>" ] . getValue ( ) ) <EOL> class _GridPlugValueWidget ( GafferUI . PlugValueWidget ) : <EOL> def __init__ ( self , plug , parenting = None ) : <EOL> menu = GafferUI . Menu ( Gaffer . WeakMethod ( self . __menuDefinition ) ) <EOL> menuButton = GafferUI . MenuButton ( menu = menu , image = "<STR_LIT>" , hasFrame = False ) <EOL> GafferUI . PlugValueWidget . __init__ ( self , menuButton , plug , parenting = parenting ) <EOL> def hasLabel ( self ) : <EOL> return True <EOL> def _updateFromPlug ( self ) : <EOL> pass <EOL> def __menuDefinition ( self ) : <EOL> m = IECore . MenuDefinition ( ) <EOL> m . append ( <EOL> "<STR_LIT>" , <EOL> { <EOL> "<STR_LIT>" : self . getPlug ( ) [ "<STR_LIT>" ] . getValue ( ) , <EOL> "<STR_LIT>" : self . getPlug ( ) [ "<STR_LIT>" ] . setValue , <EOL> } <EOL> ) <EOL> m . append ( <EOL> "<STR_LIT>" , <EOL> { <EOL> "<STR_LIT>" : self . getPlug ( ) . node ( ) [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <EOL> "<STR_LIT>" : self . getPlug ( ) . node ( ) [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue , <EOL> } <EOL> ) <EOL> return m </s>
