In this lesson, you will learn how to structure your custom editor tools by using Slate Panels to organize widgets into clean, responsive layouts.
The Power of Panels and Slots
In Slate, you rarely place widgets at absolute coordinates. Instead, we use Panels—containers that handle the arrangement of their children for us. Every panel follows a simple relationship: the panel acts as the parent, and each child widget is placed inside a Slot.
Slots act as "containers with rules." When you add a widget to a slot, you gain access to layout parameters like alignment, padding, and size constraints.
Horizontal and Vertical Boxes
The two most essential layout containers are SVerticalBox and SHorizontalBox.
SVerticalBox: Stacks widgets vertically. Each child occupies a slot that can be set to eitherAuto(the widget takes up only the space it needs) orFill(the widget expands to fill available space).SHorizontalBox: Works identically to the vertical box, but aligns widgets side-by-side in a row.
Here is how you define these in your declarative Slate code:
SNew(SVerticalBox)
+SVerticalBox::Slot()
.AutoHeight()
[
SNew(STextBlock).Text(FText::FromString("My Tool Title"))
]
+SVerticalBox::Slot()
.FillHeight(1.0f)
[
SNew(SButton).Text(FText::FromString("Main Action"))
]
Why Use Slots?
By nesting these panels, you can create sophisticated layouts. For example, you might create an SVerticalBox that contains an SHorizontalBox as one of its slots. This allows you to create rows of buttons inside a larger vertical list.
When you use the .Padding() attribute on a slot, you add space around the widget without affecting its internal logic. This keeps your editor tools visually consistent and prevents elements from looking cramped. By relying on these panels, your UI will automatically adjust when the user resizes your editor window, ensuring your tools remain professional and usable regardless of screen resolution.
Key Takeaway: Slate layouts rely on nested Panels and Slots to manage spacing and alignment; use SVerticalBox and SHorizontalBox to build responsive, structured interfaces by defining how each widget fills or shrinks within its designated slot.