预设设置

This commit is contained in:
Sch 2023-08-09 02:07:35 +08:00
parent b9ee84436e
commit c817dffd24
7 changed files with 77 additions and 31 deletions

View File

@ -117,6 +117,7 @@ struct CUT5_API FTrackData
};
struct CUT5_API FCursorData
{
FCursorData() {};
FCursorData(int32 Offset, FLinearColor InColor)
{
CursorFrameOffset = Offset;
@ -128,6 +129,7 @@ struct CUT5_API FCursorData
friend FArchive& operator<<(FArchive& Ar, FCursorData& CursorData)
{
Ar << CursorData.CursorFrameOffset;
Ar << CursorData.Color;
return Ar;
}
};
@ -164,6 +166,8 @@ struct CUT5_API FClipData
Ar << ClipData.PlayerName;
Ar << ClipData.PlayerLightData;
Ar << ClipData.ResourcePropertyGuid;
Ar << ClipData.Cursors;
Ar << ClipData.PresetType;
return Ar;
};

View File

@ -73,7 +73,7 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
FClipData NewClipData;
NewClipData.PresetType = PresetDragOperation->PresetData.PresetType;
NewClipData.ClipGuid = FGuid::NewGuid();
NewClipData.ClipType = PresetDragOperation->ManualClipType;
NewClipData.ClipType = TrackHead->TrackData.TrackType;
NewClipData.ClipStartFrame = MyGeometry.AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / FGlobalData::DefaultTimeTickSpace;
NewClipData.ClipEndFrame = (MyGeometry.AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X + 100) / FGlobalData::DefaultTimeTickSpace;
NewClipData.ClipColors.Add(FLinearColor(1, 1, 1, 1));

View File

@ -12,8 +12,10 @@ void SEffectPreset::Construct(const FArguments& InArgs)
{
Name = InArgs._Name;
PresetPath = InArgs._PresetPath;
PresetType = InArgs._PresetType;
MainInterface = InArgs._MainInterface;
PresetsData.PresetType = EPresetType::Gradient;
PresetsData.PresetType = PresetType;
ChildSlot
[
SNew(SBox)

View File

@ -19,6 +19,7 @@ public:
}
SLATE_ARGUMENT(FString, Name)
SLATE_ARGUMENT(FString, PresetPath)
SLATE_ARGUMENT(EPresetType, PresetType)
SLATE_ARGUMENT(ICutMainWidgetInterface*, MainInterface)
SLATE_END_ARGS()
@ -29,6 +30,7 @@ public:
FString PresetPath;
FPresetsData PresetsData;
ICutMainWidgetInterface* MainInterface;
EPresetType PresetType;
TSharedPtr<SComboBox<TSharedPtr<FString>>> GroupComboBox;
virtual TSharedPtr<SWidget> GetPropertiesWidget() override;

View File

@ -349,17 +349,17 @@ void SCustomInputPanel::Construct(const FArguments& InArgs)
AddPreset(TEXT("结束后常亮"), TEXT(""));
AddPreset(TEXT("渐变"), TEXT(""));
AddPreset(TEXT("亮白"), TEXT(""));
AddPreset(TEXT("红色"), TEXT(""));
AddPreset(TEXT("紫色"), TEXT(""));
AddPreset(TEXT("蓝色"), TEXT(""));
AddPreset(TEXT("绿色"), TEXT(""));
AddPreset(TEXT("橘色"), TEXT(""));
AddPreset(TEXT("青柠"), TEXT(""));
AddPreset(TEXT("红-暗"), TEXT(""));
AddPreset(TEXT("闪电"), TEXT(""));
AddPreset(TEXT("结束后常亮"), TEXT(""), EPresetType::Color);
AddPreset(TEXT("渐变"), TEXT(""), EPresetType::Gradient);
AddPreset(TEXT("亮白"), TEXT(""), EPresetType::Color);
AddPreset(TEXT("红色"), TEXT(""), EPresetType::Color);
AddPreset(TEXT("紫色"), TEXT(""), EPresetType::Color);
AddPreset(TEXT("蓝色"), TEXT(""), EPresetType::Color);
AddPreset(TEXT("绿色"), TEXT(""), EPresetType::Color);
AddPreset(TEXT("橘色"), TEXT(""), EPresetType::Color);
AddPreset(TEXT("青柠"), TEXT(""), EPresetType::Color);
AddPreset(TEXT("红-暗"), TEXT(""), EPresetType::Gradient);
AddPreset(TEXT("闪电"), TEXT(""), EPresetType::Video);
AddPreset(TEXT("跑马灯-玫红"), TEXT(""));
AddPreset(TEXT("心跳-宏"), TEXT(""));
AddPreset(TEXT("5次闪电"), TEXT(""));
@ -551,7 +551,7 @@ void SCustomInputPanel::ClearPanel()
PropertyData.Empty();
}
void SCustomInputPanel::AddPreset(const FString& Name, const FString& PresetPath)
void SCustomInputPanel::AddPreset(const FString& Name, const FString& PresetPath, EPresetType PresetType)
{
if (Name != "")
{
@ -561,6 +561,7 @@ void SCustomInputPanel::AddPreset(const FString& Name, const FString& PresetPath
.Name(Name)
.PresetPath(PresetPath)
.MainInterface(MainWidgetInterface)
.PresetType(PresetType)
];
}
}

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

