片段修改与保存

This commit is contained in:
Sch 2023-08-25 04:19:14 +08:00
parent 93c4688851
commit abcfe4997e
11 changed files with 230 additions and 179 deletions

View File

@ -123,8 +123,6 @@ enum class ETrackType
enum class EPresetType
{
NotAPresets,
Color,
Gradient,
Video,
DisableProjector,
EnableProjector,
@ -306,7 +304,6 @@ struct CUT5_API FClipData
Ar << ClipData.PlayerName;
Ar << ClipData.PlayerLightData;
Ar << ClipData.ResourcePropertyGuid;
Ar << ClipData.Cursors;
Ar << ClipData.PresetType;
Ar << ClipData.bCanDrag;
Ar << ClipData.PresetsCustomData;
@ -355,14 +352,14 @@ struct CUT5_API FClipData
};
void UpdateGradientCursor()
{
if (PresetType == EPresetType::Gradient)
if (PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient)
{
int32 OffsetFrame = ClipEndFrame - ClipStartFrame;
for (int32 i = 0; i < Cursors.Num(); i++)
for (int32 i = 0; i < PresetsCustomData.Cursors.Num(); i++)
{
if (Cursors[i].CursorFrameOffset > OffsetFrame)
if (PresetsCustomData.Cursors[i].CursorFrameOffset > OffsetFrame)
{
Cursors[i].CursorFrameOffset = OffsetFrame;
PresetsCustomData.Cursors[i].CursorFrameOffset = OffsetFrame;
}
}
}
@ -388,14 +385,14 @@ struct CUT5_API FClipData
}
}
if (PresetType == EPresetType::Gradient)
if (PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None)
{
int32 OffsetFrame = ClipEndFrame - ClipStartFrame;
for (int32 i = 0; i < Cursors.Num(); i++)
for (int32 i = 0; i < PresetsCustomData.Cursors.Num(); i++)
{
if (Cursors[i].CursorFrameOffset > OffsetFrame)
if (PresetsCustomData.Cursors[i].CursorFrameOffset > OffsetFrame)
{
Cursors[i].CursorFrameOffset = OffsetFrame;
PresetsCustomData.Cursors[i].CursorFrameOffset = OffsetFrame;
}
}
}
@ -420,8 +417,7 @@ struct CUT5_API FClipData
TArray<FColor> PlayerLightData;
// Cursor
TArray<FCursorData> Cursors;
EPresetType PresetType = EPresetType::NotAPresets;
@ -429,6 +425,73 @@ struct CUT5_API FClipData
{
return ClipGuid == Other.ClipGuid;
}
FColor GetBreathColor(int32 SeekMovieFrame) const
{
// 先拿到目前位置在第几个区间
float Between = -1;
const int32 SingleAreaLength = (ClipEndFrame - ClipStartFrame) / PresetsCustomData.Times / 2;
if (SeekMovieFrame > 0)
{
Between = static_cast<float>(SeekMovieFrame) / static_cast<float>(SingleAreaLength);
}
if (Between != -1)
{
FLinearColor LinearColor = FLinearColor::Black;
FLinearColor CustomColor = PresetsCustomData.Colors[0];
LinearColor = FMath::Lerp(static_cast<int32>(Between) % 2 == 0 ? CustomColor : FLinearColor::Black, static_cast<int32>(Between) % 2 == 0 ? FLinearColor::Black : CustomColor, Between - static_cast<int32>(Between));
return LinearColor.ToFColor(false);
}
return FColor();
}
FColor GetFlashColor(int32 SeekMovieFrame) const
{
float Between = -1;
const int32 SingleAreaLength = (ClipEndFrame - ClipStartFrame) / PresetsCustomData.Times / 2;
if (SeekMovieFrame > 0)
{
Between = static_cast<float>(SeekMovieFrame) / static_cast<float>(SingleAreaLength);
}
if (Between != -1)
{
return static_cast<int32>(Between) % 2 == 1 ? PresetsCustomData.Colors[0].ToFColor(false) : FLinearColor::Black.ToFColor(false);
}
return FColor();
}
FColor GetGradientColor(int32 SeekMovieFrame) const
{
int32 Between = -1;
for (int32 i = 0; i < PresetsCustomData.Cursors.Num() - 1; i++)
{
if (SeekMovieFrame >= PresetsCustomData.Cursors[i].CursorFrameOffset && SeekMovieFrame <= PresetsCustomData.Cursors[i + 1].CursorFrameOffset)
{
Between = i;
}
}
if (SeekMovieFrame >= PresetsCustomData.Cursors[PresetsCustomData.Cursors.Num() - 1].CursorFrameOffset)
{
Between = PresetsCustomData.Cursors.Num() - 1;
}
if (Between != -1)
{
if (Between == PresetsCustomData.Cursors.Num() - 1)
{
return PresetsCustomData.Cursors[Between].Color.ToFColor(false);
}
else
{
FLinearColor LinearColor = FLinearColor::Black;
LinearColor = FMath::Lerp(PresetsCustomData.Cursors[Between].Color, PresetsCustomData.Cursors[Between + 1].Color, (float)(SeekMovieFrame - PresetsCustomData.Cursors[Between].CursorFrameOffset) / (float)(PresetsCustomData.Cursors[Between + 1].CursorFrameOffset - PresetsCustomData.Cursors[Between].CursorFrameOffset));
return LinearColor.ToFColor(false);
}
}
return FColor();
}
};
struct CUT5_API FTimelinePropertyData
{
@ -553,6 +616,7 @@ class CUT5_API FPresetDragOperation final : public FCutDragDropBase
public:
// It's a Ptr to Resource;
FPresetsData PresetData = FPresetsData();
FPresetsCustomData CustomData = FPresetsCustomData();
TSharedPtr<SWidget> PresetWidget;
};

