颜色条,自定义效果

This commit is contained in:
Sch 2023-08-13 03:25:44 +08:00
parent db9c0854a2
commit 5b1640d4f3
20 changed files with 582 additions and 37 deletions

BIN
Resources/Color.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

BIN
Resources/CustomPreset.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

View File

@ -48,8 +48,8 @@ public:
virtual void SaveProject() {};
virtual FString GetGroupName(TSharedPtr<class IWidgetInterface> WidgetInterface) { return FString(); };
virtual FTimelinePropertyData* GetResourcePropertyDataPtr(FGuid GUID) { return nullptr; };
virtual void OpenColorPanel(FLinearColor* ColorPtr) {};
virtual void AddNewCustomPreset(const FString& Name, const FPresetsCustomData CustomData) {};
virtual void OnSelectCard(const FGuid& SelectedCard) {};
virtual void OnRemoveCard(const FGuid& SelectedCard) {};

View File

@ -165,7 +165,7 @@ struct CUT5_API FPresetsData
struct CUT5_API FPresetsCustomData
{
TArray<FLinearColor> Colors;
TArray<FLinearColor> Colors = { FLinearColor::White };
int32 Times;
float Angle;
int32 Time;
@ -333,6 +333,10 @@ struct CUT5_API FTimelinePropertyData
int32 MovieFrameLength = 0;
TArray<uint8> AudioData;
bool bIsCustomPresetData = false;
FPresetsCustomData PresetsCustomData = FPresetsCustomData();
friend FArchive& operator<<(FArchive& Ar, FTimelinePropertyData& PropertyData)
{
Ar << PropertyData.Guid;
@ -345,6 +349,8 @@ struct CUT5_API FTimelinePropertyData
Ar << PropertyData.AudioStream;
Ar << PropertyData.MoviePath;
Ar << PropertyData.MovieFrameLength;
Ar << PropertyData.bIsCustomPresetData;
Ar << PropertyData.PresetsCustomData;
return Ar;
}
@ -370,6 +376,9 @@ public:
Device,
PresetDrag,
CursorDrag,
ColorDragH,
ColorDragS,
ColorDragV,
};
FCutDragDropBase() {};
FCutDragDropBase(EType InType)
@ -402,6 +411,12 @@ public:
FPresetsData PresetData = FPresetsData();
};
class CUT5_API FColorDragOperation final : public FCutDragDropBase
{
public:
};
class CUT5_API FClip2ClipDragDropOperation final : public FCutDragDropBase
{
public:

View File

@ -5,6 +5,8 @@
#include "Cut5/Widgets/SCutMainWindow.h"
#include "Cut5/Widgets/STimelineClip.h"
#include "Cut5/Widgets/STrackBody.h"
#include "Cut5/Widgets/MicroWidgets/SColorBar.h"
#include "Cut5/Widgets/MicroWidgets/SColorPanel.h"
DragDropOperator* DragDropOperator::Operator = nullptr;
@ -19,6 +21,65 @@ DragDropOperator* DragDropOperator::GetDragDropOperator()
void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
{
if (TSharedPtr<FCutDragDropBase> DragDropBase = DragDropEvent.GetOperationAs<FCutDragDropBase>())
{
if (DragDropBase->DragDropType == FCutDragDropBase::EType::ColorDragH || DragDropBase->DragDropType == FCutDragDropBase::EType::ColorDragV)
{
TSharedPtr<SColorBar> ColorBar = StaticCastSharedPtr<SColorBar>(DragDropBase->DraggingWidget);
float Local = ColorBar->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / ColorBar->GetCachedGeometry().Size.X;
switch (ColorBar->ColorType)
{
case SColorBar::EColorType::H:
{
if (Local < 1.0 && Local >= 0)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Local: %f"), Local));
ColorBar->ColorPtr->R = (ColorBar->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / ColorBar->GetCachedGeometry().Size.X) * 360.0;
ColorBar->OnColorCallback.ExecuteIfBound(ColorBar->ColorPtr->R);
}
break;
}
case SColorBar::EColorType::S:
{
if (Local < 1.0 && Local >= 0)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Local: %f"), Local));
ColorBar->ColorPtr->G = (ColorBar->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / ColorBar->GetCachedGeometry().Size.X) * 360.0;
ColorBar->OnColorCallback.ExecuteIfBound(ColorBar->ColorPtr->G);
}
}
case SColorBar::EColorType::V:
{
if (Local < 1.0 && Local >= 0)
{
ColorBar->ColorPtr->B = (ColorBar->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / ColorBar->GetCachedGeometry().Size.X);
ColorBar->OnColorCallback.ExecuteIfBound(ColorBar->ColorPtr->B);
}
break;
}
default:
break;
}
}
if (DragDropBase->DragDropType == FCutDragDropBase::EType::ColorDragS)
{
TSharedPtr<SColorPanel> ColorPanel = StaticCastSharedPtr<SColorPanel>(DragDropBase->DraggingWidget);
float Local = ColorPanel->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / ColorPanel->GetCachedGeometry().Size.X;
if (ColorPanel)
{
if (Local < 1.0 && Local >= 0)
{
ColorPanel->ColorS = (ColorPanel->GetCachedGeometry().AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / ColorPanel->GetCachedGeometry().Size.X);
}
}
}
}
if (TSharedPtr<FCursorDragDrop> DragDrop = DragDropEvent.GetOperationAs<FCursorDragDrop>())
{
if (DragDrop->DragDropType == FCutDragDropBase::EType::CursorDrag)

View File

@ -0,0 +1,115 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "SColorBar.h"
#include "SlateOptMacros.h"
#include "Cut5/Widgets/DefineGlobal.h"
#include "Cut5/Widgets/DragDropOperator/DragDropOperator.h"
#include "Rendering/DrawElementPayloads.h"
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SColorBar::Construct(const FArguments& InArgs)
{
ColorType = InArgs._ColorType;
OnColorCallback = InArgs._OnColorCallBack;
ColorPtr = InArgs._ColorPtr;
ChildSlot
[
SNew(SBox)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.WidthOverride(286)
.HeightOverride(8)
[
SAssignNew(Bar, SImage)
.DesiredSizeOverride(FVector2D(286, 8))
.OnMouseButtonDown_Lambda([this](const FGeometry& Geometry, const FPointerEvent& Event)
{
TSharedPtr<FColorDragOperation> ColorDragOperation = MakeShared<FColorDragOperation>();
ColorDragOperation->DragDropType = ColorType == EColorType::H ? FCutDragDropBase::EType::ColorDragH : FCutDragDropBase::EType::ColorDragV;
ColorDragOperation->DraggingWidget = SharedThis(this);
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton).BeginDragDrop(ColorDragOperation.ToSharedRef());
})
]
];
}
int32 SColorBar::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect,
FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle,
bool bParentEnabled) const
{
switch (ColorType)
{
case EColorType::H:
{
FLinearColor Color = FLinearColor(0, 1, 1, 1);
TArray<FSlateGradientStop> GradientStops;
for (int32 i = 0; i < 50; i++)
{
Color.R = i / 50.0f * 360.0;
FLinearColor RGB = Color.HSVToLinearRGB();
float Loc = i / 50.0f * Bar->GetCachedGeometry().Size.X;
GradientStops.Add(FSlateGradientStop(FVector2D(Loc, 0), RGB));
}
FSlateDrawElement::MakeGradient(OutDrawElements, LayerId + 10, Bar->GetPaintSpaceGeometry().ToPaintGeometry(FVector2D(286, 8), FSlateLayoutTransform(FVector2D(0))),
GradientStops, EOrientation::Orient_Vertical, ESlateDrawEffect::None);
}
break;
case EColorType::V:
{
FLinearColor Color = FLinearColor(0, 1, 1, 1);
TArray<FSlateGradientStop> GradientStops;
for (int32 i = 0; i < 50; i++)
{
Color.B = i / 50.0f;
FLinearColor RGB = Color.HSVToLinearRGB();
float Loc = i / 50.0f * Bar->GetCachedGeometry().Size.X;
GradientStops.Add(FSlateGradientStop(FVector2D(Loc, 0), RGB));
}
FSlateDrawElement::MakeGradient(OutDrawElements, LayerId + 10, Bar->GetPaintSpaceGeometry().ToPaintGeometry(FVector2D(286, 8), FSlateLayoutTransform(FVector2D(0))),
GradientStops, EOrientation::Orient_Vertical, ESlateDrawEffect::None);
}
break;
default:
break;
}
return SCompoundWidget::OnPaint(Args, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle,
bParentEnabled);
}
FReply SColorBar::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
return SCompoundWidget::OnMouseMove(MyGeometry, MouseEvent);
}
FReply SColorBar::OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
{
DragDropOperator::GetDragDropOperator()->OnDragOver(MyGeometry, DragDropEvent);
return SCompoundWidget::OnDragOver(MyGeometry, DragDropEvent);
switch (ColorType)
{
case EColorType::H:
{
ColorPtr->R = (MyGeometry.AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / MyGeometry.Size.X) * 360.0;
OnColorCallback.ExecuteIfBound(ColorPtr->R);
break;
}
case EColorType::V:
{
ColorPtr->B = (MyGeometry.AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()).X / MyGeometry.Size.X);
OnColorCallback.ExecuteIfBound(ColorPtr->B);
break;
}
default:
return SCompoundWidget::OnDragOver(MyGeometry, DragDropEvent);
break;
}
return SCompoundWidget::OnDragOver(MyGeometry, DragDropEvent);
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -0,0 +1,41 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Widgets/SCompoundWidget.h"
/**
*
*/
DECLARE_DELEGATE_OneParam(FOnColorCallback, float)
class CUT5_API SColorBar : public SCompoundWidget
{
public:
enum class EColorType
{
H,
S,
V,
};
SLATE_BEGIN_ARGS(SColorBar)
{
}
SLATE_ARGUMENT(EColorType, ColorType)
SLATE_ARGUMENT(FLinearColor*, ColorPtr)
SLATE_EVENT(FOnColorCallback, OnColorCallBack)
SLATE_END_ARGS()
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
TSharedPtr<SImage> Bar;
FOnColorCallback OnColorCallback;
EColorType ColorType;
FLinearColor* ColorPtr;
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
};

View File

@ -3,21 +3,40 @@
#include "SColorPanel.h"
#include "SColorBar.h"
#include "SlateOptMacros.h"
#include "Cut5/Utils/Utils.h"
#include "Cut5/Widgets/DragDropOperator/DragDropOperator.h"
#include "Rendering/DrawElementPayloads.h"
#include "Widgets/Input/SSlider.h"
#include "Widgets/Layout/SConstraintCanvas.h"
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SColorPanel::Construct(const FArguments& InArgs)
{
ColorPtr = InArgs._ColorPtr;
FTextBlockStyle TextBlockStyle = FAppStyle::GetWidgetStyle<FTextBlockStyle>("NormalText");
TextBlockStyle.SetFontSize(16);
ChildSlot
[
SNew(SConstraintCanvas)
+ SConstraintCanvas::Slot()
.Anchors(FAnchors(0, 0, 0, 0))
.Offset(FMargin(0, 0, 320, 445))
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(320)
.HeightOverride(445)
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("ColorPanelBackGround.png"), {320, 445}))
]
]
+ SOverlay::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(320)
@ -29,7 +48,7 @@ void SColorPanel::Construct(const FArguments& InArgs)
SNew(SBox)
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
.Padding(21, 16, 267, 405)
.Padding(21, 16, 0, 0)
.WidthOverride(32)
.HeightOverride(24)
[
@ -38,9 +57,223 @@ void SColorPanel::Construct(const FArguments& InArgs)
.Font(TextBlockStyle.Font)
]
]
+ SOverlay::Slot()
[
SNew(SBox)
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
.Padding(18, 272, 0, 0)
.WidthOverride(286)
.HeightOverride(8)
[
SNew(SColorBar)
.ColorPtr(&CurrentSelectColor)
.ColorType(SColorBar::EColorType::V)
.OnColorCallBack_Lambda([this](float A)
{
})
]
]
+ SOverlay::Slot()
[
SNew(SBox)
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
.Padding(18, 246, 0, 0)
.WidthOverride(286)
.HeightOverride(8)
[
SNew(SColorBar)
.ColorPtr(&CurrentSelectColor)
.ColorType(SColorBar::EColorType::H)
.OnColorCallBack_Lambda([this](float A)
{
})
]
]
+ SOverlay::Slot()
[
SNew(SBox)
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
.Padding(17, 56, 0, 0)
.WidthOverride(287)
.HeightOverride(176)
[
SAssignNew(ColorBox, SImage)
.DesiredSizeOverride(FVector2D(287, 176))
.OnMouseButtonDown_Lambda([this](const FGeometry&, const FPointerEvent&)
{
TSharedPtr<FColorDragOperation> ColorDragOperation = MakeShared<FColorDragOperation>();
ColorDragOperation->DragDropType = FCutDragDropBase::EType::ColorDragS;
ColorDragOperation->DraggingWidget = SharedThis(this);
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton).BeginDragDrop(ColorDragOperation.ToSharedRef());
return FReply::Handled();
})
]
]
+ SOverlay::Slot()
[
SNew(SBox)
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
.Padding(61, 17, 0, 0)
.WidthOverride(40)
.HeightOverride(21.5)
[
SAssignNew(ColorImage, SImage)
.DesiredSizeOverride(FVector2D(40, 21.5))
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("Color.png"), {40, 21.5}))
.ColorAndOpacity(GetColor())
]
]
+ SOverlay::Slot()
.HAlign(HAlign_Right)
.VAlign(VAlign_Top)
[
SNew(SBox)
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
.Padding(0, 0, 16, 16)
.WidthOverride(24)
.HeightOverride(24)
[
SNew(SImage)
.DesiredSizeOverride(FVector2D(24, 24))
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("ColorPanelClose.png"), {24, 24}))
.OnMouseButtonDown_Lambda([this](const FGeometry&, const FPointerEvent&)
{
GEngine->GameViewport->RemoveViewportWidgetContent(SharedThis(this));
return FReply::Handled();
})
]
]
+ SOverlay::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
[
SNew(SBox)
.WidthOverride(12)
.HeightOverride(12)
[
SAssignNew(ColorBarHCircle, SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("ColorSelectCircle.png"), {16, 16}))
]
]
+ SOverlay::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
[
SNew(SBox)
.WidthOverride(12)
.HeightOverride(12)
[
SAssignNew(ColorBarVCircle, SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("ColorSelectCircle.png"), {16, 16}))
]
]
+ SOverlay::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
[
SNew(SBox)
.WidthOverride(12)
.HeightOverride(12)
[
SAssignNew(ColorBarSCircle, SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("ColorSelectCircle.png"), {16, 16}))
]
]
]
]
];
}
int32 SColorPanel::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect,
FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle,
bool bParentEnabled) const
{
// {
// FLinearColor Color = FLinearColor(0, 1, 1, 1);
// TArray<FSlateGradientStop> GradientStops;
// for (int32 i = 0; i < 50; i++)
// {
// Color.R = i / 50.0f * 360.0;
// FLinearColor RGB = Color.HSVToLinearRGB();
// float Loc = i / 50.0f * ColorBar->GetCachedGeometry().Size.X;
// GradientStops.Add(FSlateGradientStop(FVector2D(Loc, 0), RGB));
// }
//
// FSlateDrawElement::MakeGradient(OutDrawElements, LayerId + 10000, ColorBar->GetPaintSpaceGeometry().ToPaintGeometry(FVector2D(286, 8), FSlateLayoutTransform(FVector2D(0))),
// GradientStops, EOrientation::Orient_Vertical, ESlateDrawEffect::None);
// }
//
//
// {
// FLinearColor Color = FLinearColor(0, 1, 1, 1);
// TArray<FSlateGradientStop> GradientStops;
// for (int32 i = 0; i < 50; i++)
// {
// Color.B = i / 50.0f;
// FLinearColor RGB = Color.HSVToLinearRGB();
// float Loc = i / 50.0f * SBar->GetCachedGeometry().Size.X;
// GradientStops.Add(FSlateGradientStop(FVector2D(Loc, 0), RGB));
// }
//
// FSlateDrawElement::MakeGradient(OutDrawElements, LayerId + 10000, SBar->GetPaintSpaceGeometry().ToPaintGeometry(FVector2D(286, 8), FSlateLayoutTransform(FVector2D(0))),
// GradientStops, EOrientation::Orient_Vertical, ESlateDrawEffect::None);
//
// }
TArray<FSlateGradientStop> ColorBoxGradientStops;
ColorBoxGradientStops.Add(FSlateGradientStop(FVector2D(0, 0), FLinearColor(1, 1, 1, 1)));
ColorBoxGradientStops.Add(FSlateGradientStop(FVector2D(ColorBox->GetCachedGeometry().Size.X, 0), CurrentSelectColor.HSVToLinearRGB()));
FSlateDrawElement::MakeGradient(OutDrawElements, LayerId + 10000, ColorBox->GetPaintSpaceGeometry().ToPaintGeometry(FVector2D(287, 176), FSlateLayoutTransform(FVector2D(0))),
ColorBoxGradientStops, EOrientation::Orient_Vertical, ESlateDrawEffect::NoGamma);
return SCompoundWidget::OnPaint(Args, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle,
bParentEnabled);
}
FReply SColorPanel::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
return FReply::Handled();
}
void SColorPanel::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
{
ColorBarHCircle->SetRenderTransform(FVector2D(18 + (CurrentSelectColor.R / 360.0f * 286), 246));
ColorBarSCircle->SetRenderTransform(FVector2D(18 + (CurrentSelectColor.G * 286), 246));
ColorBarVCircle->SetRenderTransform(FVector2D(18 + (CurrentSelectColor.B * 286), 272));
ColorImage->SetColorAndOpacity(GetColor());
*ColorPtr = GetColor();
}
FReply SColorPanel::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
{
return SCompoundWidget::OnDrop(MyGeometry, DragDropEvent);
}
FReply SColorPanel::OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
{
DragDropOperator::GetDragDropOperator()->OnDragOver(MyGeometry, DragDropEvent);
return SCompoundWidget::OnDragOver(MyGeometry, DragDropEvent);
}
FLinearColor SColorPanel::GetColor()
{
FLinearColor RGB = FLinearColor(CurrentSelectColor.R, ColorS, CurrentSelectColor.B, 1).HSVToLinearRGB();
return RGB;
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -14,9 +14,26 @@ public:
SLATE_BEGIN_ARGS(SColorPanel)
{
}
SLATE_ARGUMENT(FLinearColor*, ColorPtr)
SLATE_END_ARGS()
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
FLinearColor GetColor();
TSharedPtr<SImage> ColorBar;
TSharedPtr<SImage> SBar;
TSharedPtr<SImage> ColorBox;
TSharedPtr<SImage> ColorImage;
FLinearColor CurrentSelectColor = FLinearColor(1, 1, 0, 1);
float ColorS = 0;
FLinearColor* ColorPtr;
TSharedPtr<SImage> ColorBarHCircle;
TSharedPtr<SImage> ColorBarSCircle;
TSharedPtr<SImage> ColorBarVCircle;
};

