Files
UnrealEngineUWP/Engine/Source/Editor/AnimationBlueprintEditor/Private/StateMachineConnectionDrawingPolicy.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

63 lines
2.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "ConnectionDrawingPolicy.h"
#include "Containers/Map.h"
#include "HAL/Platform.h"
#include "Math/Vector2D.h"
#include "Templates/SharedPointer.h"
class FArrangedChildren;
class FArrangedWidget;
class FSlateRect;
class FSlateWindowElementList;
class SWidget;
class UEdGraph;
class UEdGraphNode;
class UEdGraphPin;
struct FGeometry;
/////////////////////////////////////////////////////
// FStateMachineConnectionDrawingPolicy
// This class draws the connections for an UEdGraph with a state machine schema
class FStateMachineConnectionDrawingPolicy : public FConnectionDrawingPolicy
{
protected:
UEdGraph* GraphObj;
TMap<UEdGraphNode*, int32> NodeWidgetMap;
public:
// @Note FConnectionParams.bUserFlag2: Is used here to indicate whether the drawn arrow is a preview transition or a real one.
//
FStateMachineConnectionDrawingPolicy(int32 InBackLayerID, int32 InFrontLayerID, float ZoomFactor, const FSlateRect& InClippingRect, FSlateWindowElementList& InDrawElements, UEdGraph* InGraphObj);
// FConnectionDrawingPolicy interface
virtual void DetermineWiringStyle(UEdGraphPin* OutputPin, UEdGraphPin* InputPin, /*inout*/ FConnectionParams& Params) override;
virtual void Draw(TMap<TSharedRef<SWidget>, FArrangedWidget>& PinGeometries, FArrangedChildren& ArrangedNodes) override;
virtual void DetermineLinkGeometry(
FArrangedChildren& ArrangedNodes,
TSharedRef<SWidget>& OutputPinWidget,
UEdGraphPin* OutputPin,
UEdGraphPin* InputPin,
/*out*/ FArrangedWidget*& StartWidgetGeometry,
/*out*/ FArrangedWidget*& EndWidgetGeometry
) override;
virtual void DrawSplineWithArrow(const FGeometry& StartGeom, const FGeometry& EndGeom, const FConnectionParams& Params) override;
virtual void DrawSplineWithArrow(const FVector2D& StartPoint, const FVector2D& EndPoint, const FConnectionParams& Params) override;
virtual void DrawPreviewConnector(const FGeometry& PinGeometry, const FVector2D& StartPoint, const FVector2D& EndPoint, UEdGraphPin* Pin) override;
virtual FVector2D ComputeSplineTangent(const FVector2D& Start, const FVector2D& End) const override;
// End of FConnectionDrawingPolicy interface
protected:
void Internal_DrawLineWithArrow(const FVector2D& StartAnchorPoint, const FVector2D& EndAnchorPoint, const FConnectionParams& Params);
// Draw line-based circle (no solid filling)
void DrawCircle(const FVector2D& Center, float Radius, const FLinearColor& Color, const int NumLineSegments);
TArray<FVector2D> TempPoints;
static constexpr float RelinkHandleHoverRadius = 20.0f;
};