You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#TTP 334976 - BLUEPRINTS: Drag-dropping can still create nodes in read-only graphs (e.g., during PIE or when viewing an anim parent graph) #Branch UE4 #Proj GraphEditor #Add added SGraphPanel::IsGraphEditable so nodes and objects placed in the graph can easily determine if the graph is read only. #Change Modified SGraphPanel::OnDragLeave to restore the tooltip if a FDecoratedDragDropOp has been modified to indicate that the graph is read only. #Change Modified SGraphPanel::OnDragOver to change the icon on the tooltip to a lined circle if the graph is read only. #Change Modified SGraphPanel::OnDrop to exit without changes if the graph is read only. #Change Modified FGraphEditorDragDropAction to present feedback to the user if the drag drop target is invalid. this is activated by setting FGraphEditorDragDropAction::SetDropTargetValid, this just collpases the active icon and displays a lined circle with the same tooltip when set to false. #Add added SGraphNode::IsNodeEditable to determine if the node is currently editable, based on an evaluation of the IsEditable attribute and the parent graphs IsGraphEditable. #Change modified SGraphNode::OnDragOver to display a lined circle if the parent graph or the node is read only. #Change modified SGraphNode::OnDrop to exit without changes if the parent graph or the node is read only. #Change modified SGraphPin::OnDrop to exit without changes if the parent graph or the owner node is read only. ReviewedBy Chris.Wood, Nick.Whiting [CL 2109030 by Ben Cosh in Main branch]
181 lines
4.3 KiB
C++
181 lines
4.3 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
#include "GraphEditorCommon.h"
|
|
|
|
UEdGraphPin* FGraphEditorDragDropAction::GetHoveredPin() const
|
|
{
|
|
return HoveredPin.Get();
|
|
}
|
|
|
|
UEdGraphNode* FGraphEditorDragDropAction::GetHoveredNode() const
|
|
{
|
|
return HoveredNode.IsValid() ? HoveredNode->GetNodeObj() : NULL;
|
|
}
|
|
|
|
UEdGraph* FGraphEditorDragDropAction::GetHoveredGraph() const
|
|
{
|
|
// Note: We always want to report a graph even when hovering over a node or pin;
|
|
// the same is not true for nodes when hovering over a pin (at least right now)
|
|
if (HoveredGraph.IsValid())
|
|
{
|
|
return HoveredGraph->GetGraphObj();
|
|
}
|
|
else if (UEdGraphNode* Node = GetHoveredNode())
|
|
{
|
|
return Node->GetGraph();
|
|
}
|
|
else if (UEdGraphPin* Pin = GetHoveredPin())
|
|
{
|
|
return Pin->GetOwningNode()->GetGraph();
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void FGraphEditorDragDropAction::SetHoveredPin(UEdGraphPin* InPin)
|
|
{
|
|
if (HoveredPin != InPin)
|
|
{
|
|
HoveredPin = InPin;
|
|
HoverTargetChanged();
|
|
}
|
|
}
|
|
|
|
void FGraphEditorDragDropAction::SetHoveredNode(const TSharedPtr<SGraphNode>& InNode)
|
|
{
|
|
if (HoveredNode != InNode)
|
|
{
|
|
HoveredNode = InNode;
|
|
HoverTargetChanged();
|
|
}
|
|
}
|
|
|
|
void FGraphEditorDragDropAction::SetHoveredGraph(const TSharedPtr<SGraphPanel>& InGraph)
|
|
{
|
|
if (HoveredGraph != InGraph)
|
|
{
|
|
HoveredGraph = InGraph;
|
|
HoverTargetChanged();
|
|
}
|
|
}
|
|
|
|
void FGraphEditorDragDropAction::SetHoveredCategoryName(const FString& InHoverCategoryName)
|
|
{
|
|
if(HoveredCategoryName != InHoverCategoryName)
|
|
{
|
|
HoveredCategoryName = InHoverCategoryName;
|
|
HoverTargetChanged();
|
|
}
|
|
}
|
|
|
|
void FGraphEditorDragDropAction::SetHoveredAction(TSharedPtr<struct FEdGraphSchemaAction> Action)
|
|
{
|
|
if(HoveredAction.Pin().Get() != Action.Get())
|
|
{
|
|
HoveredAction = Action;
|
|
HoverTargetChanged();
|
|
}
|
|
}
|
|
|
|
|
|
void FGraphEditorDragDropAction::Construct()
|
|
{
|
|
// Create the drag-drop decorator window
|
|
CursorDecoratorWindow = SWindow::MakeCursorDecorator();
|
|
const bool bShowImmediately = false;
|
|
FSlateApplication::Get().AddWindow(CursorDecoratorWindow.ToSharedRef(), bShowImmediately);
|
|
|
|
HoverTargetChanged();
|
|
}
|
|
|
|
void FGraphEditorDragDropAction::SetFeedbackMessage(const TSharedPtr<SWidget>& Message)
|
|
{
|
|
if (Message.IsValid())
|
|
{
|
|
CursorDecoratorWindow->ShowWindow();
|
|
CursorDecoratorWindow->SetContent
|
|
(
|
|
SNew(SBorder)
|
|
. BorderImage(FEditorStyle::GetBrush("Graph.ConnectorFeedback.Border"))
|
|
[
|
|
Message.ToSharedRef()
|
|
]
|
|
);
|
|
}
|
|
else
|
|
{
|
|
CursorDecoratorWindow->HideWindow();
|
|
CursorDecoratorWindow->SetContent(SNullWidget::NullWidget);
|
|
}
|
|
}
|
|
|
|
void FGraphEditorDragDropAction::SetSimpleFeedbackMessage(const FSlateBrush* Icon, const FSlateColor& IconColor, const FText& Message)
|
|
{
|
|
// Let the user know the status of making this connection.
|
|
SetFeedbackMessage(
|
|
SNew(SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.Padding(3.0f)
|
|
[
|
|
SNew(SImage)
|
|
.Visibility( this, &FGraphEditorDragDropAction::GetErrorIconVisible )
|
|
.Image( FEditorStyle::GetBrush( TEXT("Graph.ConnectorFeedback.Error") ))
|
|
.ColorAndOpacity( FLinearColor::White )
|
|
]
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.Padding(3.0f)
|
|
[
|
|
SNew(SImage)
|
|
.Visibility( this, &FGraphEditorDragDropAction::GetIconVisible )
|
|
.Image( Icon )
|
|
.ColorAndOpacity( IconColor )
|
|
]
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.MaxWidth(500)
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
SNew(STextBlock)
|
|
.Text( Message )
|
|
]
|
|
);
|
|
}
|
|
|
|
EVisibility FGraphEditorDragDropAction::GetIconVisible() const
|
|
{
|
|
return bDropTargetValid ? EVisibility::Visible : EVisibility::Collapsed;
|
|
}
|
|
|
|
EVisibility FGraphEditorDragDropAction::GetErrorIconVisible() const
|
|
{
|
|
return bDropTargetValid ? EVisibility::Collapsed : EVisibility::Visible;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
void FGraphSchemaActionDragDropAction::HoverTargetChanged()
|
|
{
|
|
if(ActionNode.IsValid())
|
|
{
|
|
const FSlateBrush* StatusSymbol = FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.NewNode"));
|
|
|
|
//Create feedback message with the function name.
|
|
SetSimpleFeedbackMessage(StatusSymbol, FLinearColor::White, ActionNode->MenuDescription);
|
|
}
|
|
}
|
|
|
|
FReply FGraphSchemaActionDragDropAction::DroppedOnPanel( const TSharedRef< SWidget >& Panel, FVector2D ScreenPosition, FVector2D GraphPosition, UEdGraph& Graph)
|
|
{
|
|
if(ActionNode.IsValid())
|
|
{
|
|
TArray<UEdGraphPin*> DummyPins;
|
|
ActionNode->PerformAction(&Graph, DummyPins, GraphPosition);
|
|
|
|
return FReply::Handled();
|
|
}
|
|
return FReply::Unhandled();
|
|
}
|