自定义幕面板

This commit is contained in:
Sch 2023-08-09 12:22:49 +08:00
parent c817dffd24
commit 0c76c49108
14 changed files with 164 additions and 55 deletions

BIN
Resources/CurtainHover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

BIN
Resources/CurtainNormal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

View File

@ -57,8 +57,12 @@ uint8* FUtils::ConvertTwoChannelSound2PortAudioSound(uint8* Channel1, uint8* Cha
}
FString FUtils::GetResourcesPath(FString ResourcesName)
FString FUtils::GetResourcesPath(FString ResourcesName, bool bFullPath)
{
if (bFullPath)
{
return FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::ProjectDir() + "/Resources/", ResourcesName));
}
return FPaths::Combine(FPaths::ProjectDir() + "/Resources/", ResourcesName);
}

View File

@ -11,7 +11,7 @@ public:
static uint8* ConvertFfMpegSound2PortAudioSound(uint8* inData[8], int32 Size);
static uint8* ConvertTwoChannelSound2PortAudioSound(uint8* Channel1, uint8* Channel2, int32 Size);
static FString GetResourcesPath(FString ResourcesName);
static FString GetResourcesPath(FString ResourcesName, bool bFullPath = false);
static FSlateDynamicImageBrush* GetBrushFromImage(const FString& ImageName, const FVector2D Size);
static TArray<FSlateDynamicImageBrush*> BrushPtr;

View File

@ -5,6 +5,8 @@
#include "SCurtainPanel.h"
#include "SlateOptMacros.h"
#include "Brushes/SlateBoxBrush.h"
#include "Brushes/SlateImageBrush.h"
#include "Cut5/Utils/Utils.h"
#include "Widgets/Text/SInlineEditableTextBlock.h"
@ -16,27 +18,32 @@ void SCurtain::Construct(const FArguments& InArgs)
CurtainPanel = InArgs._CurtainPanel;
CurtainGroup = InArgs._CurtainGroup;
CurtainIndex = InArgs._CurtainIndex;
UnSelectedButtonStyle.SetNormal(FSlateImageBrush("D:\\Project\\Cut5\\Resources\\CurtainNormal.png", FVector2D(257, 32), FLinearColor(42.0f /255, 42.0f /255, 42.0f /255, 1.0f)));
UnSelectedButtonStyle.SetHovered(FSlateBoxBrush(*FUtils::GetResourcesPath("CurtainHover.png", true), FMargin(1.0), FLinearColor(46.0 /255,48.0/255,54.0/255,1.0f)));
UnSelectedButtonStyle.SetPressed(FSlateBoxBrush(*FUtils::GetResourcesPath("CurtainSelected.png", true), FMargin(1.0), FLinearColor(88.0/255,96.0/255,121.0/255,1.0f)));
SelectedButtonStyle.SetNormal(FSlateBoxBrush(FUtils::GetResourcesPath("CurtainSelected.png", true), FMargin(1.0), FLinearColor(88.0/255,96.0/255,121.0/255,1.0f)));
ChildSlot
[
SNew(SBox)
.WidthOverride(257)
.HeightOverride(50)
.HeightOverride(32)
[
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SImage)
.ColorAndOpacity(Curtain->bIsActive ? FLinearColor(0.5, 0.5, 1.0, 1) : FLinearColor(1, 1, 1, 1))
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("BackGround.png"), {}))
.OnMouseButtonDown_Lambda([this](const FGeometry& Geometry, const FPointerEvent& Event)
SAssignNew(CurtainButton, SButton)
.ClickMethod(EButtonClickMethod::MouseDown)
.ButtonStyle(&UnSelectedButtonStyle)
.OnClicked_Lambda([this]()
{
if (Event.GetEffectingButton() == EKeys::RightMouseButton)
{
CurtainPanel->ShowCurtainCommand(Curtain->CurtainUUID);
return FReply::Handled();
}
CurtainPanel->DeSelectedAll();
Curtain->bIsActive = true;
CurtainPanel->CallRender();
@ -47,7 +54,9 @@ void SCurtain::Construct(const FArguments& InArgs)
CurtainDragDrop->DragDropType = FCutDragDropBase::EType::CurtainDrag;
CurtainDragDrop->DraggingWidget = SharedThis(this);
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton).BeginDragDrop(CurtainDragDrop.ToSharedRef());
return FReply::Handled();
})
]
+ SOverlay::Slot()
.HAlign(HAlign_Left)
@ -95,6 +104,7 @@ FReply SCurtain::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEv
CurtainPanel->ShowCurtainCommand(Curtain->CurtainUUID);
return FReply::Handled();
}
return SCompoundWidget::OnMouseButtonDown(MyGeometry, MouseEvent);
}

