Skip to content

Class FloatingPosition

Definition

Namespace: StardewUI.Layout
Assembly: StardewUI.dll

Describes the position of a FloatingElement.

[StardewUI.DuckType]
public class FloatingPosition

Inheritance
Object ⇦ FloatingPosition

Members

Constructors

Name Description
FloatingPosition(Func<Vector2, Vector2, Vector2>) Describes the position of a FloatingElement.

Fields

Name Description
AboveParent Positions the floating element immediately above the parent view, so that its bottom edge is flush with the parent's top edge.
AfterParent Positions the floating element immediately to the right of (after) the parent view, so that its left edge is flush with the parent's right edge.
BeforeParent Positions the floating element immediately to the left of (before) the parent view, so that its right edge is flush with the parent's left edge.
BelowParent Positions the floating element immediately below the parent view, so that its top edge is flush with the parent's bottom edge.

Methods

Name Description
GetOffset(IView, IView) Calculates the final position of the floating view.
GetOffset(Vector2, Vector2) Calculates the relative origin position of a floating view based on its size and the size of its parent.
Parse(string) Parses a FloatingPosition from its string representation.
TryParse(string, FloatingPosition) Attempts to parse a FloatingPosition from its string representation.

Details

Constructors

FloatingPosition(Func<Vector2, Vector2, Vector2>)

Describes the position of a FloatingElement.

public FloatingPosition(Func<Microsoft.Xna.Framework.Vector2, Microsoft.Xna.Framework.Vector2, Microsoft.Xna.Framework.Vector2> offsetSelector);
Parameters

offsetSelector   Func<Vector2, Vector2, Vector2>
Calculates the position offset (relative to the parent) of the floating view. Takes the measured floating view size, and then the parent size, as arguments.


Fields

AboveParent

Positions the floating element immediately above the parent view, so that its bottom edge is flush with the parent's top edge.

public static readonly StardewUI.Layout.FloatingPosition AboveParent;
Field Value

FloatingPosition


AfterParent

Positions the floating element immediately to the right of (after) the parent view, so that its left edge is flush with the parent's right edge.

public static readonly StardewUI.Layout.FloatingPosition AfterParent;
Field Value

FloatingPosition


BeforeParent

Positions the floating element immediately to the left of (before) the parent view, so that its right edge is flush with the parent's left edge.

public static readonly StardewUI.Layout.FloatingPosition BeforeParent;
Field Value

FloatingPosition


BelowParent

Positions the floating element immediately below the parent view, so that its top edge is flush with the parent's bottom edge.

public static readonly StardewUI.Layout.FloatingPosition BelowParent;
Field Value

FloatingPosition


Methods

GetOffset(IView, IView)

Calculates the final position of the floating view.

public Microsoft.Xna.Framework.Vector2 GetOffset(StardewUI.IView view, StardewUI.IView parentView);
Parameters

view   IView
The floating view to position.

parentView   IView
The parent relative to which the floating view is being positioned.

Returns

Vector2

The final position where the view should be drawn.


GetOffset(Vector2, Vector2)

Calculates the relative origin position of a floating view based on its size and the size of its parent.

public Microsoft.Xna.Framework.Vector2 GetOffset(Microsoft.Xna.Framework.Vector2 viewSize, Microsoft.Xna.Framework.Vector2 parentViewSize);
Parameters

viewSize   Vector2
The size of the floating view.

parentViewSize   Vector2
The size of the parent against which the floating element is positioned.

Returns

Vector2

The final position where the floating element should be drawn.


Parse(string)

Parses a FloatingPosition from its string representation.

public static StardewUI.Layout.FloatingPosition Parse(string text);
Parameters

text   string
The string value to parse.

Returns

FloatingPosition

The parsed position.


TryParse(string, FloatingPosition)

Attempts to parse a FloatingPosition from its string representation.

public static bool TryParse(string text, out StardewUI.Layout.FloatingPosition result);
Parameters

text   string
The string value to parse.

result   FloatingPosition
If the method returns true, holds the parsed position; otherwise null.

Returns

Boolean

true if the text was successfully parsed into a position; false if the input was not in a valid format.