From cf766b8abb16dc54b330aabde79cbf31c578f94f Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Thu, 13 Feb 2025 11:51:25 -0800 Subject: [PATCH] Inspector : Direct edits should set the TweakPlug to `Create` mode --- python/GafferSceneUITest/AttributeInspectorTest.py | 6 ++++++ python/GafferSceneUITest/OptionInspectorTest.py | 6 ++++++ python/GafferSceneUITest/ParameterInspectorTest.py | 6 ++++++ src/GafferSceneUI/Inspector.cpp | 1 + 4 files changed, 19 insertions(+) diff --git a/python/GafferSceneUITest/AttributeInspectorTest.py b/python/GafferSceneUITest/AttributeInspectorTest.py index 91c5dd9d9e..a54280c270 100644 --- a/python/GafferSceneUITest/AttributeInspectorTest.py +++ b/python/GafferSceneUITest/AttributeInspectorTest.py @@ -1082,5 +1082,11 @@ def assertEdit( inspection, data, nonEditableReason ) : self.assertEqual( acquiredEdit["enabled"].getValue(), True ) self.assertEqual( acquiredEdit["value"].getValue(), 789.0 ) + # Editing an existing edit should set its mode to `Create` + acquiredEdit["mode"].setValue( Gaffer.TweakPlug.Mode.Multiply ) + assertEdit( inspection, IECore.FloatData( 123.0 ), "" ) + self.assertEqual( acquiredEdit["mode"].getValue(), Gaffer.TweakPlug.Mode.Create ) + self.assertEqual( acquiredEdit["value"].getValue(), 123.0 ) + if __name__ == "__main__" : unittest.main() diff --git a/python/GafferSceneUITest/OptionInspectorTest.py b/python/GafferSceneUITest/OptionInspectorTest.py index 70c6a52fe5..f8116e548a 100644 --- a/python/GafferSceneUITest/OptionInspectorTest.py +++ b/python/GafferSceneUITest/OptionInspectorTest.py @@ -1094,5 +1094,11 @@ def assertEdit( inspection, data, nonEditableReason ) : self.assertTrue( acquiredEdit["enabled"].getValue() ) self.assertEqual( acquiredEdit["value"].getValue(), "/anotherCamera" ) + # Editing an existing edit should set its mode to `Create` + acquiredEdit["mode"].setValue( Gaffer.TweakPlug.Mode.ListAppend ) + assertEdit( inspection, IECore.StringData( "/existingCamera" ), "" ) + self.assertEqual( acquiredEdit["mode"].getValue(), Gaffer.TweakPlug.Mode.Create ) + self.assertEqual( acquiredEdit["value"].getValue(), "/existingCamera" ) + if __name__ == "__main__" : unittest.main() diff --git a/python/GafferSceneUITest/ParameterInspectorTest.py b/python/GafferSceneUITest/ParameterInspectorTest.py index 0abf3ed78a..255e9bdde3 100644 --- a/python/GafferSceneUITest/ParameterInspectorTest.py +++ b/python/GafferSceneUITest/ParameterInspectorTest.py @@ -1269,5 +1269,11 @@ def assertEdit( inspection, data, nonEditableReason ) : self.assertTrue( acquiredEdit["enabled"].getValue() ) self.assertEqual( acquiredEdit["value"].getValue(), 789.0 ) + # Editing an existing edit should set its mode to `Create` + acquiredEdit["mode"].setValue( Gaffer.TweakPlug.Mode.Max ) + assertEdit( inspection, IECore.FloatData( 123.0 ), "" ) + self.assertEqual( acquiredEdit["mode"].getValue(), Gaffer.TweakPlug.Mode.Create ) + self.assertEqual( acquiredEdit["value"].getValue(), 123.0 ) + if __name__ == "__main__": unittest.main() diff --git a/src/GafferSceneUI/Inspector.cpp b/src/GafferSceneUI/Inspector.cpp index 9dc8e7078e..8f8e1ff638 100644 --- a/src/GafferSceneUI/Inspector.cpp +++ b/src/GafferSceneUI/Inspector.cpp @@ -215,6 +215,7 @@ void edit( Gaffer::ValuePlug *plug, const IECore::Object *value ) else if( auto tweakPlug = runTimeCast( plug ) ) { tweakPlug->enabledPlug()->setValue( true ); + tweakPlug->modePlug()->setValue( TweakPlug::Mode::Create ); valuePlug = tweakPlug->valuePlug(); } else if( auto optionalValuePlug = runTimeCast( plug ) )