片段属性设置

This commit is contained in:
Sch 2023-08-24 22:47:18 +08:00
parent de15282a40
commit 93c4688851
5 changed files with 312 additions and 249 deletions

View File

@ -267,6 +267,8 @@ struct CUT5_API FPresetsCustomData
float Time = 0.3;
EPresetCustomType PresetCustomType = EPresetCustomType::None;
TArray<FCursorData> Cursors;
friend FArchive& operator<<(FArchive& Ar, FPresetsCustomData& PresetsData)
{
Ar << PresetsData.Colors;
@ -274,6 +276,7 @@ struct CUT5_API FPresetsCustomData
Ar << PresetsData.Angle;
Ar << PresetsData.Time;
Ar << PresetsData.PresetCustomType;
Ar << PresetsData.Cursors;
return Ar;
}
};

View File

@ -23,6 +23,7 @@
#include "Presets/SClipCursor.h"
#include "Rendering/DrawElementPayloads.h"
#include "Slate/Private/Framework/Application/Menu.h"
#include "TimelineClips/ClipProxy.h"
#include "Widgets/Input/SSpinBox.h"
#include "Widgets/Layout/SSpacer.h"
@ -52,7 +53,8 @@ FReply STimelineClip::OnBorderMouseButtonDown(const FGeometry& Geometry, const F
return FReply::Handled();
}
TSharedPtr<FClipProxy> ClipProxy = FClipProxy::GetProxy();
ClipProxy->UpdateInterface(this);
if (MainWidgetInterface->GetSelectedMode() == ESelectMode::CutMode)
{
Body->SelectedClipFrame = (Geometry.AbsoluteToLocal(PointerEvent.GetScreenSpacePosition()).X) / FGlobalData::DefaultTimeTickSpace;
@ -62,8 +64,6 @@ FReply STimelineClip::OnBorderMouseButtonDown(const FGeometry& Geometry, const F
MainWidgetInterface->GetCutTimeline()->SelectedClips.AddUnique(ClipData->ClipGuid);
MainWidgetInterface->UpdateProperties(nullptr);
MainWidgetInterface->UpdateProperties(this);
LocalPos = Geometry.AbsoluteToLocal(PointerEvent.GetScreenSpacePosition());
const float DragOffset = MainWidgetInterface->GetCutTimeline()->GetCachedGeometry().AbsoluteToLocal(PointerEvent.GetScreenSpacePosition()).X;
@ -205,6 +205,7 @@ void STimelineClip::Construct(const FArguments& InArgs)
}
}
void STimelineClip::Seek(int32 Frame)
@ -1003,251 +1004,6 @@ void STimelineClip::Tick(const FGeometry& AllottedGeometry, const double InCurre
TSharedPtr<SWidget> STimelineClip::GetPropertiesWidget()
{
Selectable.Empty();
Selectable.Add(MakeShared<FString>(TEXT("")));
Selectable.Add(MakeShared<FString>(TEXT("呼吸")));
Selectable.Add(MakeShared<FString>(TEXT("闪烁")));
Selectable.Add(MakeShared<FString>(TEXT("渐变")));
FTextBlockStyle NormalText = FAppStyle::GetWidgetStyle<FTextBlockStyle>("NormalText");
NormalText.SetFontSize(13);
PropertiesWidget =
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.Padding(0, 13, 0, 0)
[
SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(TEXT("颜色")))
.Font(NormalText.Font)
.Justification(ETextJustify::Center)
]
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("Color.png"), {}))
.ColorAndOpacity_Lambda([this]()
{
if (CustomData.Colors.Num() == 0)
{
return FLinearColor(1, 1, 1, 0.5);
}
return CustomData.Colors[0];
})
.OnMouseButtonDown_Lambda([this](const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
MainWidgetInterface->OpenColorPanel(&CustomData.Colors[0]);
return FReply::Handled();
})
]
]
]
]
+ SVerticalBox::Slot()
.Padding(0, 13, 0, 0)
[
SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(TEXT("动效")))
.Font(NormalText.Font)
.Justification(ETextJustify::Center)
]
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SNew(SComboBox<TSharedPtr<FString>>)
.OptionsSource(&Selectable)
.OnGenerateWidget_Lambda([this](TSharedPtr<FString> InItem)
{
return SNew(STextBlock).Text(FText::FromString(*InItem));
})
.OnSelectionChanged_Lambda([this](TSharedPtr<FString> InItem, ESelectInfo::Type SelectInfo)
{
switch (Selectable.Find(InItem))
{
case 0:
CustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::None;
break;
case 1:
CustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Breathe;
break;
case 2:
CustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Flash;
break;
case 3:
CustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Gradient;
default:
break;
}
})
[
SNew(STextBlock)
.Text_Lambda([this]()
{
return FText::FromString( CustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::None ? TEXT("") : CustomData.PresetCustomType == FPresetsCustomData::EPresetCustomType::Breathe ? TEXT("呼吸") : TEXT("闪烁"));
})
]
]
]
]
]
+ SVerticalBox::Slot()
.Padding(0, 13, 0, 0)
[
SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(TEXT("次数")))
.Font(NormalText.Font)
.Justification(ETextJustify::Center)
]
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SNew(SSpinBox<int32>)
.Value(1)
.MinValue(1)
.OnValueChanged_Lambda([this](const int32& Value)
{
CustomData.Times = Value;
})
]
]
]
]
+ SVerticalBox::Slot()
.Padding(0, 13, 0, 0)
[
SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(TEXT("时间")))
.Font(NormalText.Font)
.Justification(ETextJustify::Center)
]
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SNew(SSpinBox<float>)
.Value(0.3)
.MinValue(0.3)
.OnValueChanged_Lambda([this](const float& Value)
{
CustomData.Time = Value;
})
// .TypeInterface(MakeShared<TNumericUnitTypeInterface<int32>>(EUnit::Seconds))
]
]
]
]
+ SVerticalBox::Slot()
.SizeParam(FStretch(1.0))
[
SNew(SSpacer)
]
+ SVerticalBox::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Bottom)
.Padding(0, 0, 0, 24)
[
SNew(SBox).HeightOverride(40).WidthOverride(144)
[
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("SaveCustomPreset.png"), {144, 40}))
.OnMouseButtonDown_Lambda([this](const FGeometry&, const FPointerEvent&)
{
TSharedPtr<SNewProjectTips> NewProjectTips = SNew(SNewProjectTips).Title(TEXT("保存自定义效果名称"));
NewProjectTips->OnEnsure.BindLambda([this, NewProjectTips](const FString& String)
{
MainWidgetInterface->AddNewCustomPreset(String, CustomData);
GEngine->GameViewport->RemoveViewportWidgetContent(NewProjectTips.ToSharedRef());
});
GEngine->GameViewport->AddViewportWidgetContent(NewProjectTips.ToSharedRef()
, 1);
return FReply::Handled();
})
]
+ SOverlay::Slot()
[
SNew(STextBlock)
.Visibility(EVisibility::HitTestInvisible)
.Text(FText::FromString((TEXT("保存自定义效果"))))
.Font(NormalText.Font)
.Justification(ETextJustify::Center)
]
]
];
// TODO: 配置文件保存自定义效果
// TODO: 自定义效果拖拽到轨道
return PropertiesWidget;
}

