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

Render Pass Menu #6177

Merged
merged 12 commits into from
Jan 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PlugLayout : Support width metadata on customWidgets
murraystevenson authored and johnhaddon committed Jan 17, 2025
commit d32925da6350fec56c01e20c321d28691f085da4
4 changes: 3 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
@@ -17,7 +17,9 @@ Improvements
- The shading mode menu icon now updates to indicate when a non-default shading mode is in use.
- Added the ability to toggle between default shading and the last selected shading mode by <kbd>Ctrl</kbd> + clicking the shading mode menu button.
- PythonEditor : Added workaround for slow code completion caused by poorly performing Python property getters.
- PlugLayout : A warning widget is now displayed when an invalid custom widget is registered.
- PlugLayout :
- A warning widget is now displayed when an invalid custom widget is registered.
- `layout:customWidget:<name>:width` and `layout:customWidget:<name>:minimumWidth` metadata registrations are now supported for custom widgets.

Fixes
-----
25 changes: 15 additions & 10 deletions python/GafferUI/PlugLayout.py
Original file line number Diff line number Diff line change
@@ -390,22 +390,26 @@ def __import( self, path ) :

return result

def __setWidthFromMetadata( self, widget, item ) :

width = self.__itemMetadataValue( item, "width" )
if width is not None :
widget._qtWidget().setFixedWidth( width )

minimumWidth = self.__itemMetadataValue( item, "minimumWidth" )
if minimumWidth is not None :
widget._qtWidget().setMinimumWidth( minimumWidth )

if widget._qtWidget().layout() is not None and ( width is not None or minimumWidth is not None ) :
widget._qtWidget().layout().setSizeConstraint( QtWidgets.QLayout.SetDefaultConstraint )

def __createPlugWidget( self, plug ) :

result = GafferUI.PlugValueWidget.create( plug )
if result is None :
return result

width = self.__itemMetadataValue( plug, "width" )
if width is not None :
result._qtWidget().setFixedWidth( width )

minimumWidth = self.__itemMetadataValue( plug, "minimumWidth" )
if minimumWidth is not None :
result._qtWidget().setMinimumWidth( minimumWidth )

if result._qtWidget().layout() is not None and ( width is not None or minimumWidth is not None ) :
result._qtWidget().layout().setSizeConstraint( QtWidgets.QLayout.SetDefaultConstraint )
self.__setWidthFromMetadata( result, plug )

if isinstance( result, GafferUI.PlugValueWidget ) and not result.hasLabel() and self.__itemMetadataValue( plug, "label" ) != "" :
result = GafferUI.PlugWidget( result )
@@ -429,6 +433,7 @@ def __createCustomWidget( self, name ) :
try :
widgetClass = self.__import( widgetType )
result = widgetClass( self.__parent )
self.__setWidthFromMetadata( result, name )
except Exception as e :
message = "Could not create custom widget \"{}\" : {}".format( name, str( e ) )
IECore.msg( IECore.Msg.Level.Error, "GafferUI.PlugLayout", message )