UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Margin.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"
7#include "Types/SlateEnums.h"
9#include "Margin.generated.h"
10
11
15USTRUCT(BlueprintType)
17{
19
20
21 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Appearance)
23
25 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Appearance)
26 float Top;
27
29 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Appearance)
30 float Right;
31
33 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Appearance)
34 float Bottom;
35
36public:
37
44 : Left(0.0f)
45 , Top(0.0f)
46 , Right(0.0f)
47 , Bottom(0.0f)
48 { }
49
57
61 , Top(Vertical)
64 { }
65
67 FMargin(const FVector2f InVector)
68 : Left(InVector.X)
69 , Top(InVector.Y)
70 , Right(InVector.X)
71 , Bottom(InVector.Y)
72 { }
73
75 FMargin(const FVector2d InVector)
76 : Left(UE_REAL_TO_FLOAT(InVector.X))
77 , Top(UE_REAL_TO_FLOAT(InVector.Y))
78 , Right(UE_REAL_TO_FLOAT(InVector.X))
79 , Bottom(UE_REAL_TO_FLOAT(InVector.Y))
80 { }
81
83 FMargin(double InLeft, double InTop, double InRight, double InBottom)
84 : Left((float)InLeft)
85 , Top((float)InTop)
88 { }
89
91 FMargin(const FVector4f InVector)
92 : Left(InVector.X)
93 , Top(InVector.Y)
94 , Right(InVector.Z)
95 , Bottom(InVector.W)
96 { }
97
99 FMargin(const FVector4d InVector)
100 : Left(UE_REAL_TO_FLOAT(InVector.X))
101 , Top(UE_REAL_TO_FLOAT(InVector.Y))
102 , Right(UE_REAL_TO_FLOAT(InVector.Z))
103 , Bottom(UE_REAL_TO_FLOAT(InVector.W))
104 { }
105
106public:
107
114 FMargin operator*( float Scale ) const
115 {
116 return FMargin(Left * Scale, Top * Scale, Right * Scale, Bottom * Scale);
117 }
118
126 {
127 return FMargin(Left * InScale.Left, Top * InScale.Top, Right * InScale.Right, Bottom * InScale.Bottom);
128 }
129
137 {
138 return FMargin(Left + InDelta.Left, Top + InDelta.Top, Right + InDelta.Right, Bottom + InDelta.Bottom);
139 }
140
148 {
149 return FMargin(Left - Other.Left, Top - Other.Top, Right - Other.Right, Bottom - Other.Bottom);
150 }
151
158 bool operator==( const FMargin& Other ) const
159 {
160 return (Left == Other.Left) && (Right == Other.Right) && (Top == Other.Top) && (Bottom == Other.Bottom);
161 }
162
169 bool operator!=( const FMargin& Other ) const
170 {
171 return Left != Other.Left || Right != Other.Right || Top != Other.Top || Bottom != Other.Bottom;
172 }
173
174public:
175
186 {
187 return FVector2f(Left, Top);
188 }
189
200 {
201 return FVector2f(Left + Right, Top + Bottom);
202 }
203
209 template<EOrientation Orientation>
210 float GetTotalSpaceAlong( ) const
211 {
212 return 0.0f;
213 }
214};
215
216template <> struct TIsPODType<FMargin> { enum { Value = true }; };
217
218template<>
219inline float FMargin::GetTotalSpaceAlong<Orient_Horizontal>( ) const { return Left + Right; }
220
221template<>
222inline float FMargin::GetTotalSpaceAlong<Orient_Vertical>( ) const { return Top + Bottom; }
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define X(Name, Desc)
Definition FormatStringSan.h:47
#define UE_REAL_TO_FLOAT(argument)
Definition LargeWorldCoordinates.h:30
@ Bottom
Definition MaterialExpressionFunctionInput.h:43
@ Top
Definition MaterialExpressionFunctionInput.h:42
UE::Math::TVector2< float > FVector2f
Definition MathFwd.h:74
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
FDeprecateSlateVector2D FDeprecateVector2DResult
Definition SlateVector2.h:469
Definition Margin.h:17
FMargin(float Horizontal, float Vertical)
Definition Margin.h:59
FMargin operator*(const FMargin &InScale) const
Definition Margin.h:125
float Right
Definition Margin.h:30
UE::Slate::FDeprecateVector2DResult GetDesiredSize() const
Definition Margin.h:195
FMargin(const FVector2d InVector)
Definition Margin.h:75
float Bottom
Definition Margin.h:34
float Top
Definition Margin.h:26
FVector2f GetDesiredSize2f() const
Definition Margin.h:199
bool operator==(const FMargin &Other) const
Definition Margin.h:158
FMargin operator-(const FMargin &Other) const
Definition Margin.h:147
FMargin operator+(const FMargin &InDelta) const
Definition Margin.h:136
float Left
Definition Margin.h:22
bool operator!=(const FMargin &Other) const
Definition Margin.h:169
FMargin(float UniformMargin)
Definition Margin.h:51
FVector2f GetTopLeft2f() const
Definition Margin.h:185
float GetTotalSpaceAlong() const
Definition Margin.h:210
FMargin(const FVector2f InVector)
Definition Margin.h:67
FMargin(const FVector4f InVector)
Definition Margin.h:91
UE::Slate::FDeprecateVector2DResult GetTopLeft() const
Definition Margin.h:181
FMargin operator*(float Scale) const
Definition Margin.h:114
FMargin(double InLeft, double InTop, double InRight, double InBottom)
Definition Margin.h:83
FMargin(const FVector4d InVector)
Definition Margin.h:99
Definition IsPODType.h:12
@ Value
Definition IsPODType.h:13