Table of Contents

Class UiLayouter

Namespace
MLEM.Ui
Assembly
MLEM.Ui.dll

Generic tools and utilities for layouting ILayoutItem objects for automatic positioning and sizing. For the recommended ui system implementation that uses this layouter, see UiSystem and specifically Element.

public static class UiLayouter
Inheritance
UiLayouter
Inherited Members

Methods

GetChildren<T>(ILayoutItem, Func<T, bool>, bool, bool)

Returns all of the given layout item's children of the given type that match the given condition. Optionally, the entire tree of children (grandchildren) can be searched.

public static IEnumerable<T> GetChildren<T>(ILayoutItem item, Func<T, bool> condition = null, bool regardGrandchildren = false, bool ignoreFalseGrandchildren = false) where T : class, ILayoutItem

Parameters

item ILayoutItem

The item whose children to retrieve.

condition Func<T, bool>

The condition to match

regardGrandchildren bool

If this value is true, children of children of the item are also searched

ignoreFalseGrandchildren bool

If this value is true, children for which the condition does not match will not have their children searched

Returns

IEnumerable<T>

All children that match the condition

Type Parameters

T

The type of children to search for

GetLowestChild<T>(T, Func<T, bool>, bool)

Returns the given layout item's lowest child layout item (in terms of y position) that matches the given condition.

public static T GetLowestChild<T>(T item, Func<T, bool> condition = null, bool total = false) where T : class, ILayoutItem

Parameters

item T

The item whose lowest child to retrieve.

condition Func<T, bool>

The condition to match

total bool

Whether to evaluate based on the child's GetTotalCoveredArea(bool), rather than its UnscrolledArea.

Returns

T

The lowest layout item, or null if no such layout item exists

Type Parameters

T

GetLowestOlderSibling<T>(T, Func<T, bool>, bool)

Returns the given layout item's lowest sibling that is also older (lower in its parent's Children list) than the given layout item that also matches the given condition. The returned layout item's Parent will always be equal to the given layout item's Parent.

public static T GetLowestOlderSibling<T>(T item, Func<T, bool> condition = null, bool total = false) where T : class, ILayoutItem

Parameters

item T

The item whose lowest older sibling to retrieve.

condition Func<T, bool>

The condition to match

total bool

Whether to evaluate based on the child's GetTotalCoveredArea(bool), rather than its UnscrolledArea.

Returns

T

The lowest older sibling of the given layout item, or null if no such layout item exists

Type Parameters

T

GetOlderSibling<T>(T, Func<T, bool>)

Returns the given layout item's first older sibling that matches the given condition. The returned layout item's Parent will always be equal to the given layout item's Parent.

public static T GetOlderSibling<T>(T item, Func<T, bool> condition = null) where T : class, ILayoutItem

Parameters

item T

The item whose older siblings to retrieve.

condition Func<T, bool>

The condition to match

Returns

T

The older sibling, or null if no such layout item exists

Type Parameters

T

GetRightmostChild<T>(T, Func<T, bool>, bool)

Returns the given layout item's rightmost child (in terms of x position) that matches the given condition.

public static T GetRightmostChild<T>(T item, Func<T, bool> condition = null, bool total = false) where T : class, ILayoutItem

Parameters

item T

The item whose rightmost child to retrieve.

condition Func<T, bool>

The condition to match

total bool

Whether to evaluate based on the child's GetTotalCoveredArea(bool), rather than its UnscrolledArea.

Returns

T

The rightmost layout item, or null if no such layout item exists

Type Parameters

T

Layout<T>(T, ref int, float)

Lays out the given item based on the information specified in its ILayoutItem interface.

public static void Layout<T>(T item, ref int layoutRecursionTracker, float epsilon = 0) where T : class, ILayoutItem

Parameters

item T

The item to lay out.

layoutRecursionTracker int

A reference to a field in the item that is used by the layouter to track recursion counts across Layout<T>(T, ref int, float) calls.

epsilon float

An epsilon value used in layout item size, position and resulting area calculations to mitigate floating point rounding inaccuracies.

Type Parameters

T