Table of Contents

Interface ILayoutItem

Namespace
MLEM.Ui
Assembly
MLEM.Ui.dll

A layout item is an object that can be layouted automatically using UiLayouter. The layoug item system is used by the UiSystem, specifically the Element class.

public interface ILayoutItem

Properties

Anchor

The Anchor that this layout item uses for positioning within its parent

Anchor Anchor { get; }

Property Value

Anchor

AutoAnchorArea

Returns the area that should be used for determining where auto-anchoring children should attach.

RectangleF AutoAnchorArea { get; }

Property Value

RectangleF

CanAutoAnchorsAttach

Set this field to false to cause auto-anchored siblings to ignore this layout item as a possible anchor point.

bool CanAutoAnchorsAttach { get; }

Property Value

bool

Children

A collection of all of this layout item's direct children.

IEnumerable<ILayoutItem> Children { get; }

Property Value

IEnumerable<ILayoutItem>

IsHidden

Set this property to true to cause this layout item to be hidden. Hidden layout items don't receive input events, aren't rendered and don't factor into auto-anchoring.

bool IsHidden { get; }

Property Value

bool

Parent

This layout item's parent layout item. If this layout item has no parent (it is the root item of an item tree), this value is null.

ILayoutItem Parent { get; }

Property Value

ILayoutItem

ParentArea

The area that this layout item's Parent takes up, or, if it has no parent, the viewport or the total ui area. This value is the one that is passed to CalcActualSize(RectangleF) during Layout<T>(T, ref int, float).

RectangleF ParentArea { get; }

Property Value

RectangleF

PreventParentSpill

Set this field to true to cause this layout item's final display area to never exceed that of its Parent. If the resulting area is too large, the size of this layout item is shrunk to fit the target area. This can be useful if an layout item should fill the remaining area of a parent exactly.

bool PreventParentSpill { get; }

Property Value

bool

ScaledChildPadding

The child padding that this layout item has. The child padding moves any Children added to this layout item inwards by the given amount in each direction.

Padding ScaledChildPadding { get; }

Property Value

Padding

ScaledOffset

This layout item's offset from its default position, which is dictated by its Anchor. Note that, depending on the side that the layout item is anchored to, this offset moves it in a different direction.

Vector2 ScaledOffset { get; }

Property Value

Vector2

SetHeightBasedOnChildren

Set this property to true to cause this layout item's height to be automatically calculated based on the area that its Children take up. To use this layout item's Size's Y coordinate as a minimum or maximum height rather than ignoring it, set TreatSizeAsMinimum or TreatSizeAsMaximum to true.

bool SetHeightBasedOnChildren { get; }

Property Value

bool

SetWidthBasedOnChildren

Set this property to true to cause this layout item's width to be automatically calculated based on the area that its Children take up. To use this layout item's Size's X coordinate as a minimum or maximum width rather than ignoring it, set TreatSizeAsMinimum or TreatSizeAsMaximum to true.

bool SetWidthBasedOnChildren { get; }

Property Value

bool

TreatSizeAsMaximum

If this field is set to true, and SetWidthBasedOnChildren or SetHeightBasedOnChildrenare enabled, the resulting width or height weill always be less than or equal to this layout item's Size. Note that this value only has an effect if SetWidthBasedOnChildren or SetHeightBasedOnChildren are enabled.

bool TreatSizeAsMaximum { get; }

Property Value

bool

TreatSizeAsMinimum

If this field is set to true, and SetWidthBasedOnChildren or SetHeightBasedOnChildren are enabled, the resulting width or height will always be greather than or equal to this layout item's Size. For example, if an layout item's Size's Y coordinate is set to 20, but there is only one child with a height of 10 in it, the layout item's height would be shrunk to 10 if this value was false, but would remain at 20 if it was true. Note that this value only has an effect if SetWidthBasedOnChildren or SetHeightBasedOnChildren are enabled.

bool TreatSizeAsMinimum { get; }

Property Value

bool

UnscrolledArea

This layout item's area, without respecting potential offsets from scrolling panels. This area is updated automatically to fit this layout item's sizing and positioning properties.

RectangleF UnscrolledArea { get; }

Property Value

RectangleF

Methods

CalcActualSize(RectangleF)

Calculates the actual total size that this element should take up.

Vector2 CalcActualSize(RectangleF parentArea)

Parameters

parentArea RectangleF

This parent's area, or the ui system's viewport if it has no parent.

Returns

Vector2

The actual size of this element.

GetTotalCoveredArea(bool)

Returns the total covered area of this layout item, which is its area (or UnscrolledArea), unioned with all of the total covered areas of its Children. The returned area is only different from this layout item's area (or UnscrolledArea) if it has any Children that are outside of this layout item's area, or are bigger than this layout item.

RectangleF GetTotalCoveredArea(bool unscrolled)

Parameters

unscrolled bool

Whether to use layout items' UnscrolledArea (instead of their potentially modified area through scrolling panels).

Returns

RectangleF

This layout item's total covered area.

OnLayoutRecursion(int, ILayoutItem)

A method called by Layout<T>(T, ref int, float) when a layout item's size is being recalculated based on its children. Also see OnLayoutRecursionSettled(int, bool), which is called after recursive operations during element layouting have completed.

void OnLayoutRecursion(int recursion, ILayoutItem relevantChild)

Parameters

recursion int

The current recursion depth.

relevantChild ILayoutItem

The child that triggered the layout recursion. May be null in case the source of the layout recursion is unknown.

OnLayoutRecursionSettled(int, bool)

A method called by Layout<T>(T, ref int, float) when a layout item's size is being calculated, but recursive calculations have settled. Also see OnLayoutRecursion(int, ILayoutItem), which is called for every recursive operation during element layouting.

void OnLayoutRecursionSettled(int totalRecursion, bool elementInternal)

Parameters

totalRecursion int

The total reached recursion depth.

elementInternal bool

true if the settled recursive operation was element-internal (ie related to properties like SetWidthBasedOnChildren and SetHeightBasedOnChildren); false if the settled recursive operation was related to recursively updated children or parents of this element.

SetAreaAndUpdateChildren(RectangleF)

Sets this layout item's area to the given RectangleF. This method should also update all of this layout item's Children's areas. Note that this method does not take into account any auto-sizing, anchoring or positioning, and so it should be invoked sparingly, if at all.

void SetAreaAndUpdateChildren(RectangleF area)

Parameters

area RectangleF
See Also
Layout<T>(T, ref int, float)