Skip to content

BoxContainer

Eduard Gushchin edited this page Jul 1, 2026 · 3 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.BoxContainer
Namespace Electron2D
Kind class
Category UI and Text

Overview

Arranges direct child controls in a single horizontal or vertical line.

Syntax

public class Electron2D.BoxContainer : Electron2D.Container

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Supported / Parity verified
Out of profile: no
Godot reference: BoxContainer

Single-axis UI container with separation, alignment, expand/fill size flags and spacer creation.

Remarks

BoxContainer is the shared implementation behind Electron2D.HBoxContainer and Electron2D.VBoxContainer. It measures child minimum sizes, applies the separation theme constant and distributes extra space to children whose size flags expand on the main axis.

Thread Safety

This type is not synchronized. Create and mutate it on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Container
  • Electron2D.HBoxContainer
  • Electron2D.VBoxContainer

Members

Member Kind Summary
Alignment Property Gets or sets how non-expanded children are aligned along the box axis.
Vertical Property Gets or sets whether this box lays out children vertically.
Electron2D.BoxContainer() Constructor Initializes a new instance of the Electron2D.BoxContainer type.
AddSpacer(System.Boolean) Method Adds a spacer control at the beginning or end of this box.
_GetMinimumSize() Method Gets the minimum size required by this box container.

Member Details

Alignment

Kind: Property

public Electron2D.BoxContainerAlignmentMode Alignment { get; set; }

Summary

Gets or sets how non-expanded children are aligned along the box axis.

Remarks

Alignment only affects free space that was not consumed by expanded children.

Value

The current Electron2D.BoxContainerAlignmentMode. The default is Electron2D.BoxContainerAlignmentMode.Begin.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.BoxContainerAlignmentMode

Vertical

Kind: Property

public System.Boolean Vertical { get; set; }

Summary

Gets or sets whether this box lays out children vertically.

Remarks

Specialized Electron2D.HBoxContainer and Electron2D.VBoxContainer types set this value in their constructors.

Value

true for vertical layout; false for horizontal layout.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.HBoxContainer
  • Electron2D.VBoxContainer

Electron2D.BoxContainer()

Kind: Constructor

public Electron2D.BoxContainer()

Summary

Initializes a new instance of the Electron2D.BoxContainer type.

Remarks

The new container uses horizontal layout until Electron2D.BoxContainer.Vertical is set to true.

Thread Safety

This constructor is not synchronized. Call it on the main scene thread.

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.BoxContainer.Vertical

AddSpacer(System.Boolean)

Kind: Method

public Electron2D.Control AddSpacer(System.Boolean)(System.Boolean begin)

Summary

Adds a spacer control at the beginning or end of this box.

Remarks

The spacer expands and fills on the main axis. It is a normal Electron2D.Control child and can be removed or moved by regular node hierarchy APIs.

Parameters

  • begin: true to place the spacer before existing children; false to place it after existing children.

Returns

The created spacer control.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Node.AddChild(Electron2D.Node)
  • Electron2D.Node.MoveChild(Electron2D.Node,System.Int32)

_GetMinimumSize()

Kind: Method

public Electron2D.Vector2 _GetMinimumSize()()

Summary

Gets the minimum size required by this box container.

Remarks

The main axis sums child minimum sizes. The cross axis uses the largest child minimum size.

Returns

The minimum size produced by direct visible child controls and separation.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control.GetMinimumSize

Clone this wiki locally