Skip to content

Commit

Permalink
Inspector : Direct edits should set the TweakPlug to Create mode
Browse files Browse the repository at this point in the history
  • Loading branch information
murraystevenson committed Feb 14, 2025
1 parent e195bae commit cf766b8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/GafferSceneUITest/AttributeInspectorTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 6 additions & 0 deletions python/GafferSceneUITest/OptionInspectorTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 6 additions & 0 deletions python/GafferSceneUITest/ParameterInspectorTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 1 addition & 0 deletions src/GafferSceneUI/Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ void edit( Gaffer::ValuePlug *plug, const IECore::Object *value )
else if( auto tweakPlug = runTimeCast<TweakPlug>( plug ) )
{
tweakPlug->enabledPlug()->setValue( true );
tweakPlug->modePlug()->setValue( TweakPlug::Mode::Create );
valuePlug = tweakPlug->valuePlug();
}
else if( auto optionalValuePlug = runTimeCast<OptionalValuePlug>( plug ) )
Expand Down

0 comments on commit cf766b8

Please sign in to comment.