From a3281eccb11008025c7fc0ca3c83e5c86df6a926 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Tue, 24 Sep 2024 16:55:33 +0100 Subject: [PATCH] _HistoryWindow : Use ContextTracker 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. --- Changes.md | 4 ++++ python/GafferSceneUI/_HistoryWindow.py | 24 +++++++++++++----------- python/GafferSceneUI/_InspectorColumn.py | 9 +++------ 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Changes.md b/Changes.md index 142b7f005e..35e1043c79 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ Improvements ------------ - NodeEditor : Added Alt + 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 ----- @@ -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. diff --git a/python/GafferSceneUI/_HistoryWindow.py b/python/GafferSceneUI/_HistoryWindow.py index 5a1948d4fa..295326ac67 100644 --- a/python/GafferSceneUI/_HistoryWindow.py +++ b/python/GafferSceneUI/_HistoryWindow.py @@ -132,7 +132,7 @@ 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" @@ -140,7 +140,7 @@ def __init__( self, inspector, scenePath, context, title=None, **kw ) : GafferUI.Window.__init__( self, title, **kw ) self.__inspector = inspector - self.__scenePath = scenePath + self.__inspectionPath = inspectionPath with self : self.__pathListingWidget = GafferUI.PathListingWidget( @@ -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 ) : @@ -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 ) : diff --git a/python/GafferSceneUI/_InspectorColumn.py b/python/GafferSceneUI/_InspectorColumn.py index 8f1e3d5b74..5ffc842588 100644 --- a/python/GafferSceneUI/_InspectorColumn.py +++ b/python/GafferSceneUI/_InspectorColumn.py @@ -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 )