2019-12-27 09:26:59 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2019-09-17 19:12:19 -04:00
# include "ControlRigElementDetails.h"
# include "Widgets/SWidget.h"
# include "DetailLayoutBuilder.h"
# include "DetailCategoryBuilder.h"
# include "DetailWidgetRow.h"
2020-09-24 00:43:27 -04:00
# include "IDetailChildrenBuilder.h"
2019-09-17 19:12:19 -04:00
# include "Widgets/Text/STextBlock.h"
# include "Widgets/Input/SEditableTextBox.h"
# include "Widgets/Input/SVectorInputBox.h"
# include "Widgets/Input/SRotatorInputBox.h"
2020-01-22 17:58:55 -05:00
# include "Widgets/Input/SCheckBox.h"
# include "Widgets/Input/SNumericEntryBox.h"
2020-09-24 00:43:27 -04:00
# include "Widgets/Input/SComboBox.h"
2021-05-26 08:01:13 -04:00
# include "Widgets/Input/SButton.h"
2019-09-17 19:12:19 -04:00
# include "Editor/SControlRigGizmoNameList.h"
2020-01-22 17:58:55 -05:00
# include "ControlRigBlueprint.h"
# include "Graph/ControlRigGraph.h"
2020-02-04 11:06:23 -05:00
# include "PropertyCustomizationHelpers.h"
2021-01-13 13:58:36 -04:00
# include "SEnumCombo.h"
2020-09-24 00:43:27 -04:00
# include "ControlRig/Private/Units/Execution/RigUnit_BeginExecution.h"
2021-06-17 08:21:34 -04:00
# include "RigVMModel/RigVMGraph.h"
# include "RigVMModel/RigVMNode.h"
# include "Graph/SControlRigGraphPinVariableBinding.h"
2019-09-17 19:12:19 -04:00
# define LOCTEXT_NAMESPACE "ControlRigElementDetails"
2021-05-25 05:36:45 -04:00
namespace FRigElementKeyDetailsDefs
{
// Active foreground pin alpha
static const float ActivePinForegroundAlpha = 1.f ;
// InActive foreground pin alpha
static const float InactivePinForegroundAlpha = 0.15f ;
// Active background pin alpha
static const float ActivePinBackgroundAlpha = 0.8f ;
// InActive background pin alpha
static const float InactivePinBackgroundAlpha = 0.4f ;
} ;
2021-02-22 13:36:33 -04:00
void RigElementDetails_GetCustomizedInfo ( TSharedRef < IPropertyHandle > InStructPropertyHandle , UControlRigBlueprint * & OutBlueprint )
2020-09-24 00:43:27 -04:00
{
TArray < UObject * > Objects ;
InStructPropertyHandle - > GetOuterObjects ( Objects ) ;
for ( UObject * Object : Objects )
{
if ( Object - > IsA < UControlRigBlueprint > ( ) )
{
2021-02-22 13:36:33 -04:00
OutBlueprint = Cast < UControlRigBlueprint > ( Object ) ;
if ( OutBlueprint )
2020-09-24 00:43:27 -04:00
{
break ;
}
}
}
2021-02-22 13:36:33 -04:00
if ( OutBlueprint = = nullptr )
2020-09-24 00:43:27 -04:00
{
TArray < UPackage * > Packages ;
InStructPropertyHandle - > GetOuterPackages ( Packages ) ;
for ( UPackage * Package : Packages )
{
if ( Package = = nullptr )
{
continue ;
}
TArray < UObject * > SubObjects ;
Package - > GetDefaultSubobjects ( SubObjects ) ;
for ( UObject * SubObject : SubObjects )
{
if ( UControlRig * Rig = Cast < UControlRig > ( SubObject ) )
{
2021-02-22 13:36:33 -04:00
OutBlueprint = Cast < UControlRigBlueprint > ( Rig - > GetClass ( ) - > ClassGeneratedBy ) ;
if ( OutBlueprint )
2020-09-24 00:43:27 -04:00
{
break ;
}
}
}
2021-02-22 13:36:33 -04:00
if ( OutBlueprint )
2020-09-24 00:43:27 -04:00
{
break ;
}
}
}
2021-02-22 13:36:33 -04:00
}
2021-05-06 10:50:31 -04:00
UControlRigBlueprint * RigElementDetails_GetBlueprintFromHierarchy ( URigHierarchy * InHierarchy )
{
if ( InHierarchy = = nullptr )
{
return nullptr ;
}
UControlRigBlueprint * Blueprint = InHierarchy - > GetTypedOuter < UControlRigBlueprint > ( ) ;
if ( Blueprint = = nullptr )
{
UControlRig * Rig = InHierarchy - > GetTypedOuter < UControlRig > ( ) ;
if ( Rig )
{
Blueprint = Cast < UControlRigBlueprint > ( Rig - > GetClass ( ) - > ClassGeneratedBy ) ;
}
}
return Blueprint ;
}
2021-02-22 13:36:33 -04:00
void FRigElementKeyDetails : : CustomizeHeader ( TSharedRef < IPropertyHandle > InStructPropertyHandle , FDetailWidgetRow & HeaderRow , IPropertyTypeCustomizationUtils & StructCustomizationUtils )
{
BlueprintBeingCustomized = nullptr ;
RigElementDetails_GetCustomizedInfo ( InStructPropertyHandle , BlueprintBeingCustomized ) ;
2020-09-24 00:43:27 -04:00
UControlRigGraph * RigGraph = nullptr ;
if ( BlueprintBeingCustomized )
{
for ( UEdGraph * Graph : BlueprintBeingCustomized - > UbergraphPages )
{
RigGraph = Cast < UControlRigGraph > ( Graph ) ;
if ( RigGraph )
{
break ;
}
}
}
// only allow blueprints with at least one rig graph
if ( RigGraph = = nullptr )
{
BlueprintBeingCustomized = nullptr ;
}
if ( BlueprintBeingCustomized = = nullptr )
{
HeaderRow
. NameContent ( )
[
InStructPropertyHandle - > CreatePropertyNameWidget ( )
]
. ValueContent ( )
[
InStructPropertyHandle - > CreatePropertyValueWidget ( )
] ;
}
else
{
TypeHandle = InStructPropertyHandle - > GetChildHandle ( TEXT ( " Type " ) ) ;
NameHandle = InStructPropertyHandle - > GetChildHandle ( TEXT ( " Name " ) ) ;
TypeHandle - > SetOnPropertyValueChanged ( FSimpleDelegate : : CreateLambda (
[ this ] ( )
{
this - > UpdateElementNameList ( ) ;
SetElementName ( FString ( ) ) ;
}
) ) ;
UpdateElementNameList ( ) ;
HeaderRow
. NameContent ( )
[
InStructPropertyHandle - > CreatePropertyNameWidget ( )
]
. ValueContent ( )
. MinDesiredWidth ( 250.f )
[
SNew ( SHorizontalBox )
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
[
TypeHandle - > CreatePropertyValueWidget ( )
]
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. Padding ( 4.f , 0.f , 0.f , 0.f )
[
2021-05-21 09:45:38 -04:00
SAssignNew ( SearchableComboBox , SSearchableComboBox )
2020-09-24 00:43:27 -04:00
. OptionsSource ( & ElementNameList )
. OnSelectionChanged ( this , & FRigElementKeyDetails : : OnElementNameChanged )
. OnGenerateWidget ( this , & FRigElementKeyDetails : : OnGetElementNameWidget )
. Content ( )
[
SNew ( STextBlock )
. Text ( this , & FRigElementKeyDetails : : GetElementNameAsText )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
]
2021-05-25 05:36:45 -04:00
// Use button
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. Padding ( 1 , 0 )
. VAlign ( VAlign_Center )
[
SAssignNew ( UseSelectedButton , SButton )
. ButtonStyle ( FEditorStyle : : Get ( ) , " NoBorder " )
. ButtonColorAndOpacity_Lambda ( [ this ] ( ) { return OnGetWidgetBackground ( UseSelectedButton ) ; } )
. OnClicked ( this , & FRigElementKeyDetails : : OnGetSelectedClicked )
. ContentPadding ( 1.f )
. ToolTipText ( NSLOCTEXT ( " GraphEditor " , " ObjectGraphPin_Use_Tooltip " , " Use item selected " ) )
[
SNew ( SImage )
. ColorAndOpacity_Lambda ( [ this ] ( ) { return OnGetWidgetForeground ( UseSelectedButton ) ; } )
. Image ( FEditorStyle : : GetBrush ( " Icons.CircleArrowLeft " ) )
]
]
// Select in hierarchy button
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. Padding ( 1 , 0 )
. VAlign ( VAlign_Center )
[
SAssignNew ( SelectElementButton , SButton )
. ButtonStyle ( FEditorStyle : : Get ( ) , " NoBorder " )
. ButtonColorAndOpacity_Lambda ( [ this ] ( ) { return OnGetWidgetBackground ( SelectElementButton ) ; } )
. OnClicked ( this , & FRigElementKeyDetails : : OnSelectInHierarchyClicked )
. ContentPadding ( 0 )
. ToolTipText ( NSLOCTEXT ( " GraphEditor " , " ObjectGraphPin_Browse_Tooltip " , " Select in hierarchy " ) )
[
SNew ( SImage )
. ColorAndOpacity_Lambda ( [ this ] ( ) { return OnGetWidgetForeground ( SelectElementButton ) ; } )
. Image ( FEditorStyle : : GetBrush ( " Icons.Search " ) )
]
]
2020-09-24 00:43:27 -04:00
] ;
}
}
void FRigElementKeyDetails : : CustomizeChildren ( TSharedRef < IPropertyHandle > InStructPropertyHandle , IDetailChildrenBuilder & StructBuilder , IPropertyTypeCustomizationUtils & StructCustomizationUtils )
{
if ( InStructPropertyHandle - > IsValidHandle ( ) )
{
// only fill the children if the blueprint cannot be found
if ( BlueprintBeingCustomized = = nullptr )
{
uint32 NumChildren = 0 ;
InStructPropertyHandle - > GetNumChildren ( NumChildren ) ;
for ( uint32 ChildIndex = 0 ; ChildIndex < NumChildren ; ChildIndex + + )
{
StructBuilder . AddProperty ( InStructPropertyHandle - > GetChildHandle ( ChildIndex ) . ToSharedRef ( ) ) ;
}
}
}
}
ERigElementType FRigElementKeyDetails : : GetElementType ( ) const
{
ERigElementType ElementType = ERigElementType : : None ;
if ( TypeHandle . IsValid ( ) )
{
uint8 Index = 0 ;
TypeHandle - > GetValue ( Index ) ;
ElementType = ( ERigElementType ) Index ;
}
return ElementType ;
}
FString FRigElementKeyDetails : : GetElementName ( ) const
{
FString ElementNameStr ;
if ( NameHandle . IsValid ( ) )
{
FName ElementName ;
NameHandle - > GetValue ( ElementName ) ;
ElementNameStr = ElementName . ToString ( ) ;
}
return ElementNameStr ;
}
void FRigElementKeyDetails : : SetElementName ( FString InName )
{
if ( NameHandle . IsValid ( ) )
{
NameHandle - > SetValue ( InName ) ;
}
}
void FRigElementKeyDetails : : UpdateElementNameList ( )
{
if ( ! TypeHandle . IsValid ( ) )
{
return ;
}
ElementNameList . Reset ( ) ;
if ( BlueprintBeingCustomized )
{
for ( UEdGraph * Graph : BlueprintBeingCustomized - > UbergraphPages )
{
if ( UControlRigGraph * RigGraph = Cast < UControlRigGraph > ( Graph ) )
{
2021-05-06 14:21:04 -04:00
ElementNameList = * RigGraph - > GetElementNameList ( GetElementType ( ) ) ;
2021-05-21 09:45:38 -04:00
if ( SearchableComboBox . IsValid ( ) )
{
SearchableComboBox - > RefreshOptions ( ) ;
}
2020-09-24 00:43:27 -04:00
return ;
}
}
}
}
void FRigElementKeyDetails : : OnElementNameChanged ( TSharedPtr < FString > InItem , ESelectInfo : : Type InSelectionInfo )
{
if ( InItem . IsValid ( ) )
{
SetElementName ( * InItem ) ;
}
else
{
SetElementName ( FString ( ) ) ;
}
}
TSharedRef < SWidget > FRigElementKeyDetails : : OnGetElementNameWidget ( TSharedPtr < FString > InItem )
{
return SNew ( STextBlock )
. Text ( FText : : FromString ( InItem . IsValid ( ) ? * InItem : FString ( ) ) )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) ) ;
}
FText FRigElementKeyDetails : : GetElementNameAsText ( ) const
{
return FText : : FromString ( GetElementName ( ) ) ;
}
2021-05-25 05:36:45 -04:00
FSlateColor FRigElementKeyDetails : : OnGetWidgetForeground ( const TSharedPtr < SButton > Button ) const
{
float Alpha = ( Button . IsValid ( ) & & Button - > IsHovered ( ) ) ? FRigElementKeyDetailsDefs : : ActivePinForegroundAlpha : FRigElementKeyDetailsDefs : : InactivePinForegroundAlpha ;
return FSlateColor ( FLinearColor ( 1.f , 1.f , 1.f , Alpha ) ) ;
}
FSlateColor FRigElementKeyDetails : : OnGetWidgetBackground ( const TSharedPtr < SButton > Button ) const
{
float Alpha = ( Button . IsValid ( ) & & Button - > IsHovered ( ) ) ? FRigElementKeyDetailsDefs : : ActivePinBackgroundAlpha : FRigElementKeyDetailsDefs : : InactivePinBackgroundAlpha ;
return FSlateColor ( FLinearColor ( 1.f , 1.f , 1.f , Alpha ) ) ;
}
FReply FRigElementKeyDetails : : OnGetSelectedClicked ( )
{
if ( BlueprintBeingCustomized )
{
const TArray < FRigElementKey > & Selected = BlueprintBeingCustomized - > Hierarchy - > GetSelectedKeys ( ) ;
if ( Selected . Num ( ) > 0 )
{
if ( TypeHandle . IsValid ( ) )
{
uint8 Index = ( uint8 ) Selected [ 0 ] . Type ;
TypeHandle - > SetValue ( Index ) ;
}
SetElementName ( Selected [ 0 ] . Name . ToString ( ) ) ;
}
}
return FReply : : Handled ( ) ;
}
FReply FRigElementKeyDetails : : OnSelectInHierarchyClicked ( )
{
if ( BlueprintBeingCustomized )
{
FRigElementKey Key ;
if ( TypeHandle . IsValid ( ) )
{
uint8 Type ;
TypeHandle - > GetValue ( Type ) ;
Key . Type = ( ERigElementType ) Type ;
}
if ( NameHandle . IsValid ( ) )
{
NameHandle - > GetValue ( Key . Name ) ;
}
if ( Key . IsValid ( ) )
{
BlueprintBeingCustomized - > GetHierarchyController ( ) - > SetSelection ( { Key } ) ;
}
}
return FReply : : Handled ( ) ;
}
2020-01-22 17:58:55 -05:00
void FRigUnitDetails : : CustomizeDetails ( IDetailLayoutBuilder & DetailBuilder )
{
TArray < TSharedPtr < FStructOnScope > > StructsBeingCustomized ;
DetailBuilder . GetStructsBeingCustomized ( StructsBeingCustomized ) ;
if ( StructsBeingCustomized . Num ( ) = = 0 )
{
return ;
}
TSharedPtr < FStructOnScope > StructBeingCustomized = StructsBeingCustomized [ 0 ] ;
BlueprintBeingCustomized = nullptr ;
if ( UPackage * Package = StructBeingCustomized - > GetPackage ( ) )
{
TArray < UObject * > SubObjects ;
Package - > GetDefaultSubobjects ( SubObjects ) ;
for ( UObject * SubObject : SubObjects )
{
if ( UControlRig * Rig = Cast < UControlRig > ( SubObject ) )
{
BlueprintBeingCustomized = Cast < UControlRigBlueprint > ( Rig - > GetClass ( ) - > ClassGeneratedBy ) ;
if ( BlueprintBeingCustomized )
{
break ;
}
}
}
}
if ( BlueprintBeingCustomized = = nullptr )
{
return ;
}
GraphBeingCustomized = nullptr ;
for ( UEdGraph * Graph : BlueprintBeingCustomized - > UbergraphPages )
{
GraphBeingCustomized = Cast < UControlRigGraph > ( Graph ) ;
if ( GraphBeingCustomized )
{
break ;
}
}
if ( GraphBeingCustomized = = nullptr )
{
return ;
}
2021-06-17 08:21:34 -04:00
URigVMGraph * Model = GraphBeingCustomized - > GetModel ( ) ;
if ( Model = = nullptr )
{
return ;
}
const TArray < FName > SelectedNodeNames = Model - > GetSelectNodes ( ) ;
if ( SelectedNodeNames . Num ( ) = = 0 )
{
return ;
}
URigVMNode * ModelNode = Model - > FindNodeByName ( SelectedNodeNames [ 0 ] ) ;
if ( ModelNode = = nullptr )
{
return ;
}
2020-01-22 17:58:55 -05:00
UScriptStruct * ScriptStruct = Cast < UScriptStruct > ( ( UStruct * ) StructBeingCustomized - > GetStruct ( ) ) ;
check ( ScriptStruct ) ;
IDetailCategoryBuilder & CategoryBuilder = DetailBuilder . EditCategory ( * ScriptStruct - > GetDisplayNameText ( ) . ToString ( ) ) ;
for ( TFieldIterator < FProperty > PropertyIt ( ScriptStruct ) ; PropertyIt ; + + PropertyIt )
{
FProperty * Property = * PropertyIt ;
TSharedPtr < IPropertyHandle > PropertyHandle = DetailBuilder . GetProperty ( Property - > GetFName ( ) , ScriptStruct ) ;
if ( ! PropertyHandle - > IsValidHandle ( ) )
{
continue ;
}
DetailBuilder . HideProperty ( PropertyHandle ) ;
2021-06-17 08:21:34 -04:00
URigVMPin * ModelPin = ModelNode - > FindPin ( Property - > GetName ( ) ) ;
if ( ModelPin = = nullptr )
{
continue ;
}
if ( ModelPin - > IsBoundToVariable ( ) )
{
CategoryBuilder . AddCustomRow ( FText : : FromString ( Property - > GetName ( ) ) )
. NameContent ( )
[
PropertyHandle - > CreatePropertyNameWidget ( )
]
. ValueContent ( )
[
SNew ( SControlRigVariableBinding )
. ModelPin ( ModelPin )
. Blueprint ( BlueprintBeingCustomized )
] ;
continue ;
}
2020-01-22 17:58:55 -05:00
if ( FNameProperty * NameProperty = CastField < FNameProperty > ( Property ) )
{
FString CustomWidgetName = NameProperty - > GetMetaData ( TEXT ( " CustomWidget " ) ) ;
if ( ! CustomWidgetName . IsEmpty ( ) )
{
const TArray < TSharedPtr < FString > > * NameList = nullptr ;
if ( CustomWidgetName = = TEXT ( " BoneName " ) )
{
2021-05-06 14:21:04 -04:00
NameList = GraphBeingCustomized - > GetBoneNameList ( ) ;
2020-01-22 17:58:55 -05:00
}
else if ( CustomWidgetName = = TEXT ( " ControlName " ) )
{
2021-05-06 14:21:04 -04:00
NameList = GraphBeingCustomized - > GetControlNameList ( ) ;
2020-01-22 17:58:55 -05:00
}
else if ( CustomWidgetName = = TEXT ( " SpaceName " ) )
{
2021-05-06 14:21:04 -04:00
NameList = GraphBeingCustomized - > GetNullNameList ( ) ;
2020-01-22 17:58:55 -05:00
}
else if ( CustomWidgetName = = TEXT ( " CurveName " ) )
{
2021-05-06 14:21:04 -04:00
NameList = GraphBeingCustomized - > GetCurveNameList ( ) ;
2020-01-22 17:58:55 -05:00
}
if ( NameList )
{
TSharedPtr < SControlRigGraphPinNameListValueWidget > NameListWidget ;
CategoryBuilder . AddCustomRow ( FText : : FromString ( Property - > GetName ( ) ) )
. NameContent ( )
[
PropertyHandle - > CreatePropertyNameWidget ( )
]
. ValueContent ( )
[
SAssignNew ( NameListWidget , SControlRigGraphPinNameListValueWidget )
. OptionsSource ( NameList )
. OnGenerateWidget ( this , & FRigUnitDetails : : MakeNameListItemWidget )
. OnSelectionChanged ( this , & FRigUnitDetails : : OnNameListChanged , StructBeingCustomized , NameProperty , DetailBuilder . GetPropertyUtilities ( ) )
. OnComboBoxOpening ( this , & FRigUnitDetails : : OnNameListComboBox , StructBeingCustomized , NameProperty , NameList )
. InitiallySelectedItem ( GetCurrentlySelectedItem ( StructBeingCustomized , NameProperty , NameList ) )
. Content ( )
[
SNew ( STextBlock )
. Text ( this , & FRigUnitDetails : : GetNameListText , StructBeingCustomized , NameProperty )
]
] ;
NameListWidgets . Add ( Property - > GetFName ( ) , NameListWidget ) ;
}
else
{
CategoryBuilder . AddCustomRow ( FText : : FromString ( Property - > GetName ( ) ) )
. NameContent ( )
[
PropertyHandle - > CreatePropertyNameWidget ( )
] ;
}
continue ;
}
}
2021-06-14 08:02:22 -04:00
else if ( FStructProperty * StructProperty = CastField < FStructProperty > ( Property ) )
{
const FSimpleDelegate OnStructContentsChangedDelegate = FSimpleDelegate : : CreateSP ( this , & FRigUnitDetails : : OnStructContentsChanged , Property , DetailBuilder . GetPropertyUtilities ( ) ) ;
PropertyHandle - > SetOnPropertyValueChanged ( OnStructContentsChangedDelegate ) ;
PropertyHandle - > SetOnChildPropertyValueChanged ( OnStructContentsChangedDelegate ) ;
}
2020-01-22 17:58:55 -05:00
CategoryBuilder . AddProperty ( PropertyHandle ) ;
}
}
TSharedRef < SWidget > FRigUnitDetails : : MakeNameListItemWidget ( TSharedPtr < FString > InItem )
{
return SNew ( STextBlock ) . Text ( FText : : FromString ( * InItem ) ) ; // .Font(FEditorStyle::GetFontStyle(TEXT("PropertyWindow.NormalFont")));
}
FText FRigUnitDetails : : GetNameListText ( TSharedPtr < FStructOnScope > InStructOnScope , FNameProperty * InProperty ) const
{
if ( FName * Value = InProperty - > ContainerPtrToValuePtr < FName > ( InStructOnScope - > GetStructMemory ( ) ) )
{
return FText : : FromName ( * Value ) ;
}
return FText ( ) ;
}
TSharedPtr < FString > FRigUnitDetails : : GetCurrentlySelectedItem ( TSharedPtr < FStructOnScope > InStructOnScope , FNameProperty * InProperty , const TArray < TSharedPtr < FString > > * InNameList ) const
{
FString CurrentItem = GetNameListText ( InStructOnScope , InProperty ) . ToString ( ) ;
for ( const TSharedPtr < FString > & Item : * InNameList )
{
if ( Item - > Equals ( CurrentItem ) )
{
return Item ;
}
}
return TSharedPtr < FString > ( ) ;
}
void FRigUnitDetails : : SetNameListText ( const FText & NewTypeInValue , ETextCommit : : Type /*CommitInfo*/ , TSharedPtr < FStructOnScope > InStructOnScope , FNameProperty * InProperty , TSharedRef < IPropertyUtilities > PropertyUtilities )
{
if ( FName * Value = InProperty - > ContainerPtrToValuePtr < FName > ( InStructOnScope - > GetStructMemory ( ) ) )
{
* Value = * NewTypeInValue . ToString ( ) ;
FPropertyChangedEvent ChangeEvent ( InProperty , EPropertyChangeType : : ValueSet ) ;
PropertyUtilities - > NotifyFinishedChangingProperties ( ChangeEvent ) ;
}
}
void FRigUnitDetails : : OnNameListChanged ( TSharedPtr < FString > NewSelection , ESelectInfo : : Type SelectInfo , TSharedPtr < FStructOnScope > InStructOnScope , FNameProperty * InProperty , TSharedRef < IPropertyUtilities > PropertyUtilities )
{
if ( SelectInfo ! = ESelectInfo : : Direct )
{
FString NewValue = * NewSelection . Get ( ) ;
SetNameListText ( FText : : FromString ( NewValue ) , ETextCommit : : OnEnter , InStructOnScope , InProperty , PropertyUtilities ) ;
}
}
void FRigUnitDetails : : OnNameListComboBox ( TSharedPtr < FStructOnScope > InStructOnScope , FNameProperty * InProperty , const TArray < TSharedPtr < FString > > * InNameList )
{
TSharedPtr < SControlRigGraphPinNameListValueWidget > Widget = NameListWidgets . FindChecked ( InProperty - > GetFName ( ) ) ;
2021-02-22 13:36:33 -04:00
const TSharedPtr < FString > CurrentlySelected = GetCurrentlySelectedItem ( InStructOnScope , InProperty , InNameList ) ;
2020-01-22 17:58:55 -05:00
Widget - > SetSelectedItem ( CurrentlySelected ) ;
}
2021-06-14 08:02:22 -04:00
void FRigUnitDetails : : OnStructContentsChanged ( FProperty * InProperty , const TSharedRef < IPropertyUtilities > PropertyUtilities )
{
const FPropertyChangedEvent ChangeEvent ( InProperty , EPropertyChangeType : : ValueSet ) ;
PropertyUtilities - > NotifyFinishedChangingProperties ( ChangeEvent ) ;
}
2021-02-22 13:36:33 -04:00
void FRigComputedTransformDetails : : CustomizeHeader ( TSharedRef < IPropertyHandle > InStructPropertyHandle , FDetailWidgetRow & HeaderRow , IPropertyTypeCustomizationUtils & StructCustomizationUtils )
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
BlueprintBeingCustomized = nullptr ;
RigElementDetails_GetCustomizedInfo ( InStructPropertyHandle , BlueprintBeingCustomized ) ;
}
void FRigComputedTransformDetails : : CustomizeChildren ( TSharedRef < IPropertyHandle > InStructPropertyHandle , IDetailChildrenBuilder & StructBuilder , IPropertyTypeCustomizationUtils & StructCustomizationUtils )
{
TransformHandle = InStructPropertyHandle - > GetChildHandle ( TEXT ( " Transform " ) ) ;
StructBuilder
. AddProperty ( TransformHandle . ToSharedRef ( ) )
. DisplayName ( InStructPropertyHandle - > GetPropertyDisplayName ( ) ) ;
FString PropertyPath = TransformHandle - > GeneratePathToProperty ( ) ;
if ( PropertyPath . StartsWith ( TEXT ( " Struct. " ) ) )
{
PropertyPath . RightChopInline ( 7 ) ;
}
if ( PropertyPath . StartsWith ( TEXT ( " Pose. " ) ) )
{
PropertyPath . RightChopInline ( 5 ) ;
PropertyChain . AddTail ( FRigTransformElement : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Pose " ) ) ) ;
}
else if ( PropertyPath . StartsWith ( TEXT ( " Offset. " ) ) )
{
PropertyPath . RightChopInline ( 7 ) ;
PropertyChain . AddTail ( FRigControlElement : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Offset " ) ) ) ;
}
else if ( PropertyPath . StartsWith ( TEXT ( " Gizmo. " ) ) )
{
PropertyPath . RightChopInline ( 6 ) ;
PropertyChain . AddTail ( FRigControlElement : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Gizmo " ) ) ) ;
}
if ( PropertyPath . StartsWith ( TEXT ( " Current. " ) ) )
{
PropertyPath . RightChopInline ( 8 ) ;
PropertyChain . AddTail ( FRigCurrentAndInitialTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Current " ) ) ) ;
}
else if ( PropertyPath . StartsWith ( TEXT ( " Initial. " ) ) )
{
PropertyPath . RightChopInline ( 8 ) ;
PropertyChain . AddTail ( FRigCurrentAndInitialTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Initial " ) ) ) ;
}
if ( PropertyPath . StartsWith ( TEXT ( " Local. " ) ) )
{
PropertyPath . RightChopInline ( 6 ) ;
PropertyChain . AddTail ( FRigLocalAndGlobalTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Local " ) ) ) ;
}
else if ( PropertyPath . StartsWith ( TEXT ( " Global. " ) ) )
{
PropertyPath . RightChopInline ( 7 ) ;
PropertyChain . AddTail ( FRigLocalAndGlobalTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Global " ) ) ) ;
}
PropertyChain . AddTail ( TransformHandle - > GetProperty ( ) ) ;
PropertyChain . SetActiveMemberPropertyNode ( PropertyChain . GetTail ( ) - > GetValue ( ) ) ;
const FSimpleDelegate OnTransformChangedDelegate = FSimpleDelegate : : CreateSP ( this , & FRigComputedTransformDetails : : OnTransformChanged , & PropertyChain ) ;
TransformHandle - > SetOnPropertyValueChanged ( OnTransformChangedDelegate ) ;
TransformHandle - > SetOnChildPropertyValueChanged ( OnTransformChangedDelegate ) ;
}
void FRigComputedTransformDetails : : OnTransformChanged ( FEditPropertyChain * InPropertyChain )
{
if ( BlueprintBeingCustomized & & InPropertyChain )
{
if ( InPropertyChain - > Num ( ) > 1 )
{
FPropertyChangedEvent ChangeEvent ( InPropertyChain - > GetHead ( ) - > GetValue ( ) , EPropertyChangeType : : ValueSet ) ;
ChangeEvent . SetActiveMemberProperty ( InPropertyChain - > GetTail ( ) - > GetValue ( ) ) ;
FPropertyChangedChainEvent ChainEvent ( * InPropertyChain , ChangeEvent ) ;
BlueprintBeingCustomized - > BroadcastPostEditChangeChainProperty ( ChainEvent ) ;
}
}
}
void FRigBaseElementDetails : : CustomizeDetails ( IDetailLayoutBuilder & DetailBuilder )
{
DetailBuilder . HideProperty ( TEXT ( " Key " ) , FRigBaseElement : : StaticStruct ( ) ) ;
DetailBuilder . HideProperty ( TEXT ( " Index " ) , FRigBaseElement : : StaticStruct ( ) ) ;
DetailBuilder . HideProperty ( TEXT ( " SubIndex " ) , FRigBaseElement : : StaticStruct ( ) ) ;
2019-09-17 19:12:19 -04:00
TArray < TSharedPtr < FStructOnScope > > StructsBeingCustomized ;
DetailBuilder . GetStructsBeingCustomized ( StructsBeingCustomized ) ;
for ( TSharedPtr < FStructOnScope > StructBeingCustomized : StructsBeingCustomized )
{
if ( UPackage * Package = StructBeingCustomized - > GetPackage ( ) )
{
TArray < UObject * > SubObjects ;
Package - > GetDefaultSubobjects ( SubObjects ) ;
for ( UObject * SubObject : SubObjects )
{
if ( UControlRig * Rig = Cast < UControlRig > ( SubObject ) )
{
BlueprintBeingCustomized = Cast < UControlRigBlueprint > ( Rig - > GetClass ( ) - > ClassGeneratedBy ) ;
if ( BlueprintBeingCustomized )
{
2021-02-22 13:36:33 -04:00
HierarchyBeingCustomized = BlueprintBeingCustomized - > Hierarchy ;
2020-09-24 00:43:27 -04:00
if ( UControlRig * DebuggedControlRig = Cast < UControlRig > ( BlueprintBeingCustomized - > GetObjectBeingDebugged ( ) ) )
{
if ( ! DebuggedControlRig - > IsSetupModeEnabled ( ) )
{
2021-02-22 13:36:33 -04:00
HierarchyBeingCustomized = DebuggedControlRig - > GetHierarchy ( ) ;
2020-09-24 00:43:27 -04:00
}
}
2019-09-17 19:12:19 -04:00
break ;
}
}
}
2021-02-22 13:36:33 -04:00
if ( HierarchyBeingCustomized )
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
ElementKeyBeingCustomized = ( ( const FRigBaseElement * ) StructBeingCustomized - > GetStructMemory ( ) ) - > GetKey ( ) ;
2019-09-17 19:12:19 -04:00
break ;
}
}
}
2021-02-22 13:36:33 -04:00
IDetailCategoryBuilder & Category = DetailBuilder . EditCategory ( TEXT ( " RigElement " ) ) ;
Category . InitiallyCollapsed ( false ) ;
Category . AddCustomRow ( FText : : FromString ( TEXT ( " Name " ) ) )
. NameContent ( )
[
SNew ( STextBlock )
. Text ( FText : : FromString ( TEXT ( " Name " ) ) )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
. ValueContent ( )
[
SNew ( SEditableTextBox )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
. Text ( this , & FRigBaseElementDetails : : GetName )
. OnTextCommitted ( this , & FRigBaseElementDetails : : SetName )
] ;
2019-09-17 19:12:19 -04:00
}
2021-02-22 13:36:33 -04:00
void FRigBaseElementDetails : : SetName ( const FText & InNewText , ETextCommit : : Type InCommitType )
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
URigHierarchy * Hierarchy = nullptr ;
2020-09-24 00:43:27 -04:00
if ( BlueprintBeingCustomized )
{
2021-02-22 13:36:33 -04:00
Hierarchy = BlueprintBeingCustomized - > Hierarchy ;
2020-09-24 00:43:27 -04:00
}
else
{
Hierarchy = GetHierarchy ( ) ;
}
if ( Hierarchy )
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
URigHierarchyController * Controller = Hierarchy - > GetController ( true ) ;
check ( Controller ) ;
Controller - > RenameElement ( ElementKeyBeingCustomized , * InNewText . ToString ( ) , true ) ;
2019-09-17 19:12:19 -04:00
}
}
2021-02-22 13:36:33 -04:00
void FRigBaseElementDetails : : OnStructContentsChanged ( FProperty * InProperty , const TSharedRef < IPropertyUtilities > PropertyUtilities )
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
const FPropertyChangedEvent ChangeEvent ( InProperty , EPropertyChangeType : : ValueSet ) ;
PropertyUtilities - > NotifyFinishedChangingProperties ( ChangeEvent ) ;
2019-09-17 19:12:19 -04:00
}
2021-03-11 15:00:29 -04:00
bool FRigBaseElementDetails : : IsSetupModeEnabled ( ) const
{
if ( BlueprintBeingCustomized )
{
if ( UControlRig * DebuggedRig = Cast < UControlRig > ( BlueprintBeingCustomized - > GetObjectBeingDebugged ( ) ) )
{
return DebuggedRig - > IsSetupModeEnabled ( ) ;
}
}
return false ;
}
2021-02-22 13:36:33 -04:00
void FRigTransformElementDetails : : CustomizeDetails ( IDetailLayoutBuilder & DetailBuilder )
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
FRigBaseElementDetails : : CustomizeDetails ( DetailBuilder ) ;
2021-03-11 15:00:29 -04:00
//if(ElementKeyBeingCustomized.Type != ERigElementType::Control)
{
IDetailCategoryBuilder & Category = DetailBuilder . EditCategory ( TEXT ( " Pose " ) ) ;
if ( ElementKeyBeingCustomized . Type = = ERigElementType : : Control )
{
Category
. InitiallyCollapsed ( true ) ;
}
2021-02-22 13:36:33 -04:00
2021-03-11 15:00:29 -04:00
// setup initial global
{
const TSharedRef < IPropertyHandle > PropertyHandle = DetailBuilder . GetProperty ( TEXT ( " Pose.Initial.Global.Transform " ) , FRigTransformElement : : StaticStruct ( ) ) ;
Category . AddProperty ( PropertyHandle , EPropertyLocation : : Advanced ) . DisplayName ( FText : : FromString ( TEXT ( " Initial Global " ) ) )
. IsEnabled ( TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateSP ( this , & FRigBaseElementDetails : : IsSetupModeEnabled ) ) ) ;
PoseInitialGlobal . AddHead ( FRigControlElement : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Pose " ) ) ) ;
PoseInitialGlobal . AddTail ( FRigCurrentAndInitialTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Initial " ) ) ) ;
PoseInitialGlobal . AddTail ( FRigLocalAndGlobalTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Global " ) ) ) ;
PoseInitialGlobal . AddTail ( FRigComputedTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Transform " ) ) ) ;
PoseInitialGlobal . SetActiveMemberPropertyNode ( PoseInitialGlobal . GetTail ( ) - > GetValue ( ) ) ;
const FSimpleDelegate OnTransformChangedDelegate = FSimpleDelegate : : CreateStatic ( & FRigTransformElementDetails : : OnTransformChanged , & PoseInitialGlobal , BlueprintBeingCustomized ) ;
PropertyHandle - > SetOnPropertyValueChanged ( OnTransformChangedDelegate ) ;
PropertyHandle - > SetOnChildPropertyValueChanged ( OnTransformChangedDelegate ) ;
PropertyHandle - > SetToolTipText ( FText : : FromString ( TEXT ( " The initial / ref pose global transform in the space of the rig / actor. " ) ) ) ;
}
// setup initial local
{
const TSharedRef < IPropertyHandle > PropertyHandle = DetailBuilder . GetProperty ( TEXT ( " Pose.Initial.Local.Transform " ) , FRigTransformElement : : StaticStruct ( ) ) ;
Category . AddProperty ( PropertyHandle , EPropertyLocation : : Advanced ) . DisplayName ( FText : : FromString ( TEXT ( " Initial Local " ) ) )
. IsEnabled ( TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateSP ( this , & FRigBaseElementDetails : : IsSetupModeEnabled ) ) ) ;
PoseInitialLocal . AddHead ( FRigControlElement : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Pose " ) ) ) ;
PoseInitialLocal . AddTail ( FRigCurrentAndInitialTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Initial " ) ) ) ;
PoseInitialLocal . AddTail ( FRigLocalAndGlobalTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Local " ) ) ) ;
PoseInitialLocal . AddTail ( FRigComputedTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Transform " ) ) ) ;
PoseInitialLocal . SetActiveMemberPropertyNode ( PoseInitialLocal . GetTail ( ) - > GetValue ( ) ) ;
const FSimpleDelegate OnTransformChangedDelegate = FSimpleDelegate : : CreateStatic ( & FRigTransformElementDetails : : OnTransformChanged , & PoseInitialLocal , BlueprintBeingCustomized ) ;
PropertyHandle - > SetOnPropertyValueChanged ( OnTransformChangedDelegate ) ;
PropertyHandle - > SetOnChildPropertyValueChanged ( OnTransformChangedDelegate ) ;
PropertyHandle - > SetToolTipText ( FText : : FromString ( TEXT ( " The initial / ref pose local transform in the space of the parent. \n For Controls the initial value is relative to the offset. " ) ) ) ;
}
// setup current global
{
const TSharedRef < IPropertyHandle > PropertyHandle = DetailBuilder . GetProperty ( TEXT ( " Pose.Current.Global.Transform " ) , FRigTransformElement : : StaticStruct ( ) ) ;
Category . AddProperty ( PropertyHandle , EPropertyLocation : : Advanced ) . DisplayName ( FText : : FromString ( TEXT ( " Current Global " ) ) )
. IsEnabled ( TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateSP ( this , & FRigBaseElementDetails : : IsSetupModeEnabled ) ) ) ;
PoseCurrentGlobal . AddHead ( FRigControlElement : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Pose " ) ) ) ;
PoseCurrentGlobal . AddTail ( FRigCurrentAndInitialTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Current " ) ) ) ;
PoseCurrentGlobal . AddTail ( FRigLocalAndGlobalTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Global " ) ) ) ;
PoseCurrentGlobal . AddTail ( FRigComputedTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Transform " ) ) ) ;
PoseCurrentGlobal . SetActiveMemberPropertyNode ( PoseCurrentGlobal . GetTail ( ) - > GetValue ( ) ) ;
const FSimpleDelegate OnTransformChangedDelegate = FSimpleDelegate : : CreateStatic ( & FRigTransformElementDetails : : OnTransformChanged , & PoseCurrentGlobal , BlueprintBeingCustomized ) ;
PropertyHandle - > SetOnPropertyValueChanged ( OnTransformChangedDelegate ) ;
PropertyHandle - > SetOnChildPropertyValueChanged ( OnTransformChangedDelegate ) ;
PropertyHandle - > SetToolTipText ( FText : : FromString ( TEXT ( " The current global transform in the space of the rig / actor. " ) ) ) ;
}
// setup current local
{
const TSharedRef < IPropertyHandle > PropertyHandle = DetailBuilder . GetProperty ( TEXT ( " Pose.Current.Local.Transform " ) , FRigTransformElement : : StaticStruct ( ) ) ;
Category . AddProperty ( PropertyHandle ) . DisplayName ( FText : : FromString ( TEXT ( " Current Local " ) ) )
. IsEnabled ( ElementKeyBeingCustomized . Type ! = ERigElementType : : Control ) ;
PoseCurrentLocal . AddHead ( FRigControlElement : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Pose " ) ) ) ;
PoseCurrentLocal . AddTail ( FRigCurrentAndInitialTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Current " ) ) ) ;
PoseCurrentLocal . AddTail ( FRigLocalAndGlobalTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Local " ) ) ) ;
PoseCurrentLocal . AddTail ( FRigComputedTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Transform " ) ) ) ;
PoseCurrentLocal . SetActiveMemberPropertyNode ( PoseCurrentLocal . GetTail ( ) - > GetValue ( ) ) ;
const FSimpleDelegate OnTransformChangedDelegate = FSimpleDelegate : : CreateStatic ( & FRigTransformElementDetails : : OnTransformChanged , & PoseCurrentLocal , BlueprintBeingCustomized ) ;
PropertyHandle - > SetOnPropertyValueChanged ( OnTransformChangedDelegate ) ;
PropertyHandle - > SetOnChildPropertyValueChanged ( OnTransformChangedDelegate ) ;
PropertyHandle - > SetToolTipText ( FText : : FromString ( TEXT ( " The current local transform in the space of the parent. \n For Controls the initial value is relative to the offset. " ) ) ) ;
}
DetailBuilder . HideProperty ( TEXT ( " Pose " ) , FRigTransformElement : : StaticStruct ( ) ) ;
}
}
void FRigTransformElementDetails : : OnTransformChanged ( FEditPropertyChain * InPropertyChain , UControlRigBlueprint * InBlueprint )
{
if ( InBlueprint & & InPropertyChain )
{
if ( InPropertyChain - > Num ( ) > 1 )
{
FPropertyChangedEvent ChangeEvent ( InPropertyChain - > GetHead ( ) - > GetValue ( ) , EPropertyChangeType : : ValueSet ) ;
ChangeEvent . SetActiveMemberProperty ( InPropertyChain - > GetTail ( ) - > GetValue ( ) ) ;
FPropertyChangedChainEvent ChainEvent ( * InPropertyChain , ChangeEvent ) ;
InBlueprint - > BroadcastPostEditChangeChainProperty ( ChainEvent ) ;
}
}
2019-09-17 19:12:19 -04:00
}
2021-02-22 13:36:33 -04:00
void FRigBoneElementDetails : : CustomizeDetails ( IDetailLayoutBuilder & DetailBuilder )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
FRigTransformElementDetails : : CustomizeDetails ( DetailBuilder ) ;
2020-09-24 00:43:27 -04:00
}
2021-02-22 13:36:33 -04:00
void FRigControlElementDetails_SetupBoolValueWidget ( IDetailCategoryBuilder & InCategory , ERigControlValueType InValueType , FRigControlElement * InControlElement , URigHierarchy * InHierarchy )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
UEnum * ControlTypeEnum = StaticEnum < ERigControlType > ( ) ;
UEnum * ValueTypeEnum = StaticEnum < ERigControlValueType > ( ) ;
2020-09-24 00:43:27 -04:00
2021-02-22 13:36:33 -04:00
const FString ValueTypeName = ValueTypeEnum - > GetDisplayNameTextByValue ( ( int64 ) InValueType ) . ToString ( ) ;
const FText PropertyLabel = FText : : FromString ( FString : : Printf ( TEXT ( " %s Value " ) , * ValueTypeName ) ) ;
TWeakObjectPtr < URigHierarchy > HierarchyPtr = InHierarchy ;
const FRigElementKey Key = InControlElement - > GetKey ( ) ;
2020-09-24 00:43:27 -04:00
2021-02-22 13:36:33 -04:00
InCategory . AddCustomRow ( PropertyLabel )
2019-09-17 19:12:19 -04:00
. NameContent ( )
[
2021-02-22 13:36:33 -04:00
SNew ( STextBlock )
. Text ( PropertyLabel )
2019-09-17 19:12:19 -04:00
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
. ValueContent ( )
[
2021-02-22 13:36:33 -04:00
SNew ( SVerticalBox )
+ SVerticalBox : : Slot ( )
[
SNew ( SCheckBox )
. IsChecked_Lambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > ECheckBoxState
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
bool Value = HierarchyPtr - > GetControlValue ( ControlElement , InValueType ) . Get < bool > ( ) ;
return Value ? ECheckBoxState : : Checked : ECheckBoxState : : Unchecked ;
}
}
return ECheckBoxState : : Unchecked ;
} )
. OnCheckStateChanged_Lambda ( [ HierarchyPtr , Key , InValueType ] ( ECheckBoxState NewState )
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
const FRigControlValue Value = FRigControlValue : : Make < bool > ( NewState = = ECheckBoxState : : Checked ) ;
HierarchyPtr - > SetControlValue ( ControlElement - > GetKey ( ) , Value , InValueType , true ) ;
2021-05-06 10:50:31 -04:00
if ( InValueType = = ERigControlValueType : : Initial )
{
if ( UControlRigBlueprint * Blueprint = RigElementDetails_GetBlueprintFromHierarchy ( HierarchyPtr . Get ( ) ) )
{
Blueprint - > Hierarchy - > SetControlValue ( ControlElement - > GetKey ( ) , Value , InValueType , true ) ;
}
}
}
2021-02-22 13:36:33 -04:00
}
} )
]
]
. IsEnabled ( TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateLambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > bool
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
return ControlElement - > Settings . IsValueTypeEnabled ( InValueType ) ;
}
}
return false ;
} ) ) ) ;
}
2020-09-24 00:43:27 -04:00
2021-02-22 13:36:33 -04:00
void FRigControlElementDetails_SetupIntegerValueWidget ( IDetailCategoryBuilder & InCategory , ERigControlValueType InValueType , FRigControlElement * InControlElement , URigHierarchy * InHierarchy )
{
UEnum * ControlTypeEnum = StaticEnum < ERigControlType > ( ) ;
UEnum * ValueTypeEnum = StaticEnum < ERigControlValueType > ( ) ;
const FString ValueTypeName = ValueTypeEnum - > GetDisplayNameTextByValue ( ( int64 ) InValueType ) . ToString ( ) ;
const FText PropertyLabel = FText : : FromString ( FString : : Printf ( TEXT ( " %s Value " ) , * ValueTypeName ) ) ;
TWeakObjectPtr < URigHierarchy > HierarchyPtr = InHierarchy ;
const FRigElementKey Key = InControlElement - > GetKey ( ) ;
const TAttribute < bool > EnabledAttribute = TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateLambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > bool
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
return ControlElement - > Settings . IsValueTypeEnabled ( InValueType ) ;
}
}
return false ;
} ) ) ;
const TAttribute < EVisibility > VisibilityAttribute = TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateLambda ( [ EnabledAttribute ] ( ) - > EVisibility
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
return EnabledAttribute . Get ( ) ? EVisibility : : Visible : EVisibility : : Hidden ;
} ) ) ;
2020-09-24 00:43:27 -04:00
2021-02-22 13:36:33 -04:00
if ( InControlElement - > Settings . ControlEnum )
{
InCategory . AddCustomRow ( PropertyLabel )
. Visibility ( VisibilityAttribute )
. NameContent ( )
[
SNew ( STextBlock )
. Text ( PropertyLabel )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
. ValueContent ( )
. MinDesiredWidth ( 125.0f * 3.0f ) // copied from FComponentTransformDetails
. MaxDesiredWidth ( 125.0f * 3.0f )
[
SNew ( SVerticalBox )
+ SVerticalBox : : Slot ( )
[
SNew ( SEnumComboBox , InControlElement - > Settings . ControlEnum )
. CurrentValue_Lambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > int32
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
return HierarchyPtr - > GetControlValue ( ControlElement , InValueType ) . Get < int32 > ( ) ;
}
}
return 0 ;
} )
. OnEnumSelectionChanged_Lambda ( [ HierarchyPtr , Key , InValueType ] ( int32 NewSelection , ESelectInfo : : Type )
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
const FRigControlValue Value = FRigControlValue : : Make < int32 > ( NewSelection ) ;
HierarchyPtr - > SetControlValue ( ControlElement - > GetKey ( ) , Value , InValueType , true ) ;
2021-05-06 10:50:31 -04:00
if ( InValueType = = ERigControlValueType : : Initial )
{
if ( UControlRigBlueprint * Blueprint = RigElementDetails_GetBlueprintFromHierarchy ( HierarchyPtr . Get ( ) ) )
{
Blueprint - > Hierarchy - > SetControlValue ( ControlElement - > GetKey ( ) , Value , InValueType , true ) ;
}
}
}
2021-02-22 13:36:33 -04:00
}
} )
. Font ( FEditorStyle : : GetFontStyle ( TEXT ( " MenuItem.Font " ) ) )
]
]
. IsEnabled ( EnabledAttribute ) ;
}
else
{
InCategory . AddCustomRow ( PropertyLabel )
. Visibility ( VisibilityAttribute )
. NameContent ( )
[
SNew ( STextBlock )
. Text ( PropertyLabel )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
. ValueContent ( )
. MinDesiredWidth ( 125.0f * 3.0f ) // copied from FComponentTransformDetails
. MaxDesiredWidth ( 125.0f * 3.0f )
[
SNew ( SVerticalBox )
+ SVerticalBox : : Slot ( )
[
SNew ( SNumericEntryBox < int32 > )
. Font ( FEditorStyle : : GetFontStyle ( TEXT ( " MenuItem.Font " ) ) )
2021-03-17 06:58:59 -04:00
. AllowSpin ( InValueType = = ERigControlValueType : : Current | | InValueType = = ERigControlValueType : : Initial )
2021-02-22 13:36:33 -04:00
. MinSliderValue_Lambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > TOptional < int32 >
{
if ( InValueType = = ERigControlValueType : : Current | | InValueType = = ERigControlValueType : : Initial )
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
return ControlElement - > Settings . MinimumValue . Get < int32 > ( ) ;
}
}
}
return TOptional < int32 > ( ) ;
} )
. MaxSliderValue_Lambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > TOptional < int32 >
{
if ( InValueType = = ERigControlValueType : : Current | | InValueType = = ERigControlValueType : : Initial )
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
return ControlElement - > Settings . MaximumValue . Get < int32 > ( ) ;
}
}
}
return TOptional < int32 > ( ) ;
} )
. Value_Lambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > int32
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
return HierarchyPtr - > GetControlValue ( ControlElement , InValueType ) . Get < int32 > ( ) ;
}
}
return 0 ;
} )
. OnValueChanged_Lambda ( [ HierarchyPtr , Key , InValueType ] ( TOptional < int32 > InNewSelection )
{
if ( InNewSelection . IsSet ( ) )
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
const FRigControlValue Value = FRigControlValue : : Make < int32 > ( InNewSelection . GetValue ( ) ) ;
HierarchyPtr - > SetControlValue ( ControlElement - > GetKey ( ) , Value , InValueType , true ) ;
2021-05-06 10:50:31 -04:00
if ( InValueType = = ERigControlValueType : : Initial )
{
if ( UControlRigBlueprint * Blueprint = RigElementDetails_GetBlueprintFromHierarchy ( HierarchyPtr . Get ( ) ) )
{
Blueprint - > Hierarchy - > SetControlValue ( ControlElement - > GetKey ( ) , Value , InValueType , true ) ;
}
}
2021-02-22 13:36:33 -04:00
}
}
}
} )
]
]
. IsEnabled ( EnabledAttribute ) ;
2020-09-24 00:43:27 -04:00
}
}
2021-02-22 13:36:33 -04:00
void FRigControlElementDetails_SetupFloatValueWidget ( IDetailCategoryBuilder & InCategory , ERigControlValueType InValueType , FRigControlElement * InControlElement , URigHierarchy * InHierarchy )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
UEnum * ControlTypeEnum = StaticEnum < ERigControlType > ( ) ;
UEnum * ValueTypeEnum = StaticEnum < ERigControlValueType > ( ) ;
const FString ValueTypeName = ValueTypeEnum - > GetDisplayNameTextByValue ( ( int64 ) InValueType ) . ToString ( ) ;
const FText PropertyLabel = FText : : FromString ( FString : : Printf ( TEXT ( " %s Value " ) , * ValueTypeName ) ) ;
TWeakObjectPtr < URigHierarchy > HierarchyPtr = InHierarchy ;
const FRigElementKey Key = InControlElement - > GetKey ( ) ;
const TAttribute < bool > EnabledAttribute = TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateLambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > bool
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
return ControlElement - > Settings . IsValueTypeEnabled ( InValueType ) ;
}
}
return false ;
} ) ) ;
const TAttribute < EVisibility > VisibilityAttribute = TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateLambda ( [ EnabledAttribute ] ( ) - > EVisibility
{
return EnabledAttribute . Get ( ) ? EVisibility : : Visible : EVisibility : : Hidden ;
} ) ) ;
InCategory . AddCustomRow ( PropertyLabel )
. Visibility ( VisibilityAttribute )
. NameContent ( )
[
SNew ( STextBlock )
. Text ( PropertyLabel )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
. ValueContent ( )
. MinDesiredWidth ( 125.0f * 3.0f ) // copied from FComponentTransformDetails
. MaxDesiredWidth ( 125.0f * 3.0f )
[
SNew ( SVerticalBox )
+ SVerticalBox : : Slot ( )
[
SNew ( SNumericEntryBox < float > )
. Font ( FEditorStyle : : GetFontStyle ( TEXT ( " MenuItem.Font " ) ) )
2021-03-17 06:58:59 -04:00
. AllowSpin ( InValueType = = ERigControlValueType : : Current | | InValueType = = ERigControlValueType : : Initial )
2021-02-22 13:36:33 -04:00
. Value_Lambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > float
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
return HierarchyPtr - > GetControlValue ( ControlElement , InValueType ) . Get < float > ( ) ;
}
}
return 0.f ;
} )
. MinSliderValue_Lambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > TOptional < float >
{
if ( InValueType = = ERigControlValueType : : Current | | InValueType = = ERigControlValueType : : Initial )
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
return ControlElement - > Settings . MinimumValue . Get < float > ( ) ;
}
}
}
return TOptional < float > ( ) ;
} )
. MaxSliderValue_Lambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > TOptional < float >
{
if ( InValueType = = ERigControlValueType : : Current | | InValueType = = ERigControlValueType : : Initial )
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
return ControlElement - > Settings . MaximumValue . Get < float > ( ) ;
}
}
}
return TOptional < float > ( ) ;
} )
. OnValueChanged_Lambda ( [ HierarchyPtr , Key , InValueType ] ( TOptional < float > InNewSelection )
{
if ( InNewSelection . IsSet ( ) )
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
const FRigControlValue Value = FRigControlValue : : Make < float > ( InNewSelection . GetValue ( ) ) ;
HierarchyPtr - > SetControlValue ( ControlElement - > GetKey ( ) , Value , InValueType , true ) ;
2021-05-06 10:50:31 -04:00
if ( InValueType = = ERigControlValueType : : Initial )
{
if ( UControlRigBlueprint * Blueprint = RigElementDetails_GetBlueprintFromHierarchy ( HierarchyPtr . Get ( ) ) )
{
Blueprint - > Hierarchy - > SetControlValue ( ControlElement - > GetKey ( ) , Value , InValueType , true ) ;
}
}
2021-02-22 13:36:33 -04:00
}
}
}
} )
]
]
. IsEnabled ( EnabledAttribute ) ;
2020-09-24 00:43:27 -04:00
}
2021-02-22 13:36:33 -04:00
template < typename T >
void FRigControlElementDetails_SetupStructValueWidget ( IDetailCategoryBuilder & InCategory , ERigControlValueType InValueType , FRigControlElement * InControlElement , URigHierarchy * InHierarchy )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
UEnum * ControlTypeEnum = StaticEnum < ERigControlType > ( ) ;
UEnum * ValueTypeEnum = StaticEnum < ERigControlValueType > ( ) ;
const FString ValueTypeName = ValueTypeEnum - > GetDisplayNameTextByValue ( ( int64 ) InValueType ) . ToString ( ) ;
const FText PropertyLabel = FText : : FromString ( FString : : Printf ( TEXT ( " %s Value " ) , * ValueTypeName ) ) ;
const UStruct * ValueStruct = TBaseStructure < T > : : Get ( ) ;
const TSharedPtr < FStructOnScope > StructToDisplay = MakeShareable ( new FStructOnScope ( ValueStruct ) ) ;
TWeakObjectPtr < URigHierarchy > HierarchyPtr = InHierarchy ;
const FRigElementKey Key = InControlElement - > GetKey ( ) ;
2021-03-11 15:00:29 -04:00
const TAttribute < bool > EnabledAttribute = TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateLambda ( [ HierarchyPtr , Key , InValueType , StructToDisplay , ValueStruct ] ( ) - > bool
2021-02-22 13:36:33 -04:00
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
2021-03-11 15:00:29 -04:00
// update the struct with the current control value
uint8 * StructMemory = StructToDisplay - > GetStructMemory ( ) ;
const FRigControlValue & CurrentValue = HierarchyPtr - > GetControlValue ( Key , InValueType ) ;
FMemory : : Memcpy ( StructToDisplay - > GetStructMemory ( ) , & CurrentValue . GetRef < T > ( ) , sizeof ( T ) ) ;
return ControlElement - > Settings . IsValueTypeEnabled ( InValueType ) ;
2021-02-22 13:36:33 -04:00
}
}
return false ;
} ) ) ;
const TAttribute < EVisibility > VisibilityAttribute = TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateLambda ( [ HierarchyPtr , Key , InValueType ] ( ) - > EVisibility
{
if ( HierarchyPtr . IsValid ( ) )
{
if ( FRigControlElement * ControlElement = HierarchyPtr - > Find < FRigControlElement > ( Key ) )
{
if ( ControlElement - > Settings . IsValueTypeEnabled ( InValueType ) )
{
return EVisibility : : Visible ;
}
}
}
return EVisibility : : Hidden ;
} ) ) ;
IDetailPropertyRow * Row = InCategory . AddExternalStructure ( StructToDisplay ) ;
Row - > DisplayName ( PropertyLabel ) ;
Row - > ShouldAutoExpand ( true ) ;
Row - > IsEnabled ( EnabledAttribute ) ;
Row - > Visibility ( VisibilityAttribute ) ;
TSharedPtr < SWidget > NameWidget , ValueWidget ;
Row - > GetDefaultWidgets ( NameWidget , ValueWidget ) ;
const FSimpleDelegate OnStructContentsChangedDelegate = FSimpleDelegate : : CreateLambda ( [ HierarchyPtr , Key , StructToDisplay , InValueType ] ( )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
if ( HierarchyPtr . IsValid ( ) )
{
const FRigControlValue Value = FRigControlValue : : Make ( * ( T * ) StructToDisplay - > GetStructMemory ( ) ) ;
HierarchyPtr - > SetControlValue ( Key , Value , InValueType , true ) ;
2021-05-06 10:50:31 -04:00
if ( InValueType = = ERigControlValueType : : Initial )
{
if ( UControlRigBlueprint * Blueprint = RigElementDetails_GetBlueprintFromHierarchy ( HierarchyPtr . Get ( ) ) )
{
Blueprint - > Hierarchy - > SetControlValue ( Key , Value , InValueType , true ) ;
}
}
2021-02-22 13:36:33 -04:00
}
} ) ;
2020-09-24 00:43:27 -04:00
2021-02-22 13:36:33 -04:00
TSharedPtr < IPropertyHandle > Handle = Row - > GetPropertyHandle ( ) ;
Handle - > SetOnPropertyValueChanged ( OnStructContentsChangedDelegate ) ;
Handle - > SetOnChildPropertyValueChanged ( OnStructContentsChangedDelegate ) ;
2019-09-17 19:12:19 -04:00
}
2021-02-22 13:36:33 -04:00
void FRigControlElementDetails_SetupValueWidget ( IDetailCategoryBuilder & InCategory , ERigControlValueType InValueType , FRigControlElement * InControlElement , URigHierarchy * InHierarchy )
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
switch ( InControlElement - > Settings . ControlType )
{
case ERigControlType : : Bool :
{
if ( ( InValueType = = ERigControlValueType : : Minimum ) | | ( InValueType = = ERigControlValueType : : Maximum ) )
{
return ;
}
FRigControlElementDetails_SetupBoolValueWidget ( InCategory , InValueType , InControlElement , InHierarchy ) ;
break ;
}
case ERigControlType : : Integer :
{
FRigControlElementDetails_SetupIntegerValueWidget ( InCategory , InValueType , InControlElement , InHierarchy ) ;
break ;
}
case ERigControlType : : Float :
{
FRigControlElementDetails_SetupFloatValueWidget ( InCategory , InValueType , InControlElement , InHierarchy ) ;
break ;
}
case ERigControlType : : Vector2D :
{
FRigControlElementDetails_SetupStructValueWidget < FVector2D > ( InCategory , InValueType , InControlElement , InHierarchy ) ;
break ;
}
case ERigControlType : : Position :
case ERigControlType : : Scale :
{
FRigControlElementDetails_SetupStructValueWidget < FVector > ( InCategory , InValueType , InControlElement , InHierarchy ) ;
break ;
}
case ERigControlType : : Rotator :
{
FRigControlElementDetails_SetupStructValueWidget < FRotator > ( InCategory , InValueType , InControlElement , InHierarchy ) ;
break ;
}
case ERigControlType : : TransformNoScale :
{
FRigControlElementDetails_SetupStructValueWidget < FTransformNoScale > ( InCategory , InValueType , InControlElement , InHierarchy ) ;
break ;
}
case ERigControlType : : EulerTransform :
{
FRigControlElementDetails_SetupStructValueWidget < FEulerTransform > ( InCategory , InValueType , InControlElement , InHierarchy ) ;
break ;
}
case ERigControlType : : Transform :
{
FRigControlElementDetails_SetupStructValueWidget < FTransform > ( InCategory , InValueType , InControlElement , InHierarchy ) ;
break ;
}
default :
{
ensure ( false ) ;
break ;
}
}
}
2019-09-17 19:12:19 -04:00
2021-02-22 13:36:33 -04:00
TArray < TSharedPtr < FString > > FRigControlElementDetails : : ControlTypeList ;
void FRigControlElementDetails : : CustomizeDetails ( IDetailLayoutBuilder & DetailBuilder )
{
FRigTransformElementDetails : : CustomizeDetails ( DetailBuilder ) ;
2019-09-17 19:12:19 -04:00
GizmoNameList . Reset ( ) ;
if ( BlueprintBeingCustomized )
{
if ( ! BlueprintBeingCustomized - > GizmoLibrary . IsValid ( ) )
{
BlueprintBeingCustomized - > GizmoLibrary . LoadSynchronous ( ) ;
}
if ( BlueprintBeingCustomized - > GizmoLibrary . IsValid ( ) )
{
GizmoNameList . Add ( MakeShared < FString > ( BlueprintBeingCustomized - > GizmoLibrary - > DefaultGizmo . GizmoName . ToString ( ) ) ) ;
for ( const FControlRigGizmoDefinition & Gizmo : BlueprintBeingCustomized - > GizmoLibrary - > Gizmos )
{
GizmoNameList . Add ( MakeShared < FString > ( Gizmo . GizmoName . ToString ( ) ) ) ;
}
}
}
2021-02-22 13:36:33 -04:00
if ( HierarchyBeingCustomized = = nullptr | | ! ElementKeyBeingCustomized )
{
return ;
}
2020-01-22 17:58:55 -05:00
IDetailCategoryBuilder & ControlCategory = DetailBuilder . EditCategory ( TEXT ( " Control " ) , LOCTEXT ( " ControlCategory " , " Control " ) ) ;
IDetailCategoryBuilder & LimitsCategory = DetailBuilder . EditCategory ( TEXT ( " Limits " ) , LOCTEXT ( " LimitsCategory " , " Limits " ) ) ;
IDetailCategoryBuilder & GizmoCategory = DetailBuilder . EditCategory ( TEXT ( " Gizmo " ) , LOCTEXT ( " GizmoCategory " , " Gizmo " ) ) ;
2019-09-17 19:12:19 -04:00
2020-01-22 17:58:55 -05:00
ControlCategory . InitiallyCollapsed ( false ) ;
LimitsCategory . InitiallyCollapsed ( false ) ;
GizmoCategory . InitiallyCollapsed ( false ) ;
2021-02-22 13:36:33 -04:00
const TSharedRef < IPropertyHandle > DisplayNameHandle = DetailBuilder . GetProperty ( TEXT ( " Settings.DisplayName " ) ) ;
DetailBuilder . HideProperty ( DisplayNameHandle ) ;
ControlCategory . AddProperty ( DisplayNameHandle ) . CustomWidget ( )
2019-09-17 19:12:19 -04:00
. NameContent ( )
2021-02-22 13:36:33 -04:00
[
SNew ( STextBlock )
. Text ( FText : : FromString ( TEXT ( " Display Name " ) ) )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
2019-09-17 19:12:19 -04:00
. ValueContent ( )
2021-02-22 13:36:33 -04:00
[
2019-09-17 19:12:19 -04:00
SNew ( SEditableTextBox )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
2021-02-22 13:36:33 -04:00
. Text ( this , & FRigControlElementDetails : : GetDisplayName )
. OnTextCommitted ( this , & FRigControlElementDetails : : SetDisplayName , DetailBuilder . GetPropertyUtilities ( ) )
2019-09-17 19:12:19 -04:00
] ;
2020-01-22 17:58:55 -05:00
if ( ControlTypeList . Num ( ) = = 0 )
{
UEnum * Enum = StaticEnum < ERigControlType > ( ) ;
for ( int64 Index = 0 ; Index < Enum - > GetMaxEnumValue ( ) ; Index + + )
{
ControlTypeList . Add ( MakeShared < FString > ( Enum - > GetDisplayNameTextByValue ( Index ) . ToString ( ) ) ) ;
}
}
2021-02-22 13:36:33 -04:00
FRigControlElement * ControlElement = HierarchyBeingCustomized - > FindChecked < FRigControlElement > ( ElementKeyBeingCustomized ) ;
2020-01-22 17:58:55 -05:00
// when control type changes, we have to refresh detail panel
2021-02-22 13:36:33 -04:00
const TSharedRef < IPropertyHandle > ControlTypeHandle = DetailBuilder . GetProperty ( TEXT ( " Settings.ControlType " ) ) ;
ControlTypeHandle - > SetOnPropertyValueChanged ( FSimpleDelegate : : CreateLambda (
2020-01-22 17:58:55 -05:00
[ this , & DetailBuilder ] ( )
{
DetailBuilder . ForceRefreshDetails ( ) ;
2021-02-22 13:36:33 -04:00
if ( this - > HierarchyBeingCustomized & & this - > ElementKeyBeingCustomized . IsValid ( ) )
2020-01-22 17:58:55 -05:00
{
2021-02-22 13:36:33 -04:00
FRigControlElement * ControlElement = this - > HierarchyBeingCustomized - > FindChecked < FRigControlElement > ( ElementKeyBeingCustomized ) ;
FRigControlValue ValueToSet ;
2020-01-22 17:58:55 -05:00
2021-02-22 13:36:33 -04:00
ControlElement - > Settings . bLimitTranslation = false ;
ControlElement - > Settings . bLimitRotation = false ;
ControlElement - > Settings . bLimitScale = false ;
switch ( ControlElement - > Settings . ControlType )
2020-01-22 17:58:55 -05:00
{
case ERigControlType : : Bool :
{
2021-02-22 13:36:33 -04:00
ValueToSet = FRigControlValue : : Make < bool > ( false ) ;
2020-01-22 17:58:55 -05:00
break ;
}
case ERigControlType : : Float :
{
2021-02-22 13:36:33 -04:00
ValueToSet = FRigControlValue : : Make < float > ( 0.f ) ;
ControlElement - > Settings . bLimitTranslation = true ;
ControlElement - > Settings . MinimumValue = FRigControlValue : : Make < float > ( 0.f ) ;
2021-06-15 11:59:28 -04:00
ControlElement - > Settings . MaximumValue = FRigControlValue : : Make < float > ( 100.f ) ;
2021-02-22 13:36:33 -04:00
break ;
2020-01-22 17:58:55 -05:00
}
2020-09-24 00:43:27 -04:00
case ERigControlType : : Integer :
{
2021-02-22 13:36:33 -04:00
ValueToSet = FRigControlValue : : Make < int32 > ( 0 ) ;
ControlElement - > Settings . bLimitTranslation = true ;
ControlElement - > Settings . MinimumValue = FRigControlValue : : Make < int32 > ( 0 ) ;
2021-06-15 11:59:28 -04:00
ControlElement - > Settings . MaximumValue = FRigControlValue : : Make < int32 > ( 100 ) ;
2020-09-24 00:43:27 -04:00
break ;
}
2020-01-22 17:58:55 -05:00
case ERigControlType : : Vector2D :
{
2021-02-22 13:36:33 -04:00
ValueToSet = FRigControlValue : : Make < FVector2D > ( FVector2D : : ZeroVector ) ;
ControlElement - > Settings . bLimitTranslation = true ;
ControlElement - > Settings . MinimumValue = FRigControlValue : : Make < FVector2D > ( FVector2D : : ZeroVector ) ;
2021-06-15 11:59:28 -04:00
ControlElement - > Settings . MaximumValue = FRigControlValue : : Make < FVector2D > ( FVector2D ( 100.f , 100.f ) ) ;
2020-01-22 17:58:55 -05:00
break ;
}
case ERigControlType : : Position :
{
2021-02-22 13:36:33 -04:00
ValueToSet = FRigControlValue : : Make < FVector > ( FVector : : ZeroVector ) ;
ControlElement - > Settings . MinimumValue = FRigControlValue : : Make < FVector > ( - FVector : : OneVector ) ;
ControlElement - > Settings . MaximumValue = FRigControlValue : : Make < FVector > ( FVector : : OneVector ) ;
2020-01-22 17:58:55 -05:00
break ;
}
case ERigControlType : : Scale :
{
2021-02-22 13:36:33 -04:00
ValueToSet = FRigControlValue : : Make < FVector > ( FVector : : OneVector ) ;
ControlElement - > Settings . MinimumValue = FRigControlValue : : Make < FVector > ( FVector : : ZeroVector ) ;
ControlElement - > Settings . MaximumValue = FRigControlValue : : Make < FVector > ( FVector : : OneVector ) ;
2020-01-22 17:58:55 -05:00
break ;
}
case ERigControlType : : Rotator :
{
2021-02-22 13:36:33 -04:00
ValueToSet = FRigControlValue : : Make < FRotator > ( FRotator : : ZeroRotator ) ;
ControlElement - > Settings . MinimumValue = FRigControlValue : : Make < FRotator > ( FRotator : : ZeroRotator ) ;
ControlElement - > Settings . MaximumValue = FRigControlValue : : Make < FRotator > ( FRotator ( 180.f , 180.f , 180.f ) ) ;
2020-01-22 17:58:55 -05:00
break ;
}
case ERigControlType : : Transform :
{
2021-02-22 13:36:33 -04:00
ValueToSet = FRigControlValue : : Make < FTransform > ( FTransform : : Identity ) ;
ControlElement - > Settings . MinimumValue = ValueToSet ;
ControlElement - > Settings . MaximumValue = ValueToSet ;
2020-01-22 17:58:55 -05:00
break ;
}
case ERigControlType : : TransformNoScale :
{
FTransformNoScale Identity = FTransform : : Identity ;
2021-02-22 13:36:33 -04:00
ValueToSet = FRigControlValue : : Make < FTransformNoScale > ( Identity ) ;
ControlElement - > Settings . MinimumValue = ValueToSet ;
ControlElement - > Settings . MaximumValue = ValueToSet ;
break ;
2020-01-22 17:58:55 -05:00
}
2020-09-24 00:43:27 -04:00
case ERigControlType : : EulerTransform :
{
FEulerTransform Identity = FEulerTransform : : Identity ;
2021-02-22 13:36:33 -04:00
ValueToSet = FRigControlValue : : Make < FEulerTransform > ( Identity ) ;
ControlElement - > Settings . MinimumValue = ValueToSet ;
ControlElement - > Settings . MaximumValue = ValueToSet ;
2020-09-24 00:43:27 -04:00
break ;
}
2020-01-22 17:58:55 -05:00
default :
{
ensure ( false ) ;
break ;
}
}
2021-02-22 13:36:33 -04:00
this - > HierarchyBeingCustomized - > Notify ( ERigHierarchyNotification : : ControlSettingChanged , ControlElement ) ;
this - > HierarchyBeingCustomized - > SetControlValue ( ControlElement , ValueToSet , ERigControlValueType : : Initial , true ) ;
this - > HierarchyBeingCustomized - > SetControlValue ( ControlElement , ValueToSet , ERigControlValueType : : Current , true ) ;
if ( this - > HierarchyBeingCustomized ! = this - > BlueprintBeingCustomized - > Hierarchy )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
if ( FRigControlElement * OtherControlElement = this - > BlueprintBeingCustomized - > Hierarchy - > Find < FRigControlElement > ( ControlElement - > GetKey ( ) ) )
{
OtherControlElement - > Settings = ControlElement - > Settings ;
this - > BlueprintBeingCustomized - > Hierarchy - > Notify ( ERigHierarchyNotification : : ControlSettingChanged , ControlElement ) ;
this - > BlueprintBeingCustomized - > Hierarchy - > SetControlValue ( ControlElement , ValueToSet , ERigControlValueType : : Initial , true ) ;
this - > BlueprintBeingCustomized - > Hierarchy - > SetControlValue ( ControlElement , ValueToSet , ERigControlValueType : : Current , true ) ;
}
2020-09-24 00:43:27 -04:00
}
2020-01-22 17:58:55 -05:00
}
}
) ) ;
2021-02-23 04:30:01 -04:00
if ( ControlElement - > Settings . ControlType = = ERigControlType : : Bool )
{
DetailBuilder . HideCategory ( TEXT ( " Pose " ) ) ;
DetailBuilder . HideProperty ( TEXT ( " Offset " ) ) ;
DetailBuilder . HideProperty ( TEXT ( " Gizmo " ) ) ;
}
else
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
// setup offset transform
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
const TSharedRef < IPropertyHandle > OffsetInitialLocalTransformHandle = DetailBuilder . GetProperty ( TEXT ( " Offset.Initial.Local.Transform " ) ) ;
ControlCategory . AddProperty ( OffsetInitialLocalTransformHandle ) . DisplayName ( FText : : FromString ( TEXT ( " Offset Transform " ) ) ) ;
DetailBuilder . HideProperty ( TEXT ( " Offset " ) ) ;
2020-01-22 17:58:55 -05:00
2021-02-22 13:36:33 -04:00
OffsetPropertyChain . AddHead ( FRigControlElement : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Offset " ) ) ) ;
OffsetPropertyChain . AddTail ( FRigCurrentAndInitialTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Initial " ) ) ) ;
OffsetPropertyChain . AddTail ( FRigLocalAndGlobalTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Local " ) ) ) ;
OffsetPropertyChain . AddTail ( FRigComputedTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Transform " ) ) ) ;
OffsetPropertyChain . SetActiveMemberPropertyNode ( OffsetPropertyChain . GetTail ( ) - > GetValue ( ) ) ;
2020-01-22 17:58:55 -05:00
2021-03-11 15:00:29 -04:00
const FSimpleDelegate OnTransformChangedDelegate = FSimpleDelegate : : CreateStatic ( & FRigTransformElementDetails : : OnTransformChanged , & OffsetPropertyChain , BlueprintBeingCustomized ) ;
2021-02-22 13:36:33 -04:00
OffsetInitialLocalTransformHandle - > SetOnPropertyValueChanged ( OnTransformChangedDelegate ) ;
OffsetInitialLocalTransformHandle - > SetOnChildPropertyValueChanged ( OnTransformChangedDelegate ) ;
2021-03-11 15:00:29 -04:00
OffsetInitialLocalTransformHandle - > SetToolTipText ( FText : : FromString ( TEXT ( " The offset transform is used as a middle man between the parent and the local transform. \n You can use it to offset a control for visual adjustment. " ) ) ) ;
2020-01-22 17:58:55 -05:00
}
2021-02-22 13:36:33 -04:00
// setup gizmo transform
2020-01-22 17:58:55 -05:00
{
2021-02-22 13:36:33 -04:00
const TSharedRef < IPropertyHandle > GizmoInitialLocalTransformHandle = DetailBuilder . GetProperty ( TEXT ( " Gizmo.Initial.Local.Transform " ) ) ;
GizmoCategory . AddProperty ( GizmoInitialLocalTransformHandle ) . DisplayName ( FText : : FromString ( TEXT ( " Gizmo Transform " ) ) ) ;
DetailBuilder . HideProperty ( TEXT ( " Gizmo " ) ) ;
2020-01-22 17:58:55 -05:00
2021-02-22 13:36:33 -04:00
GizmoPropertyChain . AddHead ( FRigControlElement : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Gizmo " ) ) ) ;
GizmoPropertyChain . AddTail ( FRigCurrentAndInitialTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Initial " ) ) ) ;
GizmoPropertyChain . AddTail ( FRigLocalAndGlobalTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Local " ) ) ) ;
GizmoPropertyChain . AddTail ( FRigComputedTransform : : StaticStruct ( ) - > FindPropertyByName ( TEXT ( " Transform " ) ) ) ;
GizmoPropertyChain . SetActiveMemberPropertyNode ( GizmoPropertyChain . GetTail ( ) - > GetValue ( ) ) ;
2020-01-22 17:58:55 -05:00
2021-03-11 15:00:29 -04:00
const FSimpleDelegate OnTransformChangedDelegate = FSimpleDelegate : : CreateStatic ( & FRigTransformElementDetails : : OnTransformChanged , & GizmoPropertyChain , BlueprintBeingCustomized ) ;
2021-02-22 13:36:33 -04:00
GizmoInitialLocalTransformHandle - > SetOnPropertyValueChanged ( OnTransformChangedDelegate ) ;
GizmoInitialLocalTransformHandle - > SetOnChildPropertyValueChanged ( OnTransformChangedDelegate ) ;
2021-03-11 15:00:29 -04:00
GizmoInitialLocalTransformHandle - > SetToolTipText ( FText : : FromString ( TEXT ( " The gizmo transform is used as a transform applied only to the UI element on the screen. \n It doesn't affect animation. " ) ) ) ;
2019-09-17 19:12:19 -04:00
}
}
2021-02-22 13:36:33 -04:00
FRigControlElementDetails_SetupValueWidget ( ControlCategory , ERigControlValueType : : Current , ControlElement , HierarchyBeingCustomized ) ;
2021-03-17 06:58:59 -04:00
switch ( ControlElement - > Settings . ControlType )
{
case ERigControlType : : Bool :
case ERigControlType : : Float :
case ERigControlType : : Integer :
case ERigControlType : : Vector2D :
{
FRigControlElementDetails_SetupValueWidget ( ControlCategory , ERigControlValueType : : Initial , ControlElement , HierarchyBeingCustomized ) ;
break ;
}
default :
{
break ;
}
}
2021-02-22 13:36:33 -04:00
FRigControlElementDetails_SetupValueWidget ( LimitsCategory , ERigControlValueType : : Minimum , ControlElement , HierarchyBeingCustomized ) ;
FRigControlElementDetails_SetupValueWidget ( LimitsCategory , ERigControlValueType : : Maximum , ControlElement , HierarchyBeingCustomized ) ;
2020-01-22 17:58:55 -05:00
2021-02-22 13:36:33 -04:00
switch ( ControlElement - > Settings . ControlType )
2020-01-22 17:58:55 -05:00
{
case ERigControlType : : Float :
2020-09-24 00:43:27 -04:00
case ERigControlType : : Integer :
2020-01-22 17:58:55 -05:00
case ERigControlType : : Vector2D :
case ERigControlType : : Position :
case ERigControlType : : Scale :
case ERigControlType : : Rotator :
case ERigControlType : : Transform :
case ERigControlType : : TransformNoScale :
2020-09-24 00:43:27 -04:00
case ERigControlType : : EulerTransform :
2020-01-22 17:58:55 -05:00
{
2021-02-22 13:36:33 -04:00
const TSharedRef < IPropertyHandle > GizmoNameHandle = DetailBuilder . GetProperty ( TEXT ( " Settings.GizmoName " ) ) ;
DetailBuilder . HideProperty ( GizmoNameHandle ) ;
GizmoCategory . AddProperty ( GizmoNameHandle ) . CustomWidget ( )
2020-01-22 17:58:55 -05:00
. NameContent ( )
[
SNew ( STextBlock )
. Text ( FText : : FromString ( TEXT ( " Gizmo Name " ) ) )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
2021-02-22 13:36:33 -04:00
. IsEnabled ( this , & FRigControlElementDetails : : IsGizmoEnabled )
2020-01-22 17:58:55 -05:00
]
. ValueContent ( )
[
2021-02-22 13:36:33 -04:00
SNew ( SControlRigGizmoNameList , ControlElement , BlueprintBeingCustomized )
. OnGetNameListContent ( this , & FRigControlElementDetails : : GetGizmoNameList )
. IsEnabled ( this , & FRigControlElementDetails : : IsGizmoEnabled )
2020-01-22 17:58:55 -05:00
] ;
break ;
}
default :
{
2021-02-22 13:36:33 -04:00
DetailBuilder . HideProperty ( TEXT ( " Settings.bGizmoEnabled " ) ) ;
DetailBuilder . HideProperty ( TEXT ( " Settings.bGizmoVisible " ) ) ;
DetailBuilder . HideProperty ( TEXT ( " Settings.GizmoName " ) ) ;
DetailBuilder . HideProperty ( TEXT ( " Settings.GizmoColor " ) ) ;
2020-01-22 17:58:55 -05:00
break ;
}
}
2021-02-22 13:36:33 -04:00
if ( ControlElement - > Settings . ControlType ! = ERigControlType : : Integer )
{
DetailBuilder . HideProperty ( TEXT ( " Settings.ControlEnum " ) ) ;
}
bool bShowLimitTranslation = false ;
bool bShowLimitRotation = false ;
bool bShowLimitScale = false ;
switch ( ControlElement - > Settings . ControlType )
2020-01-22 17:58:55 -05:00
{
case ERigControlType : : Float :
2021-02-22 13:36:33 -04:00
case ERigControlType : : Integer :
case ERigControlType : : Vector2D :
case ERigControlType : : Position :
case ERigControlType : : Transform :
case ERigControlType : : TransformNoScale :
case ERigControlType : : EulerTransform :
{
bShowLimitTranslation = true ;
break ;
}
default :
{
break ;
}
}
switch ( ControlElement - > Settings . ControlType )
{
case ERigControlType : : Rotator :
case ERigControlType : : Transform :
case ERigControlType : : TransformNoScale :
case ERigControlType : : EulerTransform :
{
bShowLimitRotation = true ;
break ;
}
default :
{
break ;
}
}
switch ( ControlElement - > Settings . ControlType )
{
case ERigControlType : : Scale :
case ERigControlType : : Transform :
case ERigControlType : : EulerTransform :
{
bShowLimitScale = true ;
break ;
}
default :
{
break ;
}
}
if ( ! bShowLimitTranslation )
{
DetailBuilder . HideProperty ( TEXT ( " Settings.bLimitTranslation " ) ) ;
}
if ( ! bShowLimitRotation )
{
DetailBuilder . HideProperty ( TEXT ( " Settings.bLimitRotation " ) ) ;
}
if ( ! bShowLimitScale )
{
DetailBuilder . HideProperty ( TEXT ( " Settings.bLimitScale " ) ) ;
}
switch ( ControlElement - > Settings . ControlType )
{
2020-09-24 00:43:27 -04:00
case ERigControlType : : Integer :
2021-02-22 13:36:33 -04:00
case ERigControlType : : Float :
2020-01-22 17:58:55 -05:00
case ERigControlType : : Vector2D :
{
break ;
}
default :
{
2021-02-22 13:36:33 -04:00
DetailBuilder . HideProperty ( TEXT ( " Settings.PrimaryAxis " ) ) ;
2020-01-22 17:58:55 -05:00
break ;
}
}
2020-09-24 00:43:27 -04:00
2021-02-22 13:36:33 -04:00
if ( ControlElement - > Settings . ControlType = = ERigControlType : : Integer )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
TSharedRef < IPropertyHandle > ControlEnum = DetailBuilder . GetProperty ( TEXT ( " Settings.ControlEnum " ) ) ;
2020-09-24 00:43:27 -04:00
ControlEnum - > SetOnPropertyValueChanged ( FSimpleDelegate : : CreateLambda (
[ this , & DetailBuilder ] ( )
{
DetailBuilder . ForceRefreshDetails ( ) ;
2021-02-22 13:36:33 -04:00
if ( this - > HierarchyBeingCustomized ! = nullptr & & this - > ElementKeyBeingCustomized )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
if ( FRigControlElement * ControlBeingCustomized = this - > HierarchyBeingCustomized - > Find < FRigControlElement > ( ElementKeyBeingCustomized ) )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
const UEnum * ControlEnum = ControlBeingCustomized - > Settings . ControlEnum ;
2020-09-24 00:43:27 -04:00
if ( ControlEnum ! = nullptr )
{
int32 Maximum = ( int32 ) ControlEnum - > GetMaxEnumValue ( ) - 1 ;
2021-02-22 13:36:33 -04:00
ControlBeingCustomized - > Settings . MinimumValue . Set < int32 > ( 0 ) ;
ControlBeingCustomized - > Settings . MaximumValue . Set < int32 > ( Maximum ) ;
HierarchyBeingCustomized - > Notify ( ERigHierarchyNotification : : ControlSettingChanged , ControlBeingCustomized ) ;
2020-09-24 00:43:27 -04:00
2021-02-22 13:36:33 -04:00
FRigControlValue InitialValue = HierarchyBeingCustomized - > GetControlValue ( ControlBeingCustomized , ERigControlValueType : : Initial ) ;
FRigControlValue CurrentValue = HierarchyBeingCustomized - > GetControlValue ( ControlBeingCustomized , ERigControlValueType : : Current ) ;
2020-09-24 00:43:27 -04:00
2021-02-22 13:36:33 -04:00
ControlBeingCustomized - > Settings . ApplyLimits ( InitialValue ) ;
ControlBeingCustomized - > Settings . ApplyLimits ( CurrentValue ) ;
HierarchyBeingCustomized - > SetControlValue ( ControlBeingCustomized , InitialValue , ERigControlValueType : : Initial ) ;
HierarchyBeingCustomized - > SetControlValue ( ControlBeingCustomized , CurrentValue , ERigControlValueType : : Current ) ;
2020-09-24 00:43:27 -04:00
if ( UControlRig * DebuggedRig = Cast < UControlRig > ( BlueprintBeingCustomized - > GetObjectBeingDebugged ( ) ) )
{
2021-02-22 13:36:33 -04:00
URigHierarchy * DebuggedHierarchy = DebuggedRig - > GetHierarchy ( ) ;
if ( FRigControlElement * DebuggedControlElement = DebuggedHierarchy - > Find < FRigControlElement > ( ElementKeyBeingCustomized ) )
{
DebuggedControlElement - > Settings . MinimumValue . Set < int32 > ( 0 ) ;
DebuggedControlElement - > Settings . MaximumValue . Set < int32 > ( Maximum ) ;
DebuggedHierarchy - > Notify ( ERigHierarchyNotification : : ControlSettingChanged , DebuggedControlElement ) ;
DebuggedHierarchy - > SetControlValue ( DebuggedControlElement , InitialValue , ERigControlValueType : : Initial ) ;
DebuggedHierarchy - > SetControlValue ( DebuggedControlElement , CurrentValue , ERigControlValueType : : Current ) ;
}
2020-09-24 00:43:27 -04:00
}
}
}
}
}
) ) ;
}
2019-09-17 19:12:19 -04:00
}
2021-02-22 13:36:33 -04:00
FText FRigControlElementDetails : : GetDisplayName ( ) const
2020-02-04 11:06:23 -05:00
{
2021-02-22 13:36:33 -04:00
if ( HierarchyBeingCustomized ! = nullptr & & ElementKeyBeingCustomized )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
if ( FRigControlElement * ControlElement = HierarchyBeingCustomized - > Find < FRigControlElement > ( ElementKeyBeingCustomized ) )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
if ( ControlElement - > Settings . DisplayName . IsNone ( ) )
2020-09-24 00:43:27 -04:00
{
return FText ( ) ;
}
2021-02-22 13:36:33 -04:00
return FText : : FromName ( ControlElement - > GetDisplayName ( ) ) ;
2020-09-24 00:43:27 -04:00
}
}
return FText ( ) ;
}
2021-02-22 13:36:33 -04:00
void FRigControlElementDetails : : SetDisplayName ( const FText & InNewText , ETextCommit : : Type InCommitType , const TSharedRef < IPropertyUtilities > PropertyUtilities )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
if ( HierarchyBeingCustomized ! = nullptr & & ElementKeyBeingCustomized )
2020-09-24 00:43:27 -04:00
{
2021-02-22 13:36:33 -04:00
if ( FRigControlElement * ControlElement = HierarchyBeingCustomized - > Find < FRigControlElement > ( ElementKeyBeingCustomized ) )
2020-09-24 00:43:27 -04:00
{
2021-03-01 08:22:05 -04:00
if ( BlueprintBeingCustomized )
{
BlueprintBeingCustomized - > Hierarchy - > Modify ( ) ;
}
const FString NewDisplayName = InNewText . ToString ( ) . TrimStartAndEnd ( ) ;
2020-09-24 00:43:27 -04:00
if ( NewDisplayName . IsEmpty ( ) )
{
2021-02-22 13:36:33 -04:00
ControlElement - > Settings . DisplayName = FName ( NAME_None ) ;
2020-09-24 00:43:27 -04:00
}
else
{
2021-02-22 13:36:33 -04:00
ControlElement - > Settings . DisplayName = * NewDisplayName ;
2020-09-24 00:43:27 -04:00
}
2021-02-22 13:36:33 -04:00
HierarchyBeingCustomized - > Notify ( ERigHierarchyNotification : : ControlSettingChanged , ControlElement ) ;
2021-03-01 08:22:05 -04:00
if ( BlueprintBeingCustomized & & BlueprintBeingCustomized - > Hierarchy ! = HierarchyBeingCustomized )
{
if ( FRigControlElement * OtherControlElement = BlueprintBeingCustomized - > Hierarchy - > Find < FRigControlElement > ( ElementKeyBeingCustomized ) )
{
OtherControlElement - > Settings . DisplayName = ControlElement - > Settings . DisplayName ;
BlueprintBeingCustomized - > Hierarchy - > Notify ( ERigHierarchyNotification : : ControlSettingChanged , OtherControlElement ) ;
}
}
2020-09-24 00:43:27 -04:00
}
}
}
2021-02-22 13:36:33 -04:00
bool FRigControlElementDetails : : IsGizmoEnabled ( ) const
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
URigHierarchy * Hierarchy = HierarchyBeingCustomized ;
if ( Hierarchy ! = nullptr & & ElementKeyBeingCustomized )
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
if ( FRigControlElement * ControlElement = Hierarchy - > Find < FRigControlElement > ( ElementKeyBeingCustomized ) )
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
return ControlElement - > Settings . bGizmoEnabled ;
2020-01-22 17:58:55 -05:00
}
}
return false ;
}
2021-02-22 13:36:33 -04:00
bool FRigControlElementDetails : : IsEnabled ( ERigControlValueType InValueType ) const
2020-01-22 17:58:55 -05:00
{
switch ( InValueType )
{
case ERigControlValueType : : Minimum :
case ERigControlValueType : : Maximum :
{
2021-02-22 13:36:33 -04:00
if ( HierarchyBeingCustomized ! = nullptr & & ElementKeyBeingCustomized )
2020-01-22 17:58:55 -05:00
{
2021-02-22 13:36:33 -04:00
if ( FRigControlElement * ControlElement = HierarchyBeingCustomized - > Find < FRigControlElement > ( ElementKeyBeingCustomized ) )
2020-01-22 17:58:55 -05:00
{
2021-02-22 13:36:33 -04:00
return ControlElement - > Settings . bLimitTranslation | | ControlElement - > Settings . bLimitRotation | | ControlElement - > Settings . bLimitScale ;
2020-01-22 17:58:55 -05:00
}
}
return false ;
}
default :
{
break ;
}
}
return true ;
}
2021-02-22 13:36:33 -04:00
const TArray < TSharedPtr < FString > > & FRigControlElementDetails : : GetGizmoNameList ( ) const
2019-09-17 19:12:19 -04:00
{
return GizmoNameList ;
}
2021-02-22 13:36:33 -04:00
const TArray < TSharedPtr < FString > > & FRigControlElementDetails : : GetControlTypeList ( ) const
2020-01-22 17:58:55 -05:00
{
return ControlTypeList ;
}
2021-03-05 04:30:31 -04:00
void FRigNullElementDetails : : CustomizeDetails ( IDetailLayoutBuilder & DetailBuilder )
2019-09-17 19:12:19 -04:00
{
2021-02-22 13:36:33 -04:00
FRigTransformElementDetails : : CustomizeDetails ( DetailBuilder ) ;
2019-09-17 19:12:19 -04:00
}
# undef LOCTEXT_NAMESPACE