View File

@ -5,6 +5,7 @@
#include "SlateOptMacros.h"
#include "Cut5/Utils/Utils.h"
#include "Cut5/Widgets/MicroWidgets/SNewProjectTips.h"
#include "Cut5/Widgets/Style/CutButtonWidgetStyle.h"
#include "Math/UnitConversion.h"
#include "Widgets/Input/SComboBox.h"
@ -107,14 +108,16 @@ TSharedPtr<SWidget> SEffectPreset::GetPropertiesWidget()
.WidthOverride(136)
.HeightOverride(32)
[
SNew(SEditableTextBox)
.OnVerifyTextChanged_Lambda([this](const FText& InText, FText& OutErrorMessage)
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("Color.png"), {}))
.ColorAndOpacity_Lambda([this]()
{
return true;
return CustomData.Colors[0];
})
.OnTextCommitted_Lambda([this](const FText& InText, ETextCommit::Type InCommitType)
.OnMouseButtonDown_Lambda([this](const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
MainInterface->OpenColorPanel(&CustomData.Colors[0]);
return FReply::Handled();
})
]
]
@ -183,6 +186,10 @@ TSharedPtr<SWidget> SEffectPreset::GetPropertiesWidget()
[
SNew(SSpinBox<int32>)
.MinValue(0)
.OnValueChanged_Lambda([this](const int32& Value)
{
CustomData.Times = Value;
})
]
]
]
@ -218,6 +225,10 @@ TSharedPtr<SWidget> SEffectPreset::GetPropertiesWidget()
SNew(SSpinBox<float>)
.MinValue(0.0)
.MaxValue(360.0)
.OnValueChanged_Lambda([this](const float& Value)
{
CustomData.Angle = Value;
})
// .TypeInterface(MakeShared<TNumericUnitTypeInterface<float>>(EUnit::Degrees))
]
]
@ -253,12 +264,53 @@ TSharedPtr<SWidget> SEffectPreset::GetPropertiesWidget()
[
SNew(SSpinBox<int32>)
.MinValue(0.0)
.OnValueChanged_Lambda([this](const int32& Value)
{
CustomData.Time = Value;
})
// .TypeInterface(MakeShared<TNumericUnitTypeInterface<int32>>(EUnit::Seconds))
]
]
]
]
+ 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)
{
MainInterface->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)
]
]
];
// TODO: 配置文件保存自定义效果
// TODO: 自定义效果拖拽到轨道
return PropertiesWidget;
}

