2021-01-20 00:42:47 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
#include "SMetasoundGraphNode.h"
|
|
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
#include "AudioParameterControllerInterface.h"
|
2021-04-07 02:59:10 -04:00
|
|
|
#include "Components/AudioComponent.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "GraphEditorSettings.h"
|
2021-12-13 18:15:01 -05:00
|
|
|
#include "IAudioParameterTransmitter.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "IDocumentation.h"
|
2023-03-13 17:23:05 -04:00
|
|
|
#include "Interfaces/MetasoundFrontendInterfaceRegistry.h"
|
2021-01-27 00:58:56 -04:00
|
|
|
#include "KismetPins/SGraphPinBool.h"
|
|
|
|
|
#include "KismetPins/SGraphPinExec.h"
|
|
|
|
|
#include "KismetPins/SGraphPinInteger.h"
|
2021-04-01 22:37:16 -04:00
|
|
|
#include "KismetPins/SGraphPinNum.h"
|
2021-01-27 00:58:56 -04:00
|
|
|
#include "KismetPins/SGraphPinObject.h"
|
|
|
|
|
#include "KismetPins/SGraphPinString.h"
|
2021-04-07 02:59:10 -04:00
|
|
|
#include "MetasoundEditorGraph.h"
|
2021-01-27 00:58:56 -04:00
|
|
|
#include "MetasoundEditorGraphBuilder.h"
|
2021-12-13 18:15:01 -05:00
|
|
|
#include "MetasoundEditorGraphInputNode.h"
|
|
|
|
|
#include "MetasoundEditorGraphMemberDefaults.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "MetasoundEditorGraphNode.h"
|
2021-01-27 00:58:56 -04:00
|
|
|
#include "MetasoundEditorGraphSchema.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "MetasoundEditorModule.h"
|
2022-08-12 14:22:05 -04:00
|
|
|
#include "MetasoundFrontendNodeTemplateRegistry.h"
|
2021-04-01 22:37:16 -04:00
|
|
|
#include "MetasoundFrontendRegistries.h"
|
2022-10-22 14:43:51 -04:00
|
|
|
#include "MetasoundTrace.h"
|
2021-04-07 02:59:10 -04:00
|
|
|
#include "MetasoundTrigger.h"
|
2021-01-27 00:58:56 -04:00
|
|
|
#include "NodeFactory.h"
|
2022-08-12 14:22:05 -04:00
|
|
|
#include "NodeTemplates/MetasoundFrontendNodeTemplateReroute.h"
|
2021-04-01 22:37:16 -04:00
|
|
|
#include "PropertyCustomizationHelpers.h"
|
2021-11-07 23:43:01 -05:00
|
|
|
#include "SAudioRadialSlider.h"
|
|
|
|
|
#include "SAudioSlider.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "SCommentBubble.h"
|
2021-11-07 23:43:01 -05:00
|
|
|
#include "ScopedTransaction.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "SGraphNode.h"
|
2021-11-07 23:43:01 -05:00
|
|
|
#include "SGraphPinComboBox.h"
|
2023-03-13 17:23:05 -04:00
|
|
|
#include "Styling/AppStyle.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "SLevelOfDetailBranchNode.h"
|
2021-11-18 14:37:34 -05:00
|
|
|
#include "SMetasoundGraphEnumPin.h"
|
|
|
|
|
#include "SMetasoundGraphPin.h"
|
2022-10-18 13:07:17 -04:00
|
|
|
#include "SMetasoundPinValueInspector.h"
|
2022-08-12 14:22:05 -04:00
|
|
|
#include "SPinTypeSelector.h"
|
2021-04-07 02:59:10 -04:00
|
|
|
#include "Styling/AppStyle.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "Styling/SlateColor.h"
|
2021-11-07 23:43:01 -05:00
|
|
|
#include "Styling/SlateStyleRegistry.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "TutorialMetaData.h"
|
2021-11-07 23:43:01 -05:00
|
|
|
#include "UObject/ScriptInterface.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "Widgets/Images/SImage.h"
|
2021-04-07 02:59:10 -04:00
|
|
|
#include "Widgets/Input/SButton.h"
|
2021-04-01 22:37:16 -04:00
|
|
|
#include "Widgets/Layout/SBox.h"
|
|
|
|
|
#include "Widgets/Layout/SSpacer.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "Widgets/SBoxPanel.h"
|
|
|
|
|
#include "Widgets/SOverlay.h"
|
2021-04-01 22:37:16 -04:00
|
|
|
#include "Widgets/SWidget.h"
|
2021-07-27 15:36:03 -04:00
|
|
|
#include "Widgets/Text/SInlineEditableTextBlock.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
|
2022-10-18 13:07:17 -04:00
|
|
|
#define LOCTEXT_NAMESPACE "MetasoundEditor"
|
2021-01-20 00:42:47 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
|
|
|
|
|
namespace Metasound
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
namespace Editor
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
SMetaSoundGraphNode::~SMetaSoundGraphNode()
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2023-07-28 16:04:46 -04:00
|
|
|
// Clean up input widgets
|
2021-12-13 18:15:01 -05:00
|
|
|
UMetasoundEditorGraphNode& Node = GetMetaSoundNode();
|
|
|
|
|
if (UMetasoundEditorGraphMemberNode* MemberNode = Cast<UMetasoundEditorGraphMemberNode>(&Node))
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
if (UMetasoundEditorGraphMember* GraphMember = MemberNode->GetMember())
|
|
|
|
|
{
|
|
|
|
|
if (UMetasoundEditorGraphMemberDefaultFloat* DefaultFloat = Cast<UMetasoundEditorGraphMemberDefaultFloat>(GraphMember->GetLiteral()))
|
|
|
|
|
{
|
2023-07-28 16:04:46 -04:00
|
|
|
// This may hit if the asset editor is closed while interacting with a widget
|
|
|
|
|
// (ex. Ctrl-W is pressed mid drag before the value is committed)
|
|
|
|
|
if (bIsInputWidgetTransacting)
|
|
|
|
|
{
|
|
|
|
|
GEditor->EndTransaction();
|
|
|
|
|
if (UMetasoundEditorGraph* Graph = GraphMember->GetOwningGraph())
|
|
|
|
|
{
|
|
|
|
|
constexpr bool bPostTransaction = false;
|
|
|
|
|
GraphMember->UpdateFrontendDefaultLiteral(bPostTransaction);
|
|
|
|
|
Graph->GetModifyContext().AddMemberIDsModified({ GraphMember->GetMemberID() });
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-13 18:15:01 -05:00
|
|
|
DefaultFloat->OnDefaultValueChanged.Remove(InputSliderOnValueChangedDelegateHandle);
|
|
|
|
|
DefaultFloat->OnRangeChanged.Remove(InputSliderOnRangeChangedDelegateHandle);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-12 21:21:22 -04:00
|
|
|
}
|
|
|
|
|
}
|
2021-04-01 22:37:16 -04:00
|
|
|
|
2022-02-24 23:29:50 -05:00
|
|
|
bool SMetaSoundGraphNode::IsVariableAccessor() const
|
|
|
|
|
{
|
|
|
|
|
return ClassType == EMetasoundFrontendClassType::VariableAccessor
|
|
|
|
|
|| ClassType == EMetasoundFrontendClassType::VariableDeferredAccessor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SMetaSoundGraphNode::IsVariableMutator() const
|
|
|
|
|
{
|
|
|
|
|
return ClassType == EMetasoundFrontendClassType::VariableMutator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FSlateBrush* SMetaSoundGraphNode::GetShadowBrush(bool bSelected) const
|
|
|
|
|
{
|
|
|
|
|
if (IsVariableAccessor() || IsVariableMutator())
|
|
|
|
|
{
|
2022-05-09 13:51:26 -04:00
|
|
|
return bSelected ? FAppStyle::GetBrush(TEXT("Graph.VarNode.ShadowSelected")) : FAppStyle::GetBrush(TEXT("Graph.VarNode.Shadow"));
|
2022-02-24 23:29:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SGraphNode::GetShadowBrush(bSelected);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
void SMetaSoundGraphNode::Construct(const FArguments& InArgs, class UEdGraphNode* InNode)
|
2021-04-07 02:59:10 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
GraphNode = InNode;
|
2022-10-22 14:43:51 -04:00
|
|
|
Frontend::FConstNodeHandle NodeHandle = GetMetaSoundNode().GetConstNodeHandle();
|
|
|
|
|
ClassType = NodeHandle->GetClassMetadata().GetType();
|
|
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
SetCursor(EMouseCursor::CardinalCross);
|
|
|
|
|
UpdateGraphNode();
|
2021-04-07 02:59:10 -04:00
|
|
|
}
|
|
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
void SMetaSoundGraphNode::ExecuteTrigger(UMetasoundEditorGraphMemberDefaultLiteral& Literal)
|
2021-04-07 02:59:10 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
UMetasoundEditorGraphMember* Member = Cast<UMetasoundEditorGraphMember>(Literal.GetOuter());
|
|
|
|
|
if (!ensure(Member))
|
2021-04-07 02:59:10 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
return;
|
2021-04-07 02:59:10 -04:00
|
|
|
}
|
|
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
if (UMetasoundEditorGraph* Graph = Member->GetOwningGraph())
|
2021-02-11 15:07:57 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
if (!Graph->IsPreviewing())
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<FEditor> MetaSoundEditor = FGraphBuilder::GetEditorForMetasound(Graph->GetMetasoundChecked());
|
|
|
|
|
if (!MetaSoundEditor.IsValid())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MetaSoundEditor->Play();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (UAudioComponent* PreviewComponent = GEditor->GetPreviewAudioComponent())
|
|
|
|
|
{
|
|
|
|
|
PreviewComponent->SetTriggerParameter(Member->GetMemberName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TAttribute<EVisibility> SMetaSoundGraphNode::GetSimulationVisibilityAttribute() const
|
|
|
|
|
{
|
|
|
|
|
return TAttribute<EVisibility>::CreateLambda([this]()
|
|
|
|
|
{
|
|
|
|
|
using namespace Frontend;
|
|
|
|
|
|
|
|
|
|
if (const UMetasoundEditorGraphMemberNode* Node = Cast<UMetasoundEditorGraphMemberNode>(&GetMetaSoundNode()))
|
|
|
|
|
{
|
|
|
|
|
if (const UMetasoundEditorGraphVertex* Vertex = Cast<UMetasoundEditorGraphVertex>(Node->GetMember()))
|
|
|
|
|
{
|
|
|
|
|
if (const UMetasoundEditorGraph* Graph = Vertex->GetOwningGraph())
|
|
|
|
|
{
|
|
|
|
|
if (!Graph->IsPreviewing())
|
|
|
|
|
{
|
|
|
|
|
return EVisibility::Hidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Don't enable trigger simulation widget if its a trigger provided by an interface
|
|
|
|
|
// that does not support transmission.
|
|
|
|
|
const FInterfaceRegistryKey Key = GetInterfaceRegistryKey(Vertex->GetInterfaceVersion());
|
|
|
|
|
const IInterfaceRegistryEntry* Entry = IInterfaceRegistry::Get().FindInterfaceRegistryEntry(Key);
|
|
|
|
|
if (Entry && Entry->GetRouterName() != Audio::IParameterTransmitter::RouterName)
|
|
|
|
|
{
|
|
|
|
|
return EVisibility::Hidden;
|
|
|
|
|
}
|
|
|
|
|
else if (const UMetasoundEditorGraphMemberDefaultLiteral* Literal = Vertex->GetLiteral())
|
|
|
|
|
{
|
|
|
|
|
if (!Literal)
|
|
|
|
|
{
|
|
|
|
|
return EVisibility::Hidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EVisibility::Visible;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> SMetaSoundGraphNode::CreateTriggerSimulationWidget(UMetasoundEditorGraphMemberDefaultLiteral& InputLiteral, TAttribute<EVisibility>&& InVisibility, TAttribute<bool>&& InEnablement, const FText* InToolTip)
|
|
|
|
|
{
|
|
|
|
|
const FText ToolTip = InToolTip
|
|
|
|
|
? *InToolTip
|
2022-10-18 13:07:17 -04:00
|
|
|
: LOCTEXT("MetasoundGraphNode_TriggerTestToolTip", "Executes trigger if currently previewing MetaSound.");
|
2021-12-13 18:15:01 -05:00
|
|
|
|
|
|
|
|
TSharedPtr<SButton> SimulationButton;
|
|
|
|
|
TSharedRef<SWidget> SimulationWidget = SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.Padding(2.0f, 0.0f, 0.0f, 0.0f)
|
|
|
|
|
.HAlign(HAlign_Left)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SAssignNew(SimulationButton, SButton)
|
|
|
|
|
.ButtonStyle(FAppStyle::Get(), "SimpleButton")
|
|
|
|
|
.OnClicked_Lambda([LiteralPtr = TWeakObjectPtr<UMetasoundEditorGraphMemberDefaultLiteral>(&InputLiteral)]()
|
|
|
|
|
{
|
|
|
|
|
if (LiteralPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
ExecuteTrigger(*LiteralPtr.Get());
|
|
|
|
|
}
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
})
|
|
|
|
|
.ToolTipText(ToolTip)
|
|
|
|
|
.ForegroundColor(FSlateColor::UseForeground())
|
|
|
|
|
.ContentPadding(0)
|
|
|
|
|
.IsFocusable(false)
|
|
|
|
|
[
|
|
|
|
|
SNew(SImage)
|
|
|
|
|
.Image(FAppStyle::Get().GetBrush("Icons.CircleArrowDown"))
|
|
|
|
|
.ColorAndOpacity(FSlateColor::UseForeground())
|
|
|
|
|
]
|
|
|
|
|
.Visibility(MoveTemp(InVisibility))
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
SimulationButton->SetEnabled(MoveTemp(InEnablement));
|
|
|
|
|
|
|
|
|
|
return SimulationWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SMetaSoundGraphNode::CreateInputSideAddButton(TSharedPtr<SVerticalBox> InputBox)
|
|
|
|
|
{
|
|
|
|
|
TSharedRef<SWidget> AddPinButton = AddPinButtonContent(
|
|
|
|
|
LOCTEXT("MetasoundGraphNode_AddPinInputButton", "Add Input"),
|
|
|
|
|
LOCTEXT("MetasoundGraphNode_AddPinInputButton_Tooltip", "Add an input to the parent Metasound node.")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
FMargin AddPinPadding = Settings->GetOutputPinPadding();
|
|
|
|
|
AddPinPadding.Top += 6.0f;
|
|
|
|
|
|
|
|
|
|
InputBox->AddSlot()
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.Padding(AddPinPadding)
|
|
|
|
|
[
|
|
|
|
|
AddPinButton
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SMetaSoundGraphNode::CreateOutputSideAddButton(TSharedPtr<SVerticalBox> OutputBox)
|
|
|
|
|
{
|
|
|
|
|
TSharedRef<SWidget> AddPinButton = AddPinButtonContent(
|
|
|
|
|
LOCTEXT("MetasoundGraphNode_AddPinOutputButton", "Add Output"),
|
|
|
|
|
LOCTEXT("MetasoundGraphNode_AddPinOutputButton_Tooltip", "Add an output to the parent Metasound node.")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
FMargin AddPinPadding = Settings->GetOutputPinPadding();
|
|
|
|
|
AddPinPadding.Top += 6.0f;
|
|
|
|
|
|
|
|
|
|
OutputBox->AddSlot()
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.Padding(AddPinPadding)
|
|
|
|
|
[
|
|
|
|
|
AddPinButton
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UMetasoundEditorGraphNode& SMetaSoundGraphNode::GetMetaSoundNode()
|
|
|
|
|
{
|
|
|
|
|
return *CastChecked<UMetasoundEditorGraphNode>(GraphNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const UMetasoundEditorGraphNode& SMetaSoundGraphNode::GetMetaSoundNode() const
|
|
|
|
|
{
|
|
|
|
|
check(GraphNode);
|
|
|
|
|
return *Cast<UMetasoundEditorGraphNode>(GraphNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedPtr<SGraphPin> SMetaSoundGraphNode::CreatePinWidget(UEdGraphPin* InPin) const
|
|
|
|
|
{
|
|
|
|
|
using namespace Frontend;
|
|
|
|
|
|
|
|
|
|
TSharedPtr<SGraphPin> PinWidget;
|
|
|
|
|
|
|
|
|
|
if (const UMetasoundEditorGraphSchema* GraphSchema = Cast<const UMetasoundEditorGraphSchema>(InPin->GetSchema()))
|
|
|
|
|
{
|
|
|
|
|
// Don't show default value field for container types
|
|
|
|
|
if (InPin->PinType.ContainerType != EPinContainerType::None)
|
|
|
|
|
{
|
2022-01-27 01:31:46 -05:00
|
|
|
PinWidget = SNew(SMetasoundGraphPin, InPin);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (InPin->PinType.PinCategory == FGraphBuilder::PinCategoryAudio)
|
|
|
|
|
{
|
2022-01-27 01:31:46 -05:00
|
|
|
PinWidget = SNew(SMetasoundGraphPin, InPin);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (InPin->PinType.PinCategory == FGraphBuilder::PinCategoryBoolean)
|
|
|
|
|
{
|
2022-01-27 01:31:46 -05:00
|
|
|
PinWidget = SNew(SMetasoundGraphPinBool, InPin);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
2022-09-09 00:52:58 -04:00
|
|
|
|
|
|
|
|
else if (InPin->PinType.PinCategory == FGraphBuilder::PinCategoryFloat
|
|
|
|
|
|| InPin->PinType.PinCategory == FGraphBuilder::PinCategoryTime)
|
2021-12-13 18:15:01 -05:00
|
|
|
{
|
2022-01-27 01:31:46 -05:00
|
|
|
PinWidget = SNew(SMetasoundGraphPinFloat, InPin);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (InPin->PinType.PinCategory == FGraphBuilder::PinCategoryInt32)
|
|
|
|
|
{
|
|
|
|
|
if (SMetasoundGraphEnumPin::FindEnumInterfaceFromPin(InPin))
|
|
|
|
|
{
|
2022-01-27 01:31:46 -05:00
|
|
|
PinWidget = SNew(SMetasoundGraphEnumPin, InPin);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-01-27 01:31:46 -05:00
|
|
|
PinWidget = SNew(SMetasoundGraphPinInteger, InPin);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (InPin->PinType.PinCategory == FGraphBuilder::PinCategoryObject)
|
|
|
|
|
{
|
2022-01-27 01:31:46 -05:00
|
|
|
PinWidget = SNew(SMetasoundGraphPinObject, InPin);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (InPin->PinType.PinCategory == FGraphBuilder::PinCategoryString)
|
|
|
|
|
{
|
2022-01-27 01:31:46 -05:00
|
|
|
PinWidget = SNew(SMetasoundGraphPinString, InPin);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (InPin->PinType.PinCategory == FGraphBuilder::PinCategoryTrigger)
|
|
|
|
|
{
|
2022-01-27 01:31:46 -05:00
|
|
|
PinWidget = SNew(SMetasoundGraphPin, InPin);
|
2021-12-13 18:15:01 -05:00
|
|
|
|
2022-08-16 17:21:16 -04:00
|
|
|
const FSlateBrush& PinConnectedBrush = Editor::Style::GetSlateBrushSafe("MetasoundEditor.Graph.TriggerPin.Connected");
|
|
|
|
|
const FSlateBrush& PinDisconnectedBrush = Editor::Style::GetSlateBrushSafe("MetasoundEditor.Graph.TriggerPin.Disconnected");
|
|
|
|
|
PinWidget->SetCustomPinIcon(&PinConnectedBrush, &PinDisconnectedBrush);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!PinWidget.IsValid())
|
|
|
|
|
{
|
2022-01-27 01:31:46 -05:00
|
|
|
PinWidget = SNew(SMetasoundGraphPin, InPin);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
|
2024-01-10 15:51:22 -05:00
|
|
|
IMetasoundEditorModule& EditorModule = FModuleManager::GetModuleChecked<IMetasoundEditorModule>("MetaSoundEditor");
|
|
|
|
|
const FSlateBrush* PinConnectedIcon = nullptr;
|
|
|
|
|
const FSlateBrush* PinDisconnectedIcon = nullptr;
|
|
|
|
|
if (EditorModule.GetCustomPinIcons(InPin, PinConnectedIcon, PinDisconnectedIcon))
|
|
|
|
|
{
|
|
|
|
|
PinWidget->SetCustomPinIcon(PinConnectedIcon, PinDisconnectedIcon);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
return PinWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SMetaSoundGraphNode::CreateStandardPinWidget(UEdGraphPin* InPin)
|
|
|
|
|
{
|
|
|
|
|
const bool bShowPin = ShouldPinBeHidden(InPin);
|
|
|
|
|
if (bShowPin)
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<SGraphPin> NewPin = CreatePinWidget(InPin);
|
|
|
|
|
check(NewPin.IsValid());
|
|
|
|
|
|
2022-08-16 17:21:16 -04:00
|
|
|
Frontend::FConstNodeHandle NodeHandle = GetMetaSoundNode().GetConstNodeHandle();
|
2021-12-13 18:15:01 -05:00
|
|
|
if (InPin->Direction == EGPD_Input)
|
|
|
|
|
{
|
|
|
|
|
if (!NodeHandle->GetClassStyle().Display.bShowInputNames)
|
|
|
|
|
{
|
|
|
|
|
NewPin->SetShowLabel(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (InPin->Direction == EGPD_Output)
|
|
|
|
|
{
|
|
|
|
|
if (!NodeHandle->GetClassStyle().Display.bShowOutputNames)
|
|
|
|
|
{
|
|
|
|
|
NewPin->SetShowLabel(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AddPin(NewPin.ToSharedRef());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> SMetaSoundGraphNode::CreateTitleWidget(TSharedPtr<SNodeTitle> NodeTitle)
|
2021-01-27 00:58:56 -04:00
|
|
|
{
|
2022-08-16 17:21:16 -04:00
|
|
|
Frontend::FConstNodeHandle NodeHandle = GetMetaSoundNode().GetConstNodeHandle();
|
2021-12-13 18:15:01 -05:00
|
|
|
if (!NodeHandle->GetClassStyle().Display.bShowName)
|
2021-04-20 19:59:50 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
return SNullWidget::NullWidget;
|
2021-04-20 19:59:50 -04:00
|
|
|
}
|
2021-01-27 00:58:56 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
TSharedPtr<SHorizontalBox> TitleBoxWidget = SNew(SHorizontalBox);
|
2021-07-27 15:36:03 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
FSlateIcon NodeIcon = GetMetaSoundNode().GetNodeTitleIcon();
|
|
|
|
|
if (const FSlateBrush* IconBrush = NodeIcon.GetIcon())
|
2021-01-20 00:42:47 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
if (IconBrush != FStyleDefaults::GetNoBrush())
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<SImage> Image;
|
|
|
|
|
TitleBoxWidget->AddSlot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.HAlign(HAlign_Right)
|
|
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.Padding(0.0f, 0.0f, 4.0f, 0.0f)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.HAlign(HAlign_Right)
|
|
|
|
|
[
|
|
|
|
|
SAssignNew(Image, SImage)
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
Image->SetColorAndOpacity(TAttribute<FSlateColor>::CreateLambda([this]() { return FSlateColor(GetNodeTitleColorOverride()); }));
|
|
|
|
|
Image->SetImage(IconBrush);
|
|
|
|
|
}
|
2021-01-20 00:42:47 -04:00
|
|
|
}
|
|
|
|
|
|
2021-07-27 15:36:03 -04:00
|
|
|
TitleBoxWidget->AddSlot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
2021-12-13 18:15:01 -05:00
|
|
|
SGraphNode::CreateTitleWidget(NodeTitle)
|
2021-07-27 15:36:03 -04:00
|
|
|
];
|
2021-12-13 18:15:01 -05:00
|
|
|
|
|
|
|
|
InlineEditableText->SetColorAndOpacity(TAttribute<FLinearColor>::Create(TAttribute<FLinearColor>::FGetter::CreateSP(this, &SMetaSoundGraphNode::GetNodeTitleColorOverride)));
|
|
|
|
|
|
|
|
|
|
return TitleBoxWidget.ToSharedRef();
|
2021-07-27 15:36:03 -04:00
|
|
|
}
|
|
|
|
|
|
2022-02-24 23:29:50 -05:00
|
|
|
void SMetaSoundGraphNode::GetOverlayBrushes(bool bSelected, const FVector2D WidgetSize, TArray<FOverlayBrushInfo>& Brushes) const
|
|
|
|
|
{
|
|
|
|
|
FName CornerIcon = GetMetaSoundNode().GetCornerIcon();
|
|
|
|
|
if (CornerIcon != NAME_None)
|
|
|
|
|
{
|
|
|
|
|
|
2022-05-09 13:51:26 -04:00
|
|
|
if (const FSlateBrush* Brush = FAppStyle::GetBrush(CornerIcon))
|
2022-02-24 23:29:50 -05:00
|
|
|
{
|
|
|
|
|
FOverlayBrushInfo OverlayInfo = { Brush };
|
|
|
|
|
|
|
|
|
|
// Logic copied from SGraphNodeK2Base
|
|
|
|
|
OverlayInfo.OverlayOffset.X = (WidgetSize.X - (OverlayInfo.Brush->ImageSize.X / 2.f)) - 3.f;
|
|
|
|
|
OverlayInfo.OverlayOffset.Y = (OverlayInfo.Brush->ImageSize.Y / -2.f) + 2.f;
|
|
|
|
|
Brushes.Add(MoveTemp(OverlayInfo));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
FLinearColor SMetaSoundGraphNode::GetNodeTitleColorOverride() const
|
|
|
|
|
{
|
|
|
|
|
FLinearColor ReturnTitleColor = GraphNode->IsDeprecated() ? FLinearColor::Red : GetNodeObj()->GetNodeTitleColor();
|
2021-07-27 15:36:03 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
if (!GraphNode->IsNodeEnabled() || GraphNode->IsDisplayAsDisabledForced() || GraphNode->IsNodeUnrelated())
|
|
|
|
|
{
|
|
|
|
|
ReturnTitleColor *= FLinearColor(0.5f, 0.5f, 0.5f, 0.4f);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReturnTitleColor.A = FadeCurve.GetLerp();
|
|
|
|
|
}
|
2021-07-27 15:36:03 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
return ReturnTitleColor;
|
|
|
|
|
}
|
2021-07-27 15:36:03 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
void SMetaSoundGraphNode::SetDefaultTitleAreaWidget(TSharedRef<SOverlay> DefaultTitleAreaWidget)
|
|
|
|
|
{
|
|
|
|
|
SGraphNode::SetDefaultTitleAreaWidget(DefaultTitleAreaWidget);
|
2021-07-27 15:36:03 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
Metasound::Frontend::FNodeHandle NodeHandle = GetMetaSoundNode().GetNodeHandle();
|
|
|
|
|
if (NodeHandle->GetClassStyle().Display.bShowName)
|
|
|
|
|
{
|
|
|
|
|
DefaultTitleAreaWidget->ClearChildren();
|
|
|
|
|
TSharedPtr<SNodeTitle> NodeTitle = SNew(SNodeTitle, GraphNode);
|
2021-07-27 15:36:03 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
DefaultTitleAreaWidget->AddSlot()
|
|
|
|
|
.HAlign(HAlign_Fill)
|
|
|
|
|
.VAlign(VAlign_Center)
|
2021-01-20 00:42:47 -04:00
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
2021-12-13 18:15:01 -05:00
|
|
|
.HAlign(HAlign_Fill)
|
2021-01-20 00:42:47 -04:00
|
|
|
[
|
2021-12-13 18:15:01 -05:00
|
|
|
SNew(SBorder)
|
2022-05-09 13:12:28 -04:00
|
|
|
.BorderImage(FAppStyle::GetBrush("NoBorder"))
|
2021-01-20 00:42:47 -04:00
|
|
|
[
|
2021-12-13 18:15:01 -05:00
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
[
|
|
|
|
|
SNew(SVerticalBox)
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
.HAlign(HAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
CreateTitleWidget(NodeTitle)
|
|
|
|
|
]
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
[
|
|
|
|
|
NodeTitle.ToSharedRef()
|
|
|
|
|
]
|
|
|
|
|
]
|
2021-01-20 00:42:47 -04:00
|
|
|
]
|
|
|
|
|
]
|
2021-12-13 18:15:01 -05:00
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.HAlign(HAlign_Right)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.Padding(0, 0, 5, 0)
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
CreateTitleRightWidget()
|
|
|
|
|
]
|
|
|
|
|
];
|
2021-01-20 00:42:47 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
DefaultTitleAreaWidget->AddSlot()
|
|
|
|
|
.VAlign(VAlign_Top)
|
|
|
|
|
[
|
|
|
|
|
SNew(SBorder)
|
|
|
|
|
.Visibility(EVisibility::HitTestInvisible)
|
2022-05-09 13:12:28 -04:00
|
|
|
.BorderImage( FAppStyle::GetBrush( "Graph.Node.TitleHighlight" ) )
|
2021-12-13 18:15:01 -05:00
|
|
|
.BorderBackgroundColor( this, &SGraphNode::GetNodeTitleIconColor )
|
|
|
|
|
[
|
|
|
|
|
SNew(SSpacer)
|
|
|
|
|
.Size(FVector2D(20,20))
|
|
|
|
|
]
|
|
|
|
|
];
|
2021-07-27 15:36:03 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
else
|
2021-04-07 02:59:10 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
DefaultTitleAreaWidget->SetVisibility(EVisibility::Collapsed);
|
2021-04-07 02:59:10 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
void SMetaSoundGraphNode::MoveTo(const FVector2D& NewPosition, FNodeSet& NodeFilter, bool bMarkDirty)
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
SGraphNode::MoveTo(NewPosition, NodeFilter, bMarkDirty);
|
2021-11-07 23:43:01 -05:00
|
|
|
|
2022-03-02 22:11:18 -05:00
|
|
|
UMetasoundEditorGraphNode& Node = GetMetaSoundNode();
|
|
|
|
|
Node.GetMetasoundChecked().Modify();
|
|
|
|
|
Node.SetNodeLocation(NewPosition);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FSlateBrush* SMetaSoundGraphNode::GetNodeBodyBrush() const
|
|
|
|
|
{
|
2022-02-24 23:29:50 -05:00
|
|
|
// TODO: Add tweak & add custom bodies
|
|
|
|
|
if (GraphNode)
|
|
|
|
|
{
|
|
|
|
|
switch (ClassType)
|
|
|
|
|
{
|
|
|
|
|
case EMetasoundFrontendClassType::Variable:
|
|
|
|
|
case EMetasoundFrontendClassType::VariableAccessor:
|
|
|
|
|
case EMetasoundFrontendClassType::VariableDeferredAccessor:
|
|
|
|
|
case EMetasoundFrontendClassType::VariableMutator:
|
|
|
|
|
{
|
2022-05-09 13:51:26 -04:00
|
|
|
return FAppStyle::GetBrush("Graph.VarNode.Body");
|
2022-02-24 23:29:50 -05:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EMetasoundFrontendClassType::Input:
|
|
|
|
|
case EMetasoundFrontendClassType::Output:
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-13 18:15:01 -05:00
|
|
|
|
2022-05-09 13:12:28 -04:00
|
|
|
return FAppStyle::GetBrush("Graph.Node.Body");
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EVisibility SMetaSoundGraphNode::IsAddPinButtonVisible() const
|
|
|
|
|
{
|
|
|
|
|
EVisibility DefaultVisibility = SGraphNode::IsAddPinButtonVisible();
|
|
|
|
|
if (DefaultVisibility == EVisibility::Visible)
|
|
|
|
|
{
|
|
|
|
|
if (!GetMetaSoundNode().CanAddInputPin())
|
|
|
|
|
{
|
|
|
|
|
return EVisibility::Collapsed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DefaultVisibility;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SMetaSoundGraphNode::OnAddPin()
|
|
|
|
|
{
|
|
|
|
|
GetMetaSoundNode().CreateInputPin();
|
|
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FName SMetaSoundGraphNode::GetLiteralDataType() const
|
|
|
|
|
{
|
|
|
|
|
using namespace Frontend;
|
|
|
|
|
|
|
|
|
|
FName TypeName;
|
|
|
|
|
|
|
|
|
|
// Just take last type. If more than one, all types are the same.
|
|
|
|
|
const UMetasoundEditorGraphNode& Node = GetMetaSoundNode();
|
|
|
|
|
Node.GetNodeHandle()->IterateConstOutputs([InTypeName = &TypeName](FConstOutputHandle OutputHandle)
|
|
|
|
|
{
|
|
|
|
|
*InTypeName = OutputHandle->GetDataType();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return TypeName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> SMetaSoundGraphNode::CreateTitleRightWidget()
|
|
|
|
|
{
|
|
|
|
|
using namespace Frontend;
|
|
|
|
|
|
|
|
|
|
const FName TypeName = GetLiteralDataType();
|
|
|
|
|
if (TypeName == Metasound::GetMetasoundDataTypeName<Metasound::FTrigger>())
|
|
|
|
|
{
|
|
|
|
|
if (UMetasoundEditorGraphMemberNode* Node = Cast<UMetasoundEditorGraphMemberNode>(&GetMetaSoundNode()))
|
|
|
|
|
{
|
2022-02-10 13:42:12 -05:00
|
|
|
if (UMetasoundEditorGraphInput* Input = Cast<UMetasoundEditorGraphInput>(Node->GetMember()))
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2022-02-10 13:42:12 -05:00
|
|
|
if (UMetasoundEditorGraphMemberDefaultLiteral* Literal = Input->GetLiteral())
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
TAttribute<EVisibility> SimVisibility = GetSimulationVisibilityAttribute();
|
|
|
|
|
TAttribute<bool> SimEnablement = true;
|
|
|
|
|
return CreateTriggerSimulationWidget(*Literal, MoveTemp(SimVisibility), MoveTemp(SimEnablement));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SGraphNode::CreateTitleRightWidget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UMetasoundEditorGraphMember* SMetaSoundGraphNode::GetMetaSoundMember()
|
|
|
|
|
{
|
|
|
|
|
if (UMetasoundEditorGraphMemberNode* MemberNode = GetMetaSoundMemberNode())
|
|
|
|
|
{
|
|
|
|
|
return MemberNode->GetMember();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UMetasoundEditorGraphMemberNode* SMetaSoundGraphNode::GetMetaSoundMemberNode()
|
|
|
|
|
{
|
|
|
|
|
return Cast<UMetasoundEditorGraphMemberNode>(&GetMetaSoundNode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> SMetaSoundGraphNode::CreateNodeContentArea()
|
|
|
|
|
{
|
|
|
|
|
using namespace Frontend;
|
|
|
|
|
|
2022-08-16 17:21:16 -04:00
|
|
|
FConstNodeHandle NodeHandle = GetMetaSoundNode().GetConstNodeHandle();
|
2021-12-13 18:15:01 -05:00
|
|
|
const FMetasoundFrontendClassStyleDisplay& StyleDisplay = NodeHandle->GetClassStyle().Display;
|
|
|
|
|
TSharedPtr<SHorizontalBox> ContentBox = SNew(SHorizontalBox);
|
|
|
|
|
TSharedPtr<SWidget> OuterContentBox; // currently only used for input float nodes to accommodate the input widget
|
|
|
|
|
|
2022-07-18 17:14:25 -04:00
|
|
|
// If editable float input node and not constructor input, check if custom widget required
|
2022-06-28 13:42:14 -04:00
|
|
|
bool bShowInputWidget = false;
|
2022-06-16 12:30:27 -04:00
|
|
|
if (UMetasoundEditorGraphInput* GraphMember = Cast<UMetasoundEditorGraphInput>(GetMetaSoundMember()))
|
2021-12-13 18:15:01 -05:00
|
|
|
{
|
2022-06-28 13:42:14 -04:00
|
|
|
const UMetasoundEditorGraph* OwningGraph = GraphMember->GetOwningGraph();
|
2022-07-18 17:14:25 -04:00
|
|
|
if (OwningGraph && OwningGraph->IsEditable() && GraphMember->GetVertexAccessType() == EMetasoundFrontendVertexAccessType::Reference)
|
2021-12-13 18:15:01 -05:00
|
|
|
{
|
2022-06-28 13:42:14 -04:00
|
|
|
UMetasoundEditorGraphMemberDefaultFloat* DefaultFloat = Cast<UMetasoundEditorGraphMemberDefaultFloat>(GraphMember->GetLiteral());
|
|
|
|
|
if (DefaultFloat && DefaultFloat->WidgetType != EMetasoundMemberDefaultWidget::None)
|
2021-12-13 18:15:01 -05:00
|
|
|
{
|
|
|
|
|
constexpr float WidgetPadding = 3.0f;
|
|
|
|
|
static const FVector2D SliderDesiredSizeVertical = FVector2D(30.0f, 250.0f);
|
|
|
|
|
static const FVector2D RadialSliderDesiredSize = FVector2D(56.0f, 87.0f);
|
|
|
|
|
|
2022-06-28 13:42:14 -04:00
|
|
|
bShowInputWidget = true;
|
2021-12-13 18:15:01 -05:00
|
|
|
|
|
|
|
|
auto OnValueChangedLambda = [DefaultFloat, GraphMember, this](float Value)
|
|
|
|
|
{
|
|
|
|
|
if (InputWidget.IsValid())
|
2021-11-18 16:49:57 -05:00
|
|
|
{
|
2022-10-19 15:34:44 -04:00
|
|
|
if (!bIsInputWidgetTransacting)
|
2022-10-04 01:27:31 -04:00
|
|
|
{
|
2022-10-18 13:07:17 -04:00
|
|
|
GEditor->BeginTransaction(LOCTEXT("MetasoundGraphNode_MetasoundSetInputDefault", "Set MetaSound Input Default"));
|
2022-10-19 15:34:44 -04:00
|
|
|
bIsInputWidgetTransacting = true;
|
2022-10-04 01:27:31 -04:00
|
|
|
}
|
|
|
|
|
GraphMember->GetOwningGraph()->GetMetasound()->Modify();
|
|
|
|
|
DefaultFloat->Modify();
|
|
|
|
|
|
|
|
|
|
constexpr bool bPostTransaction = true;
|
2021-12-13 18:15:01 -05:00
|
|
|
float Output = InputWidget->GetOutputValue(Value);
|
|
|
|
|
DefaultFloat->SetDefault(Output);
|
|
|
|
|
GraphMember->UpdateFrontendDefaultLiteral(bPostTransaction);
|
2021-11-18 16:49:57 -05:00
|
|
|
}
|
2021-12-13 18:15:01 -05:00
|
|
|
};
|
2021-10-12 21:21:22 -04:00
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
auto OnValueCommittedLambda = [DefaultFloat, GraphMember, this](float Value)
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-13 18:15:01 -05:00
|
|
|
if (InputWidget.IsValid())
|
|
|
|
|
{
|
2022-10-04 01:27:31 -04:00
|
|
|
bool bPostTransaction = false;
|
2021-12-13 18:15:01 -05:00
|
|
|
float Output = InputWidget->GetOutputValue(Value);
|
|
|
|
|
DefaultFloat->SetDefault(Output);
|
2022-10-04 01:27:31 -04:00
|
|
|
|
|
|
|
|
if (bIsInputWidgetTransacting)
|
|
|
|
|
{
|
|
|
|
|
GEditor->EndTransaction();
|
|
|
|
|
bIsInputWidgetTransacting = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bPostTransaction = true;
|
|
|
|
|
UE_LOG(LogMetaSound, Warning, TEXT("Unmatched MetaSound editor widget transaction."));
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
GraphMember->UpdateFrontendDefaultLiteral(bPostTransaction);
|
|
|
|
|
|
|
|
|
|
if (UMetasoundEditorGraph* Graph = GraphMember->GetOwningGraph())
|
|
|
|
|
{
|
2022-09-22 15:02:24 -04:00
|
|
|
Graph->GetModifyContext().AddMemberIDsModified({ GraphMember->GetMemberID() });
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (DefaultFloat->WidgetType == EMetasoundMemberDefaultWidget::Slider)
|
|
|
|
|
{
|
|
|
|
|
// Create slider
|
|
|
|
|
if (DefaultFloat->WidgetValueType == EMetasoundMemberDefaultWidgetValueType::Frequency)
|
|
|
|
|
{
|
|
|
|
|
SAssignNew(InputWidget, SAudioFrequencySlider)
|
|
|
|
|
.OnValueChanged_Lambda(OnValueChangedLambda)
|
|
|
|
|
.OnValueCommitted_Lambda(OnValueCommittedLambda);
|
|
|
|
|
}
|
|
|
|
|
else if (DefaultFloat->WidgetValueType == EMetasoundMemberDefaultWidgetValueType::Volume)
|
|
|
|
|
{
|
|
|
|
|
SAssignNew(InputWidget, SAudioVolumeSlider)
|
|
|
|
|
.OnValueChanged_Lambda(OnValueChangedLambda)
|
|
|
|
|
.OnValueCommitted_Lambda(OnValueCommittedLambda);
|
2022-01-14 14:01:09 -05:00
|
|
|
StaticCastSharedPtr<SAudioVolumeSlider>(InputWidget)->SetUseLinearOutput(DefaultFloat->VolumeWidgetUseLinearOutput);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SAssignNew(InputWidget, SAudioSlider)
|
|
|
|
|
.OnValueChanged_Lambda(OnValueChangedLambda)
|
|
|
|
|
.OnValueCommitted_Lambda(OnValueCommittedLambda);
|
|
|
|
|
InputWidget->SetShowUnitsText(false);
|
|
|
|
|
}
|
|
|
|
|
// Slider layout
|
|
|
|
|
if (DefaultFloat->WidgetOrientation == Orient_Vertical)
|
|
|
|
|
{
|
|
|
|
|
SAssignNew(OuterContentBox, SVerticalBox)
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.HAlign(HAlign_Right)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
[
|
|
|
|
|
ContentBox.ToSharedRef()
|
|
|
|
|
]
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.HAlign(HAlign_Fill)
|
|
|
|
|
.VAlign(VAlign_Top)
|
|
|
|
|
.Padding(WidgetPadding, 0.0f, WidgetPadding, WidgetPadding)
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
[
|
|
|
|
|
InputWidget.ToSharedRef()
|
|
|
|
|
];
|
|
|
|
|
InputWidget->SetDesiredSizeOverride(SliderDesiredSizeVertical);
|
|
|
|
|
}
|
|
|
|
|
else // horizontal orientation
|
|
|
|
|
{
|
|
|
|
|
UMetasoundEditorGraphMemberNode* MemberNode = GetMetaSoundMemberNode();
|
|
|
|
|
TSharedPtr<SWidget> Slot1;
|
|
|
|
|
TSharedPtr<SWidget> Slot2;
|
|
|
|
|
if (MemberNode->IsA<UMetasoundEditorGraphInputNode>())
|
|
|
|
|
{
|
|
|
|
|
Slot1 = InputWidget;
|
|
|
|
|
Slot2 = ContentBox;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Slot1 = ContentBox;
|
|
|
|
|
Slot2 = InputWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SAssignNew(OuterContentBox, SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.HAlign(HAlign_Fill)
|
|
|
|
|
.VAlign(VAlign_Center)
|
2022-10-04 01:27:31 -04:00
|
|
|
.Padding(WidgetPadding, 0.0f, WidgetPadding, 0.0f)
|
2021-12-13 18:15:01 -05:00
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
Slot1.ToSharedRef()
|
|
|
|
|
]
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.HAlign(HAlign_Center)
|
|
|
|
|
.VAlign(VAlign_Fill)
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
Slot2.ToSharedRef()
|
|
|
|
|
];
|
|
|
|
|
InputWidget->SetDesiredSizeOverride(FVector2D(SliderDesiredSizeVertical.Y, SliderDesiredSizeVertical.X));
|
|
|
|
|
}
|
|
|
|
|
// safe downcast because the ptr was just assigned above
|
|
|
|
|
StaticCastSharedPtr<SAudioSliderBase>(InputWidget)->SetOrientation(DefaultFloat->WidgetOrientation);
|
2021-10-12 21:21:22 -04:00
|
|
|
}
|
2021-12-13 18:15:01 -05:00
|
|
|
else if (DefaultFloat->WidgetType == EMetasoundMemberDefaultWidget::RadialSlider)
|
|
|
|
|
{
|
2022-10-19 15:34:44 -04:00
|
|
|
auto OnRadialSliderMouseCaptureBeginLambda = [this]()
|
|
|
|
|
{
|
|
|
|
|
if (!bIsInputWidgetTransacting)
|
|
|
|
|
{
|
|
|
|
|
GEditor->BeginTransaction(LOCTEXT("MetasoundSetRadialSliderInputDefault", "Set MetaSound Input Default"));
|
|
|
|
|
bIsInputWidgetTransacting = true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto OnRadialSliderMouseCaptureEndLambda = [this]()
|
|
|
|
|
{
|
|
|
|
|
if (bIsInputWidgetTransacting)
|
|
|
|
|
{
|
|
|
|
|
GEditor->EndTransaction();
|
|
|
|
|
bIsInputWidgetTransacting = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogMetaSound, Warning, TEXT("Unmatched MetaSound editor widget transaction."));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-12-13 18:15:01 -05:00
|
|
|
// Create slider
|
|
|
|
|
if (DefaultFloat->WidgetValueType == EMetasoundMemberDefaultWidgetValueType::Frequency)
|
|
|
|
|
{
|
|
|
|
|
SAssignNew(InputWidget, SAudioFrequencyRadialSlider)
|
2022-10-19 15:34:44 -04:00
|
|
|
.OnValueChanged_Lambda(OnValueChangedLambda)
|
|
|
|
|
.OnMouseCaptureBegin_Lambda(OnRadialSliderMouseCaptureBeginLambda)
|
|
|
|
|
.OnMouseCaptureEnd_Lambda(OnRadialSliderMouseCaptureEndLambda);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
else if (DefaultFloat->WidgetValueType == EMetasoundMemberDefaultWidgetValueType::Volume)
|
|
|
|
|
{
|
|
|
|
|
SAssignNew(InputWidget, SAudioVolumeRadialSlider)
|
2022-10-19 15:34:44 -04:00
|
|
|
.OnValueChanged_Lambda(OnValueChangedLambda)
|
|
|
|
|
.OnMouseCaptureBegin_Lambda(OnRadialSliderMouseCaptureBeginLambda)
|
|
|
|
|
.OnMouseCaptureEnd_Lambda(OnRadialSliderMouseCaptureEndLambda);
|
2022-01-14 14:01:09 -05:00
|
|
|
StaticCastSharedPtr<SAudioVolumeRadialSlider>(InputWidget)->SetUseLinearOutput(DefaultFloat->VolumeWidgetUseLinearOutput);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SAssignNew(InputWidget, SAudioRadialSlider)
|
2022-10-19 15:34:44 -04:00
|
|
|
.OnValueChanged_Lambda(OnValueChangedLambda)
|
|
|
|
|
.OnMouseCaptureBegin_Lambda(OnRadialSliderMouseCaptureBeginLambda)
|
|
|
|
|
.OnMouseCaptureEnd_Lambda(OnRadialSliderMouseCaptureEndLambda);
|
2021-12-13 18:15:01 -05:00
|
|
|
InputWidget->SetShowUnitsText(false);
|
|
|
|
|
}
|
|
|
|
|
// Only vertical layout for radial slider
|
|
|
|
|
SAssignNew(OuterContentBox, SVerticalBox)
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.HAlign(HAlign_Right)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
[
|
|
|
|
|
ContentBox.ToSharedRef()
|
|
|
|
|
]
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.HAlign(HAlign_Fill)
|
|
|
|
|
.VAlign(VAlign_Top)
|
|
|
|
|
.Padding(WidgetPadding, 0.0f, WidgetPadding, WidgetPadding)
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
[
|
|
|
|
|
InputWidget.ToSharedRef()
|
|
|
|
|
];
|
|
|
|
|
InputWidget->SetDesiredSizeOverride(RadialSliderDesiredSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InputWidget->SetOutputRange(DefaultFloat->GetRange());
|
|
|
|
|
InputWidget->SetUnitsTextReadOnly(true);
|
2022-10-19 15:34:44 -04:00
|
|
|
InputWidget->SetSliderValue(InputWidget->GetSliderValue(DefaultFloat->GetDefault()));
|
2021-12-13 18:15:01 -05:00
|
|
|
InputWidget->SetVisibility(TAttribute<EVisibility>::Create([this]()
|
|
|
|
|
{
|
|
|
|
|
if (UMetasoundEditorGraphMemberNode* Node = GetMetaSoundMemberNode())
|
|
|
|
|
{
|
|
|
|
|
return Node->EnableInteractWidgets() ? EVisibility::Visible : EVisibility::Collapsed;
|
|
|
|
|
}
|
|
|
|
|
return EVisibility::Collapsed;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// Setup & clear delegate if necessary (ex. if was just saved)
|
|
|
|
|
if (InputSliderOnValueChangedDelegateHandle.IsValid())
|
|
|
|
|
{
|
|
|
|
|
DefaultFloat->OnDefaultValueChanged.Remove(InputSliderOnValueChangedDelegateHandle);
|
|
|
|
|
InputSliderOnValueChangedDelegateHandle.Reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InputSliderOnValueChangedDelegateHandle = DefaultFloat->OnDefaultValueChanged.AddLambda([Widget = InputWidget](float Value)
|
|
|
|
|
{
|
|
|
|
|
if (Widget.IsValid())
|
|
|
|
|
{
|
2022-10-19 15:34:44 -04:00
|
|
|
const float SliderValue = Widget->GetSliderValue(Value);
|
|
|
|
|
Widget->SetSliderValue(SliderValue);
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (InputSliderOnRangeChangedDelegateHandle.IsValid())
|
|
|
|
|
{
|
|
|
|
|
DefaultFloat->OnRangeChanged.Remove(InputSliderOnRangeChangedDelegateHandle);
|
|
|
|
|
InputSliderOnRangeChangedDelegateHandle.Reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InputSliderOnRangeChangedDelegateHandle = DefaultFloat->OnRangeChanged.AddLambda([Widget = InputWidget](FVector2D Range)
|
|
|
|
|
{
|
|
|
|
|
if (Widget.IsValid())
|
|
|
|
|
{
|
|
|
|
|
Widget->SetOutputRange(Range);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-10-12 21:21:22 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-24 23:29:50 -05:00
|
|
|
// Gives more space for user to grab a bit easier as variables do not have any title area nor icon
|
2022-08-16 17:21:16 -04:00
|
|
|
const float GrabPadding = IsVariableMutator() ? 28.0f : 0.0f;
|
|
|
|
|
|
|
|
|
|
const EVerticalAlignment PinNodeAlignInput = (!StyleDisplay.bShowInputNames && NodeHandle->GetNumInputs() == 1) ? VAlign_Center : VAlign_Top;
|
2022-02-24 23:29:50 -05:00
|
|
|
ContentBox->AddSlot()
|
|
|
|
|
.HAlign(HAlign_Left)
|
2022-08-16 17:21:16 -04:00
|
|
|
.VAlign(PinNodeAlignInput)
|
2022-03-02 16:52:01 -05:00
|
|
|
.FillWidth(1.0f)
|
2022-08-16 17:21:16 -04:00
|
|
|
.Padding(0.0f, 0.0f, GrabPadding, 0.0f)
|
2022-02-24 23:29:50 -05:00
|
|
|
[
|
|
|
|
|
SAssignNew(LeftNodeBox, SVerticalBox)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (!StyleDisplay.ImageName.IsNone())
|
|
|
|
|
{
|
2022-08-16 17:21:16 -04:00
|
|
|
const FSlateBrush& ImageBrush = Metasound::Editor::Style::GetSlateBrushSafe(StyleDisplay.ImageName);
|
|
|
|
|
ContentBox->AddSlot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
.HAlign(HAlign_Center)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SNew(SImage)
|
|
|
|
|
.Image(&ImageBrush)
|
|
|
|
|
.ColorAndOpacity(FSlateColor::UseForeground())
|
|
|
|
|
.DesiredSizeOverride(FVector2D(20, 20))
|
|
|
|
|
];
|
2021-12-13 18:15:01 -05:00
|
|
|
}
|
2021-01-20 00:42:47 -04:00
|
|
|
|
2022-08-16 17:21:16 -04:00
|
|
|
const EVerticalAlignment PinNodeAlignOutput = (!StyleDisplay.bShowInputNames && NodeHandle->GetNumOutputs() == 1) ? VAlign_Center : VAlign_Top;
|
2021-01-20 00:42:47 -04:00
|
|
|
ContentBox->AddSlot()
|
2021-12-13 18:15:01 -05:00
|
|
|
.AutoWidth()
|
|
|
|
|
.HAlign(HAlign_Right)
|
2022-08-16 17:21:16 -04:00
|
|
|
.VAlign(PinNodeAlignOutput)
|
|
|
|
|
.Padding(GrabPadding, 0.0f, 0.0f, 0.0f)
|
2021-12-13 18:15:01 -05:00
|
|
|
[
|
|
|
|
|
SAssignNew(RightNodeBox, SVerticalBox)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return SNew(SBorder)
|
2022-05-09 13:12:28 -04:00
|
|
|
.BorderImage(FAppStyle::GetBrush("NoBorder"))
|
2021-12-13 18:15:01 -05:00
|
|
|
.HAlign(HAlign_Fill)
|
|
|
|
|
.VAlign(VAlign_Fill)
|
|
|
|
|
.Padding(FMargin(0,3))
|
|
|
|
|
[
|
2022-06-28 13:42:14 -04:00
|
|
|
(bShowInputWidget ? OuterContentBox : ContentBox).ToSharedRef()
|
2021-12-13 18:15:01 -05:00
|
|
|
];
|
2021-01-20 00:42:47 -04:00
|
|
|
}
|
2022-08-12 14:22:05 -04:00
|
|
|
|
|
|
|
|
TSharedPtr<SGraphPin> SMetaSoundGraphNodeKnot::CreatePinWidget(UEdGraphPin* Pin) const
|
|
|
|
|
{
|
|
|
|
|
return SNew(SMetaSoundGraphPinKnot, Pin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SMetaSoundGraphNodeKnot::Construct(const FArguments& InArgs, class UEdGraphNode* InNode)
|
|
|
|
|
{
|
|
|
|
|
GraphNode = InNode;
|
|
|
|
|
SetCursor(EMouseCursor::CardinalCross);
|
|
|
|
|
UpdateGraphNode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SMetaSoundGraphNodeKnot::MoveTo(const FVector2D& NewPosition, FNodeSet& NodeFilter, bool bMarkDirty)
|
|
|
|
|
{
|
|
|
|
|
SGraphNode::MoveTo(NewPosition, NodeFilter, bMarkDirty);
|
|
|
|
|
|
|
|
|
|
UMetasoundEditorGraphNode& Node = GetMetaSoundNode();
|
|
|
|
|
Node.GetMetasoundChecked().Modify();
|
|
|
|
|
Node.SetNodeLocation(NewPosition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UMetasoundEditorGraphNode& SMetaSoundGraphNodeKnot::GetMetaSoundNode()
|
|
|
|
|
{
|
|
|
|
|
return *CastChecked<UMetasoundEditorGraphNode>(GraphNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const UMetasoundEditorGraphNode& SMetaSoundGraphNodeKnot::GetMetaSoundNode() const
|
|
|
|
|
{
|
|
|
|
|
check(GraphNode);
|
|
|
|
|
return *Cast<UMetasoundEditorGraphNode>(GraphNode);
|
|
|
|
|
}
|
2021-12-13 18:15:01 -05:00
|
|
|
} // namespace Editor
|
|
|
|
|
} // namespace Metasound
|
2022-10-18 13:07:17 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE // MetasoundEditor
|