Skip to content

Commit

Permalink
Path / SetFilterUI : Add notEditable pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Nov 18, 2024
1 parent 863be3d commit 42f7ab3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions python/GafferSceneUI/PathFilterUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def __popupMenu( menuDefinition, plugValueWidget ) :
GafferUI.Pointer.registerPointer( "removeObjects", GafferUI.Pointer( "removeObjects.png", imath.V2i( 53, 14 ) ) )
GafferUI.Pointer.registerPointer( "replaceObjects", GafferUI.Pointer( "replaceObjects.png", imath.V2i( 53, 14 ) ) )

__DropMode = enum.Enum( "__DropMode", [ "None_", "Add", "Remove", "Replace" ] )
__DropMode = enum.Enum( "__DropMode", [ "None_", "Add", "Remove", "Replace", "NotEditable" ] )

__originalDragPointer = None

Expand Down Expand Up @@ -272,13 +272,13 @@ def __dropMode( nodeGadget, event ) :
if filterPlug.getInput() is not None :
filter = filterPlug.source().node()
if filter is None :
return __DropMode.Replace if __editable( filterPlug ) else __DropMode.None_
return __DropMode.Replace if __editable( filterPlug ) else __DropMode.NotEditable
elif not isinstance( filter, GafferScene.PathFilter ) :
return __DropMode.None_
pathsPlug = __pathsPlug( filter )

if not __editable( pathsPlug ) :
return __DropMode.None_
return __DropMode.NotEditable

if event.modifiers & event.Modifiers.Shift :
return __DropMode.Add
Expand Down Expand Up @@ -351,7 +351,10 @@ def __dragMove( nodeGadget, event ) :
if __originalDragPointer is None :
return False

GafferUI.Pointer.setCurrent( __dropMode( nodeGadget, event ).name.lower() + "Objects" )
dropMode = __dropMode( nodeGadget, event )
GafferUI.Pointer.setCurrent(
dropMode.name.lower() + "Objects" if dropMode != __DropMode.NotEditable else "notEditable"
)

return True

Expand All @@ -361,6 +364,9 @@ def __drop( nodeGadget, event ) :
if __originalDragPointer is None :
return False

if __dropMode( nodeGadget, event ) == __DropMode.NotEditable :
return True

pathsPlug = __pathsPlug( nodeGadget.node() )
if pathsPlug is None :
pathsPlug = __pathsPlug( __filterPlug( nodeGadget.node() ).source().node() )
Expand Down
14 changes: 10 additions & 4 deletions python/GafferSceneUI/SetFilterUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
GafferUI.Pointer.registerPointer( "removeSets", GafferUI.Pointer( "pointerRemoveSets.png", imath.V2i( 53, 14 ) ) )
GafferUI.Pointer.registerPointer( "replaceSets", GafferUI.Pointer( "pointerReplaceSets.png", imath.V2i( 53, 14 ) ) )

__DropMode = enum.Enum( "__DropMode", [ "None_", "Add", "Remove", "Replace" ] )
__DropMode = enum.Enum( "__DropMode", [ "None_", "Add", "Remove", "Replace", "NotEditable" ] )

__originalDragPointer = None

Expand Down Expand Up @@ -146,13 +146,13 @@ def __dropMode( nodeGadget, event ) :
if nodeGadget.node()["filter"].getInput() is not None :
filter = nodeGadget.node()["filter"].source().node()
if filter is None :
return __DropMode.Replace if __editable( nodeGadget.node()["filter"] ) else __DropMode.None_
return __DropMode.Replace if __editable( nodeGadget.node()["filter"] ) else __DropMode.NotEditable
elif not isinstance( filter, GafferScene.SetFilter ) :
return __DropMode.None_
setsPlug = filter["setExpression"]

if not __editable( setsPlug ) :
return __DropMode.None_
return __DropMode.NotEditable

if event.modifiers & event.Modifiers.Shift :
return __DropMode.Add
Expand Down Expand Up @@ -201,7 +201,10 @@ def __dragMove( nodeGadget, event ) :
if __originalDragPointer is None :
return False

GafferUI.Pointer.setCurrent( __dropMode( nodeGadget, event ).name.lower() + "Sets" )
dropMode = __dropMode( nodeGadget, event )
GafferUI.Pointer.setCurrent(
dropMode.name.lower() + "Sets" if dropMode != __DropMode.NotEditable else "notEditable"
)

return True

Expand All @@ -211,6 +214,9 @@ def __drop( nodeGadget, event ) :
if __originalDragPointer is None :
return False

if __dropMode( nodeGadget, event ) == __DropMode.NotEditable :
return True

setsPlug = __setsPlug( nodeGadget.node() )
if setsPlug is None :
setsPlug = __setsPlug( nodeGadget.node()["filter"].source().node() )
Expand Down

0 comments on commit 42f7ab3

Please sign in to comment.