View File

@ -129,18 +129,22 @@ void STimelineClip::Construct(const FArguments& InArgs)
}
if (MainWidgetInterface->GetCutTimeline()->SelectedClipGUID == ClipData->ClipGuid)
{
for (int32 i = 0; i < ClipData->Cursors.Num(); i++)
if (ClipData->PresetType == EPresetType::Gradient)
{
TSharedPtr<SClipCursor> NewClipCursor = SNew(SClipCursor).CursorData(&ClipData->Cursors[i])
.TimelineClip(this)
.ClipData(ClipData).RenderTransform(FSlateRenderTransform(FVector2D(ClipData->Cursors[i].CursorFrameOffset * FGlobalData::DefaultTimeTickSpace - 11, 0)));
ClipOverlay->AddSlot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Center)
[
NewClipCursor.ToSharedRef()
];
for (int32 i = 0; i < ClipData->Cursors.Num(); i++)
{
TSharedPtr<SClipCursor> NewClipCursor = SNew(SClipCursor).CursorData(&ClipData->Cursors[i])
.TimelineClip(this)
.ClipData(ClipData).RenderTransform(FSlateRenderTransform(FVector2D(ClipData->Cursors[i].CursorFrameOffset * FGlobalData::DefaultTimeTickSpace - 11, 0)));
ClipOverlay->AddSlot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Center)
[
NewClipCursor.ToSharedRef()
];
}
}
}
}
@ -280,11 +284,40 @@ void STimelineClip::Seek(int32 Frame)
{
const int32 Offset = Frame - ClipData->ClipStartFrame;
const int32 SeekMovieFrame = ClipData->VideoStartFrame + Offset;
if (SeekMovieFrame < ClipData->PlayerLightData.Num())
if (ClipData->PresetType == EPresetType::NotAPresets)
{
MainWidgetInterface->OnUpdatePlayers(Body, ClipData->PlayerLightData[SeekMovieFrame]);
if (SeekMovieFrame < ClipData->PlayerLightData.Num())
{
MainWidgetInterface->OnUpdatePlayers(Body, ClipData->PlayerLightData[SeekMovieFrame]);
}
break;
}
break;
else if (ClipData->PresetType == EPresetType::Color)
{
MainWidgetInterface->OnUpdatePlayers(Body, 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 (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->OnUpdatePlayers(Body, LinearColor.ToFColor(false));
}
}
}
default:
@ -344,9 +377,13 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle,
bool bParentEnabled) const
{
// const FSlateBrush Brush;
// FSlateDrawElement::MakeBox(OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(),
// &Brush, ESlateDrawEffect::None, FColor(0.5, 0.3, 0.1, 1.0));
if (ClipData->PresetType == EPresetType::Color)
{
const FSlateBrush Brush;
FSlateDrawElement::MakeBox(OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(),
&Brush, ESlateDrawEffect::None, ClipData->ClipColors[0]);
}
if (ClipData->PresetType == EPresetType::Gradient)
{
TArray<FSlateGradientStop> GradientStops;