Skip to content

Commit

Permalink
_HistoryWindow : Use ContextTracker
Browse files Browse the repository at this point in the history
While also taking some small steps to making the window scene-agnostic. We no longer manage `scene:path` explicitly in the window, with one immediate benefit being that it doesn't leak a nonsense value into the context given to RenderPassEditor inspectors.

This also fixes updates in the RenderPassEditor for animated properties, which weren't working in 1.4, even before the introduction of ContextTracker.

I'm not entirely happy about passing an `inspectionPath` though. We do need to pass something to provide an inspection context, but it seems weird to pass a path, especially when the majority of the Context now comes from the ContextTracker. I'm wondering if we should instead pass a small dictionary of context overrides (`scene:path` in LightEditor and `renderPass` in RenderPassEditor). But I'm not sure how we'd obtain them. Regardless, this still represents progress.
  • Loading branch information
johnhaddon committed Sep 24, 2024
1 parent f2cb10b commit a3281ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
4 changes: 4 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Improvements
------------

- NodeEditor : Added <kbd>Alt</kbd> + middle-click action for showing context variable substitutions in strings.
- LightEditor, RenderPassEditor : History windows now use a context determined relative to the current focus node.

Fixes
-----
Expand All @@ -15,6 +16,9 @@ Fixes
- Fixed unnecessary texture updates when specific image tiles don't change.
- GraphEditor :
- Fixed lingering error badges (#3820).
- RenderPassEditor :
- Fixed history window to update on context changes, for example, when the current frame is changed.
- Fixed invalid `scene:path` context variables created by the history window. [^1]

[^1]: To be omitted from 1.5.0.0 release notes.

Expand Down
24 changes: 13 additions & 11 deletions python/GafferSceneUI/_HistoryWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ def headerData( self, canceller = None ) :

class _HistoryWindow( GafferUI.Window ) :

def __init__( self, inspector, scenePath, context, title=None, **kw ) :
def __init__( self, inspector, inspectionPath, title=None, **kw ) :

if title is None :
title = "History"

GafferUI.Window.__init__( self, title, **kw )

self.__inspector = inspector
self.__scenePath = scenePath
self.__inspectionPath = inspectionPath

with self :
self.__pathListingWidget = GafferUI.PathListingWidget(
Expand Down Expand Up @@ -168,17 +168,19 @@ def __init__( self, inspector, scenePath, context, title=None, **kw ) :

inspector.dirtiedSignal().connect( Gaffer.WeakMethod( self.__inspectorDirtied ) )

context.changedSignal().connect( Gaffer.WeakMethod( self.__contextChanged ) )
## \todo We want to make the inspection framework scene-agnostic. We could add an `Inspector::plug()` method
# to provide a scene-agnostic way of querying what is being inspected, and use it here.
self.__contextTracker = GafferUI.ContextTracker.acquireForFocus( self.__inspectionPath.getScene() )
self.__contextTracker.changedSignal().connect( Gaffer.WeakMethod( self.__contextChanged ) )
self.__updatePath()

self.__updatePath( context )
def __updatePath( self ) :

def __updatePath( self, newContext ) :

with Gaffer.Context( newContext ) as context :
context["scene:path"] = GafferScene.ScenePlug.stringToPath( self.__scenePath )
self.__inspectionPath.setContext( self.__contextTracker.context( self.__inspectionPath.getScene() ) )
with self.__inspectionPath.inspectionContext() :
self.__path = self.__inspector.historyPath()
self.__pathChangedConnection = self.__path.pathChangedSignal().connect( Gaffer.WeakMethod( self.__pathChanged ), scoped = True )

self.__pathChangedConnection = self.__path.pathChangedSignal().connect( Gaffer.WeakMethod( self.__pathChanged ), scoped = True )
self.__pathListingWidget.setPath( self.__path )

def __pathChanged( self, path ) :
Expand Down Expand Up @@ -270,9 +272,9 @@ def __inspectorDirtied( self, inspector ) :

self.__path._emitPathChanged()

def __contextChanged( self, context, key ) :
def __contextChanged( self, contextTracker ) :

self.__updatePath( context )
self.__updatePath()

def __updateFinished( self, pathListing ) :

Expand Down
9 changes: 3 additions & 6 deletions python/GafferSceneUI/_InspectorColumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,19 +329,16 @@ def __showHistory( pathListing ) :

columns = pathListing.getColumns()
selection = pathListing.getSelection()
path = pathListing.getPath().copy()

for i, column in enumerate( columns ) :
for pathString in selection[i].paths() :
path = pathListing.getPath().copy()
path.setFromString( pathString )
inspectionContext = path.inspectionContext()
if inspectionContext is None :
if path.inspectionContext() is None :
continue

window = _HistoryWindow(
column.inspector(),
pathString,
inspectionContext,
path,
"History : {} : {}".format( pathString, column.headerData().value )
)
pathListing.ancestor( GafferUI.Window ).addChildWindow( window, removeOnClose = True )
Expand Down

0 comments on commit a3281ec

Please sign in to comment.