View File

@ -78,6 +78,6 @@ public:
virtual TSharedPtr<SWidget> GetPropertiesWidget() override;
TSharedPtr<SComboBox<TSharedPtr<FString>>> GroupComboBox;
TArray<TSharedPtr<FString>> Selectable;
FPresetsCustomData CustomData;
};

View File

@ -0,0 +1,286 @@
#include "ClipProxy.h"
#include "Cut5/Utils/Utils.h"
#include "Cut5/Widgets/STimelineClip.h"
#include "Cut5/Widgets/MicroWidgets/SNewProjectTips.h"
#include "Widgets/Input/SSpinBox.h"
#include "Widgets/Layout/SSpacer.h"
TSharedPtr<FClipProxy> FClipProxy::GetProxy()
{
static TSharedPtr<FClipProxy> Proxy = MakeShareable(new FClipProxy());
return Proxy;
}
void FClipProxy::UpdateInterface(STimelineClip* InTimeClip)
{
this->TimelineClip = InTimeClip;
TimelineClip->MainWidgetInterface->UpdateProperties(nullptr);
TimelineClip->MainWidgetInterface->UpdateProperties(this);
}
TSharedPtr<SWidget> FClipProxy::GetPropertiesWidget()
{
Selectable.Empty();
Selectable.Add(MakeShared<FString>(TEXT("")));
Selectable.Add(MakeShared<FString>(TEXT("呼吸")));
Selectable.Add(MakeShared<FString>(TEXT("闪烁")));
Selectable.Add(MakeShared<FString>(TEXT("渐变")));
FTextBlockStyle NormalText = FAppStyle::GetWidgetStyle<FTextBlockStyle>("NormalText");
NormalText.SetFontSize(13);
return PropertiesWidget =
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.Padding(0, 13, 0, 0)
[
SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(TEXT("颜色")))
.Font(NormalText.Font)
.Justification(ETextJustify::Center)
]
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("Color.png"), {}))
.ColorAndOpacity_Lambda([this]()
{
if (TimelineClip->ClipData->PresetsCustomData.Colors.Num() == 0)
{
return FLinearColor(1, 1, 1, 0.5);
}
else
{
return TimelineClip->ClipData->PresetsCustomData.Colors[0];
}
})
.OnMouseButtonDown_Lambda([this](const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
TimelineClip->MainWidgetInterface->OpenColorPanel(&TimelineClip->ClipData->PresetsCustomData.Colors[0]);
return FReply::Handled();
})
]
]
]
]
+ SVerticalBox::Slot()
.Padding(0, 13, 0, 0)
[
SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(TEXT("动效")))
.Font(NormalText.Font)
.Justification(ETextJustify::Center)
]
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SNew(SComboBox<TSharedPtr<FString>>)
.OptionsSource(&Selectable)
.OnGenerateWidget_Lambda([this](TSharedPtr<FString> InItem)
{
return SNew(STextBlock).Text(FText::FromString(*InItem));
})
.OnSelectionChanged_Lambda([this](TSharedPtr<FString> InItem, ESelectInfo::Type SelectInfo)
{
switch (Selectable.Find(InItem))
{
case 0:
TimelineClip->ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::None;
break;
case 1:
TimelineClip->ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Breathe;
break;
case 2:
TimelineClip->ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Flash;
break;
case 3:
TimelineClip->ClipData->PresetsCustomData.PresetCustomType = FPresetsCustomData::EPresetCustomType::Gradient;
default:
break;
}
})
[
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("闪烁"));
})
]
]
]
]
]
+ SVerticalBox::Slot()
.Padding(0, 13, 0, 0)
[
SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(TEXT("次数")))
.Font(NormalText.Font)
.Justification(ETextJustify::Center)
]
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SNew(SSpinBox<int32>)
.Value_Lambda([this]()
{
return TimelineClip->ClipData->PresetsCustomData.Times;
})
.MinValue(1)
.MaxValue(200)
.OnValueChanged_Lambda([this](const int32& Value)
{
TimelineClip->ClipData->PresetsCustomData.Times = Value;
})
]
]
]
]
+ SVerticalBox::Slot()
.Padding(0, 13, 0, 0)
[
SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(TEXT("时间")))
.Font(NormalText.Font)
.Justification(ETextJustify::Center)
]
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SNew(SSpinBox<float>)
.Value(0.3)
.MinValue(0.3)
.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;
})
.Value_Lambda([this]()
{
return (TimelineClip->ClipData->ClipEndFrame - TimelineClip->ClipData->ClipStartFrame) / FGlobalData::GlobalFPS;
})
// .TypeInterface(MakeShared<TNumericUnitTypeInterface<int32>>(EUnit::Seconds))
]
]
]
]
+ SVerticalBox::Slot()
.SizeParam(FStretch(1.0))
[
SNew(SSpacer)
]
+ SVerticalBox::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Bottom)
.Padding(0, 0, 0, 24)
[
SNew(SBox).HeightOverride(40).WidthOverride(144)
[
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("SaveCustomPreset.png"), {144, 40}))
.OnMouseButtonDown_Lambda([this](const FGeometry&, const FPointerEvent&)
{
TSharedPtr<SNewProjectTips> NewProjectTips = SNew(SNewProjectTips).Title(TEXT("保存自定义效果名称"));
NewProjectTips->OnEnsure.BindLambda([this, NewProjectTips](const FString& String)
{
TimelineClip->MainWidgetInterface->AddNewCustomPreset(String, TimelineClip->ClipData->PresetsCustomData);
GEngine->GameViewport->RemoveViewportWidgetContent(NewProjectTips.ToSharedRef());
});
GEngine->GameViewport->AddViewportWidgetContent(NewProjectTips.ToSharedRef()
, 1);
return FReply::Handled();
})
]
+ SOverlay::Slot()
[
SNew(STextBlock)
.Visibility(EVisibility::HitTestInvisible)
.Text(FText::FromString((TEXT("保存自定义效果"))))
.Font(NormalText.Font)
.Justification(ETextJustify::Center)
]
]
];
// TODO: 配置文件保存自定义效果
// TODO: 自定义效果拖拽到轨道
}

View File

@ -0,0 +1,18 @@
#pragma once
#include "Cut5/Interface/PropertiesInterface.h"
#include "Widgets/Input/SComboBox.h"
class FClipProxy : public IPropertiesInterface
{
public:
static TSharedPtr<FClipProxy> GetProxy();
void UpdateInterface(class STimelineClip* InTimeClip);
virtual TSharedPtr<SWidget> GetPropertiesWidget() override;
TSharedPtr<SComboBox<TSharedPtr<FString>>> GroupComboBox;
TArray<TSharedPtr<FString>> Selectable;
STimelineClip* TimelineClip;
};