UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WidgetSlotWithAttributeSupport.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 "SlotBase.h"
10
11#include <limits>
12
13
19template <typename SlotType>
21{
22private:
24protected:
25 using TSlotBase<SlotType>::TSlotBase;
26
31 template<typename InObjectType, typename InComparePredicate = TSlateAttributeComparePredicate<>>
32 struct TSlateSlotAttribute : public ::SlateAttributePrivate::TSlateContainedAttribute<InObjectType, ::SlateAttributePrivate::FSlateAttributeNoInvalidationReason, InComparePredicate>
33 {
34 using ::SlateAttributePrivate::TSlateContainedAttribute<InObjectType, ::SlateAttributePrivate::FSlateAttributeNoInvalidationReason, InComparePredicate>::TSlateContainedAttribute;
35 };
36
37public:
39 {
40 if (SWidget* WidgetPtr = Super::GetOwnerWidget())
41 {
42 RemoveContainerWidget(*WidgetPtr);
43 }
44 }
45
46 void Construct(const FChildren& SlotOwner, typename Super::FSlotArguments&& InArgs)
47 {
48 checkf(SlotOwner.SupportSlotWithSlateAttribute(), TEXT("The FChildren '%s' does not support SlateSlotAttribute but use a Slot type that does."), *SlotOwner.GetName().ToString());
49 checkf(SlotOwner.GetName().IsValid(), TEXT("The FChildren '%s' does not have a valid name."), *SlotOwner.GetName().ToString());
51 }
52
56
58 {
59 SWidget* WidgetPtr = Super::GetOwnerWidget();
60 ensureAlwaysMsgf(WidgetPtr, TEXT("FSlot needs to be constructed before we modify the FChildren."));
61 if (WidgetPtr)
62 {
63 UpdateContainerSortOrder(*WidgetPtr);
64 }
65 }
66
67
68 //~ Begin ISlateAttributeContainer interface
69 virtual SWidget& GetContainerWidget() const override
70 {
72 checkf(WidgetPtr, TEXT("Slot Attributes has to be registered after the FSlot is constructed."));
73 return *WidgetPtr;
74 }
75
76 virtual FName GetContainerName() const override
77 {
78 return FSlotBase::GetOwner()->GetName();
79 }
80
81 virtual uint32 GetContainerSortOrder() const override
82 {
84 const int32 NumSlot = FSlotBase::GetOwner()->NumSlot();
85 for (int32 Index = 0; Index < NumSlot; ++Index)
86 {
87 if (&FSlotBase::GetOwner()->GetSlotAt(Index) == this)
88 {
89 return Index;
90 }
91 }
92#pragma push_macro("UNDEF_MAX")
93#undef max
94 return std::numeric_limits<uint32>::max();
95#pragma pop_macro("UNDEF_MAX")
96 }
97 //~ End ISlateAttributeContainer interface
98};
#define ensureAlwaysMsgf(InExpression, InFormat,...)
Definition AssertionMacros.h:467
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition ChildrenBase.h:27
FName GetName() const
Definition ChildrenBase.h:113
virtual int32 NumSlot() const
Definition ChildrenBase.h:98
Definition NameTypes.h:617
const FChildren * GetOwner() const
Definition SlotBase.h:32
SLATECORE_API SWidget * GetOwnerWidget() const
Definition SlotBase.cpp:29
Definition SWidget.h:165
Definition SlateAttributeDefinition.inl:43
SLATECORE_API void RemoveContainerWidget(SWidget &Widget)
Definition SlateAttribute.cpp:35
SLATECORE_API void UpdateContainerSortOrder(SWidget &Widget)
Definition SlateAttribute.cpp:41
Definition SlotBase.h:122
void Construct(const FChildren &SlotOwner, FSlotArguments &&InArgs)
Definition SlotBase.h:212
Definition WidgetSlotWithAttributeSupport.h:21
virtual uint32 GetContainerSortOrder() const override
Definition WidgetSlotWithAttributeSupport.h:81
static void RegisterAttributes(FSlateWidgetSlotAttributeInitializer &AttributeInitializer)
Definition WidgetSlotWithAttributeSupport.h:53
void RequestSortAttribute()
Definition WidgetSlotWithAttributeSupport.h:57
virtual ~TWidgetSlotWithAttributeSupport()
Definition WidgetSlotWithAttributeSupport.h:38
virtual FName GetContainerName() const override
Definition WidgetSlotWithAttributeSupport.h:76
void Construct(const FChildren &SlotOwner, typename Super::FSlotArguments &&InArgs)
Definition WidgetSlotWithAttributeSupport.h:46
virtual SWidget & GetContainerWidget() const override
Definition WidgetSlotWithAttributeSupport.h:69
U16 Index
Definition radfft.cpp:71
Definition SlateAttributeDescriptor.h:205
Definition SlateAttributeContained.inl:19
Definition SlotBase.h:149
Definition WidgetSlotWithAttributeSupport.h:33