UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SlateVector2.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Math/Vector2D.h"
7#include "Math/IntPoint.h"
9#include "Misc/Optional.h"
10
11#include "SlateVector2.generated.h"
12
16#ifndef UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS
17 #define UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS 1
18#endif
19
20
25#define UE_INCLUDETOOL_IGNORE_INCONSISTENT_STATE
26
27
32#ifndef UE_REPORT_SLATE_VECTOR_DEPRECATION
33 #define UE_REPORT_SLATE_VECTOR_DEPRECATION 0
34#endif
35
36static_assert(UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS || !UE_REPORT_SLATE_VECTOR_DEPRECATION, "UE_REPORT_SLATE_VECTOR_DEPRECATION should never be specified where UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS is disabled.");
37
38#ifndef UE_REPORT_SLATE_VECTOR_DEPRECATION_VERSION
39 #define UE_REPORT_SLATE_VECTOR_DEPRECATION_VERSION all
40#endif
41
42
43#if UE_REPORT_SLATE_VECTOR_DEPRECATION
44 #define UE_SLATE_VECTOR_DEPRECATED(Text) UE_DEPRECATED(UE_REPORT_SLATE_VECTOR_DEPRECATION_VERSION, Text)
45 #define UE_SLATE_VECTOR_DEPRECATED_DEFAULT() UE_DEPRECATED(UE_REPORT_SLATE_VECTOR_DEPRECATION_VERSION, "Use FVector2f or float directly; this Slate API no longer interfaces directly with double-precision scalars and vectors.")
46#else
47 #define UE_SLATE_VECTOR_DEPRECATED(Text)
48 #define UE_SLATE_VECTOR_DEPRECATED_DEFAULT()
49#endif
50
51#if UE_REPORT_SLATE_VECTOR_DEPRECATION && UE_WARNINGS_AS_ERRORS
52 #define UE_SLATE_DEPRECATED_VECTOR_VIRTUAL_FUNCTION final
53#else
54 #define UE_SLATE_DEPRECATED_VECTOR_VIRTUAL_FUNCTION
55#endif
56
57
58#undef UE_INCLUDETOOL_IGNORE_INCONSISTENT_STATE
59#undef UE_REPORT_SLATE_VECTOR_DEPRECATION
60
61
63
64namespace UE::Slate
65{
66
73
74
75#if UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS
76
77 struct FDeprecateVector2DParameter;
78 struct FDeprecateOptionalVector2DParameter;
79
82 const FVector2f& CastToVector2f(const FDeprecateVector2DParameter& InValue);
83
98
99#else // UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS
100
104
105#endif
106
107} // namespace UE::Slate
108
109
123USTRUCT(BlueprintInternalUseOnly, DisplayName="Vector2D", meta=(HiddenByDefault, ShortTooltip="Vector2D (single-precision)", ToolTip="Vector2D (single-precision)", ScriptDefaultMake, ScriptDefaultBreak, HasNativeMake="/Script/Engine.KismetMathLibrary.MakeVector2D", HasNativeBreak="/Script/Engine.KismetMathLibrary.BreakVector2D"))
125{
127
128 FDeprecateSlateVector2D() = default;
129
133 {
134 }
135
137 explicit FDeprecateSlateVector2D(float InX, float InY)
138 : FVector2f(InX, InY)
139 {
140 }
141
143 FDeprecateSlateVector2D& operator=(const FVector2f& InValue)
144 {
145 X = InValue.X;
146 Y = InValue.Y;
147 return *this;
148 }
149
151 FDeprecateSlateVector2D& operator=(const FVector2d& InValue)
152 {
155 return *this;
156 }
157
158
160 FDeprecateSlateVector2D& operator=(const FIntPoint& InValue)
161 {
164 return *this;
165 }
166
171 operator FVector2d() const
172 {
173 return FVector2d(X, Y);
174 }
175
176#if UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS
177
179 {
181 }
182
184 {
186 }
187
188#endif
189
192
193public:
194
195 /*~ ---------------------------------------
196 * These functions hide the similarly named functions from FVector2f in order to provide FVector2d interop */
197
199 FDeprecateSlateVector2D RoundToVector() const
200 {
202 }
203
204 bool Equals(const UE::Slate::FDeprecateVector2DParameter& V, float Tolerance=UE_KINDA_SMALL_NUMBER) const
205 {
206 return FVector2f::Equals(UE::Slate::CastToVector2f(V), Tolerance);
207 }
208
209 FDeprecateSlateVector2D GetSignVector() const
210 {
212 }
213
214 FDeprecateSlateVector2D GetAbs() const
215 {
217 }
218
219 FDeprecateSlateVector2D ClampAxes(float MinAxisVal, float MaxAxisVal) const
220 {
222 }
223
224 FDeprecateSlateVector2D GetRotated(float AngleDeg) const
225 {
227 }
228
230 {
231 return FVector2f::GetSafeNormal(Tolerance);
232 }
233
234 SLATECORE_API bool ComponentwiseAllLessThan(const UE::Slate::FDeprecateVector2DParameter& Other) const;
235
236 SLATECORE_API bool ComponentwiseAllGreaterThan(const UE::Slate::FDeprecateVector2DParameter& Other) const;
237
238 SLATECORE_API bool ComponentwiseAllLessOrEqual(const UE::Slate::FDeprecateVector2DParameter& Other) const;
239
240 SLATECORE_API bool ComponentwiseAllGreaterOrEqual(const UE::Slate::FDeprecateVector2DParameter& Other) const;
241
243 FDeprecateSlateVector2D ClampAxes(double MinAxisVal, double MaxAxisVal) const
244 {
246 }
247
249 FDeprecateSlateVector2D GetRotated(double AngleDeg) const
250 {
251 return GetRotated(UE_REAL_TO_FLOAT(AngleDeg));
252 }
254 FDeprecateSlateVector2D GetSafeNormal(double Tolerance) const
255 {
256 return GetSafeNormal(UE_REAL_TO_FLOAT(Tolerance));
257 }
258
259 /*~ End interop
260 * --------------------------------------- */
261
262public:
263
264#if UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS
265
266 /*~ Macros to assist in defining explicit binary mathematical operators.
267 These are generally all necessary in order to resolve otherwise ambiguous overloaded operators
268 if we were to define them in terms of FDeprecateVector2DParameter */
269 #define UE_SLATE_BINARY_VECTOR_OPERATORS_A(Type, ...)\
270 __VA_ARGS__\
271 friend FDeprecateSlateVector2D operator+(const Type& A, const FDeprecateSlateVector2D& B)\
272 {\
273 return FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) + UE::Slate::CastToVector2f(B));\
274 }\
275 __VA_ARGS__\
276 friend FDeprecateSlateVector2D operator-(const Type& A, const FDeprecateSlateVector2D& B)\
277 {\
278 return FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) - UE::Slate::CastToVector2f(B));\
279 }\
280 __VA_ARGS__\
281 friend FDeprecateSlateVector2D operator*(const Type& A, const FDeprecateSlateVector2D& B)\
282 {\
283 return FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) * UE::Slate::CastToVector2f(B));\
284 }\
285 __VA_ARGS__\
286 friend FDeprecateSlateVector2D operator/(const Type& A, const FDeprecateSlateVector2D& B)\
287 {\
288 return FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) / UE::Slate::CastToVector2f(B));\
289 }\
290 __VA_ARGS__\
291 friend bool operator==(const Type& A, const FDeprecateSlateVector2D& B)\
292 {\
293 return UE::Slate::CastToVector2f(A) == UE::Slate::CastToVector2f(B);\
294 }\
295 __VA_ARGS__\
296 friend bool operator!=(const Type& A, const FDeprecateSlateVector2D& B)\
297 {\
298 return UE::Slate::CastToVector2f(A) != UE::Slate::CastToVector2f(B);\
299 }
300
301 #define UE_SLATE_BINARY_ASSIGNMENT_VECTOR_OPERATORS_A(Type, ...)\
302 __VA_ARGS__\
303 friend Type& operator+=(Type& A, const FDeprecateSlateVector2D& B)\
304 {\
305 A = Type(FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) + UE::Slate::CastToVector2f(B)));\
306 return A;\
307 }\
308 __VA_ARGS__\
309 friend Type& operator-=(Type& A, const FDeprecateSlateVector2D& B)\
310 {\
311 A = Type(FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) - UE::Slate::CastToVector2f(B)));\
312 return A;\
313 }\
314 __VA_ARGS__\
315 friend Type& operator*=(Type& A, const FDeprecateSlateVector2D& B)\
316 {\
317 A = Type(FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) * UE::Slate::CastToVector2f(B)));\
318 return A;\
319 }\
320 __VA_ARGS__\
321 friend Type& operator/=(Type& A, const FDeprecateSlateVector2D& B)\
322 {\
323 A = Type(FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) / UE::Slate::CastToVector2f(B)));\
324 return A;\
325 }
326
327 #define UE_SLATE_BINARY_VECTOR_OPERATORS_B(Type, ...)\
328 __VA_ARGS__\
329 friend FDeprecateSlateVector2D operator+(const FDeprecateSlateVector2D& A, const Type& B)\
330 {\
331 return FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) + UE::Slate::CastToVector2f(B));\
332 }\
333 __VA_ARGS__\
334 friend FDeprecateSlateVector2D operator-(const FDeprecateSlateVector2D& A, const Type& B)\
335 {\
336 return FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) - UE::Slate::CastToVector2f(B));\
337 }\
338 __VA_ARGS__\
339 friend FDeprecateSlateVector2D operator*(const FDeprecateSlateVector2D& A, const Type& B)\
340 {\
341 return FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) * UE::Slate::CastToVector2f(B));\
342 }\
343 __VA_ARGS__\
344 friend FDeprecateSlateVector2D operator/(const FDeprecateSlateVector2D& A, const Type& B)\
345 {\
346 return FDeprecateSlateVector2D(UE::Slate::CastToVector2f(A) / UE::Slate::CastToVector2f(B));\
347 }\
348 __VA_ARGS__\
349 friend bool operator==(const FDeprecateSlateVector2D& A, const Type& B)\
350 {\
351 return UE::Slate::CastToVector2f(A) == UE::Slate::CastToVector2f(B);\
352 }\
353 __VA_ARGS__\
354 friend bool operator!=(const FDeprecateSlateVector2D& A, const Type& B)\
355 {\
356 return UE::Slate::CastToVector2f(A) != UE::Slate::CastToVector2f(B);\
357 }
358
359 #define UE_SLATE_BINARY_ASSIGNMENT_VECTOR_OPERATORS_B(Type, ...)\
360 __VA_ARGS__\
361 friend FDeprecateSlateVector2D& operator+=(FDeprecateSlateVector2D& A, const Type& B)\
362 {\
363 static_cast<FVector2f&>(A) += UE::Slate::CastToVector2f(B);\
364 return A;\
365 }\
366 __VA_ARGS__\
367 friend FDeprecateSlateVector2D& operator-=(FDeprecateSlateVector2D& A, const Type& B)\
368 {\
369 static_cast<FVector2f&>(A) -= UE::Slate::CastToVector2f(B);\
370 return A;\
371 }\
372 __VA_ARGS__\
373 friend FDeprecateSlateVector2D& operator*=(FDeprecateSlateVector2D& A, const Type& B)\
374 {\
375 static_cast<FVector2f&>(A) *= UE::Slate::CastToVector2f(B);\
376 return A;\
377 }\
378 __VA_ARGS__\
379 friend FDeprecateSlateVector2D& operator/=(FDeprecateSlateVector2D& A, const Type& B)\
380 {\
381 static_cast<FVector2f&>(A) /= UE::Slate::CastToVector2f(B);\
382 return A;\
383 }
384
385 /*~ Begin binary operator overloads */
388
393
398
401
403 {
405 }
407 {
409 }
411 {
413 }
415 {
417 }
419 {
421 }
422
423 /*~ End binary operator overloads */
424
425 /*~ Unary operator overloads */
427 {
429 }
430 /*~ Unary operator overloads */
431
432#undef UE_SLATE_BINARY_VECTOR_OPERATORS_A
433#undef UE_SLATE_BINARY_VECTOR_OPERATORS_B
434#undef UE_SLATE_BINARY_ASSIGNMENT_VECTOR_OPERATORS_A
435#undef UE_SLATE_BINARY_ASSIGNMENT_VECTOR_OPERATORS_B
436
437#endif // UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS
438};
439
440template<>
442{
443 enum
444 {
447 };
448};
449
450
451#if UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS
452
453namespace UE::Slate
454{
455
470
513
546
548{
549 return InValue;
550}
551
553{
554 return InValue;
555}
556
558{
559 return InValue;
560}
561
562} // namespace UE::Slate
563
568
573
574template <typename TransformType>
579
580template <typename TransformType>
585
586#endif // UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS
587
588namespace UE::Slate
589{
590
592 {
593 return InValue;
594 }
596 {
597 const float X = UE_REAL_TO_FLOAT(InValue.X);
598 const float Y = UE_REAL_TO_FLOAT(InValue.Y);
599 #if 0
602 #endif
603 return FVector2f(X, Y);
604 }
605
606} // namespace UE::Slate
constexpr EUpdateTransformFlags operator&(EUpdateTransformFlags Left, EUpdateTransformFlags Right)
Definition ActorComponent.h:111
#define ensureAlways( InExpression)
Definition AssertionMacros.h:466
UE_FORCEINLINE_HINT FLinearColor operator*(float Scalar, const FLinearColor &Color)
Definition Color.h:473
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define X(Name, Desc)
Definition FormatStringSan.h:47
constexpr EIOSEventType operator+(EIOSEventType type, int Index)
Definition IOSInputInterface.cpp:138
#define UE_REAL_TO_FLOAT(argument)
Definition LargeWorldCoordinates.h:30
UE::Math::TVector2< float > FVector2f
Definition MathFwd.h:74
UE::Math::TVector2< double > FVector2d
Definition MathFwd.h:61
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define USTRUCT(...)
Definition ObjectMacros.h:746
FScreenTransform operator/(const FScreenTransform &AToB, const FVector2f &InvertedScale)
Definition ScreenPass.inl:280
FScreenTransform operator-(const FScreenTransform &AToB, const FVector2f &Bias)
Definition ScreenPass.inl:264
#define UE_ENABLE_SLATE_VECTOR_DEPRECATION_MECHANISMS
Definition SlateVector2.h:17
#define UE_SLATE_BINARY_ASSIGNMENT_VECTOR_OPERATORS_B(Type,...)
#define UE_REPORT_SLATE_VECTOR_DEPRECATION
Definition SlateVector2.h:33
UE::Slate::FDeprecateVector2DResult TransformPoint(float Transform, const UE::Slate::FDeprecateVector2DResult &Point)
Definition SlateVector2.h:564
#define UE_SLATE_BINARY_VECTOR_OPERATORS_B(Type,...)
#define UE_SLATE_VECTOR_DEPRECATED_DEFAULT()
Definition SlateVector2.h:48
#define UE_SLATE_BINARY_VECTOR_OPERATORS_A(Type,...)
UE::Slate::FDeprecateVector2DResult TransformVector(float Transform, const UE::Slate::FDeprecateVector2DResult &Vector)
Definition SlateVector2.h:569
#define UE_SLATE_BINARY_ASSIGNMENT_VECTOR_OPERATORS_A(Type,...)
#define UE_SMALL_NUMBER
Definition UnrealMathUtility.h:130
#define UE_KINDA_SMALL_NUMBER
Definition UnrealMathUtility.h:131
OutType FloatCastChecked(InType In, InType Precision)
Definition UnrealTemplate.h:190
Definition StructuredArchiveSlots.h:52
std::enable_if_t< std::is_floating_point_v< typename FType::FReal >, bool > SerializeFromMismatchedTag(FType &Target, FName StructTag, FArSlot &ArSlot, FName BaseTag, FName ThisTag, FName AltTag)
Definition LargeWorldCoordinatesSerializer.h:18
T GetSafeNormal(const T &Value)
Definition SplineMath.h:221
Definition DockingUtilsPrivate.h:8
FDeprecateSlateVector2D FDeprecateVector2DResult
Definition SlateVector2.h:469
const FVector2f & CastToVector2f(const FVector2f &InValue)
Definition SlateVector2.h:591
static UE_FORCEINLINE_HINT bool IsNearlyEqual(float A, float B, float ErrorTolerance=UE_SMALL_NUMBER)
Definition UnrealMathUtility.h:388
Definition PropertyTag.h:38
Definition Optional.h:131
FVector2f & Emplace(ArgsType &&... Args)
Definition Optional.h:323
Definition StructOpsTypeTraits.h:11
@ WithStructuredSerializeFromMismatchedTag
Definition StructOpsTypeTraits.h:29
@ WithStructuredSerializer
Definition StructOpsTypeTraits.h:24
Definition StructOpsTypeTraits.h:46
Definition IntPoint.h:25
bool Equals(const TVector2< float > &V, float Tolerance=UE_KINDA_SMALL_NUMBER) const
Definition Vector2D.h:1007
TVector2< float > RoundToVector() const
Definition Vector2D.h:1236
TVector2< float > GetSafeNormal(float Tolerance=UE_SMALL_NUMBER) const
Definition Vector2D.h:1142
TVector2< float > GetRotated(float AngleDeg) const
Definition Vector2D.h:1129
float Y
Definition Vector2D.h:52
TVector2< float > GetSignVector() const
Definition Vector2D.h:1286
UE_FORCEINLINE_HINT TVector2< float > GetAbs() const
Definition Vector2D.h:1296
TVector2< float > ClampAxes(float MinAxisVal, float MaxAxisVal) const
Definition Vector2D.h:1249
T X
Definition Vector2D.h:49
FDeprecateOptionalVector2DParameter(const TOptional< FVector2f > &In)
Definition SlateVector2.h:527
FDeprecateOptionalVector2DParameter()
Definition SlateVector2.h:520
FDeprecateOptionalVector2DParameter(const FVector2f &In)
Definition SlateVector2.h:523
Definition SlateVector2.h:85
FDeprecateSlateVector2D * Instance
Definition SlateVector2.h:95
FVector2D DoubleVector
Definition SlateVector2.h:96
Definition SlateVector2.h:485
FDeprecateVector2DParameter(const FVector2f &InValue)
Definition SlateVector2.h:490
FDeprecateVector2DParameter(const FDeprecateVector2DResult &InValue)
Definition SlateVector2.h:494
FDeprecateVector2DParameter(float InX, float InY)
Definition SlateVector2.h:486