Skip to content

Commit

Permalink
EditScopePlugValueWidget : Add Refresh menu item
Browse files Browse the repository at this point in the history
This allows the user to get explicit feedback about ContextTracker updates in the unlikely event that they are slow enough to not be done before the menu is accessed. I've deliberately only shown the BusyWidget when the user "opts in" via a refresh as I think most updates are going to be so rapid that it would flicker annoyingly for them.
  • Loading branch information
johnhaddon committed Jul 24, 2024
1 parent 608216c commit d8e5fa0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions python/GafferUI/EditScopeUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def __init__( self, plug, **kw ) :
with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) :
GafferUI.Spacer( imath.V2i( 4, 1 ), imath.V2i( 4, 1 ) )
GafferUI.Label( "Edit Scope" )
self.__busyWidget = GafferUI.BusyWidget( size = 18 )
self.__busyWidget.setVisible( False )
self.__menuButton = GafferUI.MenuButton(
"",
menu = GafferUI.Menu( Gaffer.WeakMethod( self.__menuDefinition ) ),
Expand Down Expand Up @@ -247,6 +249,7 @@ def __editScopeMetadataChanged( self, editScope, key, reason ) :
def __contextTrackerChanged( self, contextTracker ) :

self.__updateMenuButton()
self.__busyWidget.setVisible( False )

def __editScope( self ) :

Expand Down Expand Up @@ -409,13 +412,24 @@ def addToMenuHierarchy( editScope, root ) :
result.update( self.__buildMenu( result, category, currentEditScope ) )


if self.__contextTracker.updatePending() :
result.append( "/__RefreshDivider__", { "divider" : True } )
result.append( "/Refresh", { "command" : Gaffer.WeakMethod( self.__refreshMenu ) } )

result.append( "/__NoneDivider__", { "divider" : True } )
result.append(
"/None", { "command" : functools.partial( self.getPlug().setInput, None ) },
)

return result

def __refreshMenu( self ) :

if self.__contextTracker.updatePending() :
# An update will already be in progress so we just show our busy
# widget until it is done.
self.__busyWidget.setVisible( True )

def __navigationMenuDefinition( self ) :

result = IECore.MenuDefinition()
Expand Down

0 comments on commit d8e5fa0

Please sign in to comment.