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)]
  • SWindow : SCompoundWidget : SWidget
    • window = SNew(SWindow)
      • [SNew(SButton),SNew(SWidget)…]
    • FSlateApplication::Get().AddWindow(window.ToSharedRef())
  • 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()
  • SCustomWidget : SWidget
  • SOverlay
    • +SOverlay::Slot()
      • SNew(SWidget)
  • SHorizontalBox
    • +SHorizontalBox::Slot()
      • SNew(SWidget)
  • IDetailsView
    • SCSVtoSVG 参考Source\Editor\CSVtoSVG\Private\SCSVtoSVG.cpp
      • FDetailsViewArgs DetailsViewArgs
      • TSharedPtr DetailsView = PropertyEditorModule.CreateDetailView(DetailsViewArgs)
      • DetailsView->SetObject(Arguments.Get())
  • SDockTab
    • SDockingTabStack
      • Source\Runtime\Slate\Private\Framework\Docking\SDockingTabStack.cpp
      • OnExtendContextMenu // 自定义右键菜单
      • TabWellRightClicked()
      • MakeContextMenu() // 右键菜单
        • FMenuBuilder // 构建菜单
  • Drag || Drop
    • Source\Editor\UnrealEd\Public\DragAndDrop
      • ActorDragDropOp
      • AssetDragDropOp
  • 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)
  • Toolbar
    • Button
      • Section.AddEntry(FToolMenuEntry::InitToolBarButton(FTaSlateCommands::Get().OpenTaToolsCommand)).SetCommandList(OpenTaToolsCommandList)
    • CombButton
  • SSegmentedControl
    • Source\Editor\GameProjectGeneration\Private\SNewClassDialog.cpp

参考


UE5 Slate C++ 笔记
https://automask.github.io/wild/2022/11/22/lab/S_Unreal_Slate/
作者
Kyle Zhou
发布于
2022年11月22日
许可协议