Skip to content

Commit

Permalink
Added value drag/drop to SceneInspector.
Browse files Browse the repository at this point in the history
Fixes #830.
  • Loading branch information
johnhaddon committed Jul 23, 2014
1 parent bbe98dc commit 5a2e90d
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions python/GafferSceneUI/SceneInspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,22 @@ def __init__( self, orientation=GafferUI.ListContainer.Orientation.Vertical, hig

Diff.__init__( self, orientation, **kw )

self.frame( 0 ).setChild( GafferUI.Label() )
self.frame( 1 ).setChild( GafferUI.Label() )
self.__connections = []
for i in range( 0, 2 ) :
label = GafferUI.Label()
self.__connections.append( label.buttonPressSignal().connect( Gaffer.WeakMethod( self.__buttonPress ) ) )
self.__connections.append( label.dragBeginSignal().connect( Gaffer.WeakMethod( self.__dragBegin ) ) )
self.__connections.append( label.dragEndSignal().connect( Gaffer.WeakMethod( self.__dragEnd ) ) )
self.frame( i ).setChild( label )

self.__highlightDiffs = highlightDiffs

def update( self, values ) :

Diff.update( self, values )

self.__values = values

formattedValues = self.__formatValues( values )
for i, value in enumerate( formattedValues ) :
self.frame( i ).getChild().setText( self.__htmlHeader + value + self.__htmlFooter )
Expand Down Expand Up @@ -429,6 +436,19 @@ def __highlightFromFirstDifference( self, values ) :
values[1][:d] + "<span class=diffB>" + values[1][d:] + "</span>",
]

def __buttonPress( self, widget, event ) :

return bool( event.buttons & event.Buttons.Left )

def __dragBegin( self, widget, event ) :

GafferUI.Pointer.setFromFile( "values.png" )
return self.__values[0] if self.frame( 0 ).isAncestorOf( widget ) else self.__values[1]

def __dragEnd( self, widget, event ) :

GafferUI.Pointer.set( None )

__htmlHeader = (
"<html><head><style type=text/css>"
".diffA { background-color:rgba( 255, 77, 3, 75 ); }"
Expand Down

0 comments on commit 5a2e90d

Please sign in to comment.