UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SBoxPanel.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"
8#include "Layout/Visibility.h"
11#include "SlotBase.h"
12#include "Widgets/SWidget.h"
14#include "Layout/Children.h"
15#include "Widgets/SPanel.h"
17#include "Input/DragAndDrop.h"
19#include "Styling/SlateBrush.h"
20
22
23template <>
25{
26 static constexpr bool SupportsInvalidation() { return true; }
27};
28
29
33class SBoxPanel : public SPanel
34{
36
37protected:
42 template<typename SlotType>
70
71public:
72 class FSlot : public TSlot<FSlot>
73 {
74 };
75
76protected:
77 template<typename SlotType>
78 struct FScopedWidgetSlotArguments : public SlotType::FSlotArguments
79 {
80 public:
87
93
95 {
96 if (this->GetSlot()) // Is nullptr when the FScopedWidgetSlotArguments is moved-constructed.
97 {
99 if (Index == INDEX_NONE)
100 {
101 Children.AddSlot(MoveTemp(*SelfAsBaseSlot));
102 }
103 else
104 {
106 }
107 }
108 }
109
110 private:
111 TPanelChildren<FSlot>& Children;
112 int32 Index;
113 };
114
115public:
122
125
127 int32 NumSlots() const { return Children.Num(); }
128
131
132 //~ Begin SWidget overrides.
133public:
134 SLATECORE_API virtual void OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const override;
135 SLATECORE_API virtual FChildren* GetChildren() override;
136
137protected:
138 SLATECORE_API virtual FVector2D ComputeDesiredSize(float) const override;
139 //~ End SWidget overrides.
140
141protected:
146
150 {
151 return Orientation;
152 }
153
154protected:
157
160};
161
162
163template <>
165{
166 static constexpr bool SupportsInvalidation() { return true; }
167};
168
171{
173public:
174 class FSlot : public SBoxPanel::TSlot<FSlot>
175 {
176 public:
182 {
183 _SizeParam = FAuto();
184 return Me();
185 }
186
197
209
212 {
213 _MinSize = MoveTemp(InMinWidth);
214 return Me();
215 }
216
219 {
220 _MaxSize = MoveTemp(InMaxWidth);
221 return Me();
222 }
224
225
229 {
231 }
232
242
253
259
265
270 };
271
276
283
289
294
295 SLATECORE_API FSlot& GetSlot(int32 SlotIndex);
296 SLATECORE_API const FSlot& GetSlot(int32 SlotIndex) const;
297
304
310 SLATECORE_API void Construct( const FArguments& InArgs );
311};
312
313
314template <>
316{
317 static constexpr bool SupportsInvalidation() { return true; }
318};
319
322{
324public:
325 class FSlot : public SBoxPanel::TSlot<FSlot>
326 {
327 public:
329
330
334 {
335 _SizeParam = FAuto();
336 return Me();
337 }
338
349
361
364 {
365 _MinSize = MoveTemp(InMinHeight);
366 return Me();
367 }
368
371 {
372 _MaxSize = MoveTemp(InMaxHeight);
373 return Me();
374 }
376
377
381 {
383 }
384
394
405
411
417
422 };
423
428
429
436
442
447
448 SLATECORE_API FSlot& GetSlot(int32 SlotIndex);
449 SLATECORE_API const FSlot& GetSlot(int32 SlotIndex) const;
450
453 {
454 SetCanTick(false);
455 bCanSupportFocus = false;
456 }
457
463 SLATECORE_API void Construct( const FArguments& InArgs );
464};
465
466
467template <>
469{
470 static constexpr bool SupportsInvalidation() { return true; }
471};
472
474class SStackBox : public SBoxPanel
475{
477public:
534
539
540
548
554
559
560 SLATECORE_API FSlot& GetSlot(int32 SlotIndex);
561 SLATECORE_API const FSlot& GetSlot(int32 SlotIndex) const;
562
564 {
565 SetCanTick(false);
566 bCanSupportFocus = false;
567 }
568
574 SLATECORE_API void Construct(const FArguments& InArgs);
575
578};
579
592
595{
596public:
600 enum class EItemDropZone
601 {
602 AboveItem,
604 };
605
610
611 UE_DEPRECATED(5.6, "FOnCanAcceptDrop is deprecated. Please use FOnCanAcceptDropAdvanced which adds the drop slot index parameter.")
617
620
621
624 {
625 return FOnCanAcceptDropAdvanced::CreateLambda([LegacyDelegate](const FDragDropEvent& Event, SDragAndDropVerticalBox::EItemDropZone DropZone, int32 SlotIndex, SVerticalBox::FSlot* Slot)
626 {
627 if (LegacyDelegate.IsBound())
628 {
629 return LegacyDelegate.Execute(Event, DropZone, Slot);
630 }
631
633 });
634 }
635
636 SLATE_EVENT_DEPRECATED(5.6, "Use FOnCanAcceptDropAdvanced instead", FOnCanAcceptDrop, OnCanAcceptDrop, OnCanAcceptDropAdvanced, ConvertCanAcceptDropFn)
638
646 SLATE_EVENT(FOnCanAcceptDropAdvanced, OnCanAcceptDropAdvanced)
647
648
654 SLATE_EVENT(FOnAcceptDrop, OnAcceptDrop)
655
656 // Low level DragAndDrop
662
663 SLATECORE_API void Construct(const FArguments& InArgs);
664
666 SDragAndDropVerticalBox& SetDropIndicator_Above(const FSlateBrush& InValue) { DropIndicator_Above = InValue; return *this; }
667 SDragAndDropVerticalBox& SetDropIndicator_Below(const FSlateBrush& InValue) { DropIndicator_Below = InValue; return *this; }
668
671
673 SLATECORE_API virtual void OnDragEnter(FGeometry const& MyGeometry, FDragDropEvent const& DragDropEvent) override;
674 SLATECORE_API virtual void OnDragLeave(FDragDropEvent const& DragDropEvent) override;
677
678 SLATECORE_API virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
679
680private:
682 FOnCanAcceptDropAdvanced OnCanAcceptDropAdvanced;
683
685 FOnAcceptDrop OnAcceptDrop;
686
688 TOptional<EItemDropZone> ItemDropZone;
689
691 FOnDragAndDropVerticalBoxDragDetected OnDragDetected_Handler;
692
694 FOnDragAndDropVerticalBoxDragEnter OnDragEnter_Handler;
695
697 FOnDragAndDropVerticalBoxDragLeave OnDragLeave_Handler;
698
700 FOnDragAndDropVerticalBoxDrop OnDrop_Handler;
701
703 FSlateBrush DropIndicator_Above;
704 FSlateBrush DropIndicator_Below;
705
707 FVector2f CurrentDragOperationScreenSpaceLocation;
708 int32 CurrentDragOverSlotIndex;
709
712};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define FORCENOINLINE
Definition AndroidPlatform.h:142
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define SLATE_EVENT_DEPRECATED(DeprecationVersion, DeprecationMessage, DelegateName, EventName, UpgradedEventName, UpgradeFuncName)
Definition DeclarativeSyntaxSupport.h:546
#define SLATE_SLOT_ARGUMENT(SlotType, SlotName)
Definition DeclarativeSyntaxSupport.h:348
#define SLATE_BEGIN_ARGS(InWidgetType)
Definition DeclarativeSyntaxSupport.h:63
#define SLATE_SLOT_BEGIN_ARGS(SlotType, SlotParentType)
Definition DeclarativeSyntaxSupport.h:361
#define SLATE_EVENT(DelegateName, EventName)
Definition DeclarativeSyntaxSupport.h:458
#define SLATE_END_ARGS()
Definition DeclarativeSyntaxSupport.h:116
#define SLATE_SLOT_END_ARGS()
Definition DeclarativeSyntaxSupport.h:386
#define SLATE_ARGUMENT(ArgType, ArgName)
Definition DeclarativeSyntaxSupport.h:208
#define DECLARE_DELEGATE_RetVal_FourParams(ReturnValueType, DelegateName, Param1Type, Param2Type, Param3Type, Param4Type)
Definition DelegateCombinations.h:81
#define DECLARE_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:48
#define DECLARE_DELEGATE_RetVal_ThreeParams(ReturnValueType, DelegateName, Param1Type, Param2Type, Param3Type)
Definition DelegateCombinations.h:72
#define DRAG_DROP_OPERATOR_TYPE(TYPE, BASE)
Definition DragAndDrop.h:207
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
EItemDropZone
Definition STableRow.h:59
#define SLATE_DECLARE_WIDGET_API(WidgetType, ParentType, ModuleApiDefine)
Definition SlateControlledConstruction.h:22
EOrientation
Definition SlateEnums.h:261
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition ArrangedChildren.h:15
Definition ChildrenBase.h:27
Definition SBoxPanel.h:581
SVerticalBox::FSlot * SlotBeingDragged
Definition SBoxPanel.h:587
int32 SlotIndexBeingDragged
Definition SBoxPanel.h:586
Definition DragAndDrop.h:141
Definition DragAndDrop.h:21
Definition PaintArgs.h:23
Definition Reply.h:24
Definition SlateRect.h:26
Definition DrawElements.h:220
Definition WidgetStyle.h:15
Definition SBoxPanel.h:73
Definition SBoxPanel.h:44
static void RegisterAttributes(FSlateWidgetSlotAttributeInitializer &AttributeInitializer)
Definition SBoxPanel.h:64
SLATE_SLOT_BEGIN_ARGS_OneMixin(TSlot, TBasicLayoutWidgetSlot< SlotType >, TResizingWidgetSlotMixin< SlotType >) protected
Definition SBoxPanel.h:46
void Construct(const FChildren &SlotOwner, FSlotArguments &&InArgs)
Definition SBoxPanel.h:58
Definition SBoxPanel.h:34
virtual SLATECORE_API FVector2D ComputeDesiredSize(float) const override
Definition SBoxPanel.cpp:199
SLATECORE_API SBoxPanel()
Definition SBoxPanel.cpp:230
SLATECORE_API ~SBoxPanel()
virtual SLATECORE_API void OnArrangeChildren(const FGeometry &AllottedGeometry, FArrangedChildren &ArrangedChildren) const override
Definition SBoxPanel.cpp:116
TPanelChildren< FSlot > Children
Definition SBoxPanel.h:156
virtual SLATECORE_API FChildren * GetChildren() override
Definition SBoxPanel.cpp:206
int32 NumSlots() const
Definition SBoxPanel.h:127
EOrientation Orientation
Definition SBoxPanel.h:159
EOrientation GetOrientation() const
Definition SBoxPanel.h:149
SLATECORE_API void ClearChildren()
Definition SBoxPanel.cpp:216
SLATECORE_API int32 RemoveSlot(const TSharedRef< SWidget > &SlotWidget)
Definition SBoxPanel.cpp:211
SLATECORE_API void SetOrientation(EOrientation InOrientation)
Definition SBoxPanel.cpp:221
bool IsValidSlotIndex(int32 Index) const
Definition SBoxPanel.h:130
Definition SBoxPanel.h:595
EItemDropZone
Definition SBoxPanel.h:601
DECLARE_DELEGATE_RetVal_FourParams(FReply, FOnDragAndDropVerticalBoxDragDetected, const FGeometry &, const FPointerEvent &, int32, SVerticalBox::FSlot *) DECLARE_DELEGATE_OneParam(FOnDragAndDropVerticalBoxDragEnter
FDragDropEvent const & DECLARE_DELEGATE_OneParam(FOnDragAndDropVerticalBoxDragLeave, FDragDropEvent const &)
virtual SLATECORE_API int32 OnPaint(const FPaintArgs &Args, const FGeometry &AllottedGeometry, const FSlateRect &MyCullingRect, FSlateWindowElementList &OutDrawElements, int32 LayerId, const FWidgetStyle &InWidgetStyle, bool bParentEnabled) const override
Definition SBoxPanel.cpp:416
SDragAndDropVerticalBox & SetDropIndicator_Below(const FSlateBrush &InValue)
Definition SBoxPanel.h:667
virtual SLATECORE_API FReply OnDrop(const FGeometry &MyGeometry, const FDragDropEvent &DragDropEvent) override
Definition SBoxPanel.cpp:371
virtual SLATECORE_API FReply OnDragDetected(const FGeometry &MyGeometry, const FPointerEvent &MouseEvent) override
Definition SBoxPanel.cpp:271
DECLARE_DELEGATE_RetVal_OneParam(FReply, FOnDragAndDropVerticalBoxDrop, FDragDropEvent const &)
SDragAndDropVerticalBox & SetDropIndicator_Above(const FSlateBrush &InValue)
Definition SBoxPanel.h:666
virtual SLATECORE_API FReply OnDragOver(const FGeometry &MyGeometry, const FDragDropEvent &DragDropEvent) override
Definition SBoxPanel.cpp:336
virtual SLATECORE_API void OnDragLeave(FDragDropEvent const &DragDropEvent) override
Definition SBoxPanel.cpp:298
virtual SLATECORE_API FReply OnMouseButtonDown(const FGeometry &MyGeometry, const FPointerEvent &MouseEvent) override
Definition SBoxPanel.cpp:261
virtual SLATECORE_API void OnDragEnter(FGeometry const &MyGeometry, FDragDropEvent const &DragDropEvent) override
Definition SBoxPanel.cpp:290
PRAGMA_DISABLE_DEPRECATION_WARNINGS FOnCanAcceptDropAdvanced ConvertCanAcceptDropFn(const FOnCanAcceptDrop &LegacyDelegate)
Definition SBoxPanel.h:623
Definition SBoxPanel.h:175
void SetMinWidth(TAttribute< float > InMinWidth)
Definition SBoxPanel.h:255
void SetFillWidth(TAttribute< float > InStretchCoefficient)
Definition SBoxPanel.h:238
FSlotArguments & AutoWidth()
Definition SBoxPanel.h:181
FSlotArguments & FillWidth(TAttribute< float > InStretchCoefficient)
Definition SBoxPanel.h:192
FSlotArguments & FillContentWidth(TAttribute< float > InStretchCoefficient, TAttribute< float > InShrinkStretchCoefficient=TAttribute< float >())
Definition SBoxPanel.h:204
FSlotArguments & MinWidth(TAttribute< float > InMinWidth)
Definition SBoxPanel.h:211
void Construct(const FChildren &SlotOwner, FSlotArguments &&InArgs)
Definition SBoxPanel.h:266
void SetAutoWidth()
Definition SBoxPanel.h:228
void SetMaxWidth(TAttribute< float > InMaxWidth)
Definition SBoxPanel.h:261
FSlotArguments & MaxWidth(TAttribute< float > InMaxWidth)
Definition SBoxPanel.h:218
void SetFillContentWidth(TAttribute< float > InStretchCoefficient, TAttribute< float > InShrinkStretchCoefficient=TAttribute< float >())
Definition SBoxPanel.h:249
Definition SBoxPanel.h:171
FScopedWidgetSlotArguments AddSlot()
Definition SBoxPanel.h:285
FORCENOINLINE SHorizontalBox()
Definition SBoxPanel.h:298
SBoxPanel::FScopedWidgetSlotArguments< SHorizontalBox::FSlot > FScopedWidgetSlotArguments
Definition SBoxPanel.h:284
SLATECORE_API FSlot & GetSlot(int32 SlotIndex)
Definition SBoxPanel.cpp:67
SLATE_BEGIN_ARGS(SHorizontalBox)
Definition SBoxPanel.h:277
static FSlot::FSlotArguments Slot()
Definition SBoxPanel.h:272
FScopedWidgetSlotArguments InsertSlot(int32 Index=INDEX_NONE)
Definition SBoxPanel.h:290
Definition SPanel.h:30
void Construct()
Definition SPanel.h:65
Definition SBoxPanel.h:479
FSlotArguments & AutoSize()
Definition SBoxPanel.h:485
FSlotArguments & MaxSize(TAttribute< float > InMaxHeight)
Definition SBoxPanel.h:522
FSlotArguments & FillContentSize(TAttribute< float > InStretchCoefficient, TAttribute< float > InShrinkStretchCoefficient=TAttribute< float >())
Definition SBoxPanel.h:508
FSlotArguments & FillSize(TAttribute< float > InStretchCoefficient)
Definition SBoxPanel.h:496
FSlotArguments & MinSize(TAttribute< float > InMinHeight)
Definition SBoxPanel.h:515
Definition SBoxPanel.h:475
FScopedWidgetSlotArguments AddSlot()
Definition SBoxPanel.h:550
static FSlot::FSlotArguments Slot()
Definition SBoxPanel.h:535
SBoxPanel::FScopedWidgetSlotArguments< SStackBox::FSlot > FScopedWidgetSlotArguments
Definition SBoxPanel.h:549
SLATECORE_API FSlot & GetSlot(int32 SlotIndex)
Definition SBoxPanel.cpp:95
FScopedWidgetSlotArguments InsertSlot(int32 Index=INDEX_NONE)
Definition SBoxPanel.h:555
SLATE_BEGIN_ARGS(SStackBox)
Definition SBoxPanel.h:541
FORCENOINLINE SStackBox()
Definition SBoxPanel.h:563
Definition SBoxPanel.h:326
void SetAutoHeight()
Definition SBoxPanel.h:380
FSlotArguments & FillContentHeight(TAttribute< float > InStretchCoefficient, TAttribute< float > InShrinkStretchCoefficient=TAttribute< float >())
Definition SBoxPanel.h:356
FSlotArguments & AutoHeight()
Definition SBoxPanel.h:333
void SetFillContentHeight(TAttribute< float > InStretchCoefficient, TAttribute< float > InShrinkStretchCoefficient=TAttribute< float >())
Definition SBoxPanel.h:401
void Construct(const FChildren &SlotOwner, FSlotArguments &&InArgs)
Definition SBoxPanel.h:418
FSlotArguments & FillHeight(TAttribute< float > InStretchCoefficient)
Definition SBoxPanel.h:344
void SetMinHeight(TAttribute< float > InMinHeight)
Definition SBoxPanel.h:407
FSlotArguments & MaxHeight(TAttribute< float > InMaxHeight)
Definition SBoxPanel.h:370
void SetMaxHeight(TAttribute< float > InMaxHeight)
Definition SBoxPanel.h:413
FSlotArguments & MinHeight(TAttribute< float > InMinHeight)
Definition SBoxPanel.h:363
void SetFillHeight(TAttribute< float > InStretchCoefficient)
Definition SBoxPanel.h:390
Definition SBoxPanel.h:322
FORCENOINLINE SVerticalBox()
Definition SBoxPanel.h:451
SBoxPanel::FScopedWidgetSlotArguments< SVerticalBox::FSlot > FScopedWidgetSlotArguments
Definition SBoxPanel.h:437
FScopedWidgetSlotArguments AddSlot()
Definition SBoxPanel.h:438
FScopedWidgetSlotArguments InsertSlot(int32 Index=INDEX_NONE)
Definition SBoxPanel.h:443
SLATE_BEGIN_ARGS(SVerticalBox)
Definition SBoxPanel.h:430
static FSlot::FSlotArguments Slot()
Definition SBoxPanel.h:424
SLATECORE_API FSlot & GetSlot(int32 SlotIndex)
Definition SBoxPanel.cpp:81
uint8 bCanSupportFocus
Definition SWidget.h:1745
void SetCanTick(bool bInCanTick)
Definition SWidget.h:671
Definition Attribute.h:17
Definition BasicLayoutWidgetSlot.h:599
FSlotArguments && InArgs
Definition BasicLayoutWidgetSlot.h:630
static void RegisterAttributes(FSlateWidgetSlotAttributeInitializer &AttributeInitializer)
Definition BasicLayoutWidgetSlot.h:636
Definition Children.h:461
virtual int32 Num() const override
Definition Children.h:485
void InsertSlot(typename SlotType::FSlotArguments &&SlotArgument, int32 Index)
Definition Children.h:569
bool IsValidIndex(int32 Index) const
Definition Children.h:598
int32 AddSlot(typename SlotType::FSlotArguments &&SlotArgument)
Definition Children.h:506
Definition BasicLayoutWidgetSlot.h:398
void SetSizeToStretchContent(TAttribute< float > InStretchCoefficient, TAttribute< float > InShrinkStretchCoefficient=TAttribute< float >())
Definition BasicLayoutWidgetSlot.h:544
void SetMaxSize(TAttribute< float > InMaxSize)
Definition BasicLayoutWidgetSlot.h:568
void SetSizeToAuto()
Definition BasicLayoutWidgetSlot.h:523
void SetMinSize(TAttribute< float > InMinSize)
Definition BasicLayoutWidgetSlot.h:556
void SetSizeToStretch(TAttribute< float > InStretchCoefficient)
Definition BasicLayoutWidgetSlot.h:533
static void RegisterAttributesMixin(FSlateWidgetSlotAttributeInitializer &AttributeInitializer)
Definition BasicLayoutWidgetSlot.h:457
void ConstructMixin(const FChildren &SlotOwner, FSlotArgumentsMixin &&InArgs)
Definition BasicLayoutWidgetSlot.h:439
Definition SharedPointer.h:153
Definition UniquePtr.h:107
void Construct(const FChildren &SlotOwner, typename Super::FSlotArguments &&InArgs)
Definition WidgetSlotWithAttributeSupport.h:46
U16 Index
Definition radfft.cpp:71
static SLATECORE_API const EVisibility SelfHitTestInvisible
Definition Visibility.h:26
Definition SlateStructs.h:184
Definition Geometry.h:40
Definition Events.h:695
Definition SlateAttributeDescriptor.h:205
Definition SlateBrush.h:239
Definition SlotBase.h:25
Definition SlateStructs.h:163
Definition SlateStructs.h:146
Definition SBoxPanel.h:79
FScopedWidgetSlotArguments & operator=(const FScopedWidgetSlotArguments &)=delete
FScopedWidgetSlotArguments(FScopedWidgetSlotArguments &&)=default
virtual ~FScopedWidgetSlotArguments()
Definition SBoxPanel.h:94
FScopedWidgetSlotArguments(const FScopedWidgetSlotArguments &)=delete
FScopedWidgetSlotArguments & operator=(FScopedWidgetSlotArguments &&)=default
FScopedWidgetSlotArguments(TUniquePtr< SlotType > InSlot, TPanelChildren< FSlot > &InChildren, int32 InIndex)
Definition SBoxPanel.h:81
Definition Optional.h:131
static constexpr bool SupportsInvalidation()
Definition SBoxPanel.h:26
static constexpr bool SupportsInvalidation()
Definition SBoxPanel.h:166
static constexpr bool SupportsInvalidation()
Definition SBoxPanel.h:470
static constexpr bool SupportsInvalidation()
Definition SBoxPanel.h:317
Definition SWidget.h:69