属性面板

This commit is contained in:
Sch 2023-08-03 03:12:19 +08:00
parent db31744317
commit 7927980d2f
10 changed files with 145 additions and 8 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ Saved
Intermediate
.vs
Binaries
DefaultProject

View File

@ -3,6 +3,7 @@
#pragma once
#include "CoreMinimal.h"
#include "PropertiesInterface.h"
#include "Cut5/Widgets/DefineGlobal.h"
#include "Engine/Texture2D.h"
#include "UObject/Interface.h"
@ -44,4 +45,6 @@ public:
virtual void OnSelectCard(const FGuid& SelectedCard) {};
virtual void OnRemoveCard(const FGuid& SelectedCard) {};
virtual void UpdateProperties(IPropertiesInterface* Interface) {};
};

View File

@ -24,6 +24,6 @@ class CUT5_API IPropertiesInterface
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
FProperties* GetProperties() { return Properties; };
virtual FProperties* GetProperties() { return Properties; };
FProperties* Properties = nullptr;
};

View File

@ -36,4 +36,16 @@ void SCustomPanel::Construct(const FArguments& InArgs)
}
void SCustomPanel::UpdateProperties(IPropertiesInterface* Interface)
{
CustomScroll->ClearChildren();
for (FGeneralPropertyBase& Base : Interface->GetProperties()->Properties)
{
CustomScroll->AddSlot()
[
Base.BaseWidget.ToSharedRef()
];
}
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -3,6 +3,7 @@
#pragma once
#include "CoreMinimal.h"
#include "Cut5/Interface/PropertiesInterface.h"
#include "Widgets/SCompoundWidget.h"
#include "Widgets/Layout/SScrollBox.h"
@ -21,7 +22,7 @@ public:
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
void UpdateProperties();
void UpdateProperties(IPropertiesInterface* Interface);
TSharedPtr<SScrollBox> CustomScroll;
};

View File

@ -1,5 +1,6 @@
#pragma once
#include "Cut5/WidgetInterface.h"
#include "Widgets/Input/SEditableTextBox.h"
extern "C"{
#include "libavformat/avformat.h"
@ -350,6 +351,66 @@ struct FGeneralPropertyBase
}
};
struct FCardNameProperty : public FGeneralPropertyBase
{
FCardNameProperty(const FString& Name, FString* CardNamePtr) : FGeneralPropertyBase()
{
BaseWidget = SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(STextBlock)
.Text(FText::FromString(Name))
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SEditableTextBox)
.OnTextCommitted_Lambda([CardNamePtr](const FText& InText, ETextCommit::Type InCommitType)
{
*CardNamePtr = InText.ToString();
})
]
];
}
};
struct FNumProperty : public FGeneralPropertyBase
{
FNumProperty(const FString& Name, int32* NumPtr) : FGeneralPropertyBase()
{
BaseWidget = SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(STextBlock)
.Text(FText::FromString(Name))
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SEditableTextBox)
.OnTextCommitted_Lambda([NumPtr](const FText& InText, ETextCommit::Type InCommitType)
{
*NumPtr = FCString::Atoi(*InText.ToString());
})
]
];
}
};
struct FSelectableProperty : public FGeneralPropertyBase
{
FSelectableProperty() : FGeneralPropertyBase()
{
}
};
struct FColorProperty : public FGeneralPropertyBase
{
FColorProperty() : FGeneralPropertyBase()
@ -404,6 +465,22 @@ struct FProperties
this->Properties.Add(FTimeProperty());
return this;
};
FProperties* AddNumProperties(const FString& Name, int32* NumPtr)
{
this->Properties.Add(FNumProperty(Name, NumPtr));
return this;
};
FProperties* AddSelectableProperties(const FString& Name, bool* SelectablePtr)
{
this->Properties.Add(FSelectableProperty());
return this;
};
FProperties* AddCardNameProperties(const FString& Name, FString* CardNamePtr)
{
this->Properties.Add(FCardNameProperty(Name, CardNamePtr));
return this;
};
TArray<FGeneralPropertyBase> Properties;

View File

@ -52,10 +52,6 @@ void SEffectCard::Construct(const FArguments& InArgs)
.Padding(10.0f)
[
SAssignNew(Overlay, SOverlay)
// + SOverlay::Slot()
// [
// SNew(SButton)
// ]
+ SOverlay::Slot()
.VAlign(VAlign_Fill)
.HAlign(HAlign_Fill)
@ -69,6 +65,7 @@ void SEffectCard::Construct(const FArguments& InArgs)
{
MainInterface->OpenTimeline(FUtils::SingleCardFullPath(CardProperty->Name), true);
MainInterface->OnSelectCard(CardProperty->Guid);
MainInterface->UpdateProperties(this);
}
else
{
@ -82,6 +79,14 @@ void SEffectCard::Construct(const FArguments& InArgs)
return FReply::Handled();
})
.OnHovered_Lambda([this]()
{
})
.OnUnhovered_Lambda([this]()
{
})
]
+ SOverlay::Slot()
[
@ -164,4 +169,26 @@ void SEffectCard::ShowClosedButton(bool bShow)
}
void SEffectCard::OnMouseEnter(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
SCompoundWidget::OnMouseEnter(MyGeometry, MouseEvent);
ShowClosedButton(true);
}
void SEffectCard::OnMouseLeave(const FPointerEvent& MouseEvent)
{
SCompoundWidget::OnMouseLeave(MouseEvent);
ShowClosedButton(false);
}
FProperties* SEffectCard::GetProperties()
{
Properties = new FProperties();
Properties->AddCardNameProperties(TEXT("名称"), &CardProperty->Name)->AddNumProperties(TEXT("ID"), &ID);
return Properties;
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -5,13 +5,14 @@
#include "CoreMinimal.h"
#include "Cut5/Interface/SaveInterface.h"
#include "Cut5/Interface/CutMainWidgetInterface.h"
#include "Cut5/Interface/PropertiesInterface.h"
#include "Cut5/Widgets/DefineGlobal.h"
#include "Widgets/SCompoundWidget.h"
/**
*
*/
class CUT5_API SEffectCard : public SCompoundWidget, public ISaveInterface
class CUT5_API SEffectCard : public SCompoundWidget, public ISaveInterface, public IPropertiesInterface
{
public:
SLATE_BEGIN_ARGS(SEffectCard)
@ -42,5 +43,14 @@ public:
TSharedPtr<SOverlay> Overlay;
TSharedPtr<SWidget> ClosedButton;
virtual void OnMouseEnter(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual void OnMouseLeave(const FPointerEvent& MouseEvent) override;
virtual FProperties* GetProperties() override;
FString CardName;
int32 ID;
};

View File

@ -575,5 +575,10 @@ FString SCutMainWindow::GetGroupName(TSharedPtr<IWidgetInterface> WidgetInterfac
}
void SCutMainWindow::UpdateProperties(IPropertiesInterface* Interface)
{
CustomPanel->UpdateProperties(Interface);
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -62,4 +62,5 @@ public:
virtual void OnRemoveCard(const FGuid& SelectedCard) override;
virtual FTimelinePropertyData* GetResourcePropertyDataPtr(FGuid GUID) override;
virtual FString GetGroupName(TSharedPtr<IWidgetInterface> WidgetInterface) override;
virtual void UpdateProperties(IPropertiesInterface* Interface) override;
};