BoxContainer
A row or column distributing available space.
BoxContainer is horizontal by default and permits changing Vertical. HBoxContainer and VBoxContainer fix orientation: do not call SetVertical on them, even with their current value.
Children are placed sequentially. The separation theme constant supplies the gap. Fill fills an allocated rectangle; Expand participates in free-space allocation. StretchRatio is a relative weight rather than an exact final-width percentage. Minima, maxima and gaps also participate. Maximize has container-specific priority behavior.
Alignment places remaining space at Begin/Center/End; ReverseSort reverses placement without reordering tree children. Account for RTL: the beginning is not necessarily the left edge. AddSpacer creates an already attached expanding Control; begin refers to the child-list beginning rather than necessarily the visual left edge.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
BoxContainerConstructor
public BoxContainer();Creates a horizontal mutable BoxContainer. Use HBoxContainer/VBoxContainer for a fixed direction.
Properties3
AlignmentProperty
public BoxContainer.AlignmentMode Alignment { get; set; }Begin, Center or End placement of remaining free space, Begin by default. Does not change individual child flags; account for Expand and RTL.
ReverseSortProperty
public bool ReverseSort { get; set; }Reverse placement order, false by default. Does not reorder tree children or change the axis; RTL is handled separately.
VerticalProperty
public bool Vertical { get; set; }Base BoxContainer axis: false is a row, true a column. Setter is rejected on HBoxContainer/VBoxContainer, even when assigning the current value.
Methods7
AddSpacerControl
public Control AddSpacer(bool begin);Creates and attaches an expanding Control; begin inserts it first in the child list. It expands along the current axis. MouseFilter is Pass; no serialization Owner is assigned. The result already belongs to the hierarchy.
| Name | Type | Default |
|---|---|---|
begin | bool | — |
begintrue inserts at the child-list beginning, false at its end. Does not guarantee a visual left/right edge with ReverseSort/RTL.
ControlAttached child Control. Its lifetime is tied to its parent; do not free it while needed for layout.
GetAlignmentBoxContainer.AlignmentMode
public BoxContainer.AlignmentMode GetAlignment();Begin, Center or End placement of remaining free space, Begin by default. Does not change individual child flags; account for Expand and RTL.
BoxContainer.AlignmentModeCurrent AlignmentMode, Begin by default.
IsReverseSortbool
public bool IsReverseSort();Reverse placement order, false by default. Does not reorder tree children or change the axis; RTL is handled separately.
boolCurrent reverse-placement flag, false by default.
IsVerticalbool
public bool IsVertical();Base BoxContainer axis: false is a row, true a column. Setter is rejected on HBoxContainer/VBoxContainer, even when assigning the current value.
boolAxis: false for HBox, true for VBox, current value for the base Box.
SetAlignmentvoid
public void SetAlignment(BoxContainer.AlignmentMode alignment);Begin, Center or End placement of remaining free space, Begin by default. Does not change individual child flags; account for Expand and RTL.
| Name | Type | Default |
|---|---|---|
alignment | BoxContainer.AlignmentMode | — |
alignmentBegin, Center or End relative to the current axis direction.
SetReverseSortvoid
public void SetReverseSort(bool reverseSort);Reverse placement order, false by default. Does not reorder tree children or change the axis; RTL is handled separately.
| Name | Type | Default |
|---|---|---|
reverseSort | bool | — |
reverseSorttrue reverses placement while retaining tree order.
SetVerticalvoid
public void SetVertical(bool vertical);Base BoxContainer axis: false is a row, true a column. Setter is rejected on HBoxContainer/VBoxContainer, even when assigning the current value.
| Name | Type | Default |
|---|---|---|
vertical | bool | — |
verticalfalse for horizontal or true for vertical orientation on the base BoxContainer only.
BoxContainer.AlignmentMode
| Value | Description |
|---|---|
Begin = 0 | The child controls will be arranged at the beginning of the container, i.e. top if orientation is vertical, left if orientation is horizontal (right for RTL layout). |
Center = 1 | The child controls will be centered in the container. |
End = 2 | The child controls will be arranged at the end of the container, i.e. bottom if orientation is vertical, right if orientation is horizontal (left for RTL layout). |
Theme properties
These are Theme resource keys, not C# properties. Use the matching Control GetTheme…() and AddTheme…Override() methods for each value type.
| Key and type | Description |
|---|---|
separationint | The space between the 4 |