diff --git a/Source/Cut5/Cut5.Build.cs b/Source/Cut5/Cut5.Build.cs index da892b3..ba41308 100644 --- a/Source/Cut5/Cut5.Build.cs +++ b/Source/Cut5/Cut5.Build.cs @@ -14,7 +14,7 @@ public class Cut5 : ModuleRules PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" , "FFMPEGMedia", "FFMPEGMediaFactory", "SchUtils"}); PrivateDependencyModuleNames.AddRange(new string[] {"ApplicationCore", "FFMPEGMedia", "FFMPEGMediaFactory", - "Slate", "SlateCore", "UMG", "OpenCV", "DesktopPlatform", "PortAudioPlugin", "SchUtils"}); + "Slate", "SlateCore", "UMG", "OpenCV", "DesktopPlatform", "PortAudioPlugin", "SchUtils", "Renderer", "RenderCore", "RHI"}); } } diff --git a/Source/Cut5/Interface/VideoThumbnailThread.cpp b/Source/Cut5/Interface/VideoThumbnailThread.cpp index 39dc737..e1657bb 100644 --- a/Source/Cut5/Interface/VideoThumbnailThread.cpp +++ b/Source/Cut5/Interface/VideoThumbnailThread.cpp @@ -10,7 +10,11 @@ FVideoThumbnailThread::FVideoThumbnailThread(const FString& MoviePath, TFunction this->BrushCount = BrushCount; this->ClipData = ClipData; - bMissionStart = true; + if (ClipData.MovieBrushesPath.Num() == 0) + { + bMissionStart = true; + } + } uint32 FVideoThumbnailThread::Run() diff --git a/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp b/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp index 547add1..7881bfb 100644 --- a/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp +++ b/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp @@ -134,17 +134,27 @@ void DragDropOperator::OnUpdateVideoTrack(const FClipData& VideoClipData) NewClipData.ClipGuid = FGuid::NewGuid(); NewClipData.ClipType = ETrackType::ProjectorTrack; NewClipData.PresetType = EPresetType::EnableProjector; + NewClipData.BindTrackGuid = ProjectorTrack->DeviceTrack.Guid; FPresetsCustomData CustomPresetData; CustomPresetData.PresetCustomType = FPresetsCustomData::EPresetCustomType::None; NewClipData.PresetsCustomData = CustomPresetData; + + ProjectorTrack->ClipData.Add(NewClipData); Timeline->RenderGroup(); } } +void DragDropOperator::OnUpdateProjectorTrack(const FClipData& ProjectorClipData) +{ + SCutTimeline* Timeline = SavedMainInterface->GetCutTimeline(); + FTrackData* ProjectorTrack = Timeline->GetTrackDataByType(ETrackType::ProjectorTrack); + ProjectorTrack->bIsEdit = true; +} + void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) { @@ -454,6 +464,10 @@ void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEv { OnUpdateVideoTrack(*TimelineClip->ClipData); } + if (TimelineClip->ClipData->ClipType == ETrackType::ProjectorTrack) + { + OnUpdateProjectorTrack(*TimelineClip->ClipData); + } } if (DragDropOperation.DragType == FClip2ClipDragDropOperation::EDragType::DragRight) @@ -464,6 +478,10 @@ void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEv { OnUpdateVideoTrack(*TimelineClip->ClipData); } + if (TimelineClip->ClipData->ClipType == ETrackType::ProjectorTrack) + { + OnUpdateProjectorTrack(*TimelineClip->ClipData); + } } if (DragDropOperation.DragType == FClip2ClipDragDropOperation::EDragType::Move) { @@ -850,7 +868,10 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& { OnUpdateVideoTrack(NewClipData); } - + if (NewClipData.ClipType == ETrackType::ProjectorTrack) + { + OnUpdateProjectorTrack(NewClipData); + } UpdateClipProcess(TrackHead->MainWidgetInterface, NewClipData); @@ -931,6 +952,10 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& { OnUpdateVideoTrack(*TimelineClip->ClipData); } + if (TimelineClip->ClipData->ClipType == ETrackType::ProjectorTrack) + { + OnUpdateProjectorTrack(*TimelineClip->ClipData); + } } diff --git a/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.h b/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.h index 6652bde..65a342b 100644 --- a/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.h +++ b/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.h @@ -20,6 +20,7 @@ public: int32 LastFrame = 0; void OnUpdateVideoTrack(const FClipData& VideoClipData); + void OnUpdateProjectorTrack(const FClipData& ProjectorClipData); }; diff --git a/Source/Cut5/Widgets/SCutTimeline.cpp b/Source/Cut5/Widgets/SCutTimeline.cpp index e4a3f05..543ef01 100644 --- a/Source/Cut5/Widgets/SCutTimeline.cpp +++ b/Source/Cut5/Widgets/SCutTimeline.cpp @@ -69,25 +69,25 @@ float SCutTimeline::UpdateTimelineLength() void SCutTimeline::UpdateZoom(float ZoomValue) { - const float OriginTickBoxOffset = LastSliderOffset; FGlobalData::DefaultTimeTickSpace = FMath::GetMappedRangeValueClamped(FVector2D(0, 1.0), FVector2D(GetCachedGeometry().GetLocalSize().X / FGlobalData::TrackLength, 15.0), ZoomValue); UpdateTimelineLength(); - const float TickBoxOffset = TickScrollBox->GetScrollOffsetOfEnd(); - LastSliderOffset = TickBoxOffset; - const float NewTickBoxOffset = TickBoxOffset - OriginTickBoxOffset; - - if (NewTickBoxOffset != 0.0f) - { - // GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::Printf(TEXT("NewTickBoxOffset: %f"), NewTickBoxOffset)); - } - - const float Scalar = NewTickBoxOffset / TrackBodyHScrollBox->GetScrollOffsetOfEnd(); - - TrackBodyHScrollBox->SetScrollOffset(TrackBodyHScrollBox->GetScrollOffset() + (TrackBodyHScrollBox->GetScrollOffset() * Scalar)); - TickScrollBox->SetScrollOffset(TrackBodyHScrollBox->GetScrollOffset() + (TrackBodyHScrollBox->GetScrollOffset() * Scalar)); - UpdateCursorPosition(GetCursorPosition(), false); + const float CursorOffset = (TimelineTick->TickCursor->GetCachedGeometry().Position.X + TimelineTick->TickCursor->GetRenderTransform()->GetTranslation().X) - LastSliderOffset; + + TrackBodyHScrollBox->SetScrollOffset(TrackBodyHScrollBox->GetScrollOffset() + CursorOffset); + TickScrollBox->SetScrollOffset(TrackBodyHScrollBox->GetScrollOffset() + CursorOffset); + + // + UpdateCursorPosition(GetCursorPosition(), false); RenderGroup(); + + ENQUEUE_RENDER_COMMAND(FMyCommand)( + [this](FRHICommandListImmediate& RHICmdList) + { + LastSliderOffset = (TimelineTick->TickCursor->GetCachedGeometry().Position.X + TimelineTick->TickCursor->GetRenderTransform()->GetTranslation().X); + } + ); + } void SCutTimeline::UpdateCursorPosition(int32 Frame, bool NeedSeek) @@ -242,7 +242,21 @@ void SCutTimeline::Construct(const FArguments& InArgs) UpdateZoom(ChangedValue); }) ] - + ] + + SHorizontalBox::Slot() + [ + SNew(SBox) + .WidthOverride(200) + [ + SNew(SSlider) + .MaxValue(1.0) + .MinValue(0.0) + .OnValueChanged_Lambda([this](float ChangedValue) + { + TrackBodyHScrollBox->SetScrollOffset(ChangedValue * TrackBodyHScrollBox->GetScrollOffsetOfEnd()); + TickScrollBox->SetScrollOffset(TrackBodyHScrollBox->GetScrollOffset()); + }) + ] ] // + SHorizontalBox::Slot() // .SizeParam(FAuto()) @@ -472,6 +486,11 @@ void SCutTimeline::Tick(const FGeometry& AllottedGeometry, const double InCurren } } + if (bNeedUpdateOffsetInNextTick) + { + + } + float ScrollBoxOffset = TrackBodyHScrollBox->GetScrollOffset(); float TickBoxOffset = TickScrollBox->GetScrollOffset(); diff --git a/Source/Cut5/Widgets/SCutTimeline.h b/Source/Cut5/Widgets/SCutTimeline.h index d3d36e4..94614ec 100644 --- a/Source/Cut5/Widgets/SCutTimeline.h +++ b/Source/Cut5/Widgets/SCutTimeline.h @@ -67,6 +67,7 @@ public: virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; float UpdateTimelineLength(); void UpdateZoom(float ZoomValue); + bool bNeedUpdateOffsetInNextTick = false; float LastSliderOffset = 0.0f; void UpdateCursorPosition(int32 Frame, bool NeedSeek = true); int32 GetCursorPosition() const; diff --git a/Source/Cut5/Widgets/STimelineClip.cpp b/Source/Cut5/Widgets/STimelineClip.cpp index c5e4c8e..25de2ac 100644 --- a/Source/Cut5/Widgets/STimelineClip.cpp +++ b/Source/Cut5/Widgets/STimelineClip.cpp @@ -272,11 +272,18 @@ void STimelineClip::Construct(const FArguments& InArgs) { if (!MainWidgetInterface->GetSelf()->GetThread(FUtils::GetVideoThumbnailThreadGuid(ClipData->ClipGuid))) { - FVideoThumbnailThread* ThumbnailThread = new FVideoThumbnailThread(ClipData->MoviePath, [this](const FString& PicPath) + FClipData& Clip = *ClipData; + FVideoThumbnailThread* ThumbnailThread = new FVideoThumbnailThread(ClipData->MoviePath, [this, &Clip](const FString& PicPath) { - ClipData->MovieBrushesPath.Add(PicPath); + if (this == nullptr) + { + return; + } + Clip.MovieBrushesPath.Add(PicPath); const FSlateDynamicImageBrush Brush = FSlateDynamicImageBrush(*ToFullPath(PicPath), FVector2f(0, 0)); - ClipData->MovieBrushes.Add(Brush); + Clip.MovieBrushes.Add(Brush); + + }, ClipData->MovieBrushNum, *ClipData); FRunnableThread::Create(ThumbnailThread, TEXT("VideoThumbnailThread")); @@ -849,10 +856,16 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe if (ClipData->PresetType == EPresetType::EnableProjector) { + const FSlateBrush Brush; + FSlateDrawElement::MakeBox(OutDrawElements, LayerId + 8, AllottedGeometry.ToPaintGeometry(), + &Brush, ESlateDrawEffect::None, FColor(0, 100, 0, 255)); FSlateDrawElement::MakeText(OutDrawElements, LayerId + 9, AllottedGeometry.ToPaintGeometry(), FText::FromString(TEXT("开启\n投影仪")), FAppStyle::Get().GetWidgetStyle("NormalText").Font, ESlateDrawEffect::None, FLinearColor::White); } if (ClipData->PresetType == EPresetType::DisableProjector) { + const FSlateBrush Brush; + FSlateDrawElement::MakeBox(OutDrawElements, LayerId + 8, AllottedGeometry.ToPaintGeometry(), + &Brush, ESlateDrawEffect::None, FColor(100, 0, 0, 255)); FSlateDrawElement::MakeText(OutDrawElements, LayerId + 9, AllottedGeometry.ToPaintGeometry(), FText::FromString(TEXT("关闭\n投影仪")), FAppStyle::Get().GetWidgetStyle("NormalText").Font, ESlateDrawEffect::None, FLinearColor::White); } if (ClipData->bIsCycle == true) @@ -906,7 +919,7 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None -&& ClipData->ClipType != ETrackType::AudioTrackR && ClipData->ClipType != ETrackType::AudioTrack) +&& ClipData->ClipType != ETrackType::AudioTrackR && ClipData->ClipType != ETrackType::AudioTrack && ClipData->ClipType != ETrackType::ProjectorTrack) { const FSlateBrush Brush; FSlateDrawElement::MakeBox(OutDrawElements, LayerId + 4, AllottedGeometry.ToPaintGeometry(),