diff --git a/python/GafferUI/RampPlugValueWidget.py b/python/GafferUI/RampPlugValueWidget.py index 774561f600..9793e3b048 100644 --- a/python/GafferUI/RampPlugValueWidget.py +++ b/python/GafferUI/RampPlugValueWidget.py @@ -146,6 +146,7 @@ def __positionsChanged( self, slider, reason ) : self.__positionsMergeGroupId += 1 self.__lastPositionChangedReason = reason + rejected = False plug = self.getPlug() with Gaffer.UndoScope( plug.ancestor( Gaffer.ScriptNode ), @@ -155,7 +156,12 @@ def __positionsChanged( self, slider, reason ) : if len( slider.getPositions() ) == plug.numPoints() : # the user has moved an existing point on the slider for index, position in enumerate( slider.getPositions() ) : - plug.pointXPlug( index ).setValue( position ) + if plug.pointXPlug( index ).getValue() != position : + curPlug = plug.pointXPlug( index ) + if curPlug.settable() and not Gaffer.MetadataAlgo.readOnly( curPlug ): + curPlug.setValue( position ) + else: + rejected = True else : # a new position was added on the end by the user clicking # on an empty area of the slider. @@ -163,14 +169,33 @@ def __positionsChanged( self, slider, reason ) : assert( len( slider.getPositions() ) == numPoints + 1 ) spline = plug.getValue().spline() position = slider.getPositions()[numPoints] - plug.addPoint() - plug.pointXPlug( numPoints ).setValue( position ) - plug.pointYPlug( numPoints ).setValue( spline( position ) ) + if not ( plug.getInput() or plug.direction() == Gaffer.Plug.Direction.Out + or Gaffer.MetadataAlgo.readOnly( plug ) + ): + plug.addPoint() + plug.pointXPlug( numPoints ).setValue( position ) + plug.pointYPlug( numPoints ).setValue( spline( position ) ) + else: + rejected = True + + if rejected: + self._updateFromPlug() def __indexRemoved( self, slider, index ) : - with Gaffer.UndoScope( self.getPlug().ancestor( Gaffer.ScriptNode ) ) : - self.getPlug().removePoint( index ) + plug = self.getPlug() + rejected = False + with Gaffer.UndoScope( plug.ancestor( Gaffer.ScriptNode ) ) : + if not ( plug.getInput() or plug.direction() == Gaffer.Plug.Direction.Out + or Gaffer.MetadataAlgo.readOnly( plug ) + ): + self.getPlug().removePoint( index ) + else: + rejected = True + + if rejected: + self._updateFromPlug() + def __selectedIndexChanged( self, slider ) : diff --git a/python/GafferUI/Slider.py b/python/GafferUI/Slider.py index b2fa525388..bcf0b2031e 100644 --- a/python/GafferUI/Slider.py +++ b/python/GafferUI/Slider.py @@ -333,7 +333,7 @@ def __buttonPress( self, widget, event ) : positions = self.getPositions()[:] positions.append( float( event.line.p0.x ) / self.size().x ) self._setPositionsInternal( positions, self.PositionChangedReason.IndexAdded ) - self.setSelectedIndex( len( positions ) - 1 ) + self.setSelectedIndex( len( self.getPositions() ) - 1 ) return True diff --git a/python/GafferUI/SplinePlugValueWidget.py b/python/GafferUI/SplinePlugValueWidget.py index eebcb78d39..61e044a1f9 100644 --- a/python/GafferUI/SplinePlugValueWidget.py +++ b/python/GafferUI/SplinePlugValueWidget.py @@ -86,9 +86,6 @@ def __buttonPress( self, button, event ) : if event.buttons & event.Buttons.Left : - if not self._editable() : - return False - _SplinePlugValueDialogue.acquire( self.getPlug() ) return True