View File

@ -637,36 +637,34 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
NewClipData.ClipType = TrackHead->TrackData.TrackType;
NewClipData.ClipStartFrame = MyGeometry.AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / FGlobalData::DefaultTimeTickSpace;
NewClipData.ClipEndFrame = NewClipData.ClipStartFrame + 20;
if (PresetDragOperation->PresetData.PresetType == EPresetType::Color)
if (PresetDragOperation->PresetData.PresetType == EPresetType::Custom)
{
if (PresetDragOperation->PresetData.Colors.Num() == 0)
if (PresetDragOperation->CustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None)
{
PresetDragOperation->PresetData.Colors.Add(FLinearColor(1, 0, 0, 1));
}
NewClipData.ClipColors.Add(PresetDragOperation->PresetData.Colors[0]);
}
else
{
NewClipData.ClipColors.Add(FLinearColor(0, 0, 0, 0));
}
if (PresetDragOperation->PresetData.PresetType == EPresetType::Gradient)
{
if (PresetDragOperation->PresetData.Colors.Num() > 0)
{
for (int32 i = 0; i < PresetDragOperation->PresetData.Colors.Num(); i++)
if (PresetDragOperation->CustomData.Colors.Num() == 0)
{
NewClipData.Cursors.Add(FCursorData(i * (100 / FGlobalData::DefaultTimeTickSpace / PresetDragOperation->PresetData.Colors.Num()), PresetDragOperation->PresetData.Colors[i]));
PresetDragOperation->CustomData.Colors.Add(FLinearColor(1, 0, 0, 1));
}
NewClipData.ClipColors.Add(PresetDragOperation->CustomData.Colors[0]);
}
if (PresetDragOperation->CustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient)
{
if (PresetDragOperation->CustomData.Colors.Num() > 0)
{
for (int32 i = 0; i < PresetDragOperation->CustomData.Colors.Num(); i++)
{
NewClipData.PresetsCustomData.Cursors.Add(FCursorData(i * (100 / FGlobalData::DefaultTimeTickSpace / PresetDragOperation->PresetData.Colors.Num()), PresetDragOperation->PresetData.Colors[i]));
}
}
else
{
NewClipData.PresetsCustomData.Cursors.Add(FCursorData(0, FLinearColor(1, 0, 0, 1)));
NewClipData.PresetsCustomData.Cursors.Add(FCursorData(6, FLinearColor(0, 1, 1, 1)));
}
}
else
{
NewClipData.Cursors.Add(FCursorData(0, FLinearColor(1, 0, 0, 1)));
NewClipData.Cursors.Add(FCursorData(6, FLinearColor(0, 1, 1, 1)));
}
}
if (PresetDragOperation->PresetData.PresetType == EPresetType::EnableProjector || PresetDragOperation->PresetData.PresetType == EPresetType::DisableProjector)
{
NewClipData.ClipEndFrame = NewClipData.ClipStartFrame + 15;

View File

@ -36,11 +36,11 @@ void SClipCursor::Construct(const FArguments& InArgs)
}
else if (MouseEvent.IsMouseButtonDown(EKeys::RightMouseButton))
{
for (int32 i = 0; i < ClipData->Cursors.Num(); i++)
for (int32 i = 0; i < ClipData->PresetsCustomData.Cursors.Num(); i++)
{
if (ClipData->Cursors[i] == *CursorData)
if (ClipData->PresetsCustomData.Cursors[i] == *CursorData)
{
TimelineClip->MainWidgetInterface->OpenColorPanel(&ClipData->Cursors[i].Color);
TimelineClip->MainWidgetInterface->OpenColorPanel(&ClipData->PresetsCustomData.Cursors[i].Color);
}
}
}
@ -60,11 +60,11 @@ FReply SClipCursor::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointe
{
if (MouseEvent.IsMouseButtonDown(EKeys::LeftMouseButton))
{
for (int32 i = 0; i < ClipData->Cursors.Num(); i++)
for (int32 i = 0; i < ClipData->PresetsCustomData.Cursors.Num(); i++)
{
if (ClipData->Cursors[i] == *CursorData)
if (ClipData->PresetsCustomData.Cursors[i] == *CursorData)
{
TimelineClip->MainWidgetInterface->OpenColorPanel(&ClipData->Cursors[i].Color);
TimelineClip->MainWidgetInterface->OpenColorPanel(&ClipData->PresetsCustomData.Cursors[i].Color);
}
}
}

View File

@ -42,6 +42,8 @@ void SEffectPreset::Construct(const FArguments& InArgs)
FMemoryReader MemoryReader(Data);
MemoryReader << PresetsData;
PresetsCustomData.Colors = PresetsData.Colors;
}
}
@ -336,6 +338,7 @@ FReply SEffectPreset::OnDragDetected(const FGeometry& MyGeometry, const FPointer
DragOperation->DragDropType = FCutDragDropBase::EType::PresetDrag;
DragOperation->PresetData = PresetsData;
DragOperation->CustomData = PresetsCustomData;
DragOperation->PresetWidget = SharedThis(this);
return FReply::Handled().BeginDragDrop(DragOperation.ToSharedRef());
}

