时间轴润色(FIXME)

This commit is contained in:
Sch 2023-09-15 09:20:45 +08:00
parent c85a308d44
commit 38116b2319
2 changed files with 29 additions and 11 deletions

View File

@ -832,7 +832,10 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
if (FUtils::DetectDragTypeCanDrop(NewClipData, TrackHead->TrackData.TrackType))
{
TrackHead->TrackData.ClipData.Add(NewClipData);
UpdateClipProcess(TrackHead->MainWidgetInterface, NewClipData);
if (NewClipData.ClipType == ETrackType::AudioTrack)
{
@ -859,11 +862,8 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
}
}
}
UpdateClipProcess(TrackHead->MainWidgetInterface, NewClipData);
}
SavedMainInterface->GetCutTimeline()->RenderGroup();

View File

@ -608,7 +608,7 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
const FSlateBrush Brush;
int32 NeedDrawCount = ClipData->GetLength() * FGlobalData::DefaultTimeTickSpace;
float DownSample = 4;
// Draw Audio Waveform
@ -617,11 +617,17 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
const float RangeEnd = MainWidgetInterface->GetCutTimeline()->TrackBodyHScrollBox->GetCachedGeometry().LocalToAbsolute(FVector2D(MainWidgetInterface->GetCutTimeline()->TrackBodyHScrollBox->GetCachedGeometry().GetLocalSize().X, 0)).X;
const float CurrentStartRange = AllottedGeometry.LocalToAbsolute(FVector2D(0, 0)).X;
const float CurrentEndRange = AllottedGeometry.LocalToAbsolute(FVector2D(AllottedGeometry.GetLocalSize().X, 0)).X;
GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Red, FString::SanitizeFloat(RangeStart));
GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Green, FString::SanitizeFloat(RangeEnd));
GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::White, FString::SanitizeFloat(CurrentStartRange));
GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Yellow, FString::SanitizeFloat(CurrentEndRange));
const int32 CropStartFrameOffset = ((CurrentStartRange * -1) + RangeStart > 0 ? (CurrentStartRange * -1) + RangeStart : 0) / FGlobalData::DefaultTimeTickSpace;
const int32 CropEndFrameOffset = (RangeEnd - CurrentEndRange > 0 ?
(RangeEnd - RangeStart) + CropStartFrameOffset * FGlobalData::DefaultTimeTickSpace : CropStartFrameOffset * FGlobalData::DefaultTimeTickSpace + (RangeEnd - RangeStart))
/ FGlobalData::DefaultTimeTickSpace;
int32 NeedDrawCount = (CropEndFrameOffset - CropStartFrameOffset) * FGlobalData::DefaultTimeTickSpace;
const int32 StartOffset = (ClipData->ResourcePropertyDataPtr->AudioSample / FGlobalData::GlobalFPS)
@ -631,8 +637,20 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
const int32 EndOffset = (ClipData->ResourcePropertyDataPtr->AudioSample / FGlobalData::GlobalFPS)
* ClipData->VideoEndFrame
* FUtils::GetFormatSampleBytesNum(ClipData->ResourcePropertyDataPtr->SampleFormat) * 2 / DownSample;
const int32 CropStartDataOffset = (ClipData->ResourcePropertyDataPtr->AudioSample / FGlobalData::GlobalFPS)
* CropStartFrameOffset * FUtils::GetFormatSampleBytesNum(ClipData->ResourcePropertyDataPtr->SampleFormat) * 2 / DownSample;
const int32 CropEndDataOffset = (ClipData->ResourcePropertyDataPtr->AudioSample / FGlobalData::GlobalFPS)
* CropEndFrameOffset * FUtils::GetFormatSampleBytesNum(ClipData->ResourcePropertyDataPtr->SampleFormat) * 2 / DownSample;
const int32 Interval = ((EndOffset + CropEndDataOffset) - (StartOffset + CropStartDataOffset)) / NeedDrawCount;
GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Red, FString::FromInt(NeedDrawCount));
GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Green, FString::FromInt(Interval));
const int32 Interval = (EndOffset - StartOffset) / NeedDrawCount;
for (int32 i = 0; i < NeedDrawCount / DownSample; i++)
{
const int32 CurrentIndex = (StartOffset * DownSample) + (i * (Interval * DownSample * 4));
@ -643,8 +661,8 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
float Y = FMath::GetMappedRangeValueClamped(FVector2D(1.0, 0.0), FVector2D(0.0, AllottedGeometry.GetLocalSize().Y),
FMath::Abs(NewFloat));
TArray<FVector2D> NewLoc;
NewLoc.Add(FVector2D(i * DownSample, AllottedGeometry.GetLocalSize().Y));
NewLoc.Add(FVector2D(i * DownSample, Y));
NewLoc.Add(FVector2D((CropStartFrameOffset * FGlobalData::DefaultTimeTickSpace + i) * DownSample, AllottedGeometry.GetLocalSize().Y));
NewLoc.Add(FVector2D((CropStartFrameOffset * FGlobalData::DefaultTimeTickSpace + i) * DownSample, Y));
FSlateDrawElement::MakeLines(OutDrawElements, LayerId + 6, AllottedGeometry.ToPaintGeometry(), NewLoc, ESlateDrawEffect::None,
FColor(45, 214, 153, 255), true, DownSample * 1.2);
}