Table of Contents

Class LayoutControl

Namespace
BSGameLib.UI.Controls.Base
Assembly
BSGameLib.UI.dll

The base of a control that holds other controls and arranges them: StackLayout, DockLayout and Grid.

public abstract class LayoutControl : UIElement, IUpdateable, IEquatable<IUpdateable>, IDrawable, IIdentifiable<Guid>, IEquatable<IDrawable>, IDisposable
Inheritance
LayoutControl
Implements
Derived
Inherited Members

Constructors

LayoutControl(ILogger, View, string)

Creates a layout in view.

protected LayoutControl(ILogger logger, View view, string id = null)

Parameters

logger ILogger
view View
id string

Properties

Background

A texture drawn behind the children, filling this layout's bounds. Null for none.

public ITexture Background { get; set; }

Property Value

ITexture

BackgroundColor

The tint applied to Background. White, the default, leaves the texture as it is.

public Color BackgroundColor { get; set; }

Property Value

Color

Children

The controls in this layout, in the order they were added.

public List<UIElement> Children { get; }

Property Value

List<UIElement>

IsLayoutDirty

Whether the layout must arrange its children again. Adding or removing a child, or a child's size changing, sets it.

protected bool IsLayoutDirty { get; set; }

Property Value

bool

Methods

AddChild(UIElement)

Adds child to this layout and marks the layout for arranging.

public virtual void AddChild(UIElement child)

Parameters

child UIElement

Exceptions

ArgumentNullException

child is null.

ArrangeControls()

Sets the location and size of each child. Called when the layout is dirty.

protected abstract void ArrangeControls()

ClearChildren()

Disposes and removes every child.

public virtual void ClearChildren()

Dispose()

Disposes every child, removes them, and then disposes the layout.

public override void Dispose()

Draw(IGameTime)

Draws this layout's bounds and fill, then Background, then the visible children.

public override sealed void Draw(IGameTime gameTime)

Parameters

gameTime IGameTime

FindById(string)

Returns the control with the id id from this layout's children, or from the children of a child layout. Null when neither has it.

public UIElement FindById(string id)

Parameters

id string

Returns

UIElement

GetDesiredSize()

The size this layout asks for. A parent layout reads it to size this one. By default it is the current Size.

protected virtual Vector2 GetDesiredSize()

Returns

Vector2

LoadContent()

Loads the content of every child.

public override void LoadContent()

RemoveChild(UIElement)

Removes child from this layout. The child is not disposed.

public virtual void RemoveChild(UIElement child)

Parameters

child UIElement

Exceptions

ArgumentNullException

child is null.

Update(IGameTime)

Arranges the layout if it is dirty, then updates the children that are visible and enabled. It arranges again after the children, because some of them size themselves during their update.

public override void Update(IGameTime gameTime)

Parameters

gameTime IGameTime