Files
UnrealEngineUWP/Engine/Source/Editor/GraphEditor/Private/MaterialGraphConnectionDrawingPolicy.cpp
Michael Noland c97e8231bb GraphEditor: Refactored connection drawing policy API to be more flexible, passing a parameter structure around instead of loose values (FConnectionParams)
Remove duplicated implementations of DrawConnection in subclasses that draw non-curved splines, overriding ComputeSplineTangent instead
Upgrade note: Any editor plugins that contain a FConnectionDrawingPolicy subclass will need to update calls to DrawSplineWithArrow, DrawConnection, and DetermineWiringStyle

[CL 2402661 by Michael Noland in Main branch]
2015-01-10 00:31:36 -05:00

48 lines
1.7 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "GraphEditorCommon.h"
#include "MaterialGraphConnectionDrawingPolicy.h"
/////////////////////////////////////////////////////
// FMaterialGraphConnectionDrawingPolicy
FMaterialGraphConnectionDrawingPolicy::FMaterialGraphConnectionDrawingPolicy(int32 InBackLayerID, int32 InFrontLayerID, float ZoomFactor, const FSlateRect& InClippingRect, FSlateWindowElementList& InDrawElements, UEdGraph* InGraphObj)
: FConnectionDrawingPolicy(InBackLayerID, InFrontLayerID, ZoomFactor, InClippingRect, InDrawElements)
, MaterialGraph(CastChecked<UMaterialGraph>(InGraphObj))
, MaterialGraphSchema(CastChecked<UMaterialGraphSchema>(InGraphObj->GetSchema()))
{
// Don't want to draw ending arrowheads
ArrowImage = nullptr;
ArrowRadius = FVector2D::ZeroVector;
// Still need to be able to perceive the graph while dragging connectors, esp over comment boxes
HoverDeemphasisDarkFraction = 0.4f;
}
void FMaterialGraphConnectionDrawingPolicy::DetermineWiringStyle(UEdGraphPin* OutputPin, UEdGraphPin* InputPin, /*inout*/ FConnectionParams& Params)
{
Params.WireColor = MaterialGraphSchema->ActivePinColor;
// Have to consider both pins as the input will be an 'output' when previewing a connection
if (OutputPin)
{
if (!MaterialGraph->IsInputActive(OutputPin))
{
Params.WireColor = MaterialGraphSchema->InactivePinColor;
}
}
if (InputPin)
{
if (!MaterialGraph->IsInputActive(InputPin))
{
Params.WireColor = MaterialGraphSchema->InactivePinColor;
}
}
const bool bDeemphasizeUnhoveredPins = HoveredPins.Num() > 0;
if (bDeemphasizeUnhoveredPins)
{
ApplyHoverDeemphasis(OutputPin, InputPin, /*inout*/ Params.WireThickness, /*inout*/ Params.WireColor);
}
}