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
Object ⇦ ValueType ⇦ 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.
Properties
Height
The vertical height/layout method.
Property Value
MaxHeight
Maximum height allowed.
Property Value
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.
Property Value
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.
Property Value
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.
Property Value
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.
Property Value
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.
Returns
Equals(Object)
Parameters
obj
Object
Returns
Remarks
Overrides the default implementation to avoid using reflection on every frame during dirty checks.
Equals(LayoutParameters)
Parameters
other
LayoutParameters
Returns
Fill()
Creates a LayoutParameters that stretches to the full available width and height.
Returns
FitContent()
Creates a LayoutParameters that tracks content width and height, and has no other constraints.
Returns
FixedSize(Point)
Creates a LayoutParameters with fixed dimensions, and no other constraints.
Parameters
size
Point
The layout size, in pixels.
Returns
FixedSize(float, float)
Creates a LayoutParameters with fixed dimensions, and no other constraints.
Parameters
width
Single
The layout width, in pixels.
height
Single
The layout height, in pixels.
Returns
GetHashCode()
Returns
GetLimits(Vector2)
Determines the effective content size limits.
Parameters
availableSize
Vector2
The available size in the container/parent.
Returns
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.