UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SlateAttribute.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 "Misc/Attribute.h"
8#include "Templates/EqualTo.h"
10
11#include <type_traits>
12
13#ifndef UE_SLATE_WITH_MEMBER_ATTRIBUTE_DEBUGGING
14 #define UE_SLATE_WITH_MEMBER_ATTRIBUTE_DEBUGGING 0
15#endif
16#ifndef UE_SLATE_WITH_ATTRIBUTE_INITIALIZATION_ON_BIND
17 #define UE_SLATE_WITH_ATTRIBUTE_INITIALIZATION_ON_BIND 0
18#endif
19#ifndef UE_SLATE_WITH_ATTRIBUTE_NAN_DIAGNOSTIC
20 #define UE_SLATE_WITH_ATTRIBUTE_NAN_DIAGNOSTIC DO_ENSURE
21#endif
22
165class SWidget;
166
168{
169 None = 0, // Do nothing when an attribute is bound.
170 Initialize = 1, // Initialize the attribute value from the binding.
171};
173#if UE_SLATE_WITH_ATTRIBUTE_INITIALIZATION_ON_BIND
174# define UE_SLATE_WITH_ATTRIBUTE_DEFAULT_INITIALIZATION_ACTION ESlateAttributeBindAction::Initialize
175#else
176# define UE_SLATE_WITH_ATTRIBUTE_DEFAULT_INITIALIZATION_ACTION ESlateAttributeBindAction::None
177#endif
178
181{
187 template<typename T>
188 constexpr static bool IsInvalidateWidgetReasonSupported(T Reason)
189 {
190 return false;
191 }
196};
197
198
200template<typename ComparePredicate = TEqualTo<>>
202{
203 template<typename ObjectType>
204 static bool IdenticalTo(const SWidget&, ObjectType&& Lhs, ObjectType&& Rhs)
205 {
206 // If you have an error here, do you have a operator== const?
208 }
209};
210
211
220
221
223template<EInvalidateWidgetReason InvalidationReason>
225{
226 static_assert(FSlateAttributeBase::IsInvalidateWidgetReasonSupported(InvalidationReason), "The invalidation is not supported by the SlateAttribute.");
227 static constexpr EInvalidateWidgetReason GetInvalidationReason(const SWidget&) { return InvalidationReason; }
228};
229
230
232template<typename ObjectType>
234{
236
238
239 template<typename OtherType>
241
243
244 template<class SourceType>
246
247 template< class SourceType >
249
250 bool IsSet() const { return false; }
251
252 template<typename OtherType>
253 void Set(const OtherType& InNewValue) {}
254
255 const ObjectType& Get(const ObjectType& DefaultValue) const { return DefaultValue; }
256 const ObjectType& Get() const { static ObjectType Temp; return Temp; }
257 FGetter GetBinding() const { return false; }
258
259 void Bind(const FGetter& InGetter) {}
260 template<class SourceType>
261 void Bind(SourceType* InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr) {}
262 bool IsBound() const { return false; }
263
264 bool IdenticalTo(const TAttribute<ObjectType>& InOther) const { return false; }
265};
266
267// IWYU pragma: begin_exports
270
274// IWYU pragma: end_exports
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
EInvalidateWidgetReason
Definition InvalidateWidgetReason.h:14
ESlateAttributeBindAction
Definition SlateAttribute.h:168
Definition Text.h:385
CORE_API bool IdenticalTo(const FText &Other, const ETextIdenticalModeFlags CompareModeFlags=ETextIdenticalModeFlags::None) const
Definition Text.cpp:1366
Definition SWidget.h:165
Definition Attribute.h:17
Definition SharedPointer.h:153
Definition SlateAttribute.h:181
static constexpr bool IsInvalidateWidgetReasonSupported(EInvalidateWidgetReason Reason)
Definition SlateAttribute.h:192
static constexpr bool IsInvalidateWidgetReasonSupported(T Reason)
Definition SlateAttribute.h:188
Definition SlateAttribute.h:202
static bool IdenticalTo(const SWidget &, ObjectType &&Lhs, ObjectType &&Rhs)
Definition SlateAttribute.h:204
Definition SlateAttribute.h:214
static bool IdenticalTo(const SWidget &, const FText &Lhs, const FText &Rhs)
Definition SlateAttribute.h:215
Definition SlateAttribute.h:225
static constexpr EInvalidateWidgetReason GetInvalidationReason(const SWidget &)
Definition SlateAttribute.h:227
Definition SlateAttribute.h:234
bool IsSet() const
Definition SlateAttribute.h:250
void Bind(SourceType *InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
Definition SlateAttribute.h:261
TSlateDeprecatedTAttribute(SourceType *InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
Definition SlateAttribute.h:248
TSlateDeprecatedTAttribute()=default
TSlateDeprecatedTAttribute(const OtherType &InInitialValue)
Definition SlateAttribute.h:240
FGetter GetBinding() const
Definition SlateAttribute.h:257
bool IsBound() const
Definition SlateAttribute.h:262
void Bind(const FGetter &InGetter)
Definition SlateAttribute.h:259
typename TAttribute< ObjectType >::FGetter FGetter
Definition SlateAttribute.h:237
const ObjectType & Get() const
Definition SlateAttribute.h:256
bool IdenticalTo(const TAttribute< ObjectType > &InOther) const
Definition SlateAttribute.h:264
TSlateDeprecatedTAttribute(TSharedRef< SourceType > InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
Definition SlateAttribute.h:245
const ObjectType & Get(const ObjectType &DefaultValue) const
Definition SlateAttribute.h:255
void Set(const OtherType &InNewValue)
Definition SlateAttribute.h:253
TSlateDeprecatedTAttribute(ObjectType &&InInitialValue)
Definition SlateAttribute.h:242