Struct Length
Definition
Namespace: StardewUI.Layout
Assembly: StardewUI.dll
Specifies how to calculate the length of a single dimension (width or height).
Inheritance
Object ⇦ ValueType ⇦ Length
Implements
IEquatable<Length>
Members
Constructors
Name | Description |
---|---|
Length(LengthType, Single) | Specifies how to calculate the length of a single dimension (width or height). |
Properties
Name | Description |
---|---|
Type | Specifies how to interpret the Value. |
Value | The dimension value, with behavior determined by Type. |
Methods
Name | Description |
---|---|
Content() | Creates a new Length having Content. |
Parse(ReadOnlySpan<Char>) | Parses a Length from its string representation. |
Parse(string) | Parses a Length from its string representation. |
Percent(Single) | Creates a new Length having Percent and the specified percent size. |
Px(Single) | Creates a new Length having Px and the specified pixel size. |
Resolve(Single, Func<Single>) | Resolves an actual (pixel) length. |
Stretch() | Creates a new Length having Stretch. |
ToString() | (Overrides Object.ToString() ) |
Details
Constructors
Length(LengthType, float)
Specifies how to calculate the length of a single dimension (width or height).
Parameters
Type
LengthType
Specifies how to interpret the Value.
Value
Single
The dimension value, with behavior determined by Type.
Properties
Type
Specifies how to interpret the Value.
Property Value
Value
The dimension value, with behavior determined by Type.
Property Value
Methods
Content()
Creates a new Length having Content.
Returns
Parse(ReadOnlySpan<Char>)
Parses a Length from its string representation.
Parameters
value
ReadOnlySpan<Char>
The string representation of the Length.
Returns
The parsed Length.
Parse(string)
Parses a Length from its string representation.
Parameters
value
string
The string representation of the Length.
Returns
The parsed Length.
Percent(float)
Creates a new Length having Percent and the specified percent size.
Parameters
value
Single
The length in 100-based percent units (e.g. 50.0
is 50%).
Returns
Px(float)
Creates a new Length having Px and the specified pixel size.
Parameters
value
Single
The length in pixels.
Returns
Resolve(float, Func<Single>)
Resolves an actual (pixel) length.
Parameters
availableLength
Single
The remaining space available.
getContentLength
Func<Single>
A function to get the length of inner content. Will not be called unless the LengthType requires it.
Returns
Remarks
This is a convenience method for common layout scenarios, where content length is relatively simple to compute. Its use is optional; complex widgets can use any means they prefer to compute ContentSize.
The result is intentionally not constrained to availableLength
, which is only used for the Stretch method. This allows callers to check if the bounds were exceeded (e.g. to render a scroll bar, ellipsis, etc.) before clamping it.
Stretch()
Creates a new Length having Stretch.