UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SlateAttributeManaged.inl
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7{
11 template<typename InObjectType, typename InInvalidationReasonPredicate, typename InComparePredicate>
12 struct TSlateManagedAttribute : protected TSlateAttributeBase<SWidget, InObjectType, InInvalidationReasonPredicate, InComparePredicate, ESlateAttributeType::Managed>
13 {
14 private:
16
17 public:
18 using FGetter = typename Super::FGetter;
19 using ObjectType = typename Super::ObjectType;
20
22 static bool IdenticalTo(const SWidget& Widget, const ObjectType& Lhs, const ObjectType& Rhs) { return Super::IdenticalTo(Widget, Lhs, Rhs); }
23
24 public:
28
33
36 , ManagedWidget(MoveTemp(Other.ManagedWidget))
37 {
38 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
39 {
41 }
42 }
43
45 {
46 Super::operator=(MoveTemp(Other));
47 ManagedWidget = MoveTemp(Other.ManagedWidget);
48
49 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
50 {
52 }
53 return *this;
54 }
55
57 : Super(Widget.Get())
58 , ManagedWidget(Widget)
59 { }
60
63 , ManagedWidget(Widget)
64 {
65 }
66
72
73 explicit TSlateManagedAttribute(TSharedRef<SWidget> Widget, const FGetter& Getter, const ObjectType& InitialValue)
74 : Super(Widget.Get(), Getter, InitialValue)
75 , ManagedWidget(Widget)
76 {
77 }
78
79 explicit TSlateManagedAttribute(TSharedRef<SWidget> Widget, const FGetter& Getter, ObjectType&& InitialValue)
80 : Super(Widget.Get(), Getter, MoveTemp(InitialValue))
81 , ManagedWidget(Widget)
82 {
83 }
84
85 explicit TSlateManagedAttribute(TSharedRef<SWidget> Widget, FGetter&& Getter, const ObjectType& InitialValue)
86 : Super(Widget.Get(), MoveTemp(Getter), InitialValue)
87 , ManagedWidget(Widget)
88 {
89 }
90
92 : Super(Widget.Get(), MoveTemp(Getter), MoveTemp(InitialValue))
93 , ManagedWidget(Widget)
94 {
95 }
96
98 : Super(Widget.Get(), Attribute, InitialValue)
99 , ManagedWidget(Widget)
100 {
101 }
102
104 : Super(Widget.Get(), MoveTemp(Attribute), MoveTemp(InitialValue))
105 , ManagedWidget(Widget)
106 {
107 }
108
109 public:
110 const ObjectType& Get() const
111 {
112 return Super::Get();
113 }
114
116 {
117 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
118 {
119 Super::UpdateNow(*Pin.Get());
120 }
121 }
122
123 public:
124 void Set(const ObjectType& NewValue)
125 {
126 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
127 {
128 Super::Set(*Pin.Get(), NewValue);
129 }
130 }
131
132 void Set(ObjectType&& NewValue)
133 {
134 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
135 {
136 Super::Set(*Pin.Get(), MoveTemp(NewValue));
137 }
138 }
139
140 void Bind(const FGetter& Getter)
141 {
142 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
143 {
144 Super::Bind(*Pin.Get(), Getter);
145 }
146 }
147
148 void Bind(FGetter&& Getter)
149 {
150 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
151 {
152 Super::Bind(*Pin.Get(), MoveTemp(Getter));
153 }
154 }
155
157 {
158 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
159 {
160 Super::Assign(*Pin.Get(), OtherAttribute);
161 }
162 }
163
165 {
166 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
167 {
169 }
170 }
171
172 void Assign(const TAttribute<ObjectType>& OtherAttribute, const ObjectType& DefaultValue)
173 {
174 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
175 {
176 Super::Assign(*Pin.Get(), OtherAttribute, DefaultValue);
177 }
178 }
179
181 {
182 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
183 {
184 Super::Assign(*Pin.Get(), OtherAttribute, MoveTemp(DefaultValue));
185 }
186 }
187
189 {
190 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
191 {
192 Super::Assign(*Pin.Get(), MoveTemp(OtherAttribute), DefaultValue);
193 }
194 }
195
197 {
198 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
199 {
200 Super::Assign(*Pin.Get(), MoveTemp(OtherAttribute), MoveTemp(DefaultValue));
201 }
202 }
203
204 void Unbind()
205 {
206 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
207 {
208 Super::Unbind(*Pin.Get());
209 }
210 }
211
212 public:
213 bool IsBound() const
214 {
215 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
216 {
217 return Super::IsBound(*Pin.Get());
218 }
219 return false;
220 }
221
223 {
224 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
225 {
226 return Super::IdenticalTo(*Pin.Get(), Other);
227 }
228 return false;
229 }
230
232 {
233 if (TSharedPtr<SWidget> Pin = ManagedWidget.Pin())
234 {
235 return Super::IdenticalTo(*Pin.Get(), Other);
236 }
237 return false;
238 }
239
240 private:
241 TWeakPtr<SWidget> ManagedWidget;
242 };
243
244} // SlateAttributePrivate
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EInvalidateWidgetReason
Definition InvalidateWidgetReason.h:14
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition SWidget.h:165
Definition Attribute.h:17
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition SharedPointer.h:1295
UE_FORCEINLINE_HINT TSharedPtr< ObjectType, Mode > Pin() const &
Definition SharedPointer.h:1512
Definition SlateAttribute.cpp:11
SLATECORE_API void ProtectedMoveAttribute(SWidget &Widget, ESlateAttributeType AttributeType, const FSlateAttributeBase *Other)
Definition SlateAttribute.cpp:162
Definition SlateAttributeBase.inl:20
static bool IdenticalTo(const SWidget &Widget, const ObjectType &Lhs, const ObjectType &Rhs)
Definition SlateAttributeBase.inl:37
bool Assign(SWidget &Widget, const TAttribute< ObjectType > &OtherAttribute, ESlateAttributeBindAction Actions=UE_SLATE_WITH_ATTRIBUTE_DEFAULT_INITIALIZATION_ACTION)
Definition SlateAttributeBase.inl:350
Definition SlateAttributeManaged.inl:13
static bool IdenticalTo(const SWidget &Widget, const ObjectType &Lhs, const ObjectType &Rhs)
Definition SlateAttributeManaged.inl:22
void Assign(const TAttribute< ObjectType > &OtherAttribute, ObjectType &&DefaultValue)
Definition SlateAttributeManaged.inl:180
bool IdenticalTo(const TAttribute< ObjectType > &Other) const
Definition SlateAttributeManaged.inl:231
void Assign(TAttribute< ObjectType > &&OtherAttribute)
Definition SlateAttributeManaged.inl:164
void Bind(FGetter &&Getter)
Definition SlateAttributeManaged.inl:148
void Assign(TAttribute< ObjectType > &&OtherAttribute, const ObjectType &DefaultValue)
Definition SlateAttributeManaged.inl:188
~TSlateManagedAttribute()
Definition SlateAttributeManaged.inl:29
TSlateManagedAttribute(TSharedRef< SWidget > Widget)
Definition SlateAttributeManaged.inl:56
void Assign(const TAttribute< ObjectType > &OtherAttribute)
Definition SlateAttributeManaged.inl:156
TSlateManagedAttribute(TSlateManagedAttribute &&Other)
Definition SlateAttributeManaged.inl:34
void Unbind()
Definition SlateAttributeManaged.inl:204
void Assign(const TAttribute< ObjectType > &OtherAttribute, const ObjectType &DefaultValue)
Definition SlateAttributeManaged.inl:172
TSlateManagedAttribute(TSharedRef< SWidget > Widget, FGetter &&Getter, const ObjectType &InitialValue)
Definition SlateAttributeManaged.inl:85
typename Super::ObjectType ObjectType
Definition SlateAttributeManaged.inl:19
void UpdateNow()
Definition SlateAttributeManaged.inl:115
static EInvalidateWidgetReason GetInvalidationReason(const SWidget &Widget)
Definition SlateAttributeManaged.inl:21
TSlateManagedAttribute & operator=(const TSlateManagedAttribute &)=delete
const ObjectType & Get() const
Definition SlateAttributeManaged.inl:110
TSlateManagedAttribute(TSharedRef< SWidget > Widget, ObjectType &&InValue)
Definition SlateAttributeManaged.inl:67
TSlateManagedAttribute(TSharedRef< SWidget > Widget, const FGetter &Getter, ObjectType &&InitialValue)
Definition SlateAttributeManaged.inl:79
bool IdenticalTo(const TSlateManagedAttribute &Other) const
Definition SlateAttributeManaged.inl:222
TSlateManagedAttribute(TSharedRef< SWidget > Widget, const ObjectType &InValue)
Definition SlateAttributeManaged.inl:61
void Set(ObjectType &&NewValue)
Definition SlateAttributeManaged.inl:132
TSlateManagedAttribute(TSharedRef< SWidget > Widget, TAttribute< ObjectType > &&Attribute, ObjectType &&InitialValue)
Definition SlateAttributeManaged.inl:103
TSlateManagedAttribute(TSharedRef< SWidget > Widget, FGetter &&Getter, ObjectType &&InitialValue)
Definition SlateAttributeManaged.inl:91
bool IsBound() const
Definition SlateAttributeManaged.inl:213
void Set(const ObjectType &NewValue)
Definition SlateAttributeManaged.inl:124
void Assign(TAttribute< ObjectType > &&OtherAttribute, ObjectType &&DefaultValue)
Definition SlateAttributeManaged.inl:196
void Bind(const FGetter &Getter)
Definition SlateAttributeManaged.inl:140
TSlateManagedAttribute(TSharedRef< SWidget > Widget, const FGetter &Getter, const ObjectType &InitialValue)
Definition SlateAttributeManaged.inl:73
TSlateManagedAttribute(const TSlateManagedAttribute &)=delete
typename Super::FGetter FGetter
Definition SlateAttributeManaged.inl:18
TSlateManagedAttribute & operator=(TSlateManagedAttribute &&Other)
Definition SlateAttributeManaged.inl:44
TSlateManagedAttribute(TSharedRef< SWidget > Widget, const TAttribute< ObjectType > &Attribute, const ObjectType &InitialValue)
Definition SlateAttributeManaged.inl:97