View File

@ -31,4 +31,8 @@ public:
FCurtainGroup* CurtainGroup;
int32 CurtainIndex;
TSharedPtr<SInlineEditableTextBlock> InlineEditableTextBlock;
TSharedPtr<SButton> CurtainButton;
FButtonStyle UnSelectedButtonStyle = FButtonStyle::GetDefault();
FButtonStyle SelectedButtonStyle = FButtonStyle::GetDefault();
};

View File

@ -22,65 +22,132 @@ void SCurtainGroup::Construct(const FArguments& InArgs)
[
SNew(SBox)
.WidthOverride(257)
.HeightOverride(53 + CurtainGroup->Curtains.Num() * 32)
.Padding(3)
[
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SBorder)
.ColorAndOpacity(CurtainGroup->bIsActive ? FLinearColor(0.5, 0.5, 1.0, 1) : FLinearColor(1, 1, 1, 1))
]
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("BackGround.png"), {}))
.ColorAndOpacity(CurtainGroup->bIsActive ? FLinearColor(0.5, 0.5, 1.0, 1) : FLinearColor(1, 1, 1, 1))
.OnMouseButtonDown_Lambda([this](const FGeometry& Geometry, const FPointerEvent& Event)
{
CurtainPanel->DeSelectedAll();
CurtainGroup->bIsActive = true;
CallRender();
return FReply::Handled();
})
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("CurtainBackGroundUnSelected.png"), {}))
]
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SExpandableArea)
.OnAreaExpansionChanged_Lambda([this](bool bIsExpanded)
{
CurtainPanel->DeSelectedAll();
CurtainGroup->bIsActive = true;
CallRender();
})
// .Style(&ExpandableAreaStyle)
.HeaderContent()
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.SizeParam(FAuto())
[
SAssignNew(InlineEditableTextBlock, SInlineEditableTextBlock)
.Text(FText::FromString(CurtainGroup->GroupName))
.OnVerifyTextChanged_Lambda([](const FText& Text, FText& ErrorMessage)
{
if (Text.ToString() == "")
{
ErrorMessage = FText::FromString(TEXT("组名不能为空"));
return false;
}
return true;
})
SNew(SBox)
.HeightOverride(53)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.HAlign(HAlign_Left)
[
SNew(SInlineEditableTextBlock)
.Text(FText::FromString(CurtainGroup->GroupName))
]
+ SHorizontalBox::Slot()
.HAlign(HAlign_Right)
.VAlign(VAlign_Center)
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(24)
.HeightOverride(24)
[
SAssignNew(ExpandedImage, SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("CurtainStateExpanded.png"), {24, 24}))
.OnMouseButtonDown_Lambda([this](const FGeometry& Geometry, const FPointerEvent& Event)
{
if (CurtainGroup->bIsExpanded)
{
CurtainGroup->bIsExpanded = false;
ExpandedImage->SetImage(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("CurtainStateExpanded.png"), {24, 24}));
}
else
{
CurtainGroup->bIsExpanded = true;
ExpandedImage->SetImage(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("CurtainStateCollapsed.png"), {24, 24}));
}
return FReply::Handled();
})
]
]
]
]
.BodyContent()
+ SVerticalBox::Slot()
.SizeParam(FAuto())
.Padding(26, 0, 0, 0)
[
SAssignNew(ContentVerticalBox, SVerticalBox)
]
]
]
// SNew(SBox)
// .WidthOverride(257)
// .Padding(3)
// [
// SNew(SOverlay)
// + SOverlay::Slot()
// .HAlign(HAlign_Fill)
// .VAlign(VAlign_Fill)
// [
// SNew(SBorder)
// .ColorAndOpacity(CurtainGroup->bIsActive ? FLinearColor(0.5, 0.5, 1.0, 1) : FLinearColor(1, 1, 1, 1))
// ]
// + SOverlay::Slot()
// .HAlign(HAlign_Fill)
// .VAlign(VAlign_Fill)
// [
// SNew(SImage)
// .Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("BackGround.png"), {}))
// .ColorAndOpacity(CurtainGroup->bIsActive ? FLinearColor(0.5, 0.5, 1.0, 1) : FLinearColor(1, 1, 1, 1))
// .OnMouseButtonDown_Lambda([this](const FGeometry& Geometry, const FPointerEvent& Event)
// {
// CurtainPanel->DeSelectedAll();
// CurtainGroup->bIsActive = true;
// CallRender();
// return FReply::Handled();
// })
// ]
// + SOverlay::Slot()
// .HAlign(HAlign_Fill)
// .VAlign(VAlign_Fill)
// [
// SNew(SExpandableArea)
//
// .OnAreaExpansionChanged_Lambda([this](bool bIsExpanded)
// {
// CurtainPanel->DeSelectedAll();
// CurtainGroup->bIsActive = true;
// CallRender();
// })
// // .Style(&ExpandableAreaStyle)
// .HeaderContent()
// [
// SAssignNew(InlineEditableTextBlock, SInlineEditableTextBlock)
// .Text(FText::FromString(CurtainGroup->GroupName))
// .OnVerifyTextChanged_Lambda([](const FText& Text, FText& ErrorMessage)
// {
// if (Text.ToString() == "")
// {
// ErrorMessage = FText::FromString(TEXT("组名不能为空"));
// return false;
// }
// return true;
// })
// ]
// .BodyContent()
// [
// SAssignNew(ContentVerticalBox, SVerticalBox)
// ]
// ]
//
// ]
];
CallRender();
}

