Files
UnrealEngineUWP/Engine/Source/Editor/GraphEditor/Private/DragConnection.h
benjamin jillich a6ef0d5b7f [UE-136096] Relinking transitions in anim graph state machines
[UE-168360] User can create a transition from a state into the entry state

* Relinking multiple transitions (transition nodes at once) when none of the transition nodes is selected.
* Selective relinking in case a subset of the transition nodes on a transitions are selected.
* Special case handling for transitions from entry state (they don't have a transition node connected).
* Drawing circle indicator around the arrow head in case the mouse cursor is approaching the transition.
* Hovering the arrow head of a transition highlights it by filling the circle with solid orange color and turning the arrow black.
* Ending the relink operation in empty space or the entry node will cancel the relink operation.
* Fixed bug that prevents creating new transitions ending in an entry state.

#jira https://jira.it.epicgames.com/browse/UE-136096
#jira https://jira.it.epicgames.com/browse/UE-168360
#preflight 636a169963037c10262bc421

[CL 23025287 by benjamin jillich in ue5-main branch]
2022-11-08 04:09:22 -05:00

68 lines
2.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Containers/Array.h"
#include "Containers/UnrealString.h"
#include "GraphEditorDragDropAction.h"
#include "Input/DragAndDrop.h"
#include "Input/Reply.h"
#include "Math/Vector2D.h"
#include "SGraphPin.h"
#include "Templates/SharedPointer.h"
class SGraphPanel;
class SWidget;
class UEdGraph;
class UEdGraphPin;
struct FPointerEvent;
class FDragConnection : public FGraphEditorDragDropAction
{
public:
DRAG_DROP_OPERATOR_TYPE(FDragConnection, FGraphEditorDragDropAction)
enum EDragMode : uint8
{
CreateConnection = 0,
RelinkConnection
};
typedef TArray<FGraphPinHandle> FDraggedPinTable;
static TSharedRef<FDragConnection> New(const TSharedRef<SGraphPanel>& InGraphPanel, const FDraggedPinTable& InStartingPins);
// FDragDropOperation interface
virtual void OnDrop( bool bDropWasHandled, const FPointerEvent& MouseEvent ) override;
// End of FDragDropOperation interface
// FGraphEditorDragDropAction interface
virtual void HoverTargetChanged() override;
virtual FReply DroppedOnPin(FVector2D ScreenPosition, FVector2D GraphPosition) override;
virtual FReply DroppedOnNode(FVector2D ScreenPosition, FVector2D GraphPosition) override;
virtual FReply DroppedOnPanel(const TSharedRef< SWidget >& Panel, FVector2D ScreenPosition, FVector2D GraphPosition, UEdGraph& Graph) override;
virtual void OnDragged(const class FDragDropEvent& DragDropEvent) override;
// End of FGraphEditorDragDropAction interface
/*
* Function to check validity of graph pins in the StartPins list. This check helps to prevent processing graph pins which are outdated.
*/
virtual void ValidateGraphPinList(TArray<UEdGraphPin*>& OutValidPins);
protected:
typedef FGraphEditorDragDropAction Super;
// Constructor: Make sure to call Construct() after factorying one of these
FDragConnection(const TSharedRef<SGraphPanel>& GraphPanel, const FDraggedPinTable& DraggedPins);
protected:
TSharedPtr<SGraphPanel> GraphPanel;
FDraggedPinTable DraggingPins;
EDragMode DragMode = EDragMode::CreateConnection;
/** Offset information for the decorator widget */
FVector2D DecoratorAdjust;
FGraphPinHandle SourcePinHandle;
FGraphPinHandle TargetPinHandle;
};