Cut5/Source/Cut5/Widgets/STimelineProperty.cpp
2023-08-11 10:28:49 +08:00

71 lines
1.9 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#include "STimelineProperty.h"
#include "SlateOptMacros.h"
#include "Cut5/Utils/Utils.h"
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void STimelineProperty::Construct(const FArguments& InArgs)
{
TimelinePropertyData = InArgs._TimelinePropertyData;
MainWindow = InArgs._MainWindow;
MainInterface = InArgs._MainInterface;
ChildSlot
[
SNew(SBox)
.WidthOverride(80)
.HeightOverride(80)
.Padding(4)
[
SNew(SOverlay)
+ SOverlay::Slot()
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("EffectCardUnSelected.png"), {}))
]
+ SOverlay::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath(TimelinePropertyData.IconPath), {40, 40}))
]
+ SOverlay::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Bottom)
[
SNew(STextBlock)
.Text(FText::FromString(TimelinePropertyData.Name))
]
]
];
// this->AssignParentWidget(MainWindow->CutTimeline.ToSharedRef());
}
FReply STimelineProperty::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton);
}
FReply STimelineProperty::OnDragDetected(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
UE_LOG(LogTemp, Warning, TEXT("On Drag Detected"));
const TSharedPtr<FDeviceDragDrop> Operation = MakeShared<FDeviceDragDrop>();
// Operation->TimelinePropertyData = &TimelinePropertyData;
Operation->DraggingWidget = SharedThis(this);
Operation->DragDropType = FCutDragDropBase::EType::Device;
Operation->MainInterface = MainInterface;
Operation->DeviceName = TimelinePropertyData.Name;
Operation->TrackType = TimelinePropertyData.Type;
return FReply::Handled().BeginDragDrop(Operation.ToSharedRef());
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION