UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SSafeZone.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"
7#include "Layout/Margin.h"
10
12
29class SSafeZone : public SBox
30{
34 , _Padding( 0.0f )
35 , _Content()
36 , _IsTitleSafe( false )
37 , _SafeAreaScale(1,1,1,1)
38 , _PadLeft( true )
39 , _PadRight( true )
40 , _PadTop( true )
41 , _PadBottom( true )
42#if WITH_EDITOR
45#endif
46 {}
47
50
51
53
54
55 SLATE_ATTRIBUTE( FMargin, Padding )
56
57
58 SLATE_DEFAULT_SLOT( FArguments, Content )
59
60
61 SLATE_ARGUMENT( bool, IsTitleSafe )
62
63
67 SLATE_ARGUMENT(FMargin, SafeAreaScale)
68
69
70 SLATE_ARGUMENT( bool, PadLeft )
71
72
73 SLATE_ARGUMENT( bool, PadRight )
74
75
76 SLATE_ARGUMENT( bool, PadTop )
77
78
79 SLATE_ARGUMENT( bool, PadBottom )
80
81#if WITH_EDITOR
84
85
87#endif
88
90
91public:
92
94 SLATE_API virtual ~SSafeZone();
95
96 SLATE_API void Construct( const FArguments& InArgs );
97
98 SLATE_API void SetTitleSafe( bool bIsTitleSafe );
100
101 SLATE_API void SetSidesToPad( bool InPadLeft, bool InPadRight, bool InPadTop, bool InPadBottom );
102
104
105#if WITH_EDITOR
108#endif
109
110 SLATE_API virtual void OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const override;
111 SLATE_API virtual FVector2D ComputeDesiredSize(float LayoutScale) const override;
112
115
116private:
117
118 void UpdateSafeMargin();
119 FMargin ComputeScaledSafeMargin(float Scale) const;
120
123 FMargin SafeAreaScale;
124 bool bIsTitleSafe;
125 bool bPadLeft;
126 bool bPadRight;
127 bool bPadTop;
128 bool bPadBottom;
129
130#if WITH_EDITOR
133#endif
134
136 mutable bool bSafeMarginNeedsUpdate;
137
139 mutable FMargin SafeMargin;
140
141 FDelegateHandle OnSafeFrameChangedHandle;
142};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define SLATE_ATTRIBUTE(AttrType, AttrName)
Definition DeclarativeSyntaxSupport.h:192
#define SLATE_BEGIN_ARGS(InWidgetType)
Definition DeclarativeSyntaxSupport.h:63
#define SLATE_END_ARGS()
Definition DeclarativeSyntaxSupport.h:116
#define SLATE_DEFAULT_SLOT(DeclarationType, SlotName)
Definition DeclarativeSyntaxSupport.h:444
#define SLATE_ARGUMENT(ArgType, ArgName)
Definition DeclarativeSyntaxSupport.h:208
EHorizontalAlignment
Definition SlateEnums.h:174
EVerticalAlignment
Definition SlateEnums.h:194
Definition ArrangedChildren.h:15
Definition IDelegateInstance.h:14
Definition SBox.h:29
void Construct()
Definition SPanel.h:65
Definition SSafeZone.h:30
SLATE_API void SetTitleSafe(bool bIsTitleSafe)
Definition SSafeZone.cpp:89
virtual SLATE_API ~SSafeZone()
Definition SSafeZone.cpp:84
SLATE_API SSafeZone()
Definition SSafeZone.cpp:25
SLATE_API void SetSafeAreaScale(FMargin InSafeAreaScale)
Definition SSafeZone.cpp:180
static SLATE_API TOptional< float > GetGlobalSafeZoneScale()
Definition SSafeZone.cpp:45
virtual SLATE_API FVector2D ComputeDesiredSize(float LayoutScale) const override
Definition SSafeZone.cpp:220
SLATE_API FMargin GetSafeMargin(float InLayoutScale) const
Definition SSafeZone.cpp:169
SLATE_API void SetSidesToPad(bool InPadLeft, bool InPadRight, bool InPadTop, bool InPadBottom)
Definition SSafeZone.cpp:143
static SLATE_API void SetGlobalSafeZoneScale(TOptional< float > InScale)
Definition SSafeZone.cpp:32
virtual SLATE_API void OnArrangeChildren(const FGeometry &AllottedGeometry, FArrangedChildren &ArrangedChildren) const override
Definition SSafeZone.cpp:201
Definition Geometry.h:40
Definition Margin.h:17
Definition SWidget.h:189
Definition Optional.h:131