2021-03-19 15:10:57 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# pragma once
# include "Components/Widget.h"
2021-12-13 18:15:01 -05:00
# include "DetailCategoryBuilder.h"
2021-03-19 15:10:57 -04:00
# include "DetailLayoutBuilder.h"
2021-12-13 18:15:01 -05:00
# include "DetailWidgetRow.h"
2021-11-07 23:43:01 -05:00
# include "EdGraph/EdGraphSchema.h"
2022-01-04 15:17:54 -05:00
# include "Framework/Application/SlateApplication.h"
2021-03-19 15:10:57 -04:00
# include "IDetailCustomization.h"
# include "IPropertyTypeCustomization.h"
# include "Layout/Visibility.h"
# include "MetasoundAssetBase.h"
2021-12-13 18:15:01 -05:00
# include "MetasoundEditorGraph.h"
2022-01-04 15:17:54 -05:00
# include "MetasoundEditorGraphBuilder.h"
2021-12-13 18:15:01 -05:00
# include "MetasoundEditorGraphMemberDefaults.h"
2021-03-19 15:10:57 -04:00
# include "MetasoundEditorGraphNode.h"
2021-12-13 18:15:01 -05:00
# include "MetasoundFrontendLiteral.h"
2021-10-12 21:21:22 -04:00
# include "MetasoundEditorModule.h"
2021-03-19 15:10:57 -04:00
# include "MetasoundUObjectRegistry.h"
2021-10-12 21:21:22 -04:00
# include "PropertyHandle.h"
2021-12-13 18:15:01 -05:00
# include "PropertyRestriction.h"
2021-03-19 15:10:57 -04:00
# include "ScopedTransaction.h"
2021-12-13 18:15:01 -05:00
# include "SSearchableComboBox.h"
2021-03-19 15:10:57 -04:00
# include "Types/SlateEnums.h"
# include "UObject/NameTypes.h"
2021-12-13 18:15:01 -05:00
# include "Widgets/Input/SCheckBox.h"
2021-03-19 15:10:57 -04:00
# include "Widgets/Input/SEditableTextBox.h"
2021-12-13 18:15:01 -05:00
# include "Widgets/Input/SMultiLineEditableTextBox.h"
# include "Widgets/Input/STextComboBox.h"
2021-03-19 15:10:57 -04:00
# include "WorkflowOrientedApp/SModeWidget.h"
2021-04-02 03:03:27 -04:00
# define LOCTEXT_NAMESPACE "MetaSoundEditor"
2021-03-19 15:10:57 -04:00
namespace Metasound
{
namespace Editor
{
2021-12-13 18:15:01 -05:00
// TODO: Move to actual style
namespace MemberCustomizationStyle
2021-10-25 20:05:28 -04:00
{
/** Maximum size of the details title panel */
static constexpr float DetailsTitleMaxWidth = 300.f ;
/** magic number retrieved from SGraphNodeComment::GetWrapAt() */
static constexpr float DetailsTitleWrapPadding = 32.0f ;
static const FText DataTypeNameText = LOCTEXT ( " Node_DataTypeName " , " Type " ) ;
static const FText DefaultPropertyText = LOCTEXT ( " Node_DefaultPropertyName " , " Default Value " ) ;
static const FText NodeTooltipText = LOCTEXT ( " Node_Tooltip " , " Tooltip " ) ;
2021-12-13 18:15:01 -05:00
} // namespace MemberCustomizationStyle
2021-10-25 20:05:28 -04:00
2022-01-04 15:17:54 -05:00
class FMetasoundFloatLiteralCustomization : public FMetasoundDefaultLiteralCustomizationBase
2021-10-12 21:21:22 -04:00
{
2021-12-13 18:15:01 -05:00
TWeakObjectPtr < UMetasoundEditorGraphMemberDefaultFloat > FloatLiteral ;
2021-10-12 21:21:22 -04:00
// Delegate for updating the clamp min/max of the input value when the slider range is changed
2021-12-13 18:15:01 -05:00
FDelegateHandle OnRangeChangedDelegateHandle ;
2021-10-12 21:21:22 -04:00
// Delegate for clamping the input value or not
2021-12-13 18:15:01 -05:00
FDelegateHandle OnClampChangedDelegateHandle ;
2021-10-12 21:21:22 -04:00
public :
2022-01-04 15:17:54 -05:00
FMetasoundFloatLiteralCustomization ( IDetailCategoryBuilder & InDefaultCategoryBuilder )
: FMetasoundDefaultLiteralCustomizationBase ( InDefaultCategoryBuilder )
{
}
virtual ~ FMetasoundFloatLiteralCustomization ( ) ;
virtual void CustomizeLiteral ( UMetasoundEditorGraphMemberDefaultLiteral & InLiteral , IDetailLayoutBuilder & InDetailLayout ) override ;
} ;
// Customization to support drag-and-drop of Proxy UObject types on underlying members that are structs.
// Struct ownership of objects required to customize asset filters based on dynamic UObject MetaSound Registry DataTypes.
class FMetasoundObjectArrayLiteralCustomization : public FMetasoundDefaultLiteralCustomizationBase
{
public :
FMetasoundObjectArrayLiteralCustomization ( IDetailCategoryBuilder & InDefaultCategoryBuilder )
: FMetasoundDefaultLiteralCustomizationBase ( InDefaultCategoryBuilder )
2021-10-12 21:21:22 -04:00
{
}
2022-01-04 15:17:54 -05:00
virtual ~ FMetasoundObjectArrayLiteralCustomization ( ) = default ;
2021-10-12 21:21:22 -04:00
2022-01-04 15:17:54 -05:00
virtual void CustomizeLiteral ( UMetasoundEditorGraphMemberDefaultLiteral & InLiteral , IDetailLayoutBuilder & InDetailLayout ) override ;
2021-10-12 21:21:22 -04:00
} ;
2022-01-04 15:17:54 -05:00
class FMetasoundDefaultLiteralCustomizationFactory : public IMemberDefaultLiteralCustomizationFactory
{
public :
virtual TUniquePtr < FMetasoundDefaultLiteralCustomizationBase > CreateLiteralCustomization ( IDetailCategoryBuilder & DefaultCategoryBuilder ) const override
{
return TUniquePtr < FMetasoundDefaultLiteralCustomizationBase > ( new FMetasoundDefaultLiteralCustomizationBase ( DefaultCategoryBuilder ) ) ;
}
} ;
// Customization to support float widgets (ex. sliders, knobs)
2021-12-13 18:15:01 -05:00
class FMetasoundFloatLiteralCustomizationFactory : public IMemberDefaultLiteralCustomizationFactory
2021-10-12 21:21:22 -04:00
{
public :
2022-01-04 15:17:54 -05:00
virtual TUniquePtr < FMetasoundDefaultLiteralCustomizationBase > CreateLiteralCustomization ( IDetailCategoryBuilder & DefaultCategoryBuilder ) const override
2021-10-12 21:21:22 -04:00
{
2022-01-04 15:17:54 -05:00
return TUniquePtr < FMetasoundDefaultLiteralCustomizationBase > ( new FMetasoundFloatLiteralCustomization ( DefaultCategoryBuilder ) ) ;
2021-10-12 21:21:22 -04:00
}
} ;
2022-01-04 15:17:54 -05:00
class FMetasoundObjectArrayLiteralCustomizationFactory : public IMemberDefaultLiteralCustomizationFactory
{
public :
virtual TUniquePtr < FMetasoundDefaultLiteralCustomizationBase > CreateLiteralCustomization ( IDetailCategoryBuilder & DefaultCategoryBuilder ) const override
{
return TUniquePtr < FMetasoundDefaultLiteralCustomizationBase > ( new FMetasoundObjectArrayLiteralCustomization ( DefaultCategoryBuilder ) ) ;
}
} ;
class FMetasoundDefaultMemberElementDetailCustomizationBase : public IPropertyTypeCustomization
2021-03-19 15:10:57 -04:00
{
public :
//~ Begin IPropertyTypeCustomization
virtual void CustomizeHeader ( TSharedRef < IPropertyHandle > StructPropertyHandle , FDetailWidgetRow & HeaderRow , IPropertyTypeCustomizationUtils & StructCustomizationUtils ) override ;
virtual void CustomizeChildren ( TSharedRef < IPropertyHandle > StructPropertyHandle , IDetailChildrenBuilder & ChildBuilder , IPropertyTypeCustomizationUtils & StructCustomizationUtils ) override ;
//~ End IPropertyTypeCustomization
protected :
2021-03-23 17:55:31 -04:00
virtual FText GetPropertyNameOverride ( ) const { return FText : : GetEmpty ( ) ; }
2022-01-04 15:17:54 -05:00
// TODO: Merge with FMetasoundDefaultLiteralCustomizationBaseFactory
2021-03-19 15:10:57 -04:00
virtual TSharedRef < SWidget > CreateStructureWidget ( TSharedPtr < IPropertyHandle > & PropertyHandle ) const = 0 ;
2022-01-04 15:17:54 -05:00
Frontend : : FDataTypeRegistryInfo DataTypeInfo ;
2021-03-19 15:10:57 -04:00
private :
2021-03-23 17:55:31 -04:00
TSharedRef < SWidget > CreateNameWidget ( TSharedPtr < IPropertyHandle > StructPropertyHandle ) const ;
2022-01-04 15:17:54 -05:00
TSharedRef < SWidget > CreateValueWidget ( TSharedPtr < IPropertyHandleArray > ParentArrayProperty , TSharedPtr < IPropertyHandle > StructPropertyHandle ) const ;
2021-03-19 15:10:57 -04:00
} ;
2022-01-04 15:17:54 -05:00
class FMetasoundMemberDefaultBoolDetailCustomization : public FMetasoundDefaultMemberElementDetailCustomizationBase
2021-03-23 17:55:31 -04:00
{
protected :
virtual FText GetPropertyNameOverride ( ) const override ;
virtual TSharedRef < SWidget > CreateStructureWidget ( TSharedPtr < IPropertyHandle > & StructPropertyHandle ) const override ;
} ;
2022-01-04 15:17:54 -05:00
class FMetasoundMemberDefaultIntDetailCustomization : public FMetasoundDefaultMemberElementDetailCustomizationBase
2021-03-19 15:10:57 -04:00
{
protected :
virtual TSharedRef < SWidget > CreateStructureWidget ( TSharedPtr < IPropertyHandle > & StructPropertyHandle ) const override ;
} ;
2022-01-04 15:17:54 -05:00
class FMetasoundMemberDefaultObjectDetailCustomization : public FMetasoundDefaultMemberElementDetailCustomizationBase
2021-03-19 15:10:57 -04:00
{
protected :
virtual TSharedRef < SWidget > CreateStructureWidget ( TSharedPtr < IPropertyHandle > & StructPropertyHandle ) const override ;
} ;
2021-11-07 23:43:01 -05:00
class FMetasoundDataTypeSelector : public TSharedFromThis < FMetasoundDataTypeSelector >
2021-03-19 15:10:57 -04:00
{
public :
2021-11-22 15:55:50 -05:00
void AddDataTypeSelector ( IDetailLayoutBuilder & InDetailLayoutBuilder , const FText & InRowName , TWeakObjectPtr < UMetasoundEditorGraphMember > InGraphMember , bool bInIsInterfaceMember ) ;
2021-10-25 20:05:28 -04:00
void OnDataTypeArrayChanged ( TWeakObjectPtr < UMetasoundEditorGraphMember > InGraphMember , ECheckBoxState InNewState ) ;
2021-03-19 15:10:57 -04:00
protected :
2021-11-07 23:43:01 -05:00
ECheckBoxState OnGetDataTypeArrayCheckState ( TWeakObjectPtr < UMetasoundEditorGraphMember > InGraphMember ) const ;
void OnDataTypeSelected ( FName InSelectedTypeName ) ;
FName GetDataType ( ) const ;
2021-03-19 15:10:57 -04:00
TFunction < void ( ) > OnDataTypeChanged ;
private :
2021-11-07 23:43:01 -05:00
TWeakObjectPtr < UMetasoundEditorGraphMember > GraphMember ;
TSharedPtr < SCheckBox > DataTypeArrayCheckbox ;
TSharedPtr < SSearchableComboBox > DataTypeComboBox ;
TArray < TSharedPtr < FString > > ComboOptions ;
2021-03-19 15:10:57 -04:00
2021-12-13 18:15:01 -05:00
FName BaseTypeName ;
FName ArrayTypeName ;
2021-03-19 15:10:57 -04:00
} ;
2021-12-13 18:15:01 -05:00
template < typename TMemberType , typename TChildClass >
2021-11-07 23:43:01 -05:00
class TMetasoundGraphMemberDetailCustomization : public IDetailCustomization
2021-03-19 15:10:57 -04:00
{
public :
2021-12-13 18:15:01 -05:00
TMetasoundGraphMemberDetailCustomization ( )
2021-03-19 15:10:57 -04:00
: IDetailCustomization ( )
{
2021-11-07 23:43:01 -05:00
DataTypeSelector = MakeShared < FMetasoundDataTypeSelector > ( ) ;
2021-03-19 15:10:57 -04:00
}
2021-12-16 19:29:43 -05:00
virtual ~ TMetasoundGraphMemberDetailCustomization ( )
{
RenameRequestedHandle . Reset ( ) ;
}
2021-03-19 15:10:57 -04:00
2021-12-13 18:15:01 -05:00
protected :
TWeakObjectPtr < TMemberType > GraphMember ;
2021-09-13 14:14:37 -04:00
TSharedPtr < SEditableTextBox > NameEditableTextBox ;
2021-03-19 15:10:57 -04:00
TSharedPtr < SEditableTextBox > DisplayNameEditableTextBox ;
2021-11-07 23:43:01 -05:00
TSharedPtr < FMetasoundDataTypeSelector > DataTypeSelector ;
2021-03-19 15:10:57 -04:00
bool bIsNameInvalid = false ;
2021-12-13 18:15:01 -05:00
static const FText & GetMemberDisplayNameText ( )
2021-03-19 15:10:57 -04:00
{
2021-12-13 18:15:01 -05:00
static const FText MemberDisplayNameTextFormat = LOCTEXT ( " GraphMember_NameFormat " , " {0} Display Name " ) ;
static const FText DisplayName = FText : : Format ( MemberDisplayNameTextFormat , TChildClass : : MemberNameText ) ;
return DisplayName ;
}
static const FText & GetMemberDisplayNameDescriptionText ( )
{
static const FText MemberDisplayNameDescriptionFormat = LOCTEXT ( " GraphMember_DisplayNameDescriptionFormat " , " Optional, localized name used within the MetaSounds editor(s) to describe the given {0}. " ) ;
static const FText DisplayName = FText : : Format ( MemberDisplayNameDescriptionFormat , TChildClass : : MemberNameText ) ;
return DisplayName ;
}
static const FText & GetMemberNameText ( )
{
static const FText MemberNameTextFormat = LOCTEXT ( " GraphMember_DisplayNameFormat " , " {0} Name " ) ;
static const FText Name = FText : : Format ( MemberNameTextFormat , TChildClass : : MemberNameText ) ;
return Name ;
}
static const FText & GetMemberNameDescriptionText ( )
{
static const FText MemberNameDescriptionFormat = LOCTEXT ( " GraphMember_DisplayDescriptionFormat " , " Name used by external systems/referencing MetaSounds to identify {0}. Used as DisplayName within MetaSound Graph Editor if no DisplayName is provided. " ) ;
static const FText Name = FText : : Format ( MemberNameDescriptionFormat , TChildClass : : MemberNameText ) ;
return Name ;
}
2022-01-04 15:17:54 -05:00
void UpdateRenameDelegate ( UMetasoundEditorGraphMemberDefaultLiteral & InMemberDefaultLiteral )
{
if ( UMetasoundEditorGraphMember * Member = InMemberDefaultLiteral . GetParentMember ( ) )
{
2022-01-25 13:25:11 -05:00
if ( Member - > CanRename ( ) )
2022-01-04 15:17:54 -05:00
{
2022-01-25 13:25:11 -05:00
if ( ! RenameRequestedHandle . IsValid ( ) )
2022-01-04 15:17:54 -05:00
{
2022-01-25 13:25:11 -05:00
Member - > OnRenameRequested . Clear ( ) ;
RenameRequestedHandle = Member - > OnRenameRequested . AddLambda ( [ this ] ( )
2022-01-04 15:17:54 -05:00
{
2022-01-25 13:25:11 -05:00
FSlateApplication : : Get ( ) . SetKeyboardFocus ( NameEditableTextBox . ToSharedRef ( ) , EFocusCause : : SetDirectly ) ;
} ) ;
2022-01-04 15:17:54 -05:00
}
}
}
}
2021-12-13 18:15:01 -05:00
virtual bool IsInterfaceMember ( ) const
{
return false ;
}
// IDetailCustomization interface
virtual void CustomizeDetails ( IDetailLayoutBuilder & InDetailLayout ) override
{
using namespace Frontend ;
2021-03-19 15:10:57 -04:00
TArray < TWeakObjectPtr < UObject > > Objects ;
2021-12-13 18:15:01 -05:00
InDetailLayout . GetObjectsBeingCustomized ( Objects ) ;
2021-03-19 15:10:57 -04:00
if ( Objects . IsEmpty ( ) )
{
return ;
}
2021-12-13 18:15:01 -05:00
GraphMember = Cast < TMemberType > ( Objects . Last ( ) . Get ( ) ) ;
if ( ! GraphMember . IsValid ( ) )
{
return ;
}
IDetailCategoryBuilder & CategoryBuilder = InDetailLayout . EditCategory ( " General " ) ;
const bool bIsInterfaceMember = IsInterfaceMember ( ) ;
const bool bIsGraphEditable = IsGraphEditable ( ) ;
NameEditableTextBox = SNew ( SEditableTextBox )
. Text ( this , & TChildClass : : GetName )
. OnTextChanged ( this , & TChildClass : : OnNameChanged )
. OnTextCommitted ( this , & TChildClass : : OnNameCommitted )
. IsReadOnly ( bIsInterfaceMember | | ! bIsGraphEditable )
2021-12-16 19:29:43 -05:00
. SelectAllTextWhenFocused ( true )
2021-12-13 18:15:01 -05:00
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) ) ;
DisplayNameEditableTextBox = SNew ( SEditableTextBox )
. Text ( this , & TChildClass : : GetDisplayName )
. OnTextCommitted ( this , & TChildClass : : OnDisplayNameCommitted )
. IsReadOnly ( bIsInterfaceMember | | ! bIsGraphEditable )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) ) ;
CategoryBuilder . AddCustomRow ( TChildClass : : MemberNameText )
. EditCondition ( ! bIsInterfaceMember & & bIsGraphEditable , nullptr )
. NameContent ( )
[
SNew ( STextBlock )
. Font ( IDetailLayoutBuilder : : GetDetailFontBold ( ) )
. Text ( TChildClass : : MemberNameText )
. ToolTipText ( GetMemberNameDescriptionText ( ) )
]
. ValueContent ( )
[
NameEditableTextBox . ToSharedRef ( )
] ;
// TODO: Enable and use proper FText property editor
// CategoryBuilder.AddCustomRow(GetMemberDisplayNameText())
// .EditCondition(!bIsInterfaceMember && bIsGraphEditable, nullptr)
// .NameContent()
// [
// SNew(STextBlock)
// .Font(IDetailLayoutBuilder::GetDetailFontBold())
// .Text(GetMemberDisplayNameText())
// .ToolTipText(GetMemberDisplayNameDescriptionText())
// ]
// .ValueContent()
// [
// DisplayNameEditableTextBox.ToSharedRef()
// ];
CategoryBuilder . AddCustomRow ( MemberCustomizationStyle : : NodeTooltipText )
. EditCondition ( ! bIsInterfaceMember & & bIsGraphEditable , nullptr )
. NameContent ( )
[
SNew ( STextBlock )
. Font ( IDetailLayoutBuilder : : GetDetailFontBold ( ) )
. Text ( MemberCustomizationStyle : : NodeTooltipText )
]
. ValueContent ( )
[
SNew ( SMultiLineEditableTextBox )
. Text ( this , & TChildClass : : GetTooltip )
. OnTextCommitted ( this , & TChildClass : : OnTooltipCommitted )
. IsReadOnly ( bIsInterfaceMember | | ! bIsGraphEditable )
. ModiferKeyForNewLine ( EModifierKey : : Shift )
. RevertTextOnEscape ( true )
. WrapTextAt ( MemberCustomizationStyle : : DetailsTitleMaxWidth - MemberCustomizationStyle : : DetailsTitleWrapPadding )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
] ;
DataTypeSelector - > AddDataTypeSelector ( InDetailLayout , MemberCustomizationStyle : : DataTypeNameText , GraphMember , ! bIsInterfaceMember & & bIsGraphEditable ) ;
IDetailCategoryBuilder & DefaultCategoryBuilder = InDetailLayout . EditCategory ( " DefaultValue " ) ;
TSharedPtr < IPropertyHandle > LiteralHandle = InDetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( TMemberType , Literal ) ) ;
if ( ensure ( GraphMember . IsValid ( ) ) & & ensure ( LiteralHandle . IsValid ( ) ) )
{
2022-01-04 15:17:54 -05:00
// Always hide, even if no customization (LiteralObject isn't found) as this is the case
// where the default object is not required (i.e. Default Member is default constructed)
LiteralHandle - > MarkHiddenByCustomization ( ) ;
2021-12-13 18:15:01 -05:00
UObject * LiteralObject = nullptr ;
if ( LiteralHandle - > GetValue ( LiteralObject ) = = FPropertyAccess : : Success )
{
2022-01-04 15:17:54 -05:00
if ( UMetasoundEditorGraphMemberDefaultLiteral * MemberDefaultLiteral = Cast < UMetasoundEditorGraphMemberDefaultLiteral > ( LiteralObject ) )
2021-12-13 18:15:01 -05:00
{
2022-01-04 15:17:54 -05:00
UpdateRenameDelegate ( * MemberDefaultLiteral ) ;
2021-12-13 18:15:01 -05:00
2022-01-04 23:44:51 -05:00
UClass * MemberClass = MemberDefaultLiteral - > GetClass ( ) ;
check ( MemberClass ) ;
2021-12-13 18:15:01 -05:00
IMetasoundEditorModule & EditorModule = FModuleManager : : GetModuleChecked < IMetasoundEditorModule > ( " MetaSoundEditor " ) ;
2022-01-04 23:44:51 -05:00
LiteralCustomization = EditorModule . CreateMemberDefaultLiteralCustomization ( * MemberClass , DefaultCategoryBuilder ) ;
2021-12-13 18:15:01 -05:00
if ( LiteralCustomization . IsValid ( ) )
{
2022-01-04 15:17:54 -05:00
LiteralCustomization - > CustomizeLiteral ( * MemberDefaultLiteral , InDetailLayout ) ;
2021-12-13 18:15:01 -05:00
}
2022-01-04 23:44:51 -05:00
else
2021-12-13 18:15:01 -05:00
{
2022-01-04 23:44:51 -05:00
IDetailPropertyRow * Row = DefaultCategoryBuilder . AddExternalObjectProperty ( TArray < UObject * > ( { MemberDefaultLiteral } ) , " Default " ) ;
2022-01-04 15:17:54 -05:00
ensureMsgf ( Row , TEXT ( " Class '%s' missing expected 'Default' member. "
" Either add/rename default member or register customization to display default value/opt out appropriately. " ) ,
2022-01-04 23:44:51 -05:00
* MemberClass - > GetName ( ) ) ;
2021-12-13 18:15:01 -05:00
}
}
}
}
2021-03-19 15:10:57 -04:00
}
// End of IDetailCustomization interface
2021-09-13 14:14:37 -04:00
void OnNameChanged ( const FText & InNewName )
2021-05-10 23:17:10 -04:00
{
using namespace Frontend ;
bIsNameInvalid = false ;
DisplayNameEditableTextBox - > SetError ( FText : : GetEmpty ( ) ) ;
2021-10-25 20:05:28 -04:00
if ( ! ensure ( GraphMember . IsValid ( ) ) )
2021-05-10 23:17:10 -04:00
{
return ;
}
FText Error ;
2021-10-25 20:05:28 -04:00
if ( ! GraphMember - > CanRename ( InNewName , Error ) )
2021-05-10 23:17:10 -04:00
{
bIsNameInvalid = true ;
DisplayNameEditableTextBox - > SetError ( Error ) ;
}
}
2021-03-19 15:10:57 -04:00
2021-09-13 14:14:37 -04:00
FText GetName ( ) const
{
2021-10-25 20:05:28 -04:00
if ( GraphMember . IsValid ( ) )
2021-09-13 14:14:37 -04:00
{
2021-10-25 20:05:28 -04:00
return FText : : FromName ( GraphMember - > GetMemberName ( ) ) ;
2021-09-13 14:14:37 -04:00
}
return FText : : GetEmpty ( ) ;
}
2021-07-27 15:36:03 -04:00
bool IsGraphEditable ( ) const
{
2021-10-25 20:05:28 -04:00
if ( GraphMember . IsValid ( ) )
2021-07-27 15:36:03 -04:00
{
2021-10-25 20:05:28 -04:00
if ( const UMetasoundEditorGraph * OwningGraph = GraphMember - > GetOwningGraph ( ) )
{
return OwningGraph - > IsEditable ( ) ;
}
2021-07-27 15:36:03 -04:00
}
return false ;
}
2021-12-13 18:15:01 -05:00
FText GetDisplayName ( ) const
{
using namespace Frontend ;
if ( GraphMember . IsValid ( ) )
{
return GraphMember - > GetDisplayName ( ) ;
}
return FText : : GetEmpty ( ) ;
}
void OnDisplayNameCommitted ( const FText & InNewName , ETextCommit : : Type InTextCommit )
{
using namespace Frontend ;
if ( ! bIsNameInvalid & & GraphMember . IsValid ( ) )
{
constexpr bool bPostTransaction = true ;
GraphMember - > SetDisplayName ( FText : : GetEmpty ( ) , bPostTransaction ) ;
}
DisplayNameEditableTextBox - > SetError ( FText : : GetEmpty ( ) ) ;
bIsNameInvalid = false ;
}
2021-03-19 15:10:57 -04:00
void OnTooltipCommitted ( const FText & InNewText , ETextCommit : : Type InTextCommit )
{
using namespace Frontend ;
2021-10-25 20:05:28 -04:00
if ( GraphMember . IsValid ( ) )
2021-03-19 15:10:57 -04:00
{
2021-11-18 14:37:34 -05:00
constexpr bool bPostTransaction = true ;
GraphMember - > SetDescription ( InNewText , bPostTransaction ) ;
2021-03-19 15:10:57 -04:00
}
}
FText GetTooltip ( ) const
{
2021-10-25 20:05:28 -04:00
if ( GraphMember . IsValid ( ) )
2021-03-19 15:10:57 -04:00
{
2021-10-25 20:05:28 -04:00
return GraphMember - > GetDescription ( ) ;
2021-03-19 15:10:57 -04:00
}
return FText : : GetEmpty ( ) ;
}
2021-09-13 14:14:37 -04:00
void OnNameCommitted ( const FText & InNewName , ETextCommit : : Type InTextCommit )
{
using namespace Frontend ;
2021-10-25 20:05:28 -04:00
if ( ! bIsNameInvalid & & GraphMember . IsValid ( ) )
2021-09-13 14:14:37 -04:00
{
2021-12-13 18:15:01 -05:00
const FText TransactionLabel = FText : : Format ( LOCTEXT ( " RenameGraphMember_Format " , " Set MetaSound {0}'s Name " ) , TChildClass : : MemberNameText ) ;
2021-11-18 14:37:34 -05:00
const FScopedTransaction Transaction ( TransactionLabel ) ;
constexpr bool bPostTransaction = false ;
GraphMember - > SetDisplayName ( FText : : GetEmpty ( ) , bPostTransaction ) ;
GraphMember - > SetMemberName ( * InNewName . ToString ( ) , bPostTransaction ) ;
2021-09-13 14:14:37 -04:00
}
DisplayNameEditableTextBox - > SetError ( FText : : GetEmpty ( ) ) ;
2021-05-10 23:17:10 -04:00
bIsNameInvalid = false ;
2021-03-19 15:10:57 -04:00
}
ECheckBoxState OnGetPrivateCheckboxState ( ) const
{
2021-10-25 20:05:28 -04:00
if ( GraphMember . IsValid ( ) )
2021-03-19 15:10:57 -04:00
{
2021-10-25 20:05:28 -04:00
return GraphMember - > GetNodeHandle ( ) - > GetNodeStyle ( ) . bIsPrivate ? ECheckBoxState : : Checked : ECheckBoxState : : Unchecked ;
2021-03-19 15:10:57 -04:00
}
return ECheckBoxState : : Unchecked ;
}
2021-12-13 18:15:01 -05:00
private :
2022-01-04 15:17:54 -05:00
TUniquePtr < FMetasoundDefaultLiteralCustomizationBase > LiteralCustomization ;
2021-12-16 19:29:43 -05:00
FDelegateHandle RenameRequestedHandle ;
2021-03-19 15:10:57 -04:00
} ;
2021-12-13 18:15:01 -05:00
class FMetasoundInputDetailCustomization : public TMetasoundGraphMemberDetailCustomization < UMetasoundEditorGraphInput , FMetasoundInputDetailCustomization >
2021-03-19 15:10:57 -04:00
{
public :
FMetasoundInputDetailCustomization ( )
2021-12-13 18:15:01 -05:00
: TMetasoundGraphMemberDetailCustomization < UMetasoundEditorGraphInput , FMetasoundInputDetailCustomization > ( )
2021-03-19 15:10:57 -04:00
{
}
2021-12-13 18:15:01 -05:00
2021-10-12 21:21:22 -04:00
virtual ~ FMetasoundInputDetailCustomization ( ) = default ;
2021-03-19 15:10:57 -04:00
2021-12-13 18:15:01 -05:00
virtual bool IsInterfaceMember ( ) const override ;
static const FText MemberNameText ;
2021-03-19 15:10:57 -04:00
private :
2022-01-04 15:17:54 -05:00
TUniquePtr < FMetasoundDefaultLiteralCustomizationBase > LiteralCustomization ;
2021-03-19 15:10:57 -04:00
} ;
2021-12-13 18:15:01 -05:00
class FMetasoundOutputDetailCustomization : public TMetasoundGraphMemberDetailCustomization < UMetasoundEditorGraphOutput , FMetasoundOutputDetailCustomization >
2021-03-19 15:10:57 -04:00
{
public :
2021-12-13 18:15:01 -05:00
static const FText MemberNameText ;
2021-03-19 15:10:57 -04:00
FMetasoundOutputDetailCustomization ( )
2021-12-13 18:15:01 -05:00
: TMetasoundGraphMemberDetailCustomization < UMetasoundEditorGraphOutput , FMetasoundOutputDetailCustomization > ( )
2021-03-19 15:10:57 -04:00
{
}
2021-12-13 18:15:01 -05:00
virtual ~ FMetasoundOutputDetailCustomization ( ) = default ;
virtual bool IsInterfaceMember ( ) const override ;
2021-03-19 15:10:57 -04:00
private :
2022-01-04 15:17:54 -05:00
TUniquePtr < FMetasoundDefaultLiteralCustomizationBase > LiteralCustomization ;
2021-03-19 15:10:57 -04:00
} ;
} // namespace Editor
} // namespace Metasound
# undef LOCTEXT_NAMESPACE