From 81b7b4b6a2d48259b6163c44f7d8c9461df3274a Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:12:16 -0700 Subject: [PATCH] EditScopeUI : Respect `:width` metadata Rather than setting a fixed width to the MenuButton, allow `:width` metadata to govern the overall width of the widget. This then allows customisation of the width via metadata registration in a startup file. --- Changes.md | 1 + python/GafferSceneUI/LightEditor.py | 1 + python/GafferSceneUI/RenderPassEditor.py | 1 + python/GafferSceneUI/SceneViewUI.py | 3 ++- python/GafferUI/EditScopeUI.py | 4 +++- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Changes.md b/Changes.md index c6b6ee71cb..ebd905bf86 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ Improvements ------------ - Cryptomatte : Renamed `__manifestScene` plug to `manifestScene` so it is no longer considered to be private. +- EditScopePlugValueWidget : Width can now be configured via `:width` metadata. This enables customisation of the Edit Scope menu width by registering metadata in a startup file, such as `Gaffer.Metadata.registerValue( GafferSceneUI.RenderPassEditor.Settings, "editScope", "layout:width", 450 )` to double the standard width of the Edit Scope menu in the Render Pass Editor. Fixes ----- diff --git a/python/GafferSceneUI/LightEditor.py b/python/GafferSceneUI/LightEditor.py index ddd4c41e37..f78ab4aa63 100644 --- a/python/GafferSceneUI/LightEditor.py +++ b/python/GafferSceneUI/LightEditor.py @@ -866,6 +866,7 @@ def __showHistory( self, *unused ) : "editScope" : [ "plugValueWidget:type", "GafferUI.EditScopeUI.EditScopePlugValueWidget", + "layout:width", 225, ], diff --git a/python/GafferSceneUI/RenderPassEditor.py b/python/GafferSceneUI/RenderPassEditor.py index b279459f24..010fd66c5d 100644 --- a/python/GafferSceneUI/RenderPassEditor.py +++ b/python/GafferSceneUI/RenderPassEditor.py @@ -1012,6 +1012,7 @@ def __updateButtonStatus( self, *unused ) : "editScope" : [ "plugValueWidget:type", "GafferUI.EditScopeUI.EditScopePlugValueWidget", + "layout:width", 225, ], diff --git a/python/GafferSceneUI/SceneViewUI.py b/python/GafferSceneUI/SceneViewUI.py index 8485fc7736..1c1fe1206a 100644 --- a/python/GafferSceneUI/SceneViewUI.py +++ b/python/GafferSceneUI/SceneViewUI.py @@ -103,8 +103,9 @@ def __rendererPlugActivator( plug ) : "editScope" : [ - "toolbarLayout:index", -1, "plugValueWidget:type", "GafferUI.EditScopeUI.EditScopePlugValueWidget", + "toolbarLayout:index", -1, + "toolbarLayout:width", 225, ], diff --git a/python/GafferUI/EditScopeUI.py b/python/GafferUI/EditScopeUI.py index 88341dcba5..7f0dc3e8ab 100644 --- a/python/GafferUI/EditScopeUI.py +++ b/python/GafferUI/EditScopeUI.py @@ -47,6 +47,7 @@ from GafferUI._StyleSheet import _styleColors from Qt import QtGui +from Qt import QtWidgets Gaffer.Metadata.registerNode( @@ -131,7 +132,8 @@ def __init__( self, plug, **kw ) : menu = GafferUI.Menu( Gaffer.WeakMethod( self.__menuDefinition ) ), highlightOnOver = False ) - self.__menuButton._qtWidget().setFixedWidth( 120 ) + # Ignore the width in X so MenuButton width is limited by the overall width of the widget + self.__menuButton._qtWidget().setSizePolicy( QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Fixed ) self.__navigationMenuButton = GafferUI.MenuButton( image = "navigationArrow.png", hasFrame = False,