View File

@ -37,4 +37,6 @@ public:
TArray<TSharedPtr<FString>> Selectable;
FPresetsCustomData CustomData;
virtual FReply OnDragDetected(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
FPresetsCustomData PresetsCustomData;
};

View File

@ -324,16 +324,16 @@ void SCustomInputPanel::Construct(const FArguments& InArgs)
AddPreset(TEXT("结束后常亮"), TEXT(""), EPresetType::Color);
AddPreset(TEXT("渐变"), TEXT(""), EPresetType::Gradient);
AddPreset(TEXT("亮白"), TEXT("亮白.dat"), EPresetType::Color);
AddPreset(TEXT("红色"), TEXT("红色.dat"), EPresetType::Color);
AddPreset(TEXT("紫色"), TEXT("紫色.dat"), EPresetType::Color);
AddPreset(TEXT("蓝色"), TEXT("蓝色.dat"), EPresetType::Color);
AddPreset(TEXT("绿色"), TEXT("绿色.dat"), EPresetType::Color);
AddPreset(TEXT("橘色"), TEXT("橘色.dat"), EPresetType::Color);
AddPreset(TEXT("青柠"), TEXT("青柠.dat"), EPresetType::Color);
AddPreset(TEXT("红-暗"), TEXT("红-暗.dat"), EPresetType::Gradient);
AddPreset(TEXT("结束后常亮"), TEXT(""), EPresetType::Custom);
AddPreset(TEXT("渐变"), TEXT(""), EPresetType::Custom);
AddPreset(TEXT("亮白"), TEXT("亮白.dat"), EPresetType::Custom);
AddPreset(TEXT("红色"), TEXT("红色.dat"), EPresetType::Custom);
AddPreset(TEXT("紫色"), TEXT("紫色.dat"), EPresetType::Custom);
AddPreset(TEXT("蓝色"), TEXT("蓝色.dat"), EPresetType::Custom);
AddPreset(TEXT("绿色"), TEXT("绿色.dat"), EPresetType::Custom);
AddPreset(TEXT("橘色"), TEXT("橘色.dat"), EPresetType::Custom);
AddPreset(TEXT("青柠"), TEXT("青柠.dat"), EPresetType::Custom);
AddPreset(TEXT("红-暗"), TEXT("红-暗.dat"), EPresetType::Custom);
AddPreset(TEXT("闪电"), TEXT("闪电.dat"), EPresetType::Video);
AddPreset(TEXT("跑马灯-玫红"), TEXT("跑马灯-玫红.mp4"), EPresetType::Video);
AddPreset(TEXT("心跳-宏"), TEXT(""), EPresetType::Video);

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::Color);
void AddPreset(const FString& Name, const FString& PresetPath, EPresetType PresetType = EPresetType::Custom);
void AddCustomPreset();
bool bIsAssetPanel = false;
bool bIsEditMode = false;

