logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class HudPlacementResolver

    Works out where an element actually goes, applying the per-player mirroring on top of its authored placement.

    Inheritance
    object
    HudPlacementResolver
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.GameUi.Application.Placement
    Assembly: Serenity.GameUi.Application.dll
    Syntax
    public static class HudPlacementResolver
    Remarks

    Kept pure so the rule is testable without a canvas, and so the editor preview and the runtime renderer place elements identically instead of each deriving the mirroring themselves.

    Methods

    IsHorizontal(HudGrowDirection)

    Whether a grow direction runs along the horizontal axis.

    Declaration
    public static bool IsHorizontal(HudGrowDirection direction)
    Parameters
    Type Name Description
    HudGrowDirection direction

    The direction to classify.

    Returns
    Type Description
    bool

    IsMirrored(IHudPlacedElement)

    Whether this element is mirrored for the player it belongs to.

    Declaration
    public static bool IsMirrored(IHudPlacedElement element)
    Parameters
    Type Name Description
    IHudPlacedElement element

    The element to inspect.

    Returns
    Type Description
    bool

    True when the element is player-scoped, mirroring is on, and the player index is odd.

    IsReversed(HudGrowDirection)

    Whether a grow direction runs against the layout's natural order, so children must be reversed. A horizontal layout already runs left-to-right and a vertical one already runs top-to-bottom.

    Declaration
    public static bool IsReversed(HudGrowDirection direction)
    Parameters
    Type Name Description
    HudGrowDirection direction

    The direction to classify.

    Returns
    Type Description
    bool

    MirrorHorizontally(HudGrowDirection)

    Reverses a horizontal grow direction, leaving a vertical one alone.

    Declaration
    public static HudGrowDirection MirrorHorizontally(HudGrowDirection direction)
    Parameters
    Type Name Description
    HudGrowDirection direction

    The direction to mirror.

    Returns
    Type Description
    HudGrowDirection

    MirrorHorizontally(UiAnchorType)

    Reflects an anchor across the vertical centre line, leaving the vertical edge alone.

    Declaration
    public static UiAnchorType MirrorHorizontally(UiAnchorType anchor)
    Parameters
    Type Name Description
    UiAnchorType anchor

    The anchor to mirror.

    Returns
    Type Description
    UiAnchorType

    ResolveAnchor(IHudPlacedElement)

    The anchor the element is placed at once mirroring is applied.

    Declaration
    public static UiAnchorType ResolveAnchor(IHudPlacedElement element)
    Parameters
    Type Name Description
    IHudPlacedElement element

    The element to place.

    Returns
    Type Description
    UiAnchorType

    ResolveGrowDirection(IHudElementDefinition)

    The direction repeating content extends in once mirroring is applied.

    Declaration
    public static HudGrowDirection ResolveGrowDirection(IHudElementDefinition element)
    Parameters
    Type Name Description
    IHudElementDefinition element

    The element to place.

    Returns
    Type Description
    HudGrowDirection

    ResolveOffset(IHudPlacedElement)

    The offset applied once mirroring is applied.

    Declaration
    public static HudOffset ResolveOffset(IHudPlacedElement element)
    Parameters
    Type Name Description
    IHudPlacedElement element

    The element to place.

    Returns
    Type Description
    HudOffset

    ResolveRotationDegrees(IHudPlacedElement)

    The rotation applied once mirroring is applied.

    Declaration
    public static float ResolveRotationDegrees(IHudPlacedElement element)
    Parameters
    Type Name Description
    IHudPlacedElement element

    The element to place.

    Returns
    Type Description
    float

    The authored rotation, negated for a mirrored element — a horizontal mirror reverses the sense of a counter-clockwise turn just as it does the horizontal offset.

    UnresolveOffset(IHudPlacedElement, HudOffset)

    Mirrors a displayed-space offset back into the element's authored space.

    Declaration
    public static HudOffset UnresolveOffset(IHudPlacedElement element, HudOffset displayedOffset)
    Parameters
    Type Name Description
    IHudPlacedElement element

    The element being placed.

    HudOffset displayedOffset

    The offset in displayed (post-mirror) space.

    Returns
    Type Description
    HudOffset

    The offset to author, so that ResolveOffset(IHudPlacedElement) reproduces it.

    Remarks

    The exact inverse of ResolveOffset(IHudPlacedElement) — horizontal mirroring is its own inverse, so a gesture solver that works out a new offset in displayed space and needs to write the authored value back applies the same negation ResolveOffset(IHudPlacedElement) already applies going the other way. Kept here rather than duplicated in each solver, for the same reason ResolveOffset(IHudPlacedElement) is.

    In this article
    © 2026 Serenity. All Rights Reserved