View File

@ -28,6 +28,7 @@ public:
SCurtainPanel* CurtainPanel;
TSharedPtr<SVerticalBox> ContentVerticalBox;
TSharedPtr<SImage> ExpandedImage;
void CallRender();

View File

@ -205,6 +205,17 @@ struct CUT5_API FClipData
{
VideoStartFrame += CropFrame;
}
if (ClipType == ETrackType::AtomSphereLightTrack)
{
int32 OffsetFrame = ClipEndFrame - ClipStartFrame + CropFrame;
for (int32 i = 0; i < Cursors.Num(); i++)
{
if (Cursors[i].CursorFrameOffset < OffsetFrame)
{
Cursors[i].CursorFrameOffset = OffsetFrame;
}
}
}
}
else
@ -214,6 +225,17 @@ struct CUT5_API FClipData
{
VideoEndFrame -= CropFrame;
}
if (ClipType == ETrackType::AtomSphereLightTrack)
{
int32 OffsetFrame = ClipEndFrame - ClipStartFrame;
for (int32 i = 0; i < Cursors.Num(); i++)
{
if (Cursors[i].CursorFrameOffset > OffsetFrame)
{
Cursors[i].CursorFrameOffset = OffsetFrame;
}
}
}
}
}
// A Ptr to Input Resource;
@ -477,7 +499,7 @@ public:
FGuid GroupUID = FGuid::NewGuid();
TArray<FCurtain> Curtains;
bool bIsActive = false;
bool bIsExpanded = false;
friend FArchive& operator<< (FArchive& Ar, FCurtainGroup& Curtain)
{
Ar << Curtain.GroupName;

View File

@ -334,7 +334,7 @@ void STimelineClip::UpdatePosition(int32 StartFrame)
const int32 NewPosX = StartFrame * FGlobalData::DefaultTimeTickSpace;
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::FromInt(NewPosX));
SetRenderTransform(FSlateRenderTransform(FVector2D(NewPosX, 0)));
ClipDataBox->SetWidthOverride((ClipData->ClipEndFrame - StartFrame) * FGlobalData::DefaultTimeTickSpace);
ClipDataBox->SetWidthOverride((ClipData->ClipEndFrame - StartFrame) * FGlobalData::DefaultTimeTickSpace * 10);
if (ClipData->ClipType == ETrackType::VideoTrack)
{
ClipData->VideoStartFrame += StartFrame - ClipData->ClipStartFrame;

View File

@ -65,6 +65,7 @@ void STrackBody::Construct(const FArguments& InArgs)
void STrackBody::CallRender()
{
Overlay->ClearChildren();
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Black, FString::Printf(TEXT("CallRender")));
SlateClips.Empty();
for (FClipData& TempClipData : TrackHead->TrackData.ClipData)
{