删除视频

This commit is contained in:
Sch 2023-08-05 15:53:33 +08:00
parent e992cca891
commit 7ca0aaed8d
10 changed files with 252 additions and 12 deletions

BIN
Resources/CheckBox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

BIN
Resources/DeleteButton.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

BIN
Resources/Edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

BIN
Resources/ImportVideo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

View File

@ -62,6 +62,15 @@ void SEffectCard::Construct(const FArguments& InArgs)
SNew(SButton) SNew(SButton)
.HAlign(HAlign_Fill) .HAlign(HAlign_Fill)
.VAlign(VAlign_Fill) .VAlign(VAlign_Fill)
.OnPressed_Lambda([this]()
{
FGeometry Geometry;
FPointerEvent PointerEvent;
TSharedPtr<FEffectCardDragDrop> EffectCardDragDrop = MakeShared<FEffectCardDragDrop>();
OnDragDetected(Geometry, PointerEvent).BeginDragDrop(EffectCardDragDrop.ToSharedRef());
})
.ClickMethod(EButtonClickMethod::MouseDown)
.OnClicked_Lambda([this]() .OnClicked_Lambda([this]()
{ {
if (GroupProperty->bIsDedicated) if (GroupProperty->bIsDedicated)
@ -145,6 +154,11 @@ void SEffectCard::Construct(const FArguments& InArgs)
PropertiesInterfaceGUID = CardProperty->Guid; PropertiesInterfaceGUID = CardProperty->Guid;
} }
FReply SEffectCard::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
{
return SCompoundWidget::OnDrop(MyGeometry, DragDropEvent);
}
void SEffectCard::ShowClosedButton(bool bShow) void SEffectCard::ShowClosedButton(bool bShow)
{ {
if (bShow) if (bShow)

View File

@ -37,6 +37,7 @@ public:
/** Constructs this widget with InArgs */ /** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs); void Construct(const FArguments& InArgs);
virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
ICutMainWidgetInterface* MainInterface; ICutMainWidgetInterface* MainInterface;
void ShowClosedButton(bool bShow); void ShowClosedButton(bool bShow);
@ -57,3 +58,5 @@ public:
FString CardName; FString CardName;
}; };

View File

@ -39,6 +39,8 @@ BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SCustomInputPanel::Construct(const FArguments& InArgs) void SCustomInputPanel::Construct(const FArguments& InArgs)
{ {
FTextBlockStyle NormalText = FAppStyle::GetWidgetStyle<FTextBlockStyle>("NormalText");
NormalText.SetFontSize(16);
ChildSlot ChildSlot
[ [
@ -65,14 +67,21 @@ void SCustomInputPanel::Construct(const FArguments& InArgs)
[ [
SNew(SHorizontalBox) SNew(SHorizontalBox)
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.SizeParam(FAuto())
.Padding(16, 11, 0, 0)
[ [
SNew(SOverlay) SNew(SOverlay)
+ SOverlay::Slot() + SOverlay::Slot()
[ [
SNew(SButton) SNew(SButton)
.ButtonStyle(FCoreStyle::Get(), "NoBorder")
.OnClicked_Lambda([this]() .OnClicked_Lambda([this]()
{ {
Switcher->SetActiveWidgetIndex(0); Switcher->SetActiveWidgetIndex(0);
bIsAssetPanel = false;
bIsEditMode = false;
EditButton->SetVisibility(bIsAssetPanel ? EVisibility::Visible : EVisibility::Collapsed);
return FReply::Handled(); return FReply::Handled();
}) })
] ]
@ -80,18 +89,26 @@ void SCustomInputPanel::Construct(const FArguments& InArgs)
[ [
SNew(STextBlock) SNew(STextBlock)
.Text(FText::FromString(TEXT("效果预设"))) .Text(FText::FromString(TEXT("效果预设")))
.Font(NormalText.Font)
.Visibility(EVisibility::HitTestInvisible) .Visibility(EVisibility::HitTestInvisible)
] ]
] ]
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.SizeParam(FAuto())
.Padding(16, 11, 0, 0)
[ [
SNew(SOverlay) SNew(SOverlay)
+ SOverlay::Slot() + SOverlay::Slot()
[ [
SNew(SButton) SNew(SButton)
.ButtonStyle(FCoreStyle::Get(), "NoBorder")
.OnClicked_Lambda([this]() .OnClicked_Lambda([this]()
{ {
Switcher->SetActiveWidgetIndex(1); Switcher->SetActiveWidgetIndex(1);
bIsAssetPanel = true;
bIsEditMode = false;
EditButton->SetVisibility(bIsAssetPanel ? EVisibility::Visible : EVisibility::Collapsed);
return FReply::Handled(); return FReply::Handled();
}) })
] ]
@ -99,9 +116,51 @@ void SCustomInputPanel::Construct(const FArguments& InArgs)
[ [
SNew(STextBlock) SNew(STextBlock)
.Text(FText::FromString(TEXT("素材库"))) .Text(FText::FromString(TEXT("素材库")))
.Font(NormalText.Font)
.Visibility(EVisibility::HitTestInvisible) .Visibility(EVisibility::HitTestInvisible)
] ]
] ]
+ SHorizontalBox::Slot()
.Padding(0, 0, 10, 0)
.HAlign(HAlign_Right)
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(20)
.HeightOverride(20)
[
SAssignNew(EditButton, SImage)
.Visibility(bIsAssetPanel ? EVisibility::Visible : EVisibility::Collapsed)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("Edit.png"), {20, 20}))
.OnMouseButtonDown_Lambda([this](const FGeometry& Geometry, const FPointerEvent& MouseEvent)
{
if (bIsEditMode)
{
bIsEditMode = false;
ImportImage->SetImage(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("ImportVideo.png"), {}));
ImportText->SetText(FText::FromString(TEXT("导入视频")));
for (int32 i = 0; i < ResourceInst.Num(); i++)
{
ResourceInst[i]->ShowCheckBox(false);
}
SelectedProperties.Empty();
}
else
{
bIsEditMode = true;
ImportImage->SetImage(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("DeleteButton.png"), {}));
ImportText->SetText(FText::FromString(TEXT("删除预设")));
for (int32 i = 0; i < ResourceInst.Num(); i++)
{
ResourceInst[i]->ShowCheckBox(true);
}
}
return FReply::Handled();
})
]
]
] ]
+ SVerticalBox::Slot() + SVerticalBox::Slot()
[ [
@ -130,17 +189,46 @@ void SCustomInputPanel::Construct(const FArguments& InArgs)
] ]
+ SVerticalBox::Slot() + SVerticalBox::Slot()
.SizeParam(FStretch(0.1)) .SizeParam(FAuto())
.HAlign(HAlign_Fill) .HAlign(HAlign_Fill)
.VAlign(VAlign_Fill) .VAlign(VAlign_Bottom)
.Padding(102, 0, 102, 24)
[ [
SNew(SVerticalBox) SNew(SBox)
+ SVerticalBox::Slot() .WidthOverride(144)
.HeightOverride(40)
[ [
SNew(SButton) SNew(SButton)
.Text(FText::FromString(TEXT("Open Video"))) .ButtonStyle(FCoreStyle::Get(), "NoBorder")
.OnClicked_Lambda([this]() .OnClicked_Lambda([this]()
{ {
if (bIsEditMode)
{
for (int32 i = 0; i < SelectedProperties.Num(); i++)
{
for (int32 j = 0; j < ResourceInst.Num(); j++)
{
if (ResourceInst[j]->PropertyData.Guid == SelectedProperties[i].Guid)
{
ResourceInst[j]->ShowCheckBox(false);
ResourceInst[j]->SetVisibility(EVisibility::Collapsed);
ResourceInst.RemoveAt(j);
break;
}
GridPanel->RemoveSlot(ResourceInst[j].ToSharedRef());
}
for (int32 j = 0; j < PropertyData.Num(); j++)
{
if (PropertyData[j].Guid == SelectedProperties[i].Guid)
{
PropertyData.RemoveAt(j);
break;
}
}
}
return FReply::Handled();
}
IDesktopPlatform* DesktopPlatformModule = FDesktopPlatformModule::Get(); IDesktopPlatform* DesktopPlatformModule = FDesktopPlatformModule::Get();
TArray<FString> OpenFileName; TArray<FString> OpenFileName;
DesktopPlatformModule->OpenFileDialog(nullptr, (TEXT("打开文件")), TEXT(""), TEXT(""), TEXT(""), EFileDialogFlags::None, OpenFileName); DesktopPlatformModule->OpenFileDialog(nullptr, (TEXT("打开文件")), TEXT(""), TEXT(""), TEXT(""), EFileDialogFlags::None, OpenFileName);
@ -151,28 +239,89 @@ void SCustomInputPanel::Construct(const FArguments& InArgs)
{ {
FTimelinePropertyData Data; FTimelinePropertyData Data;
FFFMPEGUtils::LoadMedia(OpenFileName[i], &Data); FFFMPEGUtils::LoadMedia(OpenFileName[i], &Data);
TSharedPtr<SCustomInputResource> Resource = SNew(SCustomInputResource)
.PropertyData(Data).OnCheckBoxChecked_Lambda([this](FTimelinePropertyData& Data, bool bIsChecked)
{
if (bIsChecked == true)
{
SelectedProperties.Add(Data);
}
else
{
SelectedProperties.Remove(Data);
}
});
GridPanel->AddSlot(GridPanel->GetChildren()->Num() % 2, GridPanel->GetChildren()->Num() / 2) GridPanel->AddSlot(GridPanel->GetChildren()->Num() % 2, GridPanel->GetChildren()->Num() / 2)
[ [
SNew(SCustomInputResource) Resource.ToSharedRef()
.PropertyData(Data)
]; ];
PropertyData.Add(Data); PropertyData.Add(Data);
ResourceInst.Add(Resource.ToSharedRef());
if (bIsEditMode)
{
Resource->ShowCheckBox(true);
}
return FReply::Handled(); return FReply::Handled();
} }
else else
{ {
FTimelinePropertyData Data; FTimelinePropertyData Data;
FFFMPEGUtils::LoadMedia(OpenFileName[i], &Data); FFFMPEGUtils::LoadMedia(OpenFileName[i], &Data);
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, FString::Printf(TEXT("GUID %s"), *Data.Guid.ToString()));
TSharedPtr<SCustomInputResource> Resource = SNew(SCustomInputResource)
.PropertyData(Data).OnCheckBoxChecked_Lambda([this](FTimelinePropertyData& ClickedData, bool bIsChecked)
{
if (bIsChecked == true)
{
SelectedProperties.Add(ClickedData);
}
else
{
for (int32 i = 0; i < SelectedProperties.Num(); i++)
{
if (SelectedProperties[i].Guid == ClickedData.Guid)
{
SelectedProperties.RemoveAt(i);
break;
}
}
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, FString::Printf(TEXT("Num %d"), SelectedProperties.Num()));
}
});
GridPanel->AddSlot(GridPanel->GetChildren()->Num() % 2, GridPanel->GetChildren()->Num() / 2) GridPanel->AddSlot(GridPanel->GetChildren()->Num() % 2, GridPanel->GetChildren()->Num() / 2)
[ [
SNew(SCustomInputResource) Resource.ToSharedRef()
.PropertyData(Data)
]; ];
PropertyData.Add(Data); PropertyData.Add(Data);
ResourceInst.Add(Resource.ToSharedRef());
if (bIsEditMode)
{
Resource->ShowCheckBox(true);
} }
} }
}
return FReply::Handled(); return FReply::Handled();
}) })
[
SNew(SOverlay)
+ SOverlay::Slot()
[
SAssignNew(ImportImage, SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("ImportVideo.png"), {}))
]
+ SOverlay::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SAssignNew(ImportText, STextBlock)
.Text(FText::FromString(TEXT("导入视频")))
.Justification(ETextJustify::Center)
]
]
] ]
] ]
] ]
@ -366,5 +515,15 @@ void SCustomInputPanel::ClearPanel()
PropertyData.Empty(); PropertyData.Empty();
} }
void SCustomInputPanel::AddPreset(const FString& PresetPath)
{
}
void SCustomInputPanel::AddCustomPreset()
{
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -48,7 +48,17 @@ public:
TSharedPtr<SWidgetSwitcher> Switcher; TSharedPtr<SWidgetSwitcher> Switcher;
TArray<FTimelinePropertyData> PropertyData; TArray<FTimelinePropertyData> PropertyData;
TArray<TSharedPtr<class SCustomInputResource>> ResourceInst;
void SavePanel(const FString& SavePlace); void SavePanel(const FString& SavePlace);
void LoadPanel(const FString& LoadPlace); void LoadPanel(const FString& LoadPlace);
void ClearPanel(); void ClearPanel();
void AddPreset(const FString& PresetPath);
void AddCustomPreset();
bool bIsAssetPanel = false;
bool bIsEditMode = false;
TSharedPtr<SImage> EditButton;
TSharedPtr<SImage> ImportImage;
TSharedPtr<STextBlock> ImportText;
TArray<FTimelinePropertyData> SelectedProperties;
}; };

View File

@ -13,13 +13,16 @@ void SCustomInputResource::Construct(const FArguments& InArgs)
{ {
PropertyData = InArgs._PropertyData; PropertyData = InArgs._PropertyData;
VideoCapture = InArgs._VideoCapture; VideoCapture = InArgs._VideoCapture;
OnCheckBoxChecked = InArgs._OnCheckBoxChecked;
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Orange, FString::Printf(TEXT("GUID %s"), *PropertyData.Guid.ToString()));
ChildSlot ChildSlot
[ [
SNew(SBox) SNew(SBox)
.WidthOverride(173.5) .WidthOverride(155)
.HeightOverride(97.5) .HeightOverride(76)
.Padding(9, 10, -9, 0)
[ [
SNew(SOverlay) SAssignNew(ImageOverlay, SOverlay)
+ SOverlay::Slot() + SOverlay::Slot()
.HAlign(HAlign_Fill) .HAlign(HAlign_Fill)
.VAlign(VAlign_Fill) .VAlign(VAlign_Fill)
@ -54,4 +57,47 @@ FReply SCustomInputResource::OnDragDetected(const FGeometry& MyGeometry, const F
return FReply::Handled().BeginDragDrop(Operation.ToSharedRef()); return FReply::Handled().BeginDragDrop(Operation.ToSharedRef());
} }
void SCustomInputResource::ShowCheckBox(bool bShow)
{
if (bShow)
{
if (Box)
return;
CheckBox =
SNew(SCheckBox)
// .BackgroundImage(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("CheckBox.png"), {}))
.OnCheckStateChanged_Lambda([this](const ECheckBoxState& State)
{
if (State == ECheckBoxState::Checked)
OnCheckBoxChecked.ExecuteIfBound(PropertyData, true);
else
OnCheckBoxChecked.ExecuteIfBound(PropertyData, false);
});
ImageOverlay->AddSlot()
.HAlign(HAlign_Right)
.VAlign(VAlign_Top)
[
SAssignNew(Box, SBox)
.WidthOverride(20)
.HeightOverride(20)
[
CheckBox.ToSharedRef()
]
];
}
else
{
if (Box)
{
ImageOverlay->RemoveSlot(Box.ToSharedRef());
Box.Reset();
}
}
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -9,6 +9,7 @@
/** /**
* *
*/ */
DECLARE_DELEGATE_TwoParams(FOnCheckBoxChecked, FTimelinePropertyData, bool);
class CUT5_API SCustomInputResource : public SCompoundWidget class CUT5_API SCustomInputResource : public SCompoundWidget
{ {
public: public:
@ -17,6 +18,7 @@ public:
} }
SLATE_ARGUMENT(FTimelinePropertyData, PropertyData) SLATE_ARGUMENT(FTimelinePropertyData, PropertyData)
SLATE_ARGUMENT(cv::VideoCapture, VideoCapture) SLATE_ARGUMENT(cv::VideoCapture, VideoCapture)
SLATE_EVENT(FOnCheckBoxChecked, OnCheckBoxChecked)
SLATE_END_ARGS() SLATE_END_ARGS()
/** Constructs this widget with InArgs */ /** Constructs this widget with InArgs */
@ -24,5 +26,11 @@ public:
void Construct(const FArguments& InArgs); void Construct(const FArguments& InArgs);
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override; virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnDragDetected(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override; virtual FReply OnDragDetected(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
void ShowCheckBox(bool bShow);
FOnCheckBoxChecked OnCheckBoxChecked;
TSharedPtr<SOverlay> ImageOverlay;
cv::VideoCapture VideoCapture; cv::VideoCapture VideoCapture;
TSharedPtr<SWidget> CheckBox;
TSharedPtr<SBox> Box;
}; };