2021-09-16 14:06:52 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-11-07 23:43:01 -05:00
|
|
|
#include "GraphEditor.h"
|
2021-09-16 14:06:52 -04:00
|
|
|
#include "EdGraph/EdGraph.h"
|
|
|
|
|
#include "EdGraph/EdGraphPin.h"
|
|
|
|
|
#include "EdGraph/EdGraphSchema.h"
|
2021-11-07 23:43:01 -05:00
|
|
|
#include "Layout/Margin.h"
|
|
|
|
|
#include "Layout/Visibility.h"
|
|
|
|
|
#include "SGraphActionMenu.h"
|
|
|
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
|
|
|
#include "Widgets/Input/SEditableTextBox.h"
|
|
|
|
|
#include "Widgets/Layout/SBorder.h"
|
|
|
|
|
#include "Widgets/SWidget.h"
|
|
|
|
|
#include "Widgets/Views/SExpanderArrow.h"
|
2021-09-16 14:06:52 -04:00
|
|
|
|
|
|
|
|
class SEditableTextBox;
|
|
|
|
|
class SGraphActionMenu;
|
|
|
|
|
class UEdGraph;
|
|
|
|
|
struct FCustomExpanderData;
|
|
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
namespace Metasound
|
2021-09-16 14:06:52 -04:00
|
|
|
{
|
2021-12-10 20:37:31 -05:00
|
|
|
namespace Editor
|
2021-09-16 14:06:52 -04:00
|
|
|
{
|
2021-12-10 20:37:31 -05:00
|
|
|
// Custom expander to specify our desired padding
|
|
|
|
|
class SMetasoundActionMenuExpanderArrow : public SExpanderArrow
|
|
|
|
|
{
|
|
|
|
|
SLATE_BEGIN_ARGS(SMetasoundActionMenuExpanderArrow)
|
|
|
|
|
{
|
|
|
|
|
}
|
2021-09-16 14:06:52 -04:00
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
SLATE_ATTRIBUTE(float, IndentAmount)
|
|
|
|
|
SLATE_END_ARGS()
|
2021-09-16 14:06:52 -04:00
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
public:
|
|
|
|
|
void Construct(const FArguments& InArgs, const FCustomExpanderData& ActionMenuData);
|
2021-09-16 14:06:52 -04:00
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
private:
|
|
|
|
|
FMargin GetCustomIndentPadding() const;
|
2021-09-16 14:06:52 -04:00
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
TWeakPtr<FEdGraphSchemaAction> ActionPtr;
|
|
|
|
|
};
|
2021-09-16 14:06:52 -04:00
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
class SMetasoundActionMenu : public SBorder
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/** Delegate for the OnCloseReason event which is always raised when the SMetasoundActionMenu closes */
|
|
|
|
|
DECLARE_DELEGATE_ThreeParams(FClosedReason, bool /*bActionExecuted*/, bool /*bContextSensitiveChecked*/, bool /*bGraphPinContext*/);
|
2021-09-16 14:06:52 -04:00
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
SLATE_BEGIN_ARGS(SMetasoundActionMenu)
|
|
|
|
|
: _Graph(static_cast<UEdGraph*>(nullptr))
|
|
|
|
|
, _NewNodePosition(FVector2D::ZeroVector)
|
|
|
|
|
, _AutoExpandActionMenu(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
SLATE_ARGUMENT(UEdGraph*, Graph)
|
|
|
|
|
SLATE_ARGUMENT(FVector2D, NewNodePosition)
|
|
|
|
|
SLATE_ARGUMENT(TArray<UEdGraphPin*>, DraggedFromPins)
|
|
|
|
|
SLATE_ARGUMENT(SGraphEditor::FActionMenuClosed, OnClosedCallback)
|
|
|
|
|
SLATE_ARGUMENT(bool, AutoExpandActionMenu)
|
|
|
|
|
SLATE_EVENT(FClosedReason, OnCloseReason)
|
|
|
|
|
SLATE_END_ARGS()
|
2021-09-16 14:06:52 -04:00
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
void Construct(const FArguments& InArgs);
|
2021-09-16 14:06:52 -04:00
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
~SMetasoundActionMenu();
|
2021-09-16 14:06:52 -04:00
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
TSharedRef<SEditableTextBox> GetFilterTextBox();
|
2021-09-16 14:06:52 -04:00
|
|
|
|
2021-12-10 20:37:31 -05:00
|
|
|
protected:
|
|
|
|
|
void OnActionSelected(const TArray<TSharedPtr<FEdGraphSchemaAction>>& SelectedAction, ESelectInfo::Type InSelectionType);
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> OnCreateWidgetForAction(struct FCreateWidgetForActionData* const InCreateData);
|
|
|
|
|
|
|
|
|
|
/** Callback used to populate all actions list in SGraphActionMenu */
|
|
|
|
|
void CollectAllActions(FGraphActionListBuilderBase& OutAllActions);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
UEdGraph* Graph = nullptr;
|
|
|
|
|
bool bAutoExpandActionMenu = false;
|
|
|
|
|
bool bActionExecuted = false;
|
|
|
|
|
|
|
|
|
|
TArray<UEdGraphPin*> DraggedFromPins;
|
|
|
|
|
FVector2D NewNodePosition = FVector2D::ZeroVector;
|
|
|
|
|
|
|
|
|
|
SGraphEditor::FActionMenuClosed OnClosedCallback;
|
|
|
|
|
FClosedReason OnCloseReasonCallback;
|
|
|
|
|
|
|
|
|
|
TSharedPtr<SGraphActionMenu> GraphActionMenu;
|
|
|
|
|
};
|
|
|
|
|
} // namespace Editor
|
|
|
|
|
} // namespace Metasound
|