Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Ramp Widget For Read-Only Plugs #3417

Merged
merged 3 commits into from Oct 24, 2019

Conversation

danieldresser-ie
Copy link
Contributor

It's been a long term annoyance for artists at IE that they would gang the channels of a color plug on a ramp, and everything would work fine, but then once they closed the ramp editor, they would be unable to open it again. We only recently figured out what was happening - it was just reported as "ramps break sometimes" - it is pretty tricky to figure out what's going on, because everything continues working fine until you close the window.

When thinking about how to fix this, one option would have been to allow showing ramps as long as everything but the Y components are editable, since the existing UI already handles readOnly y components properly.

I decided to take a quick look at fixing it properly though, so you can always open the editor, even for completely readOnly ramps. Maybe you'll spot something I've missed, but this now seems to all be working correctly, and is definitely a nice feature.

@andrewkaufman
Copy link
Contributor

As mentioned, it'd be lovely to get this into 0.55

@johnhaddon johnhaddon merged commit 78d4434 into GafferHQ:master Oct 24, 2019
Copy link
Member

@johnhaddon johnhaddon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting to the bottom of this one Daniel. I had already merged this when I realised we actually do have enough in the Slider API to proactively prevent rather than retroactively revert some of the unwanted edits, so let's take advantage of that where we can. I'll release as-is, but if you could make a follow up PR that would be great...

@@ -155,22 +156,46 @@ 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 :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the better approach to this would be to add something like a Slider.setPositionsReadOnly( boolPerPosition ) method, so we don't have to retroactively undo the unwanted actions, and the UI has the knowledge to represent immovability graphically if it wants to. One problem with that would be the inconsistent state in between a setPositions( someNewLength ) call and a setPositionsReadOnly( matchingTheNewLength ) call, so maybe it should really be a second argument to setPositions( positions, readOnly )? I dunno, I don't have a strong idea here, and @themissingcow and I are considering a future Slider refactor anyway, so I'm happy to leave that for later.

plug.addPoint()
plug.pointXPlug( numPoints ).setValue( position )
plug.pointYPlug( numPoints ).setValue( spline( position ) )
if not ( plug.getInput() or plug.direction() == Gaffer.Plug.Direction.Out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary - we already have Slider.setSizeEditable(), so we can just tell the slider upfront that it can't introduce new points, rather than having to retroactively remove them.

plug = self.getPlug()
rejected = False
with Gaffer.UndoScope( plug.ancestor( Gaffer.ScriptNode ) ) :
if not ( plug.getInput() or plug.direction() == Gaffer.Plug.Direction.Out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be covered by use of Slider.setSizeEditable().

@@ -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 )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can revert this if we take advantage of setSizeEditable() instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants