修改组

This commit is contained in:
Sch 2023-08-17 21:38:59 +08:00
parent 7347bee2f3
commit 447a7ffd89
3 changed files with 84 additions and 8 deletions

View File

@ -454,6 +454,7 @@ public:
MovePanel,
MoveTickCursor,
SelectClips,
ClipsMove,
};
FCutDragDropBase() {};
FCutDragDropBase(EType InType)
@ -465,6 +466,7 @@ public:
TSharedPtr<IWidgetInterface> MoveAboutWidget;
class ICutMainWidgetInterface* MainInterface;
float DragOffset = 0.0f;
float OriginOffset = 0.0f;
EType DragDropType = EType::TrackClip;
ETrackType ManualClipType = ETrackType::None;
@ -505,7 +507,13 @@ public:
TSharedPtr<SWidget> TrackBody;
};
class CUT5_API FClipsMoveDragDropOperation final : public FCutDragDropBase
{
public:
FClipsMoveDragDropOperation() { DragDropType = EType::ClipsMove; }
TArray<FClipData> OriginClipData;
};
class CUT5_API FCurtainDragDrop final : public FCutDragDropBase
{

View File

@ -97,6 +97,38 @@ void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEv
{
if (TSharedPtr<FCutDragDropBase> DragDropBase = DragDropEvent.GetOperationAs<FCutDragDropBase>())
{
TSharedPtr<FClipsMoveDragDropOperation> ClipsMoveDragDropBase = StaticCastSharedPtr<FClipsMoveDragDropOperation>(DragDropBase);
if (DragDropBase->DragDropType == FCutDragDropBase::EType::ClipsMove)
{
for (FClipData& OriginClipData : ClipsMoveDragDropBase->OriginClipData)
{
for (FSingleTrackGroupInstance& TrackGroupInstance : DragDropBase->MainInterface->GetCutTimeline()->TrackGroupInstances)
{
TSharedPtr<STrackHead> Head = StaticCastSharedPtr<STrackHead>(TrackGroupInstance.Head);
TSharedPtr<STrackBody> Body = StaticCastSharedPtr<STrackBody>(TrackGroupInstance.Body);
float X = Body->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / FGlobalData::DefaultTimeTickSpace;
for (TSharedPtr<STimelineClip> Clip : Body->SlateClips)
{
if (Clip->ClipData->ClipGuid == OriginClipData.ClipGuid)
{
const float OriginOffset = OriginClipData.ClipStartFrame * FGlobalData::DefaultTimeTickSpace - (X / FGlobalData::DefaultTimeTickSpace) - DragDropBase->DragOffset / FGlobalData::DefaultTimeTickSpace;
float DragOffset = DragDropBase->DragOffset / FGlobalData::DefaultTimeTickSpace;
float Length = Clip->ClipData->ClipEndFrame - Clip->ClipData->ClipStartFrame;
Clip->ClipData->ClipStartFrame = X - DragOffset + OriginOffset / FGlobalData::DefaultTimeTickSpace;
Clip->ClipData->ClipEndFrame = X + Length - DragOffset + OriginOffset / FGlobalData::DefaultTimeTickSpace;
Clip->ClipDataBox->SetWidthOverride(Length * FGlobalData::DefaultTimeTickSpace);
Clip->SetRenderTransform(FSlateRenderTransform(FVector2D(Clip->ClipData->ClipStartFrame * FGlobalData::DefaultTimeTickSpace, 0)));
}
}
Body->CallRender();
}
}
return;
}
if (DragDropBase->DragDropType == FCutDragDropBase::EType::SelectClips)
{
TSharedPtr<FClipSelectDragDrop> ClipSelectDragDrop = DragDropEvent.GetOperationAs<FClipSelectDragDrop>();
@ -370,6 +402,14 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
{
const auto& DragDropOperation = static_cast<FTrackClipDragOperation&>(DragDropEvent.GetOperation().ToSharedRef().Get());
if (DragDropOperation.DragDropType == FCutDragDropBase::EType::ClipsMove)
{
return;
}
if (DragDropOperation.DragDropType == FCutDragDropBase::EType::SelectClips)
{
TSharedPtr<FClipSelectDragDrop> ClipSelectDragDrop = DragDropEvent.GetOperationAs<FClipSelectDragDrop>();

View File

@ -94,14 +94,42 @@ FReply STimelineClip::OnBorderMouseButtonDown(const FGeometry& Geometry, const F
}
else
{
const TSharedPtr<FClip2ClipDragDropOperation> Clip2ClipDragDropOperation = MakeShared<FClip2ClipDragDropOperation>();
Clip2ClipDragDropOperation->TrackBody = StaticCastSharedPtr<STrackBody>(Body);
Clip2ClipDragDropOperation->DraggingWidget = SharedThis(this);
Clip2ClipDragDropOperation->DragDropType = FCutDragDropBase::EType::Clip2Clip;
Clip2ClipDragDropOperation->DragType = FClip2ClipDragDropOperation::EDragType::Move;
Clip2ClipDragDropOperation->OverrideWidget = Body;
Clip2ClipDragDropOperation->DragOffset = LocalPos.X;
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton).BeginDragDrop(Clip2ClipDragDropOperation.ToSharedRef());
if (MainWidgetInterface->GetCutTimeline()->SelectedClips.Num() <= 1)
{
const TSharedPtr<FClip2ClipDragDropOperation> Clip2ClipDragDropOperation = MakeShared<FClip2ClipDragDropOperation>();
Clip2ClipDragDropOperation->TrackBody = StaticCastSharedPtr<STrackBody>(Body);
Clip2ClipDragDropOperation->DraggingWidget = SharedThis(this);
Clip2ClipDragDropOperation->DragDropType = FCutDragDropBase::EType::Clip2Clip;
Clip2ClipDragDropOperation->DragType = FClip2ClipDragDropOperation::EDragType::Move;
Clip2ClipDragDropOperation->OverrideWidget = Body;
Clip2ClipDragDropOperation->DragOffset = LocalPos.X;
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton).BeginDragDrop(Clip2ClipDragDropOperation.ToSharedRef());
}
else
{
const TSharedPtr<FClipsMoveDragDropOperation> Clip2ClipDragDropOperation = MakeShared<FClipsMoveDragDropOperation>();
Clip2ClipDragDropOperation->MainInterface = MainWidgetInterface;
Clip2ClipDragDropOperation->DragOffset = LocalPos.X;
float X = StaticCastSharedPtr<STrackBody>(Body)->GetCachedGeometry().AbsoluteToLocal(PointerEvent.GetScreenSpacePosition()).X / FGlobalData::DefaultTimeTickSpace;
Clip2ClipDragDropOperation->OriginOffset = ClipData->ClipStartFrame - X / FGlobalData::DefaultTimeTickSpace;
for (FSingleTrackGroupInstance& TrackGroupInstance : MainWidgetInterface->GetCutTimeline()->TrackGroupInstances)
{
TSharedPtr<STrackBody> TrackBody = StaticCastSharedPtr<STrackBody>(TrackGroupInstance.Body);
for (TSharedPtr<STimelineClip> Clip : TrackBody->SlateClips)
{
if (MainWidgetInterface->GetCutTimeline()->SelectedClips.Contains(Clip->ClipData->ClipGuid))
{
Clip2ClipDragDropOperation->OriginClipData.Add(*Clip->ClipData);
}
}
}
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton).BeginDragDrop(Clip2ClipDragDropOperation.ToSharedRef());
}
}
return SCompoundWidget::OnMouseButtonDown(Geometry, PointerEvent);