UE5 Slate C++ 笔记
Slate
- https://zhuanlan.zhihu.com/p/377745543
- SAssignNew和SNew都能创建SWidget
- SNew返回TSharedRef
- SAssignNew返回TSharedPtr
- AsShared() //TSharedPtr转TSharedRef
- (TSharedPtr
)Button->AsShared()
- 但是因为TSharedRef可以被隐式转换为TSharedPtr,所以对于TSharedPtr来说用哪个都一样
- 对于TSharedRef来说只能使用SNew。后面加点表示构造时要传入的参数。
- SCompoundWidget
- Construct || ChildSlot
- SCustomSlate : public SCompoundWidget
- SLATE_BEGIN_ARGS(SCSVtoSVG){}
- SLATE_END_ARGS()
- void Construct(const FArguments& Args)
- this->ChildSlot[SNew(SVerticalBox)]
- SCustomSlate : public SCompoundWidget
- SWindow : SCompoundWidget : SWidget
- window = SNew(SWindow)
- [SNew(SButton),SNew(SWidget)…]
- FSlateApplication::Get().AddWindow(window.ToSharedRef())
- window = SNew(SWindow)
- SButton : SBorder : SCompoundWidget
- SetOnClicked(FOnclicked)
- OnClicked(FOnclicked::CreateLambda(Lambda->FReply))
- FOnclicked::CreateLambda(Lambda->FReply)
- FOnclicked::CreateStatic(&Func)
- FOnclicked::CreateRaw()
- STextBlock
- Font || Font Style
- Font(FCoreStyle::GetDefaultFontStyle(“Italic”,25))
- FSlateFontInfo
- FCoreStyle::GetDefaultFontStyle(TypefaceFontName,InSize)
- FAppStyle::Get().GetFontStyle(“LargeFont”)
- TypefaceFont
- Regular
- Italic // 斜体
- Bold // 粗体
- Light
- VeryLight
- Black // 黑体
- FCompositeFont
- FCoreStyle::GetDefaultFont()
- FLegacySlateFontInfoCache::Get().GetDefaultFont();-
- FLegacySlateFontInfoCache::GetDefaultFont()
- Runtime\AppFramework\Private\Framework\Testing\SStarshipGallery.cpp
- ConstructTextGallery()
- Font(FAppStyle::Get().GetFontStyle(“LargeFont”))
- ConstructIconsGallery()
- ConstructColorsGallery()
- Font || Font Style
- SCustomWidget : SWidget
- https://www.youtube.com/watch?v=je3Zid_OmGg
- Construct(const FArguments& InArgs)
- ChildSlot[]
- SOverlay
- +SOverlay::Slot()
- SNew(SWidget)
- +SOverlay::Slot()
- SHorizontalBox
- +SHorizontalBox::Slot()
- SNew(SWidget)
- +SHorizontalBox::Slot()
- IDetailsView
- SCSVtoSVG 参考Source\Editor\CSVtoSVG\Private\SCSVtoSVG.cpp
- FDetailsViewArgs DetailsViewArgs
- TSharedPtr
DetailsView = PropertyEditorModule.CreateDetailView(DetailsViewArgs) - DetailsView->SetObject(Arguments.Get())
- SCSVtoSVG 参考Source\Editor\CSVtoSVG\Private\SCSVtoSVG.cpp
- SDockTab
- SDockingTabStack
- Source\Runtime\Slate\Private\Framework\Docking\SDockingTabStack.cpp
- OnExtendContextMenu // 自定义右键菜单
- TabWellRightClicked()
- MakeContextMenu() // 右键菜单
- FMenuBuilder // 构建菜单
- SDockingTabStack
- Drag || Drop
- Source\Editor\UnrealEd\Public\DragAndDrop
- ActorDragDropOp
- AssetDragDropOp
- Source\Editor\UnrealEd\Public\DragAndDrop
- Style
- FSlateFontInfo
- FCoreStyle::GetDefaultFontStyle(FName(TEXT(“Regular”)), 8))
- FSlateBrush
- FCoreStyle::Get().GetDefaultBrush()
- FCoreStyle::Get().GetBrush(“Border”)
- FSlateIcon
- FSlateIcon(FTaSlateStyle::GetStyleSetName(),IconName,NAME_None,IconName)
- FSlateStyleSet
- static const ISlateStyle& Get()
- TSharedRef
Style = MakeShareable(new FSlateStyleSet(“TaSlateStyle”)) - Style->SetContentRoot()
- Style->Set(“XXX.Logo”, new IMAGE_BRUSH(TEXT(“Logo”), Icon32x32))
- FSlateStyleRegistry::RegisterSlateStyle(*Style)
- FSlateFontInfo
- Toolbar
- Button
- Section.AddEntry(FToolMenuEntry::InitToolBarButton(FTaSlateCommands::Get().OpenTaToolsCommand)).SetCommandList(OpenTaToolsCommandList)
- CombButton
- Button
- SSegmentedControl
- Source\Editor\GameProjectGeneration\Private\SNewClassDialog.cpp
参考
TAPython
UE5 Slate C++ 笔记
https://automask.github.io/wild/2022/11/22/lab/S_Unreal_Slate/