Files
UnrealEngineUWP/Engine/Source/Editor/GraphEditor/Public/GraphEditorDragDropAction.h
Ben Cosh 34f4d6d5fd Modified the dragdrop operations in the blueprint graphs to respect read only attributes set on either graphs or nodes.
#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]
2014-06-18 05:04:59 -04:00

89 lines
3.4 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
// Base class for drag-drop actions that pass into the graph editor and perform an action when dropped
class GRAPHEDITOR_API FGraphEditorDragDropAction : public FDragDropOperation
{
public:
DRAG_DROP_OPERATOR_TYPE(FGraphEditorDragDropAction, FDragDropOperation)
void SetHoveredPin(class UEdGraphPin* InPin);
void SetHoveredNode(const TSharedPtr<class SGraphNode>& InNode);
void SetHoveredGraph(const TSharedPtr<class SGraphPanel>& InGraph);
void SetHoveredCategoryName(const FString& InHoverCategoryName);
void SetHoveredAction(TSharedPtr<struct FEdGraphSchemaAction> Action);
void SetDropTargetValid( bool bValid ) { bDropTargetValid = bValid; }
// Interface to override
virtual void HoverTargetChanged() {}
virtual FReply DroppedOnPin(FVector2D ScreenPosition, FVector2D GraphPosition) { return FReply::Unhandled(); }
virtual FReply DroppedOnNode(FVector2D ScreenPosition, FVector2D GraphPosition) { return FReply::Unhandled(); }
virtual FReply DroppedOnPanel( const TSharedRef< class SWidget >& Panel, FVector2D ScreenPosition, FVector2D GraphPosition, UEdGraph& Graph) { return FReply::Unhandled(); }
virtual FReply DroppedOnAction(TSharedRef<struct FEdGraphSchemaAction> Action) { return FReply::Unhandled(); }
virtual FReply DroppedOnCategory(FString Category) { return FReply::Unhandled(); }
virtual void OnDragBegin(const TSharedRef<class SGraphPin>& InPin) {}
// End of interface to override
protected:
void SetFeedbackMessage(const TSharedPtr<SWidget>& Message);
void SetSimpleFeedbackMessage(const FSlateBrush* Icon, const FSlateColor& IconColor, const FText& Message);
UEdGraphPin* GetHoveredPin() const;
UEdGraphNode* GetHoveredNode() const;
UEdGraph* GetHoveredGraph() const;
/** Constructs the window and widget if applicable */
virtual void Construct();
private:
EVisibility GetIconVisible() const;
EVisibility GetErrorIconVisible() const;
// The pin that the drag action is currently hovering over
TWeakObjectPtr<class UEdGraphPin> HoveredPin;
// The node that the drag action is currently hovering over
TSharedPtr<class SGraphNode> HoveredNode;
// The graph that the drag action is currently hovering over
TSharedPtr<class SGraphPanel> HoveredGraph;
protected:
// Name of category we are hovering over
FString HoveredCategoryName;
// Action we are hovering over
TWeakPtr<struct FEdGraphSchemaAction> HoveredAction;
// drop target status
bool bDropTargetValid;
};
// Drag-drop action where an FEdGraphSchemaAction should be performed when dropped
class GRAPHEDITOR_API FGraphSchemaActionDragDropAction : public FGraphEditorDragDropAction
{
public:
DRAG_DROP_OPERATOR_TYPE(FGraphSchemaActionDragDropAction, FGraphEditorDragDropAction)
// FGraphEditorDragDropAction interface
virtual void HoverTargetChanged() override;
virtual FReply DroppedOnPanel( const TSharedRef< class SWidget >& Panel, FVector2D ScreenPosition, FVector2D GraphPosition, UEdGraph& Graph) override;
// End of FGraphEditorDragDropAction
static TSharedRef<FGraphSchemaActionDragDropAction> New(TSharedPtr<FEdGraphSchemaAction> InActionNode )
{
TSharedRef<FGraphSchemaActionDragDropAction> Operation = MakeShareable(new FGraphSchemaActionDragDropAction);
Operation->ActionNode = InActionNode;
Operation->Construct();
return Operation;
}
protected:
/** */
TSharedPtr<FEdGraphSchemaAction> ActionNode;
};