View File

@ -34,5 +34,6 @@ public:
TSharedPtr<SComboBox<TSharedPtr<FString>>> GroupComboBox;
virtual TSharedPtr<SWidget> GetPropertiesWidget() override;
FPresetsCustomData CustomData;
virtual FReply OnDragDetected(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
};

View File

@ -14,7 +14,7 @@ void SCustomInputResource::Construct(const FArguments& InArgs)
PropertyData = InArgs._PropertyData;
VideoCapture = InArgs._VideoCapture;
OnCheckBoxChecked = InArgs._OnCheckBoxChecked;
CustomPresetName = InArgs._CustomPresetName;
ChildSlot
[
SNew(SBox)
@ -34,7 +34,15 @@ void SCustomInputResource::Construct(const FArguments& InArgs)
.VAlign(VAlign_Fill)
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(PropertyData.IconPath, {}))
.Image(PropertyData.bIsCustomPresetData == false ? FUtils::GetBrushFromImage(PropertyData.IconPath, {}) : FUtils::GetBrushFromImage(FUtils::GetResourcesPath("CustomPreset.png"), {}))
]
+ SOverlay::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(CustomPresetName))
.Visibility(PropertyData.bIsCustomPresetData == true ? EVisibility::Visible : EVisibility::Collapsed)
]
]

