UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SlateControlledConstruction.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "SlateGlobals.h"
9
10enum class ESPMode : uint8;
13{
14 template <typename ObjectType, ESPMode Mode>
15 class TIntrusiveReferenceController;
16}
17
19#define SLATE_DECLARE_WIDGET(WidgetType, ParentType) \
20 SLATE_DECLARE_WIDGET_API(WidgetType, ParentType, NO_API)
21
22#define SLATE_DECLARE_WIDGET_API(WidgetType, ParentType, ModuleApiDefine) \
23 private: \
24 using Super = ParentType; \
25 using ThisClass = WidgetType; \
26 using PrivateThisType = WidgetType; \
27 using PrivateParentType = ParentType; \
28 template<class WidgetType, bool bIsUserWidget> \
29 friend struct TWidgetAllocator; \
30 template <typename ObjectType, ESPMode Mode> \
31 friend class SharedPointerInternals::TIntrusiveReferenceController; /* Shouldn't really forward-declare this to allow MakeShared to work, but is for legacy reasons */ \
32 static const FSlateWidgetClassData& GetPrivateWidgetClass() \
33 { \
34 static FSlateWidgetClassData WidgetClassDataInstance = FSlateWidgetClassData(TIdentity<ParentType>(), #WidgetType, &WidgetType::PrivateRegisterAttributes); \
35 return WidgetClassDataInstance; \
36 } \
37 static ModuleApiDefine void PrivateRegisterAttributes(FSlateAttributeInitializer&); \
38 public: \
39 static const FSlateWidgetClassData& StaticWidgetClass() { return GetPrivateWidgetClass(); } \
40 virtual const FSlateWidgetClassData& GetWidgetClass() const override { return GetPrivateWidgetClass(); } \
41 private:
42
43
44#define SLATE_IMPLEMENT_WIDGET(WidgetType) \
45 FSlateWidgetClassRegistration ClassRegistration__##WidgetType = WidgetType::StaticWidgetClass();
46
49{
50private:
52
54 : WidgetType(InWidgetTypeName)
55 {}
56
57public:
58 template<typename InWidgetParentType>
60 : WidgetType(InWidgetTypeName)
61 {
62 // Initialize the parent class if it's not already done
63 const FSlateWidgetClassData& ParentWidgetClassData = InWidgetParentType::StaticWidgetClass();
64 // Initialize the attribute descriptor
65 FSlateAttributeInitializer Initializer = {Descriptor, ParentWidgetClassData.GetAttributeDescriptor()};
66 (*AttributeInitializer)(Initializer);
67 }
68
69 const FSlateAttributeDescriptor& GetAttributeDescriptor() const { return Descriptor; };
70 FName GetWidgetType() const { return WidgetType; }
71
72private:
74 FName WidgetType;
75};
76
82
85{
86public:
88 virtual ~FSlateControlledConstruction() = default;
89
90public:
92 {
93 static FSlateWidgetClassData Instance = FSlateWidgetClassData(TEXT("FSlateControlledConstruction"));
94 return Instance;
95 }
96 virtual const FSlateWidgetClassData& GetWidgetClass() const = 0;
97
98private:
101
103 void operator= (const FSlateControlledConstruction& Other) = delete;
104
106 void* operator new ( const size_t InSize )
107 {
108 return FMemory::Malloc(InSize);
109 }
110
112 void* operator new ( const size_t InSize, void* Addr )
113 {
114 return Addr;
115 }
116
117 template<class WidgetType, bool bIsUserWidget>
118 friend struct TWidgetAllocator;
119
120 /* Shouldn't really forward-declare this to allow MakeShared to work, but is for legacy reasons */
121 template <typename ObjectType, ESPMode Mode>
123
124public:
125 void operator delete(void* mem)
126 {
127 FMemory::Free(mem);
128 }
129};
#define TEXT(x)
Definition Platform.h:1272
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
ESPMode
Definition SharedPointerFwd.h:12
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition NameTypes.h:617
Definition SlateAttributeDescriptor.h:32
Definition SlateControlledConstruction.h:85
static const FSlateWidgetClassData & StaticWidgetClass()
Definition SlateControlledConstruction.h:91
friend struct TWidgetAllocator
Definition SlateControlledConstruction.h:118
virtual ~FSlateControlledConstruction()=default
virtual const FSlateWidgetClassData & GetWidgetClass() const =0
Definition SlateControlledConstruction.h:49
FSlateWidgetClassData(TIdentity< InWidgetParentType >, FName InWidgetTypeName, void(*AttributeInitializer)(FSlateAttributeInitializer &))
Definition SlateControlledConstruction.h:59
const FSlateAttributeDescriptor & GetAttributeDescriptor() const
Definition SlateControlledConstruction.h:69
FName GetWidgetType() const
Definition SlateControlledConstruction.h:70
Definition SharedPointerInternals.h:400
Definition SharedPointerInternals.h:32
static FORCENOINLINE CORE_API void Free(void *Original)
Definition UnrealMemory.cpp:685
Definition SlateAttributeDescriptor.h:261
Definition SlateControlledConstruction.h:79
FSlateWidgetClassRegistration(const FSlateWidgetClassData &)
Definition SlateControlledConstruction.h:80
Definition Identity.h:18