Files
UnrealEngineUWP/Engine/Source/Editor/ViewportInteraction/ViewportDragOperation.cpp
Marc Audy 0c3be2b6ad Merge Release-Engine-Staging to Test @ CL# 18240298
[CL 18241953 by Marc Audy in ue5-release-engine-test branch]
2021-11-18 14:37:34 -05:00

47 lines
1.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "ViewportDragOperation.h"
#include "ViewportInteractionTypes.h"
UViewportDragOperationComponent::UViewportDragOperationComponent() :
Super(),
DragOperation(nullptr)
{
}
UViewportDragOperation* UViewportDragOperationComponent::GetDragOperation()
{
return DragOperation;
}
void UViewportDragOperationComponent::SetDragOperationClass( const TSubclassOf<UViewportDragOperation> InDragOperation )
{
DragOperationSubclass = InDragOperation;
}
void UViewportDragOperationComponent::StartDragOperation()
{
if ( DragOperationSubclass )
{
// Reset the drag operation to make sure we start a new one
ClearDragOperation();
// Create the drag object with the latest class
DragOperation = NewObject<UViewportDragOperation>( ( UObject* ) GetTransientPackage(), DragOperationSubclass );
}
}
void UViewportDragOperationComponent::ClearDragOperation()
{
if (DragOperation)
{
DragOperation->MarkAsGarbage();
}
DragOperation = nullptr;
}
bool UViewportDragOperationComponent::IsDragging() const
{
return DragOperation != nullptr;
}