diff --git a/Source/Cut5/Widgets/DefineGlobal.h b/Source/Cut5/Widgets/DefineGlobal.h index 7de3376..025a036 100644 --- a/Source/Cut5/Widgets/DefineGlobal.h +++ b/Source/Cut5/Widgets/DefineGlobal.h @@ -271,7 +271,9 @@ struct CUT5_API FPresetsCustomData struct CUT5_API FClipData { - FClipData(){}; + FClipData() + { + }; FClipData(const FDeviceTrack& BindTrack) { BindTrackGuid = BindTrack.Guid; @@ -331,6 +333,20 @@ struct CUT5_API FClipData FromFront, FromBack, }; + void UpdateGradientCursor() + { + if (PresetType == EPresetType::Gradient) + { + int32 OffsetFrame = ClipEndFrame - ClipStartFrame; + for (int32 i = 0; i < Cursors.Num(); i++) + { + if (Cursors[i].CursorFrameOffset > OffsetFrame) + { + Cursors[i].CursorFrameOffset = OffsetFrame; + } + } + } + } void CropClip(ECropMethod CropMethod, int32 CropFrame) { if (CropMethod == ECropMethod::FromFront) @@ -340,17 +356,7 @@ struct CUT5_API FClipData { VideoStartFrame += CropFrame; } - if (ClipType == ETrackType::AtomSphereLightTrack) - { - int32 OffsetFrame = ClipEndFrame - ClipStartFrame + CropFrame; - for (int32 i = 0; i < Cursors.Num(); i++) - { - if (Cursors[i].CursorFrameOffset < OffsetFrame) - { - Cursors[i].CursorFrameOffset = OffsetFrame; - } - } - } + } else @@ -360,15 +366,16 @@ struct CUT5_API FClipData { VideoEndFrame -= CropFrame; } - if (ClipType == ETrackType::AtomSphereLightTrack) + + } + if (PresetType == EPresetType::Gradient) + { + int32 OffsetFrame = ClipEndFrame - ClipStartFrame; + for (int32 i = 0; i < Cursors.Num(); i++) { - int32 OffsetFrame = ClipEndFrame - ClipStartFrame; - for (int32 i = 0; i < Cursors.Num(); i++) + if (Cursors[i].CursorFrameOffset > OffsetFrame) { - if (Cursors[i].CursorFrameOffset > OffsetFrame) - { - Cursors[i].CursorFrameOffset = OffsetFrame; - } + Cursors[i].CursorFrameOffset = OffsetFrame; } } } @@ -521,6 +528,7 @@ class CUT5_API FPresetDragOperation final : public FCutDragDropBase public: // It's a Ptr to Resource; FPresetsData PresetData = FPresetsData(); + TSharedPtr PresetWidget; }; class CUT5_API FColorDragOperation final : public FCutDragDropBase diff --git a/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp b/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp index 559e4e3..43898a2 100644 --- a/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp +++ b/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp @@ -9,6 +9,7 @@ #include "Cut5/Widgets/STrackBody.h" #include "Cut5/Widgets/MicroWidgets/SColorBar.h" #include "Cut5/Widgets/MicroWidgets/SColorPanel.h" +#include "Cut5/Widgets/Presets/SEffectPreset.h" DragDropOperator* DragDropOperator::Operator = nullptr; @@ -36,6 +37,10 @@ void DragDropOperator::UpdateClipProcess(ICutMainWidgetInterface* MainInterface, { continue; } + if (!TrackHead->TrackData.ClipData.Contains(TimelineClip)) + { + continue; + } const double ClipStartFrame = TrackHead->TrackData.ClipData[i].ClipStartFrame; const double ClipEndFrame = TrackHead->TrackData.ClipData[i].ClipEndFrame; @@ -47,25 +52,33 @@ void DragDropOperator::UpdateClipProcess(ICutMainWidgetInterface* MainInterface, // Left FClipData LeftClipData = SaveClipData; - LeftClipData.ClipEndFrame = TimelineClip.ClipStartFrame; + LeftClipData.CropClip(FClipData::ECropMethod::FromBack, LeftClipData.ClipEndFrame - TimelineClip.ClipStartFrame); + LeftClipData.ClipGuid = FGuid::NewGuid(); + LeftClipData.UpdateGradientCursor(); TrackHead->TrackData.ClipData.Add(LeftClipData); FClipData RightClipData = SaveClipData; - RightClipData.ClipStartFrame = TimelineClip.ClipEndFrame; + int32 Offset = TimelineClip.ClipEndFrame - RightClipData.ClipStartFrame; + + RightClipData.CropClip(FClipData::ECropMethod::FromFront, Offset); + RightClipData.ClipGuid = FGuid::NewGuid(); + RightClipData.UpdateGradientCursor(); TrackHead->TrackData.ClipData.Add(RightClipData); continue; } - if (TimelineClip.ClipStartFrame <= ClipEndFrame && TimelineClip.ClipEndFrame >= ClipEndFrame) + if (TimelineClip.ClipStartFrame <= ClipEndFrame && TimelineClip.ClipStartFrame >= ClipStartFrame && TimelineClip.ClipEndFrame >= ClipEndFrame) { // It mean the new clip start point is in the old clip int32 NewStartFrame = TimelineClip.ClipStartFrame; int32 LeftCropFrame = TrackHead->TrackData.ClipData[i].ClipEndFrame - NewStartFrame; TrackHead->TrackData.ClipData[i].CropClip(FClipData::ECropMethod::FromBack, LeftCropFrame); + + continue; } - if (TimelineClip.ClipEndFrame > ClipStartFrame && TimelineClip.ClipStartFrame < ClipStartFrame) + if (TimelineClip.ClipEndFrame > ClipStartFrame && TimelineClip.ClipStartFrame < ClipStartFrame && TimelineClip.ClipEndFrame <= ClipEndFrame) { // It mean the new clip end point is in the old clip TrackHead->TrackData.ClipData[i].CropClip(FClipData::ECropMethod::FromFront, (TimelineClip.ClipEndFrame - ClipStartFrame)); @@ -82,12 +95,14 @@ void DragDropOperator::UpdateClipProcess(ICutMainWidgetInterface* MainInterface, // // NewClipData.CropClip(FClipData::ECropMethod::FromFront, SelectedClipFrame + 1); // TrackHead->TrackData.ClipData.Add(NewClipData); + + TrackHead->TrackData.ClipData[i].UpdateGradientCursor(); } - + TimelineClip.UpdateGradientCursor(); + } return; - } @@ -337,27 +352,29 @@ void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEv } if (DragDropOperation.DragType == FClip2ClipDragDropOperation::EDragType::Move) { - TSharedPtr TimelineClip = StaticCastSharedPtr(DragDropOperation.DraggingWidget); // TimelineClip->ClipData->ClipStartFrame += NewPos; // TimelineClip->ClipData->ClipEndFrame += NewPos; - - - - for (FSingleTrackGroupInstance& TrackGroupInstance : Body->MainWidgetInterface->GetCutTimeline()->TrackGroupInstances) + if (TimelineClip->ClipData->ClipStartFrame + NewPos >= 0) { - TSharedPtr TrackBody = StaticCastSharedPtr(TrackGroupInstance.Body); - TrackBody->DragDropShowProperties.Empty(); - TrackBody->bNeedRenderDragDropOver = false; - } + for (FSingleTrackGroupInstance& TrackGroupInstance : Body->MainWidgetInterface->GetCutTimeline()->TrackGroupInstances) + { + TSharedPtr TrackBody = StaticCastSharedPtr(TrackGroupInstance.Body); + TrackBody->DragDropShowProperties.Empty(); + TrackBody->bNeedRenderDragDropOver = false; + } - Body->DragDropShowProperties.Empty(); - Body->bNeedRenderDragDropOver = true; - IDragDropShowInterface::FDragDropShowProperties NewProperty = IDragDropShowInterface::FDragDropShowProperties( - FVector2D((TimelineClip->ClipData->ClipStartFrame + NewPos) * FGlobalData::DefaultTimeTickSpace, 0), - FVector2D(((TimelineClip->ClipData->ClipEndFrame + NewPos) - (TimelineClip->ClipData->ClipStartFrame + NewPos)) * FGlobalData::DefaultTimeTickSpace, Body->GetCachedGeometry().GetLocalSize().Y), - FUtils::DetectDragTypeCanDrop(*TimelineClip->ClipData, Body->TrackHead->TrackData.TrackType) ? FLinearColor(0, 1, 0, 1) : FLinearColor(1, 0, 0, 1)); - Body->DragDropShowProperties.Add(NewProperty); + Body->DragDropShowProperties.Empty(); + Body->bNeedRenderDragDropOver = true; + IDragDropShowInterface::FDragDropShowProperties NewProperty = IDragDropShowInterface::FDragDropShowProperties( + FVector2D((TimelineClip->ClipData->ClipStartFrame + NewPos) * FGlobalData::DefaultTimeTickSpace, 0), + FVector2D(((TimelineClip->ClipData->ClipEndFrame + NewPos) - (TimelineClip->ClipData->ClipStartFrame + NewPos)) * FGlobalData::DefaultTimeTickSpace, Body->GetCachedGeometry().GetLocalSize().Y), + FUtils::DetectDragTypeCanDrop(*TimelineClip->ClipData, Body->TrackHead->TrackData.TrackType) ? FLinearColor(0, 1, 0, 1) : FLinearColor(1, 0, 0, 1)); + Body->DragDropShowProperties.Add(NewProperty); + + } + + @@ -381,7 +398,7 @@ void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEv static_cast(Body->MainWidgetInterface)->RenderLineTime = static_cast(Body->MainWidgetInterface)->GetCachedGeometry().AbsoluteToLocal(TimelineClip->GetCachedGeometry().GetAbsolutePosition()).X + NewPos * FGlobalData::DefaultTimeTickSpace; bRenderLine = true; } - if ((TimelineClip->ClipData->ClipEndFrame + NewPos - 1) == Clip->ClipData->ClipStartFrame) + if ((TimelineClip->ClipData->ClipEndFrame + NewPos) == Clip->ClipData->ClipStartFrame) { static_cast(Body->MainWidgetInterface)->bRenderLine = true; static_cast(Body->MainWidgetInterface)->RenderLineTime = static_cast(Body->MainWidgetInterface)->GetCachedGeometry().AbsoluteToLocal(Clip->GetCachedGeometry().GetAbsolutePosition()).X; @@ -582,7 +599,10 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& if (PresetDragOperation->PresetData.PresetType == EPresetType::Video) { NewClipData.ClipType = ETrackType::VideoTrack; - if (FUtils::DetectDragTypeCanDrop(NewClipData, TrackHead->TrackData.TrackType) + NewClipData.PresetType = EPresetType::Video; + NewClipData.ResourcePropertyGuid = StaticCastSharedPtr(PresetDragOperation->PresetWidget)->NewPropertyData.Guid; + NewClipData.ResourcePropertyDataPtr = &StaticCastSharedPtr(PresetDragOperation->PresetWidget)->NewPropertyData; + if (FUtils::DetectDragTypeCanDrop(NewClipData, TrackHead->TrackData.TrackType)) { TrackHead->TrackData.ClipData.Add(NewClipData); TrackBody->CallRender(); @@ -751,9 +771,25 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& if (ClipDragOperation.DragType == FClip2ClipDragDropOperation::EDragType::Move) { - const float NewPos = (TrackBody->MainWidgetInterface->GetCutTimeline()->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X - DragDropOperation.DragOffset) / FGlobalData::DefaultTimeTickSpace; - TimelineClip->ClipData->ClipStartFrame += (NewPos + (NewPos < 0 ? 1 : 0)); - TimelineClip->ClipData->ClipEndFrame += (NewPos + (NewPos < 0 ? 1 : 0)); + if (FUtils::DetectDragTypeCanDrop(*TimelineClip->ClipData, TrackHead->TrackData.TrackType)) + { + const int32 NewPos = (TrackBody->MainWidgetInterface->GetCutTimeline()->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X - DragDropOperation.DragOffset) / FGlobalData::DefaultTimeTickSpace; + if (TimelineClip->ClipData->ClipStartFrame + NewPos < 0) + { + const int32 Offset = TimelineClip->ClipData->ClipEndFrame - TimelineClip->ClipData->ClipStartFrame; + TimelineClip->ClipData->ClipStartFrame = 0; + TimelineClip->ClipData->ClipEndFrame = Offset; + + } + else + { + TimelineClip->ClipData->ClipStartFrame += NewPos; + TimelineClip->ClipData->ClipEndFrame += NewPos; + } + } + + + } @@ -762,6 +798,7 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& // It mean the clip is not in the same track FClipData NewClipData = *TimelineClip->ClipData; + NewClipData.ClipType = TrackHead->TrackData.TrackType; if (FUtils::DetectDragTypeCanDrop(NewClipData, TrackHead->TrackData.TrackType) == false) { return; diff --git a/Source/Cut5/Widgets/Presets/SEffectPreset.cpp b/Source/Cut5/Widgets/Presets/SEffectPreset.cpp index 59d004b..83fb219 100644 --- a/Source/Cut5/Widgets/Presets/SEffectPreset.cpp +++ b/Source/Cut5/Widgets/Presets/SEffectPreset.cpp @@ -336,6 +336,7 @@ FReply SEffectPreset::OnDragDetected(const FGeometry& MyGeometry, const FPointer DragOperation->DragDropType = FCutDragDropBase::EType::PresetDrag; DragOperation->PresetData = PresetsData; + DragOperation->PresetWidget = SharedThis(this); return FReply::Handled().BeginDragDrop(DragOperation.ToSharedRef()); } diff --git a/Source/Cut5/Widgets/SCutMainWindow.cpp b/Source/Cut5/Widgets/SCutMainWindow.cpp index 10216df..d020b99 100644 --- a/Source/Cut5/Widgets/SCutMainWindow.cpp +++ b/Source/Cut5/Widgets/SCutMainWindow.cpp @@ -1328,14 +1328,14 @@ tinyxml2::XMLElement* SCutMainWindow::GetVideoElement(tinyxml2::XMLElement* Pare tinyxml2::XMLElement* ProjectorEventList = Video->InsertNewChildElement("ProjectorEventList"); { - tinyxml2::XMLElement* ProjectorEvent = ProjectorEventList->InsertNewChildElement("ProjectorEvent"); + tinyxml2::XMLElement* ProjectorEvent1 = ProjectorEventList->InsertNewChildElement("ProjectorEvent"); { - tinyxml2::XMLElement* ProjectorTimeCode = ProjectorEvent->InsertNewChildElement("TimeCode"); + tinyxml2::XMLElement* ProjectorTimeCode = ProjectorEvent1->InsertNewChildElement("TimeCode"); { ProjectorTimeCode->InsertNewText(TCHAR_TO_UTF8(*FUtils::GetMsFromString(FGlobalData::GetTimeData(EncodeVideoInfo.ClipStartFrame)))); } - tinyxml2::XMLElement* Value = ProjectorEvent->InsertNewChildElement("Value"); + tinyxml2::XMLElement* Value = ProjectorEvent1->InsertNewChildElement("Value"); { Value->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(1))); } diff --git a/Source/Cut5/Widgets/SStartMenu.cpp b/Source/Cut5/Widgets/SStartMenu.cpp index 6b17cdc..8265261 100644 --- a/Source/Cut5/Widgets/SStartMenu.cpp +++ b/Source/Cut5/Widgets/SStartMenu.cpp @@ -7,6 +7,7 @@ #include "IDesktopPlatform.h" #include "SlateOptMacros.h" #include "Cut5/Utils/Utils.h" +#include "Widgets/Layout/SGridPanel.h" BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION @@ -27,6 +28,7 @@ void SStartMenu::Construct(const FArguments& InArgs) [ SNew(SVerticalBox) + SVerticalBox::Slot() + .SizeParam(FStretch(0.3)) [ SNew(SHorizontalBox) + SHorizontalBox::Slot() @@ -60,6 +62,11 @@ void SStartMenu::Construct(const FArguments& InArgs) }) ] ] + + SVerticalBox::Slot() + .SizeParam(FStretch(0.7)) + [ + SNew(SGridPanel) + ] ] ]; diff --git a/Source/Cut5/Widgets/STimelineClip.cpp b/Source/Cut5/Widgets/STimelineClip.cpp index e466dc0..194b112 100644 --- a/Source/Cut5/Widgets/STimelineClip.cpp +++ b/Source/Cut5/Widgets/STimelineClip.cpp @@ -377,11 +377,24 @@ void STimelineClip::Seek(int32 Frame) Between = i; } } + if (SeekMovieFrame >= ClipData->Cursors[ClipData->Cursors.Num() - 1].CursorFrameOffset) + { + Between = ClipData->Cursors.Num() - 1; + } if (Between != -1) { - FLinearColor LinearColor = FLinearColor::Black; - LinearColor = FMath::Lerp(ClipData->Cursors[Between].Color, ClipData->Cursors[Between + 1].Color, (float)(SeekMovieFrame - ClipData->Cursors[Between].CursorFrameOffset) / (float)(ClipData->Cursors[Between + 1].CursorFrameOffset - ClipData->Cursors[Between].CursorFrameOffset)); - MainWidgetInterface->OnUpdateSpotLight(0, LinearColor.ToFColor(false)); + if (Between == ClipData->Cursors.Num() - 1) + { + MainWidgetInterface->OnUpdateSpotLight(0, ClipData->Cursors[Between].Color.ToFColor(false)); + break; + } + else + { + FLinearColor LinearColor = FLinearColor::Black; + LinearColor = FMath::Lerp(ClipData->Cursors[Between].Color, ClipData->Cursors[Between + 1].Color, (float)(SeekMovieFrame - ClipData->Cursors[Between].CursorFrameOffset) / (float)(ClipData->Cursors[Between + 1].CursorFrameOffset - ClipData->Cursors[Between].CursorFrameOffset)); + MainWidgetInterface->OnUpdateSpotLight(0, LinearColor.ToFColor(false)); + } + } } @@ -451,35 +464,34 @@ void STimelineClip::Seek(int32 Frame) int32 Between = -1; for (int32 i = 0; i < ClipData->Cursors.Num() - 1; i++) { - if (i == 0) - { - if (SeekMovieFrame <= ClipData->Cursors[i].CursorFrameOffset) - { - Between = i; - } - } - if (i == ClipData->Cursors.Num() - 2) - { - if (SeekMovieFrame >= ClipData->Cursors[i].CursorFrameOffset && SeekMovieFrame <= ClipData->Cursors[i + 1].CursorFrameOffset) - { - Between = i; - } - } - if (SeekMovieFrame >= ClipData->Cursors[i].CursorFrameOffset && SeekMovieFrame <= ClipData->Cursors[i + 1].CursorFrameOffset) { Between = i; } } + if (SeekMovieFrame >= ClipData->Cursors[ClipData->Cursors.Num() - 1].CursorFrameOffset) + { + Between = ClipData->Cursors.Num() - 1; + } if (Between != -1) { - TArray Colors; - Colors.Init(FLinearColor::Black.ToFColor(false), FGlobalData::LightArrayX * FGlobalData::LightArrayY * 4); - for (int32 i = 0; i < FGlobalData::LightArrayX * FGlobalData::LightArrayY; i++) + if (Between == ClipData->Cursors.Num() - 1) { - Colors[i] = FMath::Lerp(ClipData->Cursors[Between].Color, ClipData->Cursors[Between + 1].Color, (float)(SeekMovieFrame - ClipData->Cursors[Between].CursorFrameOffset) / (float)(ClipData->Cursors[Between + 1].CursorFrameOffset - ClipData->Cursors[Between].CursorFrameOffset)).ToFColor(false); + TArray Colors; + Colors.Init(ClipData->Cursors[ClipData->Cursors.Num() - 1].Color.ToFColor(false), FGlobalData::LightArrayX * FGlobalData::LightArrayY * 4); + MainWidgetInterface->OnUpdateLightArray(Colors); } - MainWidgetInterface->OnUpdateLightArray(Colors); + else + { + TArray Colors; + Colors.Init(FLinearColor::Black.ToFColor(false), FGlobalData::LightArrayX * FGlobalData::LightArrayY * 4); + for (int32 i = 0; i < FGlobalData::LightArrayX * FGlobalData::LightArrayY; i++) + { + Colors[i] = FMath::Lerp(ClipData->Cursors[Between].Color, ClipData->Cursors[Between + 1].Color, (float)(SeekMovieFrame - ClipData->Cursors[Between].CursorFrameOffset) / (float)(ClipData->Cursors[Between + 1].CursorFrameOffset - ClipData->Cursors[Between].CursorFrameOffset)).ToFColor(false); + } + MainWidgetInterface->OnUpdateLightArray(Colors); + } + } break; @@ -617,7 +629,7 @@ void STimelineClip::Seek(int32 Frame) void STimelineClip::UpdatePosition(int32 StartFrame) { - if (StartFrame - ClipData->ClipEndFrame >= -1) + if (ClipData->ClipEndFrame - StartFrame <= 1) { return; } @@ -646,6 +658,10 @@ void STimelineClip::UpdatePosition(int32 StartFrame) void STimelineClip::UpdateLength(int32 EndFrame) { + if (EndFrame - ClipData->ClipStartFrame <= 1) + { + return; + } ClipDataBox->SetWidthOverride((EndFrame - ClipData->ClipStartFrame) * FGlobalData::DefaultTimeTickSpace); if (ClipData->ClipType == ETrackType::VideoTrack) {