拖拽效果,片段预设修改

This commit is contained in:
Sch 2023-08-25 07:26:37 +08:00
parent 62b6a553cc
commit f6765a04b1
16 changed files with 192 additions and 60 deletions

View File

@ -0,0 +1,6 @@
#include "VirtualDragDropShow.h"
TSharedPtr<SWidget> IVirtualDragDropShow::GetVirtualDragDropShowWidget()
{
return SNew(SBox).HeightOverride(60).WidthOverride(60);
}

View File

@ -0,0 +1,7 @@
#pragma once
class IVirtualDragDropShow
{
public:
TSharedPtr<SWidget> GetVirtualDragDropShowWidget();
};

View File

@ -212,7 +212,7 @@ struct CUT5_API FCursorData
struct CUT5_API FPresetsData
{
EPresetType PresetType = EPresetType::NotAPresets;
TArray<FLinearColor> Colors;
TArray<FLinearColor> Colors = {FLinearColor::Red, FLinearColor::Green};
FString VideoPaths;
FString PresetName;
friend FArchive& operator<<(FArchive& Ar, FPresetsData& PresetsData)
@ -264,7 +264,7 @@ struct CUT5_API FPresetsCustomData
float Angle;
float Time = 0.3;
EPresetCustomType PresetCustomType = EPresetCustomType::None;
TArray<FCursorData> Cursors;
friend FArchive& operator<<(FArchive& Ar, FPresetsCustomData& PresetsData)
@ -338,12 +338,14 @@ struct CUT5_API FClipData
TArray<FSlateBrush> MovieBrushes;
TArray<FString> MovieBrushesPath;
int32 MovieBrushNum;
TArray<FSlateBrush> AudioBrushes;
TArray<float> AudioBrushLength;
int32 AudioBrushNum;
int32 AudioBrushNum = 0;
int32 MovieBrushNum = 0;
enum class ECropMethod
{

View File

@ -109,7 +109,7 @@ void DragDropOperator::CloseCursorDecorator()
{
if (CurrentShowDragDropWindow)
{
CurrentShowDragDropWindow->DestroyWindowImmediately();
FSlateApplication::Get().RequestDestroyWindow(CurrentShowDragDropWindow.ToSharedRef());
CurrentShowDragDropWindow.Reset();
}
}
@ -123,35 +123,35 @@ void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEv
}
if (TSharedPtr<FCutDragDropBase> DragDropBase = DragDropEvent.GetOperationAs<FCutDragDropBase>())
{
// if (DragDropBase->VirtualDraggingShow && DragDropBase->MainInterface)
// {
// if (!CurrentShowDragDropWindow)
// {
// CurrentShowDragDropWindow = SWindow::MakeCursorDecorator();
// CurrentShowDragDropWindow->SetContent(DragDropBase->VirtualDraggingShow.ToSharedRef());
// FSlateApplication::Get().AddWindowAsNativeChild(CurrentShowDragDropWindow.ToSharedRef(), FSlateApplication::Get().GetActiveTopLevelWindow().ToSharedRef(), true);
// }
// CurrentShowDragDropWindow->MoveWindowTo(FSlateApplication::Get().GetCursorPos());
// // CurrentShowDragDropWidget = DragDropBase->VirtualDraggingShow.ToSharedRef();
// // SCutMainWindow* MainWindow = static_cast<SCutMainWindow*>(SavedMainInterface);
// // if (MainWindow)
// // {
// // MainWindow->Overlay->AddSlot()
// // .HAlign(HAlign_Left)
// // .VAlign(VAlign_Top)
// // [
// // SNew(SBox)
// // .WidthOverride(80)
// // .HeightOverride(80)
// // .HAlign(HAlign_Fill)
// // .VAlign(VAlign_Fill)
// // [
// // CurrentShowDragDropWidget.ToSharedRef()
// // ]
// // ];
// // }
//
// }
if (DragDropBase->VirtualDraggingShow && DragDropBase->MainInterface)
{
if (!CurrentShowDragDropWindow)
{
CurrentShowDragDropWindow = SWindow::MakeCursorDecorator();
CurrentShowDragDropWindow->SetContent(DragDropBase->VirtualDraggingShow.ToSharedRef());
FSlateApplication::Get().AddWindowAsNativeChild(CurrentShowDragDropWindow.ToSharedRef(), FSlateApplication::Get().GetActiveTopLevelWindow().ToSharedRef(), true);
}
CurrentShowDragDropWindow->MoveWindowTo(FSlateApplication::Get().GetCursorPos());
// CurrentShowDragDropWidget = DragDropBase->VirtualDraggingShow.ToSharedRef();
// SCutMainWindow* MainWindow = static_cast<SCutMainWindow*>(SavedMainInterface);
// if (MainWindow)
// {
// MainWindow->Overlay->AddSlot()
// .HAlign(HAlign_Left)
// .VAlign(VAlign_Top)
// [
// SNew(SBox)
// .WidthOverride(80)
// .HeightOverride(80)
// .HAlign(HAlign_Fill)
// .VAlign(VAlign_Fill)
// [
// CurrentShowDragDropWidget.ToSharedRef()
// ]
// ];
// }
}
TSharedPtr<FClipsMoveDragDropOperation> ClipsMoveDragDropBase = StaticCastSharedPtr<FClipsMoveDragDropOperation>(DragDropBase);
if (DragDropBase->DragDropType == FCutDragDropBase::EType::ClipsMove)
{
@ -219,12 +219,6 @@ void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEv
const FVector2D ScrollStartPosition = ClipSelectDragDrop->ScrollStartPosition;
const FVector2D ScrollEndPosition = Timeline->TrackBodyScrollBox->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition());
// const FVector2D TestPos = Timeline->TrackBodyScrollBox->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition());
// GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::White, FString::Printf(TEXT("StartPos: %f, %f"), TestPos.X, TestPos.Y));
if (StartPosition.X < CurrentPosition.X && StartPosition.Y < CurrentPosition.Y)
{
Timeline->RenderBoxPos[0] = StartPosition;
@ -252,10 +246,22 @@ void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEv
Timeline->RenderBoxPos[1] = FVector2D(CurrentPosition.X, StartPosition.Y);
ClipSelectDragDrop->ScrollResultStartPosition = FVector2D(ScrollStartPosition.X, ScrollEndPosition.Y);
ClipSelectDragDrop->ScrollResultEndPosition = FVector2D(ScrollEndPosition.X, ScrollStartPosition.Y);
}
}
GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Cyan, FString::Printf(TEXT("%d -- %d"), 0, int32(ClipSelectDragDrop->ScrollResultEndPosition.Y / FGlobalData::DefaultTimeTickSpace)));
GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Cyan, FString::Printf(TEXT("%d -- %d"), int32(ClipSelectDragDrop->ScrollResultStartPosition.X / FGlobalData::DefaultTimeTickSpace), int32(ClipSelectDragDrop->ScrollResultEndPosition.X / FGlobalData::DefaultTimeTickSpace)));
GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Red, "\n");
GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Yellow, FString::Printf(TEXT("%1.f -- %1.f"), 0.0, ClipSelectDragDrop->ScrollResultEndPosition.Y));
GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Yellow, FString::Printf(TEXT("%1.f -- %1.f"), ClipSelectDragDrop->ScrollResultStartPosition.X, ClipSelectDragDrop->ScrollResultEndPosition.X));
GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Red, "\n");
GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Green, FString::Printf(TEXT("%1.f -- %1.f"), 0.0, Timeline->RenderBoxPos[1].Y));
GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Green, FString::Printf(TEXT("%1.f -- %1.f"), Timeline->RenderBoxPos[0].X, 0.0));
GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Red, "\n\n\n\n\n\n");
}
@ -508,8 +514,8 @@ void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEv
void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent, TSharedPtr<SWidget> DropWidget)
{
TSharedPtr<FCutDragDropBase> DragDropBase = DragDropEvent.GetOperationAs<FCutDragDropBase>();
CloseCursorDecorator();
const auto& DragDropOperation = static_cast<FTrackClipDragOperation&>(DragDropEvent.GetOperation().ToSharedRef().Get());
if (DragDropOperation.DragDropType == FCutDragDropBase::EType::ClipsMove)
@ -627,11 +633,11 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
return;
}
FClipData NewClipData(TrackHead->TrackData.DeviceTrack);
NewClipData.PresetsCustomData = PresetDragOperation->CustomData;
NewClipData.PresetType = PresetDragOperation->PresetData.PresetType;
NewClipData.ClipGuid = FGuid::NewGuid();
NewClipData.ClipType = TrackHead->TrackData.TrackType;
@ -678,7 +684,9 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
NewClipData.ResourcePropertyDataPtr = &StaticCastSharedPtr<SEffectPreset>(PresetDragOperation->PresetWidget)->NewPropertyData;
if (FUtils::DetectDragTypeCanDrop(NewClipData, TrackHead->TrackData.TrackType))
{
TrackHead->TrackData.ClipData.Add(NewClipData);
UpdateClipProcess(SavedMainInterface, NewClipData);
TrackBody->CallRender();
}
return ;
@ -686,8 +694,9 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
}
TrackHead->TrackData.ClipData.Add(NewClipData);
UpdateClipProcess(SavedMainInterface, NewClipData);
TrackBody->CallRender();
return;
}

View File

@ -62,6 +62,8 @@ void SEffectCard::Construct(const FArguments& InArgs)
FPointerEvent PointerEvent;
TSharedPtr<FEffectCardDragDrop> EffectCardDragDrop = MakeShared<FEffectCardDragDrop>();
EffectCardDragDrop->MainInterface = MainInterface;
EffectCardDragDrop->VirtualDraggingShow = VirtualDraggingShow;
OnDragDetected(Geometry, PointerEvent).BeginDragDrop(EffectCardDragDrop.ToSharedRef());
})
.ClickMethod(EButtonClickMethod::MouseDown)
@ -151,6 +153,41 @@ void SEffectCard::Construct(const FArguments& InArgs)
];
VirtualDraggingShow =
SNew(SBox)
.WidthOverride(76.0f)
.HeightOverride(76.0f)
// .Padding(0, 3, 3, 3)
[
SNew(SOverlay)
+ SOverlay::Slot()
[
SNew(SImage)
.Image(CardProperty->bIsActive ? FUtils::GetBrushFromImage(FUtils::GetResourcesPath("EffectCard.png"), FVector2D(128.0, 128.0)) :
FUtils::GetBrushFromImage(FUtils::GetResourcesPath("EffectCardUnSelected.png"), FVector2D(128.0, 128.0)))
.Visibility(EVisibility::HitTestInvisible)
]
+ SOverlay::Slot()
.VAlign(VAlign_Center)
.HAlign(HAlign_Center)
.Padding(0, 0, 0, 11.0f)
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("Card.png"), FVector2D(40.0, 40.0)))
.Visibility(EVisibility::HitTestInvisible)
]
+ SOverlay::Slot()
.VAlign(VAlign_Bottom)
.HAlign(HAlign_Center)
.Padding(0, 0, 0, 11.0f)
[
SNew(SInlineEditableTextBlock)
.Visibility(GroupProperty->bIsDedicated ? CardProperty->bIsActive ? EVisibility::HitTestInvisible : EVisibility::Visible : EVisibility::Visible)
.Text(FText::FromString(CardProperty->Name))
]
];
PropertiesInterfaceGUID = CardProperty->Guid;
}

View File

@ -59,6 +59,8 @@ public:
FString CardName;
TSharedPtr<SWidget> VirtualDraggingShow;
};

View File

@ -22,7 +22,7 @@ void SEffectPreset::Construct(const FArguments& InArgs)
PresetPath = InArgs._PresetPath;
PresetType = InArgs._PresetType;
MainInterface = InArgs._MainInterface;
CustomType = InArgs._CustomType;
if (!PresetPath.IsEmpty())
@ -43,10 +43,15 @@ void SEffectPreset::Construct(const FArguments& InArgs)
FMemoryReader MemoryReader(Data);
MemoryReader << PresetsData;
PresetsCustomData.Colors = PresetsData.Colors;
}
}
PresetsData.PresetType = EPresetType::Custom;
PresetsCustomData.Colors = PresetsData.Colors;
PresetsCustomData.PresetCustomType = CustomType;
PresetsData.PresetType = PresetType;
ChildSlot
@ -340,6 +345,33 @@ FReply SEffectPreset::OnDragDetected(const FGeometry& MyGeometry, const FPointer
DragOperation->PresetData = PresetsData;
DragOperation->CustomData = PresetsCustomData;
DragOperation->PresetWidget = SharedThis(this);
DragOperation->MainInterface = MainInterface;
DragOperation->VirtualDraggingShow = SNew(SBox)
.WidthOverride(80)
.HeightOverride(80)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.Padding(2)
[
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SButton)
.ButtonStyle(FCutButtonStyle::Get(), "Preset.PresetButton")
]
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(Name))
.Justification(ETextJustify::Center)
.Visibility(EVisibility::HitTestInvisible)
]
];
return FReply::Handled().BeginDragDrop(DragOperation.ToSharedRef());
}

View File

@ -21,6 +21,7 @@ public:
SLATE_ARGUMENT(FString, PresetPath)
SLATE_ARGUMENT(EPresetType, PresetType)
SLATE_ARGUMENT(ICutMainWidgetInterface*, MainInterface)
SLATE_ARGUMENT(FPresetsCustomData::EPresetCustomType, CustomType)
SLATE_END_ARGS()
/** Constructs this widget with InArgs */
@ -28,6 +29,7 @@ public:
FString Name;
FString PresetPath;
FPresetsCustomData::EPresetCustomType CustomType;
FPresetsData PresetsData;
ICutMainWidgetInterface* MainInterface;
FTimelinePropertyData NewPropertyData;

View File

@ -325,7 +325,7 @@ void SCustomInputPanel::Construct(const FArguments& InArgs)
AddPreset(TEXT("结束后常亮"), TEXT(""), EPresetType::Custom);
AddPreset(TEXT("渐变"), TEXT(""), EPresetType::Custom);
AddPreset(TEXT("渐变"), TEXT(""), EPresetType::Custom, FPresetsCustomData::EPresetCustomType::Gradient);
AddPreset(TEXT("亮白"), TEXT("亮白.dat"), EPresetType::Custom);
AddPreset(TEXT("红色"), TEXT("红色.dat"), EPresetType::Custom);
AddPreset(TEXT("紫色"), TEXT("紫色.dat"), EPresetType::Custom);
@ -394,9 +394,9 @@ FReply SCustomInputPanel::OnDrop(const FGeometry& MyGeometry, const FDragDropEve
}
}
return FReply::Handled().EndDragDrop();
return FReply::Handled();
}
return FReply::Handled().EndDragDrop();
return SCompoundWidget::OnDrop(MyGeometry, DragDropEvent);
}
void SCustomInputPanel::LoadAudio(FString Path)
@ -576,7 +576,7 @@ void SCustomInputPanel::ClearPanel()
PropertyData.Empty();
}
void SCustomInputPanel::AddPreset(const FString& Name, const FString& PresetPath, EPresetType PresetType)
void SCustomInputPanel::AddPreset(const FString& Name, const FString& PresetPath, EPresetType PresetType, FPresetsCustomData::EPresetCustomType CustomType)
{
if (Name != "")
{
@ -587,6 +587,7 @@ void SCustomInputPanel::AddPreset(const FString& Name, const FString& PresetPath
.PresetPath(PresetPath)
.MainInterface(MainWidgetInterface)
.PresetType(PresetType)
.CustomType(CustomType)
];
}
}

View File

@ -54,7 +54,7 @@ public:
void SavePanel(const FString& SavePlace);
void LoadPanel(const FString& LoadPlace);
void ClearPanel();
void AddPreset(const FString& Name, const FString& PresetPath, EPresetType PresetType = EPresetType::Custom);
void AddPreset(const FString& Name, const FString& PresetPath, EPresetType PresetType = EPresetType::Custom, FPresetsCustomData::EPresetCustomType CustomType = FPresetsCustomData::EPresetCustomType::None);
void AddCustomPreset();
bool bIsAssetPanel = false;
bool bIsEditMode = false;