View File

@ -55,6 +55,7 @@ FReply STimelineClip::OnBorderMouseButtonDown(const FGeometry& Geometry, const F
TSharedPtr<FClipProxy> ClipProxy = FClipProxy::GetProxy();
ClipProxy->UpdateInterface(this);
if (MainWidgetInterface->GetSelectedMode() == ESelectMode::CutMode)
{
Body->SelectedClipFrame = (Geometry.AbsoluteToLocal(PointerEvent.GetScreenSpacePosition()).X) / FGlobalData::DefaultTimeTickSpace;
@ -63,7 +64,23 @@ FReply STimelineClip::OnBorderMouseButtonDown(const FGeometry& Geometry, const F
}
MainWidgetInterface->GetCutTimeline()->SelectedClips.AddUnique(ClipData->ClipGuid);
if (MainWidgetInterface->GetCutTimeline()->SelectedClips.Num() < 2)
{
MainWidgetInterface->GetCutTimeline()->SelectedClips.Empty();
MainWidgetInterface->GetCutTimeline()->SelectedClips.AddUnique(ClipData->ClipGuid);
}
else
{
if (!MainWidgetInterface->GetCutTimeline()->SelectedClips.Contains(ClipData->ClipGuid))
{
MainWidgetInterface->GetCutTimeline()->SelectedClips.Empty();
}
MainWidgetInterface->GetCutTimeline()->SelectedClips.AddUnique(ClipData->ClipGuid);
}
LocalPos = Geometry.AbsoluteToLocal(PointerEvent.GetScreenSpacePosition());
const float DragOffset = MainWidgetInterface->GetCutTimeline()->GetCachedGeometry().AbsoluteToLocal(PointerEvent.GetScreenSpacePosition()).X;
@ -142,12 +159,15 @@ FReply STimelineClip::OnBorderMouseButtonDown(const FGeometry& Geometry, const F
FReply STimelineClip::OnBorderMouseButtonUp(const FGeometry& Geometry, const FPointerEvent& PointerEvent)
{
MainWidgetInterface->SelectClip(ClipData->ClipGuid);
return FReply::Handled();
}
FReply STimelineClip::OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
return FReply::Handled();
}
@ -186,13 +206,13 @@ void STimelineClip::Construct(const FArguments& InArgs)
}
if (MainWidgetInterface->GetCutTimeline()->SelectedClipGUID == ClipData->ClipGuid)
{
if (ClipData->PresetType == EPresetType::Gradient)
if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient)
{
for (int32 i = 0; i < ClipData->Cursors.Num(); i++)
for (int32 i = 0; i < ClipData->PresetsCustomData.Cursors.Num(); i++)
{
TSharedPtr<SClipCursor> NewClipCursor = SNew(SClipCursor).CursorData(&ClipData->Cursors[i])
TSharedPtr<SClipCursor> NewClipCursor = SNew(SClipCursor).CursorData(&ClipData->PresetsCustomData.Cursors[i])
.TimelineClip(this)
.ClipData(ClipData).RenderTransform(FSlateRenderTransform(FVector2D(ClipData->Cursors[i].CursorFrameOffset * FGlobalData::DefaultTimeTickSpace - 11, 0)));
.ClipData(ClipData).RenderTransform(FSlateRenderTransform(FVector2D(ClipData->PresetsCustomData.Cursors[i].CursorFrameOffset * FGlobalData::DefaultTimeTickSpace - 11, 0)));
ClipOverlay->AddSlot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Center)
@ -310,91 +330,31 @@ void STimelineClip::Seek(int32 Frame)
const int32 Offset = Frame - ClipData->ClipStartFrame;
const int32 SeekMovieFrame = ClipData->VideoStartFrame + Offset;
if (ClipData->PlayerLightData.Num() != 0 && SeekMovieFrame < ClipData->PlayerLightData.Num())
{
MainWidgetInterface->OnUpdateSpotLight(0, ClipData->PlayerLightData[SeekMovieFrame]);
break;
}
if (ClipData->PresetsCustomData.PresetCustomType != FPresetsCustomData::EPresetCustomType::None)
{
if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Breathe)
{
// 先拿到目前位置在第几个区间
float Between = -1;
int32 SingleAreaLength = (ClipData->ClipEndFrame - ClipData->ClipStartFrame) / ClipData->PresetsCustomData.Times / 2;
if (SeekMovieFrame > 0)
{
Between = (float)SeekMovieFrame / (float)SingleAreaLength;
}
if (Between != -1)
{
FLinearColor LinearColor = FLinearColor::Black;
FLinearColor CustomColor = ClipData->PresetsCustomData.Colors[0];
LinearColor = FMath::Lerp((int32)Between % 2 == 0 ? CustomColor : FLinearColor::Black, (int32)Between % 2 == 0 ? FLinearColor::Black : CustomColor, Between - (int32)Between);
// GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Red, FString::Printf(TEXT("Between %s"), *CustomColor.ToString()));
MainWidgetInterface->OnUpdateSpotLight(0, LinearColor.ToFColor(false));
}
MainWidgetInterface->OnUpdateSpotLight(0, ClipData->GetBreathColor(SeekMovieFrame));
}
else if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Flash)
{
float Between = -1;
int32 SingleAreaLength = (ClipData->ClipEndFrame - ClipData->ClipStartFrame) / ClipData->PresetsCustomData.Times / 2;
if (SeekMovieFrame > 0)
{
Between = (float)SeekMovieFrame / (float)SingleAreaLength;
}
if (Between != -1)
{
MainWidgetInterface->OnUpdateSpotLight(0, (int32)Between % 2 == 1 ? ClipData->PresetsCustomData.Colors[0].ToFColor(false) : FLinearColor::Black.ToFColor(false));
}
MainWidgetInterface->OnUpdateSpotLight(0, ClipData->GetFlashColor(SeekMovieFrame));
}
break;
}
if (ClipData->PresetType == EPresetType::NotAPresets)
{
if (SeekMovieFrame < ClipData->PlayerLightData.Num())
else if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient)
{
MainWidgetInterface->OnUpdateSpotLight(0, ClipData->PlayerLightData[SeekMovieFrame]);
MainWidgetInterface->OnUpdateSpotLight(0, ClipData->GetGradientColor(SeekMovieFrame));
}
break;
}
else if (ClipData->PresetType == EPresetType::Color)
else if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None)
{
MainWidgetInterface->OnUpdateSpotLight(0, ClipData->ClipColors[0].ToFColor(false));
}
else if (ClipData->PresetType == EPresetType::Gradient)
{
int32 Between = -1;
for (int32 i = 0; i < ClipData->Cursors.Num() - 1; 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)
{
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));
}
}
}
break;
}
case ETrackType::LightArrayTrack:
@ -444,7 +404,7 @@ void STimelineClip::Seek(int32 Frame)
}
if (ClipData->PresetType == EPresetType::Color)
if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None)
{
TArray<FColor> Colors;
@ -452,26 +412,26 @@ void STimelineClip::Seek(int32 Frame)
MainWidgetInterface->OnUpdateLightArray(Colors);
break;
}
else if (ClipData->PresetType == EPresetType::Gradient)
else if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient)
{
int32 Between = -1;
for (int32 i = 0; i < ClipData->Cursors.Num() - 1; i++)
for (int32 i = 0; i < ClipData->PresetsCustomData.Cursors.Num() - 1; i++)
{
if (SeekMovieFrame >= ClipData->Cursors[i].CursorFrameOffset && SeekMovieFrame <= ClipData->Cursors[i + 1].CursorFrameOffset)
if (SeekMovieFrame >= ClipData->PresetsCustomData.Cursors[i].CursorFrameOffset && SeekMovieFrame <= ClipData->PresetsCustomData.Cursors[i + 1].CursorFrameOffset)
{
Between = i;
}
}
if (SeekMovieFrame >= ClipData->Cursors[ClipData->Cursors.Num() - 1].CursorFrameOffset)
if (SeekMovieFrame >= ClipData->PresetsCustomData.Cursors[ClipData->PresetsCustomData.Cursors.Num() - 1].CursorFrameOffset)
{
Between = ClipData->Cursors.Num() - 1;
Between = ClipData->PresetsCustomData.Cursors.Num() - 1;
}
if (Between != -1)
{
if (Between == ClipData->Cursors.Num() - 1)
if (Between == ClipData->PresetsCustomData.Cursors.Num() - 1)
{
TArray<FColor> Colors;
Colors.Init(ClipData->Cursors[ClipData->Cursors.Num() - 1].Color.ToFColor(false), FGlobalData::LightArrayX * FGlobalData::LightArrayY * 4);
Colors.Init(ClipData->PresetsCustomData.Cursors[ClipData->PresetsCustomData.Cursors.Num() - 1].Color.ToFColor(false), FGlobalData::LightArrayX * FGlobalData::LightArrayY * 4);
MainWidgetInterface->OnUpdateLightArray(Colors);
}
else
@ -480,7 +440,7 @@ void STimelineClip::Seek(int32 Frame)
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);
Colors[i] = FMath::Lerp(ClipData->PresetsCustomData.Cursors[Between].Color, ClipData->PresetsCustomData.Cursors[Between + 1].Color, (float)(SeekMovieFrame - ClipData->PresetsCustomData.Cursors[Between].CursorFrameOffset) / (float)(ClipData->PresetsCustomData.Cursors[Between + 1].CursorFrameOffset - ClipData->PresetsCustomData.Cursors[Between].CursorFrameOffset)).ToFColor(false);
}
MainWidgetInterface->OnUpdateLightArray(Colors);
}
@ -577,25 +537,25 @@ void STimelineClip::Seek(int32 Frame)
}
break;
}
else if (ClipData->PresetType == EPresetType::Color)
else if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None)
{
MainWidgetInterface->OnUpdatePlayers(Body, ClipData->ClipColors[0].ToFColor(false));
}
else if (ClipData->PresetType == EPresetType::Gradient)
else if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient)
{
int32 Between = -1;
for (int32 i = 0; i < ClipData->Cursors.Num() - 1; i++)
for (int32 i = 0; i < ClipData->PresetsCustomData.Cursors.Num() - 1; i++)
{
if (i == 0)
{
if (SeekMovieFrame <= ClipData->Cursors[i].CursorFrameOffset)
if (SeekMovieFrame <= ClipData->PresetsCustomData.Cursors[i].CursorFrameOffset)
{
Between = i;
}
}
if (i == ClipData->Cursors.Num() - 2)
if (i == ClipData->PresetsCustomData.Cursors.Num() - 2)
{
if (SeekMovieFrame >= ClipData->Cursors[i].CursorFrameOffset && SeekMovieFrame <= ClipData->Cursors[i + 1].CursorFrameOffset)
if (SeekMovieFrame >= ClipData->PresetsCustomData.Cursors[i].CursorFrameOffset && SeekMovieFrame <= ClipData->PresetsCustomData.Cursors[i + 1].CursorFrameOffset)
{
Between = i;
}
@ -604,7 +564,7 @@ void STimelineClip::Seek(int32 Frame)
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));
LinearColor = FMath::Lerp(ClipData->PresetsCustomData.Cursors[Between].Color, ClipData->PresetsCustomData.Cursors[Between + 1].Color, (float)(SeekMovieFrame - ClipData->PresetsCustomData.Cursors[Between].CursorFrameOffset) / (float)(ClipData->PresetsCustomData.Cursors[Between + 1].CursorFrameOffset - ClipData->PresetsCustomData.Cursors[Between].CursorFrameOffset));
MainWidgetInterface->OnUpdatePlayers(Body, LinearColor.ToFColor(false));
}
@ -631,13 +591,13 @@ void STimelineClip::UpdatePosition(int32 StartFrame)
{
ClipData->VideoStartFrame += StartFrame - ClipData->ClipStartFrame;
}
if (ClipData->PresetType == EPresetType::Gradient)
if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient)
{
for (int32 i = 0; i < ClipData->Cursors.Num(); i++)
for (int32 i = 0; i < ClipData->PresetsCustomData.Cursors.Num(); i++)
{
if (ClipData->Cursors[i].CursorFrameOffset > ClipData->ClipEndFrame - StartFrame)
if (ClipData->PresetsCustomData.Cursors[i].CursorFrameOffset > ClipData->ClipEndFrame - StartFrame)
{
ClipData->Cursors[i].CursorFrameOffset = ClipData->ClipEndFrame - StartFrame;
ClipData->PresetsCustomData.Cursors[i].CursorFrameOffset = ClipData->ClipEndFrame - StartFrame;
}
}
@ -658,13 +618,13 @@ void STimelineClip::UpdateLength(int32 EndFrame)
ClipData->VideoEndFrame += EndFrame - ClipData->ClipEndFrame;
}
ClipData->ClipEndFrame = EndFrame;
if (ClipData->PresetType == EPresetType::Gradient)
if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient)
{
for (int32 i = 0; i < ClipData->Cursors.Num(); i++)
for (int32 i = 0; i < ClipData->PresetsCustomData.Cursors.Num(); i++)
{
if (ClipData->Cursors[i].CursorFrameOffset > ClipData->ClipEndFrame - ClipData->ClipStartFrame)
if (ClipData->PresetsCustomData.Cursors[i].CursorFrameOffset > ClipData->ClipEndFrame - ClipData->ClipStartFrame)
{
ClipData->Cursors[i].CursorFrameOffset = ClipData->ClipEndFrame - ClipData->ClipStartFrame;
ClipData->PresetsCustomData.Cursors[i].CursorFrameOffset = ClipData->ClipEndFrame - ClipData->ClipStartFrame;
}
}
@ -822,19 +782,19 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
}
if (ClipData->PresetType == EPresetType::Color)
if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None)
{
const FSlateBrush Brush;
FSlateDrawElement::MakeBox(OutDrawElements, LayerId + 3, AllottedGeometry.ToPaintGeometry(),
&Brush, ESlateDrawEffect::None, ClipData->ClipColors[0]);
&Brush, ESlateDrawEffect::None, ClipData->PresetsCustomData.Colors[0]);
}
if (ClipData->PresetType == EPresetType::Gradient)
if (ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient)
{
TArray<FSlateGradientStop> GradientStops;
for (int32 i = 0; i < ClipData->Cursors.Num(); i++)
for (int32 i = 0; i < ClipData->PresetsCustomData.Cursors.Num(); i++)
{
// GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::Printf(TEXT("CursorFrameOffset %s"), *ClipData->Cursors[i].Color.ToString()));
GradientStops.Add(FSlateGradientStop(FVector2D(ClipData->Cursors[i].CursorFrameOffset * FGlobalData::DefaultTimeTickSpace, 0), ClipData->Cursors[i].Color));
// GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::Printf(TEXT("CursorFrameOffset %s"), *ClipData->PresetsCustomData.Cursors[i].Color.ToString()));
GradientStops.Add(FSlateGradientStop(FVector2D(ClipData->PresetsCustomData.Cursors[i].CursorFrameOffset * FGlobalData::DefaultTimeTickSpace, 0), ClipData->PresetsCustomData.Cursors[i].Color));
}
FSlateDrawElement::MakeGradient(OutDrawElements, LayerId + 3, AllottedGeometry.ToPaintGeometry(),

View File

@ -79,5 +79,8 @@ public:
TSharedPtr<SComboBox<TSharedPtr<FString>>> GroupComboBox;
TArray<TSharedPtr<FString>> Selectable;
int32 OriginClipStartFrame = 0;
int32 OriginClipEndFrame = 0;
};

View File

@ -1,6 +1,7 @@
#include "ClipProxy.h"
#include "Cut5/Utils/Utils.h"
#include "Cut5/Widgets/SCutTimeline.h"
#include "Cut5/Widgets/STimelineClip.h"
#include "Cut5/Widgets/MicroWidgets/SNewProjectTips.h"
#include "Widgets/Input/SSpinBox.h"
@ -14,7 +15,9 @@ TSharedPtr<FClipProxy> FClipProxy::GetProxy()
void FClipProxy::UpdateInterface(STimelineClip* InTimeClip)
{
this->ClipData = InTimeClip->ClipData;
this->TimelineClip = InTimeClip;
this->MainInterface = InTimeClip->MainWidgetInterface;
TimelineClip->MainWidgetInterface->UpdateProperties(nullptr);
TimelineClip->MainWidgetInterface->UpdateProperties(this);
}
@ -64,18 +67,23 @@ TSharedPtr<SWidget> FClipProxy::GetPropertiesWidget()
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("Color.png"), {}))
.ColorAndOpacity_Lambda([this]()
{
if (TimelineClip->ClipData->PresetsCustomData.Colors.Num() == 0)
if (ClipData)
{
return FLinearColor(1, 1, 1, 0.5);
}
else
{
return TimelineClip->ClipData->PresetsCustomData.Colors[0];
if (ClipData->PresetsCustomData.Colors.Num() == 0)
{
return FLinearColor(1, 1, 1, 0.5);
}
else
{
return ClipData->PresetsCustomData.Colors[0];
}
}
return FLinearColor(1, 1, 1, 0.5);
})
.OnMouseButtonDown_Lambda([this](const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
TimelineClip->MainWidgetInterface->OpenColorPanel(&TimelineClip->ClipData->PresetsCustomData.Colors[0]);
MainInterface->OpenColorPanel(&ClipData->PresetsCustomData.Colors[0]);
return FReply::Handled();
})
]
@ -121,25 +129,35 @@ TSharedPtr<SWidget> FClipProxy::GetPropertiesWidget()
switch (Selectable.Find(InItem))
{
case 0:
TimelineClip->ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::None;
ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::None;
break;
case 1:
TimelineClip->ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Breathe;
ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Breathe;
break;
case 2:
TimelineClip->ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Flash;
ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Flash;
break;
case 3:
TimelineClip->ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Gradient;
{
ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Gradient;
if (ClipData->PresetsCustomData.Cursors.Num() < 2)
{
ClipData->PresetsCustomData.Cursors.Add(FCursorData(0, FLinearColor::Red));
ClipData->PresetsCustomData.Cursors.Add(FCursorData(10, FLinearColor::Green));
}
}
default:
break;
}
MainInterface->GetCutTimeline()->RenderGroup();
})
[
SNew(STextBlock)
.Text_Lambda([this]()
{
return FText::FromString( TimelineClip->ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None ? TEXT("") : TimelineClip->ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Breathe ? TEXT("呼吸") : TimelineClip->ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient ? TEXT("渐变") : TEXT("闪烁"));
return FText::FromString( ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None ? TEXT("") : ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Breathe ? TEXT("呼吸") : ClipData->PresetsCustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Gradient ? TEXT("渐变") : TEXT("闪烁"));
})
]
]
@ -178,13 +196,13 @@ TSharedPtr<SWidget> FClipProxy::GetPropertiesWidget()
SNew(SSpinBox<int32>)
.Value_Lambda([this]()
{
return TimelineClip->ClipData->PresetsCustomData.Times;
return ClipData->PresetsCustomData.Times;
})
.MinValue(1)
.MaxValue(200)
.OnValueChanged_Lambda([this](const int32& Value)
{
TimelineClip->ClipData->PresetsCustomData.Times = Value;
ClipData->PresetsCustomData.Times = Value;
})
]
]
@ -224,12 +242,14 @@ TSharedPtr<SWidget> FClipProxy::GetPropertiesWidget()
.OnValueChanged_Lambda([this](const float& Value)
{
TimelineClip->ClipData->ClipEndFrame = TimelineClip->ClipData->ClipStartFrame + Value * FGlobalData::GlobalFPS;
TimelineClip->ClipData->PresetsCustomData.Time = (TimelineClip->ClipData->ClipEndFrame - TimelineClip->ClipData->ClipStartFrame) / FGlobalData::GlobalFPS;
ClipData->ClipEndFrame = ClipData->ClipStartFrame + Value * FGlobalData::GlobalFPS;
ClipData->PresetsCustomData.Time = (ClipData->ClipEndFrame - ClipData->ClipStartFrame) / FGlobalData::GlobalFPS;
MainInterface->GetCutTimeline()->RenderGroup();
})
.Value_Lambda([this]()
{
return (TimelineClip->ClipData->ClipEndFrame - TimelineClip->ClipData->ClipStartFrame) / FGlobalData::GlobalFPS;
return (ClipData->ClipEndFrame - ClipData->ClipStartFrame) / FGlobalData::GlobalFPS;
})
// .TypeInterface(MakeShared<TNumericUnitTypeInterface<int32>>(EUnit::Seconds))
]
@ -261,7 +281,7 @@ TSharedPtr<SWidget> FClipProxy::GetPropertiesWidget()
TSharedPtr<SNewProjectTips> NewProjectTips = SNew(SNewProjectTips).Title(TEXT("保存自定义效果名称"));
NewProjectTips->OnEnsure.BindLambda([this, NewProjectTips](const FString& String)
{
TimelineClip->MainWidgetInterface->AddNewCustomPreset(String, TimelineClip->ClipData->PresetsCustomData);
TimelineClip->MainWidgetInterface->AddNewCustomPreset(String, ClipData->PresetsCustomData);
GEngine->GameViewport->RemoveViewportWidgetContent(NewProjectTips.ToSharedRef());
});
GEngine->GameViewport->AddViewportWidgetContent(NewProjectTips.ToSharedRef()

View File

@ -12,7 +12,8 @@ public:
TSharedPtr<SComboBox<TSharedPtr<FString>>> GroupComboBox;
TArray<TSharedPtr<FString>> Selectable;
STimelineClip* TimelineClip;
FClipData* ClipData;
ICutMainWidgetInterface* MainInterface;
};