Skip to content

Struct LayoutParameters

Definition

Namespace: StardewUI.Layout
Assembly: StardewUI.dll

Layout parameters for an IView.

[StardewUI.DuckType]
public readonly struct LayoutParameters : 
    IEquatable<StardewUI.Layout.LayoutParameters>

Inheritance
ObjectValueType ⇦ LayoutParameters

Implements
IEquatable<LayoutParameters>

Members

Constructors

Name Description
LayoutParameters() Initializes a new LayoutParameters with default layout settings.

Properties

Name Description
Height The vertical height/layout method.
MaxHeight Maximum height allowed.
MaxWidth Maximum width allowed.
MinHeight Minimum height to occupy.
MinWidth Minimum width to occupy.
Width The horizontal width/layout method.

Methods

Name Description
AutoRow() Creates a LayoutParameters that stretches to the available horizontal width, fits the content height, and has no other constraints. Typically used for rows in a vertical layout.
Equals(Object) (Overrides Object.Equals(Object))
Equals(LayoutParameters)
Fill() Creates a LayoutParameters that stretches to the full available width and height.
FitContent() Creates a LayoutParameters that tracks content width and height, and has no other constraints.
FixedSize(Point) Creates a LayoutParameters with fixed dimensions, and no other constraints.
FixedSize(Single, Single) Creates a LayoutParameters with fixed dimensions, and no other constraints.
GetHashCode() (Overrides Object.GetHashCode())
GetLimits(Vector2) Determines the effective content size limits.
Resolve(Vector2, Func<Vector2>) Resolves the actual size for the current LayoutParameters.
ToString() (Overrides Object.ToString())

Details

Constructors

LayoutParameters()

Initializes a new LayoutParameters with default layout settings.

public LayoutParameters();

Properties

Height

The vertical height/layout method.

public StardewUI.Layout.Length Height { get; set; }
Property Value

Length


MaxHeight

Maximum height allowed.

public float? MaxHeight { get; set; }
Property Value

Nullable<Single>

Remarks

If specified, the Y component of a view's content size should never exceed this value, regardless of how the Height is configured.


MaxWidth

Maximum width allowed.

public float? MaxWidth { get; set; }
Property Value

Nullable<Single>

Remarks

If specified, the X component of a view's content size should never exceed this value, regardless of how the Width is configured.


MinHeight

Minimum height to occupy.

public float? MinHeight { get; set; }
Property Value

Nullable<Single>

Remarks

If specified, the Y component of a view's content size will always be at least this value, regardless of how the Height is configured. Typically, minimum sizes are only used with Content if there might be very little content. If a MaxHeight is also specified and is smaller than the MinHeight, then MaxHeight takes precedence.


MinWidth

Minimum width to occupy.

public float? MinWidth { get; set; }
Property Value

Nullable<Single>

Remarks

If specified, the X component of a view's content size will always be at least this value, regardless of how the Width is configured. Typically, minimum sizes are only used with Content if there might be very little content. If a MaxWidth is also specified and is smaller than the MinWidth, then MaxWidth takes precedence.


Width

The horizontal width/layout method.

public StardewUI.Layout.Length Width { get; set; }
Property Value

Length


Methods

AutoRow()

Creates a LayoutParameters that stretches to the available horizontal width, fits the content height, and has no other constraints. Typically used for rows in a vertical layout.

public static StardewUI.Layout.LayoutParameters AutoRow();
Returns

LayoutParameters


Equals(Object)

public override bool Equals(System.Object obj);
Parameters

obj   Object

Returns

Boolean

Remarks

Overrides the default implementation to avoid using reflection on every frame during dirty checks.


Equals(LayoutParameters)

public bool Equals(StardewUI.Layout.LayoutParameters other);
Parameters

other   LayoutParameters

Returns

Boolean


Fill()

Creates a LayoutParameters that stretches to the full available width and height.

public static StardewUI.Layout.LayoutParameters Fill();
Returns

LayoutParameters


FitContent()

Creates a LayoutParameters that tracks content width and height, and has no other constraints.

public static StardewUI.Layout.LayoutParameters FitContent();
Returns

LayoutParameters


FixedSize(Point)

Creates a LayoutParameters with fixed dimensions, and no other constraints.

public static StardewUI.Layout.LayoutParameters FixedSize(Microsoft.Xna.Framework.Point size);
Parameters

size   Point
The layout size, in pixels.

Returns

LayoutParameters


FixedSize(float, float)

Creates a LayoutParameters with fixed dimensions, and no other constraints.

public static StardewUI.Layout.LayoutParameters FixedSize(float width, float height);
Parameters

width   Single
The layout width, in pixels.

height   Single
The layout height, in pixels.

Returns

LayoutParameters


GetHashCode()

public override int GetHashCode();
Returns

Int32


GetLimits(Vector2)

Determines the effective content size limits.

public Microsoft.Xna.Framework.Vector2 GetLimits(Microsoft.Xna.Framework.Vector2 availableSize);
Parameters

availableSize   Vector2
The available size in the container/parent.

Returns

Vector2

The size (equal to or smaller than availableSize) that can be allocated to content.

Remarks

Limits are not the same as the actual size coming from a Resolve(Vector2, Func<Vector2>); they provide a maximum width and/or height in the event that one or both dimensions are set to Content. In these cases, the caller usually wants the "constraints" - e.g. a text block with fixed width but variable height needs to know that width before it can determine the actual height.

Implementations of View will typically obtain the limits in their OnMeasure(Vector2) method in order to perform internal/child layout, and determine the content size for Resolve(Vector2, Func<Vector2>).


Resolve(Vector2, Func<Vector2>)

Resolves the actual size for the current LayoutParameters.

public Microsoft.Xna.Framework.Vector2 Resolve(Microsoft.Xna.Framework.Vector2 availableSize, Func<Microsoft.Xna.Framework.Vector2> getContentSize);
Parameters

availableSize   Vector2
The available size in the container/parent.

getContentSize   Func<Vector2>
Function to compute the inner content size based on limits obtained from GetLimits(Vector2); will only be invoked if it is required for the current layout configuration, i.e. if one or both dimensions are set to fit content.

Returns

Vector2


ToString()

public override string ToString();
Returns

string