View File

@ -84,12 +84,14 @@ FReply SCustomInputResource::OnDragDetected(const FGeometry& MyGeometry, const F
Operation->MainInterface = MainInterface;
Operation->VirtualDraggingShow = SNew(SBox)
.WidthOverride(80)
.HeightOverride(80)
.WidthOverride(155)
.HeightOverride(76)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SImage).Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath(PropertyData.IconPath), {}))
SNew(SImage)
.Image( (PropertyData.VideoStream == -1 && PropertyData.AudioStream != -1) ? FUtils::GetBrushFromImage(FUtils::GetResourcesPath(TEXT("Music.png")), {}) :
PropertyData.bIsCustomPresetData == false ? FUtils::GetBrushFromImage(PropertyData.IconPath, {}) : FUtils::GetBrushFromImage(FUtils::GetResourcesPath("CustomPreset.png"), {}))
];
return FReply::Handled().BeginDragDrop(Operation.ToSharedRef());

View File

@ -405,6 +405,7 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
if (TrackData.ClipData[j].ClipGuid == CutTimeline->SelectedClips[i])
{
TrackData.ClipData.RemoveAt(j);
UpdateProperties(nullptr);
}
}
StaticCastSharedPtr<STrackBody>(TrackGroupInstance.Body)->CallRender();

View File

@ -743,7 +743,7 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
}
for (FSlateBrush& SlateBrush : NewBrushes)
{
FSlateDrawElement::MakeBox(OutDrawElements, LayerId + 3, AllottedGeometry.ToPaintGeometry(FVector2f(XLength / NewBrushes.Num(), AllottedGeometry.GetLocalSize().Y), FSlateLayoutTransform(FVector2f(i * (XLength / NewBrushes.Num()), 0))), &SlateBrush);
FSlateDrawElement::MakeBox(OutDrawElements, LayerId + 5, AllottedGeometry.ToPaintGeometry(FVector2f(XLength / NewBrushes.Num(), AllottedGeometry.GetLocalSize().Y), FSlateLayoutTransform(FVector2f(i * (XLength / NewBrushes.Num()), 0))), &SlateBrush);
i++;
}
}
@ -803,7 +803,7 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None)
{
const FSlateBrush Brush;
FSlateDrawElement::MakeBox(OutDrawElements, LayerId + 3, AllottedGeometry.ToPaintGeometry(),
FSlateDrawElement::MakeBox(OutDrawElements, LayerId + 4, AllottedGeometry.ToPaintGeometry(),
&Brush, ESlateDrawEffect::None, ClipData->PresetsCustomData.Colors[0]);
}
if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient)

View File

@ -64,6 +64,35 @@ FReply STimelineProperty::OnDragDetected(const FGeometry& MyGeometry, const FPoi
Operation->MainInterface = MainInterface;
Operation->DeviceName = TimelinePropertyData.Name;
Operation->TrackType = TimelinePropertyData.Type;
Operation->VirtualDraggingShow =
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))
]
];
return FReply::Handled().BeginDragDrop(Operation.ToSharedRef());
}

View File

@ -159,6 +159,7 @@ void STrackBody::RemoveClip(const FGuid& Guid)
{
TrackHead->TrackData.ClipData.RemoveAt(i);
SlateClips.RemoveAt(i);
MainWidgetInterface->UpdateProperties(nullptr);
break;
}
}

View File

@ -143,6 +143,7 @@ TSharedPtr<SWidget> FClipProxy::GetPropertiesWidget()
ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Gradient;
if (ClipData->PresetsCustomData.Cursors.Num() < 2)
{
ClipData->PresetsCustomData.Cursors.Empty();
ClipData->PresetsCustomData.Cursors.Add(FCursorData(0, FLinearColor::Red));
ClipData->PresetsCustomData.Cursors.Add(FCursorData(10, FLinearColor::Green));
}