自定义面板布局

This commit is contained in:
Sch 2023-08-05 16:17:14 +08:00
parent 7ca0aaed8d
commit b9e70230f2
5 changed files with 135 additions and 6 deletions

View File

@ -73,6 +73,14 @@ enum class ETrackType
LightBarTrack,
};
enum class EPresetType
{
NotAPresets,
Color,
Gradient,
Video,
};
struct FClipData;
struct CUT5_API FTrackData
{
@ -103,7 +111,16 @@ struct CUT5_API FTrackData
int32 TrackNum = 1;
TArray<FClipData> ClipData;
};
struct CUT5_API FCursorData
{
int32 CursorFrameOffset = 0;
friend FArchive& operator<<(FArchive& Ar, FCursorData& CursorData)
{
Ar << CursorData.CursorFrameOffset;
return Ar;
}
};
struct CUT5_API FClipData
{
@ -189,7 +206,9 @@ struct CUT5_API FClipData
TArray<FColor> PlayerLightData;
// Cursor
TArray<FCursorData> Cursors;
EPresetType PresetType;
};
struct CUT5_API FTimelinePropertyData
{
@ -239,6 +258,11 @@ struct CUT5_API FTimelinePropertyData
Ar << PropertyData.MovieFrameLength;
return Ar;
}
friend bool operator==(const FTimelinePropertyData& Lhs, const FTimelinePropertyData& Rhs)
{
return Lhs.Guid == Rhs.Guid;
}
};
class CUT5_API FCutDragDropBase : public FDragDropOperation

View File

@ -0,0 +1,46 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "SEffectPreset.h"
#include "SlateOptMacros.h"
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SEffectPreset::Construct(const FArguments& InArgs)
{
Name = InArgs._Name;
PresetPath = InArgs._PresetPath;
ChildSlot
[
SNew(SBox)
.WidthOverride(76)
.HeightOverride(76)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.Padding(2)
[
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SButton)
.ClickMethod(EButtonClickMethod::MouseDown)
]
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(Name))
.Justification(ETextJustify::Center)
.Visibility(EVisibility::HitTestInvisible)
]
]
];
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -0,0 +1,26 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Widgets/SCompoundWidget.h"
/**
*
*/
class CUT5_API SEffectPreset : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SEffectPreset)
{
}
SLATE_ARGUMENT(FString, Name)
SLATE_ARGUMENT(FString, PresetPath)
SLATE_END_ARGS()
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
FString Name;
FString PresetPath;
};

View File

@ -22,6 +22,7 @@
#include "Cut5/Utils/OpencvUtils.h"
#include "Cut5/Utils/Utils.h"
#include "Kismet/GameplayStatics.h"
#include "Presets/SEffectPreset.h"
#include "Widgets/Layout/SWidgetSwitcher.h"
@ -168,8 +169,9 @@ void SCustomInputPanel::Construct(const FArguments& InArgs)
+ SWidgetSwitcher::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.Padding(16, 0, 0, 0)
[
SNew(SGridPanel)
SAssignNew(EffectGridPanel, SGridPanel)
]
+ SWidgetSwitcher::Slot()
.HAlign(HAlign_Fill)
@ -333,6 +335,28 @@ 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(""));
AddPreset(TEXT("心跳-宏"), TEXT(""));
AddPreset(TEXT("5次闪电"), TEXT(""));
AddPreset(TEXT("闪电-绿"), TEXT(""));
AddPreset(TEXT("雷-红"), TEXT(""));
AddPreset(TEXT("雷-蓝"), TEXT(""));
AddPreset(TEXT("闪烁彩云"), TEXT(""));
AddPreset(TEXT("跑马灯-橘"), TEXT(""));
AddPreset(TEXT("随机闪电"), TEXT(""));
}
FReply SCustomInputPanel::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
@ -515,9 +539,17 @@ void SCustomInputPanel::ClearPanel()
PropertyData.Empty();
}
void SCustomInputPanel::AddPreset(const FString& PresetPath)
void SCustomInputPanel::AddPreset(const FString& Name, const FString& PresetPath)
{
if (Name != "")
{
EffectGridPanel->AddSlot(EffectGridPanel->GetChildren()->Num() % 4, EffectGridPanel->GetChildren()->Num() / 4)
[
SNew(SEffectPreset)
.Name(Name)
.PresetPath(PresetPath)
];
}
}
void SCustomInputPanel::AddCustomPreset()

View File

@ -36,6 +36,7 @@ public:
virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
TSharedPtr<SGridPanel> GridPanel;
TSharedPtr<SGridPanel> EffectGridPanel;
void LoadAudio(FString Path);
static void AudioCopy(AVFormatContext* Context, AVFrame* Dst, AVFrame* Src);
@ -52,7 +53,7 @@ public:
void SavePanel(const FString& SavePlace);
void LoadPanel(const FString& LoadPlace);
void ClearPanel();
void AddPreset(const FString& PresetPath);
void AddPreset(const FString& Name, const FString& PresetPath);
void AddCustomPreset();
bool bIsAssetPanel = false;
bool bIsEditMode = false;