View File

@ -18,6 +18,7 @@ public:
}
SLATE_ARGUMENT(FTimelinePropertyData, PropertyData)
SLATE_ARGUMENT(cv::VideoCapture, VideoCapture)
SLATE_ARGUMENT(FString, CustomPresetName)
SLATE_EVENT(FOnCheckBoxChecked, OnCheckBoxChecked)
SLATE_END_ARGS()
@ -33,4 +34,6 @@ public:
cv::VideoCapture VideoCapture;
TSharedPtr<SWidget> CheckBox;
TSharedPtr<SBox> Box;
FString CustomPresetName;
};

View File

@ -352,7 +352,6 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
CommandList->MapAction(FMainMenuCommands::Get().NewProject, FExecuteAction::CreateLambda([this]()
{
OpenColorPanel();
PreNewProject();
}));
CommandList->MapAction(FMainMenuCommands::Get().OpenProject, FExecuteAction::CreateLambda([this]()
@ -1007,26 +1006,25 @@ void SCutMainWindow::PreSettingBeforeSeek()
OnUpdateVideo(FGuid::NewGuid(), 1920, 1080, nullptr);
}
void SCutMainWindow::OpenColorPanel()
void SCutMainWindow::OpenColorPanel(FLinearColor* ColorPtr)
{
TSharedPtr<SColorPanel> ColorPanel = SNew(SColorPanel);
// GEngine->GameViewport->AddViewportWidgetContent(
// ColorPanel.ToSharedRef());
TSharedPtr<SWindow> Window = SNew(SWindow)
.CreateTitleBar(false)
.SupportsMaximize(false)
.SupportsMinimize(false)
.bDragAnywhere(true)
.MinHeight(445)
.MinWidth(320)
.MaxHeight(445)
.Content()
TSharedPtr<SColorPanel> ColorPanel = SNew(SColorPanel).ColorPtr(ColorPtr);
GEngine->GameViewport->AddViewportWidgetContent(
ColorPanel.ToSharedRef());
}
void SCutMainWindow::AddNewCustomPreset(const FString& Name, const FPresetsCustomData CustomData)
{
FTimelinePropertyData NewPropertyData;
NewPropertyData.bIsCustomPresetData = true;
NewPropertyData.PresetsCustomData = CustomData;
CustomInputPanel->GridPanel->AddSlot(CustomInputPanel->GridPanel->GetChildren()->Num() % 2, CustomInputPanel->GridPanel->GetChildren()->Num() / 2)
[
ColorPanel.ToSharedRef()
SNew(SCustomInputResource).PropertyData(NewPropertyData).CustomPresetName(Name)
];
FSlateApplication::Get().AddWindow(Window.ToSharedRef());
}
tinyxml2::XMLElement* SCutMainWindow::GetDeviceElement(tinyxml2::XMLElement* Parent)

View File

@ -78,7 +78,8 @@ public:
virtual void DeleteAllAssetsInTimeline() override;
virtual SCutTimeline* GetCutTimeline() override { return CutTimeline.Get(); };
virtual void PreSettingBeforeSeek() override;
void OpenColorPanel();
virtual void OpenColorPanel(FLinearColor* ColorPtr);
virtual void AddNewCustomPreset(const FString& Name, const FPresetsCustomData CustomData) override;
tinyxml2::XMLElement* GetDeviceElement(tinyxml2::XMLElement* Parent);
tinyxml2::XMLElement* GetVideoElement(tinyxml2::XMLElement* Parent, FEncodeVideoInfo EncodeVideoInfo);

View File

@ -535,7 +535,7 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
GradientStops.Add(FSlateGradientStop(FVector2D(ClipData->Cursors[i].CursorFrameOffset * FGlobalData::DefaultTimeTickSpace, 0), ClipData->Cursors[i].Color));
}
FSlateDrawElement::MakeGradient(OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(),
FSlateDrawElement::MakeGradient(OutDrawElements, LayerId + 10000, AllottedGeometry.ToPaintGeometry(),
GradientStops,
EOrientation::Orient_Vertical, ESlateDrawEffect::None);
}