| 1151 | } |
| 1152 | |
| 1153 | FReply SFlowGraphNode::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) |
| 1154 | { |
| 1155 | SetDragMarker(false); |
| 1156 | |
| 1157 | const TSharedPtr<FDragFlowGraphNode> DragNodeOp = DragDropEvent.GetOperationAs<FDragFlowGraphNode>(); |
| 1158 | if (DragNodeOp.IsValid()) |
| 1159 | { |
| 1160 | if (!DragNodeOp->IsValidOperation()) |
| 1161 | { |
| 1162 | return FReply::Handled(); |
| 1163 | } |
| 1164 | |
| 1165 | const float DragTime = static_cast<float>(FPlatformTime::Seconds() - DragNodeOp->StartTime); |
| 1166 | if (DragTime < 0.5f) |
| 1167 | { |
| 1168 | return FReply::Handled(); |
| 1169 | } |
| 1170 | |
| 1171 | if (FlowGraphNode == nullptr) |
| 1172 | { |
| 1173 | return FReply::Unhandled(); |
| 1174 | } |
| 1175 | |
| 1176 | const FScopedTransaction Transaction(LOCTEXT("GraphEd_DragDropNode", "Drag&Drop Node")); |
| 1177 | |
| 1178 | UFlowGraphNode* DropTargetNode = DragNodeOp->GetDropTargetNode(); |
| 1179 | check(DropTargetNode); |
| 1180 | |
| 1181 | bool bReorderOperation = true; |
| 1182 | const TArray< TSharedRef<SGraphNode> >& DraggedNodes = DragNodeOp->GetNodes(); |
| 1183 | RemoveDraggedSubNodes(DraggedNodes, bReorderOperation); |
| 1184 | |
| 1185 | const bool bShouldDropAsSubNodesOfDropTargetNode = bReorderOperation || ShouldDropDraggedNodesAsSubNodes(DraggedNodes, DropTargetNode); |
| 1186 | |
| 1187 | // Set up the DropTarget pointers based on the type of drop we've decided to do: |
| 1188 | UFlowGraphNode* DropTargetParentNode; |
| 1189 | if (bShouldDropAsSubNodesOfDropTargetNode) |
| 1190 | { |
| 1191 | DropTargetParentNode = DropTargetNode; |
| 1192 | DropTargetNode = nullptr; |
| 1193 | } |
| 1194 | else |
| 1195 | { |
| 1196 | DropTargetParentNode = DropTargetNode->GetParentNode(); |
| 1197 | } |
| 1198 | |
| 1199 | check(DropTargetParentNode); |
| 1200 | |
| 1201 | const int32 InsertIndex = DropTargetParentNode->FindSubNodeDropIndex(DropTargetNode); |
| 1202 | |
| 1203 | for (int32 Idx = 0; Idx < DraggedNodes.Num(); Idx++) |
| 1204 | { |
| 1205 | UFlowGraphNode* DraggedTestNode = Cast<UFlowGraphNode>(DraggedNodes[Idx]->GetNodeObj()); |
| 1206 | DraggedTestNode->Modify(); |
| 1207 | DraggedTestNode->SetParentNodeForSubNode(DropTargetParentNode); |
| 1208 | |
| 1209 | DropTargetParentNode->Modify(); |
| 1210 | DropTargetParentNode->InsertSubNodeAt(DraggedTestNode, InsertIndex); |
nothing calls this directly
no test coverage detected