-
Notifications
You must be signed in to change notification settings - Fork 206
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
StyleSheet : Reserve space for valueChanged
icon
#5737
Conversation
Thanks Eric. Although this does fix things as advertised, I'm seeing a few unwanted side-effects in other areas of the UI... Cropping of the labels on the various Query node outputs : Less bad, but we now have an indent on the labels in the spline editor, which breaks the top-to-bottom flow : I found these just by searching for places we used LabelPlugValueWidget - you might want to check for others. For the Query nodes I think there's a pretty simple fix - these are output plugs so they will never ever have the green dot applied to them (see I also think we could probably be a bit more frugal with the space anyway. The icon seems to contain an integral 3 pixel gap on the left, but then I think with the padding we're making a bigger (6 pixel?) gap on the right. Might be worth dropping that to 3, or maybe even dropping them both to 2? CI seems to have gone bananas, and I can't figure out why. The PR is for 1.3_maintenance but there are CI runs using the new build platform that only applies to 1.4. Hopefully that also accounts for why they're failing in an utterly bizarre way too. Could you maybe retarget this to |
I touched up the icon and its padding so it's a little more condensed now. I went with 2px on each side, though the icon doesn't strictly align to the pixel grid so it's more like 1.5px on each side. Not sure if that alignment is something that needs changing. I also put in a scheme for identifying labels for output plugs and removing the indentation for those. It seems to be helping the query plugs. Last is the color spline - I tried putting the label and value on the same line. I think it looks better, but not 100% convinced. It shrinks the available space for the color sliders a little. I haven't figured out how to get the alignment the same for the "Position" and "Value" labels - Fingers crossed for CI. I initially had it targeting It's now rebased on Not quite ready for a full review, I want to look at a wider variety of plugs and also sort out the alignment of the spline color values first. |
91438b3
to
c222cb5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Eric. This is looking good aesthetics-wise I think. I've made a few inline suggestions for potentially tidying up the implementation a little, and for getting the dots aligned in the RampPlugValueWidget...
if any( p.direction() == Gaffer.Plug.Direction.In for p in self.getPlugs() ) : | ||
self.__label._qtWidget().setProperty( "gafferValueChanged", GafferUI._Variant.toVariant( False ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this in __setValueChanged()
instead of here, so that everything is all in one place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a potential change for this in 0aedb34. It's nice to get that all in one place, but it does require a setStyleSheet()
call in order to recognized the padding-left
change.
It doesn't seem to have caused jumpy layouts or other issues, but I don't know if there are knock-on effects from setStyleSheet()
.
self.__positionLabel = GafferUI.LabelPlugValueWidget( plug.pointXPlug( 0 ) ) | ||
self.__positionField = GafferUI.NumericPlugValueWidget( plug.pointXPlug( 0 ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're inside a with column
block here, these widgets are going to first be parented to that column before being pulled out and parented elsewhere by the addChild()
calls below. I find the structured (with
) style of UI building much more readable than the manual addChild()
method, because you can see the structure of the UI in the structure of the code. So I'd suggest that the lesser evil would be to use with
when constructing the containers below, even if it means two lines that create the position widgets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely possible to give a fixed width to the labels - the trick is to do what PlugWidget does, and set the width on the label inside the widget : self.__positionLabel.label()._qtWidget().setFixedWidth( 400 )
. I think it would be worth doing this to get the green dots to align.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice, thanks for that tip on label()._qtWidget()
, it's helpful. I added that in 5cdd19a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the structured (
with
) style of UI building much more readable than the manualaddChild()
method
I agree, and definitely shouldn't be added and then removed from the parent container. I'll make that change, pending what we ultimately go with for the container choice discussed below.
if isinstance( plug.pointYPlug( 0 ), Gaffer.FloatPlug ) : | ||
row = GafferUI.ListContainer( orientation = GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) | ||
|
||
row.addChild( self.__positionLabel, verticalAlignment = GafferUI.VerticalAlignment.Top ) | ||
row.addChild( self.__positionField, verticalAlignment = GafferUI.VerticalAlignment.Top ) | ||
|
||
row.addChild( self.__valueLabel, verticalAlignment = GafferUI.VerticalAlignment.Top ) | ||
row.addChild( self.__valueField, verticalAlignment = GafferUI.VerticalAlignment.Top ) | ||
else : | ||
grid = GafferUI.GridContainer( spacing = 4 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could use a single with GridContainer()
for both cases, and then the only thing that would differ for the float and color modes would be the indices of the widgets within the grid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my initial approach, but I wasn't super happy with the layout for float splines. Here's what that looks like :
It seems odd to me that it doesn't fill the width, but maybe that's just me being used to the old style. Maybe there's a way to expand the widgets, setSizePolicy()
sounds like a good place to try.
aa3eeab
to
9bee911
Compare
Ok, now that I know how to set the width of the label, the spline plug layouts got a lot easier. The latest push has everything squashed down and is ready for a new review. |
if valueChanged == self.__getValueChanged() : | ||
return | ||
|
||
self.__label._qtWidget().setProperty( "gafferValueChanged", GafferUI._Variant.toVariant( valueChanged ) ) | ||
self.__label._repolish() | ||
self.__label._setStyleSheet() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be the only place in Gaffer where we've needed this on anything other than a top-level widget - all other widgets just inherit from their parents. It doesn't seem to be necessary here (testing on Linux), and in fact actually seems to cause clipping of the labels in the ColorSpline UI. What problems were you seeing without it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without _setStyleSheet()
I don't get the space reserved for the green dot, so it overlaps with the label.
I found some references online implying that padding would not be taken into account in Qt's polish()
method. It is a little vague, but if the Qt documentation's mention of not changing geometry includes padding, then that sounds like intended behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if isinstance( plug.pointYPlug( 0 ), Gaffer.FloatPlug ): | ||
self.__valueField = GafferUI.NumericPlugValueWidget( | ||
plug.pointYPlug( 0 ), | ||
with GafferUI.ListContainer( orientation = GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am finding the new layout for ColorSplines a little bit less satisfactory than the old one. I'm wondering if it would make sense to just have a way of turning off the green dots for certain widgets or plugs instead? The idea of a non-default value doesn't make much sense for spline positions/values, at least once you've started adding your own points.
Paging @murraystevenson for a second opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that we talked about this in our weekly meeting and decided to hide the icon for spline position and value plugs. Done in d3aaa2f
9bee911
to
d3aaa2f
Compare
I think I have a good implementation of what we talked about today. For input plugs, If it's an output plug, we never set the value And lastly, the Ready for a new look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry Eric, this seems to be the PR that refuses to die! I've made two new comments inline, which I think do need addressing. In the interests of getting a release out today, I've opened #5764 with fixups for those, and a couple of other optional commits for your consideration...I'll leave it to you and @murraystevenson which bits you take...
@@ -72,6 +74,15 @@ def __init__( self, plug, horizontalAlignment=GafferUI.Label.HorizontalAlignment | |||
self.__label._qtWidget().setFixedHeight( 20 ) | |||
layout.addWidget( self.__label._qtWidget() ) | |||
|
|||
showIndicator = False | |||
if all( p.direction() == Gaffer.Plug.Direction.In for p in self.getPlugs() ) : | |||
showIndicator = Gaffer.Metadata.value( self.getPlug(), "showValueChangedIndicator" ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.getPlug()
will throw if the widget is created for more than a single plug. I'm not sure if we're currently using the multiple-plugs facility with LabelPlugValueWidget, but elsewhere in this file we are being careful to make sure it works.
@@ -83,6 +83,7 @@ def __init__( self, plug, **kw ) : | |||
spacing = 4 | |||
) : | |||
|
|||
Gaffer.Metadata.registerValue( plug.pointXPlug( 0 ), "showValueChangedIndicator", False ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is making metadata that is serialised with the file unnecessarily. We should be able to create a static registration instead.
d3aaa2f
to
87632d3
Compare
87632d3
to
e36cc50
Compare
Thanks for the fixes in #5764, @johnhaddon. I tried to squash down and push to your branch to merge, but I don't seem to have the right permissions. I pushed back to this branch with your fixes, and dropped the speculative commit where you used a I also rebased onto #5765 to pick up that Windows build fix. @murraystevenson, this is ready for a final check and merge assuming all is well. |
Thanks! Merging. |
This fixes the
valueChanged
icon overlap with Transform tool orientation plugs. It would initially overlap the left side of the text when changing the orientation fromParent
. If you then changed to another tool and back to the first, it would be fixed when Qt laid you the widgets again. By always reserving the space, the icon always appears correctly.Checklist