添加幕

This commit is contained in:
Sch 2023-07-07 11:55:21 +08:00
parent ff430b9e70
commit fac8d5104b
4 changed files with 247 additions and 0 deletions

View File

@ -0,0 +1,171 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "SCurtainPanel.h"
#include "SlateOptMacros.h"
#include "Widgets/Layout/SScrollBox.h"
#include "Widgets/Views/STreeView.h"
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SCurtainTree::Construct(const FArguments& InArgs)
{
ChildSlot
[
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SButton)
]
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SAssignNew(TreeView, STreeView<TSharedPtr<FCurtain>>)
.OnGenerateRow(this, &SCurtainTree::GenerateRow)
.OnGetChildren(this, &SCurtainTree::GetChildrenForTree)
.TreeItemsSource(&RootCurtain)
.ItemHeight(30.0)
.SelectionMode(ESelectionMode::Single)
]
];
RootCurtain.Add(MakeShared<FCurtain>());
}
TSharedRef<ITableRow> SCurtainTree::GenerateRow(TSharedPtr<FCurtain> Curtain,
const TSharedRef<STableViewBase>& TableViewBase) const
{
return SNew(STableRow<TSharedPtr<FCurtain>>, TableViewBase)
[
SNew(SBox)
.HeightOverride(50)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
SNew(SOverlay)
+ SOverlay::Slot()
[
SNew(SButton)
]
+ SOverlay::Slot()
[
SNew(STextBlock)
.Text(FText::FromString(Curtain->CurtainName))
]
]
]
];
}
void SCurtainTree::GetChildrenForTree(TSharedPtr<FCurtain, ESPMode::ThreadSafe> Curtain,
TArray<TSharedPtr<FCurtain, ESPMode::ThreadSafe>>& Shareds)
{
if (Curtain)
{
Shareds = Curtain->ChildrenCurtain;
}
}
void SCurtainTree::AddNewStep()
{
RootCurtain.Add(MakeShared<FCurtain>());
TreeView->RebuildList();
}
void SCurtainPanel::Construct(const FArguments& InArgs)
{
ChildSlot
[
SNew(SBox)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SAssignNew(ScrollBox, SScrollBox)
]
+ SVerticalBox::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Bottom)
.SizeParam(FAuto())
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
SNew(SOverlay)
+ SOverlay::Slot()
[
SNew(SButton)
.OnClicked_Lambda([this]()
{
AddNewCurtain();
return FReply::Handled();
})
]
+ SOverlay::Slot()
[
SNew(STextBlock)
.Visibility(EVisibility::HitTestInvisible)
.Text(FText::FromString(TEXT("+ 单元")))
]
]
+ SHorizontalBox::Slot()
[
SNew(SOverlay)
+ SOverlay::Slot()
[
SNew(SButton)
.OnClicked_Lambda([this]()
{
if (CurrentSelectedTree < Trees.Num())
{
Trees[CurrentSelectedTree]->AddNewStep();
}
return FReply::Handled();
})
]
+ SOverlay::Slot()
[
SNew(STextBlock)
.Visibility(EVisibility::HitTestInvisible)
.Text(FText::FromString(TEXT("+ 步骤")))
]
]
]
]
];
}
void SCurtainPanel::AddNewCurtain()
{
if (ScrollBox)
{
Trees.Add(SNew(SCurtainTree).CurtainPanel(SharedThis(this)));
ScrollBox->AddSlot()
.Padding(0 , 15.0)
[
Trees[Trees.Num() - 1].ToSharedRef()
];
}
}
void SCurtainPanel::UnSelectAllCurtain()
{
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -0,0 +1,63 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Widgets/SCompoundWidget.h"
#include "Widgets/Views/STreeView.h"
/**
*
*/
class SScrollBox;
class FCurtain
{
public:
FString CurtainName = TEXT("新建幕");
FGuid CurtainUUID;
TSharedPtr<FCurtain> ParentCurtain;
TArray<TSharedPtr<FCurtain>> ChildrenCurtain;
};
class SCurtainTree : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SCurtainTree)
{
}
SLATE_ARGUMENT(TSharedPtr<class SCurtainPanel>, CurtainPanel)
SLATE_END_ARGS()
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
TSharedRef<ITableRow> GenerateRow(TSharedPtr<FCurtain> Curtain, const TSharedRef<STableViewBase>& TableViewBase) const;
void GetChildrenForTree(TSharedPtr<FCurtain, ESPMode::ThreadSafe> Curtain, TArray<TSharedPtr<FCurtain, ESPMode::ThreadSafe>>& Shareds);
void AddNewStep();
TSharedPtr<class SCurtainPanel> CurtainPanel;
TSharedPtr<STreeView<TSharedPtr<FCurtain>>> TreeView;
TArray<TSharedPtr<FCurtain>> RootCurtain;
};
class CUT5_API SCurtainPanel : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SCurtainPanel)
{
}
SLATE_END_ARGS()
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
void AddNewCurtain();
void UnSelectAllCurtain();
int32 CurrentSelectedTree = 0;
TArray<TSharedPtr<SCurtainTree>> Trees;
TSharedPtr<SScrollBox> ScrollBox;
};

View File

@ -3,6 +3,7 @@
#include "SCutMainWindow.h"
#include "SCurtainPanel.h"
#include "SCustomInputPanel.h"
#include "SCutTimeline.h"
#include "SlateOptMacros.h"
@ -38,6 +39,16 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
+ SHorizontalBox::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
[
SAssignNew(CurtainPanel, SCurtainPanel)
]
]
+ SHorizontalBox::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()

View File

@ -3,6 +3,7 @@
#pragma once
#include "CoreMinimal.h"
#include "SCurtainPanel.h"
#include "SCutTimeline.h"
#include "SLightArrayPanel.h"
#include "SVideoPlayer.h"
@ -27,6 +28,7 @@ public:
TSharedPtr<SCutTimeline> CutTimeline;
TSharedPtr<SLightArrayPanel> LightArrayPanel;
TSharedPtr<SVideoPlayer> VideoPlayer;
TSharedPtr<SCurtainPanel> CurtainPanel;
virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;