Skip to content

Class ViewChild

Definition

Namespace: StardewUI
Assembly: StardewUI.dll

Provides information about a view that is the child of another view. Used for interactions.

public record ViewChild : StardewUI.Layout.IOffsettable<StardewUI.ViewChild>, 
    IEquatable<StardewUI.ViewChild>

Inheritance
Object ⇦ ViewChild

Implements
IOffsettable<ViewChild>, IEquatable<ViewChild>

Members

Constructors

Name Description
ViewChild(IView, Vector2) Provides information about a view that is the child of another view. Used for interactions.

Properties

Name Description
EqualityContract
Position The position of the View, relative to the parent.
View The child view.

Methods

Name Description
Center() Gets the point at the exact center of the view.
CenterPoint() Gets the nearest whole pixel point at the exact center of the view.
ContainsPoint(Vector2) Checks if a given point, relative to the view's parent, is within the bounds of this child.
FocusSearch(Vector2, Direction) Performs a focus search on the referenced view.
GetActualBounds() Returns a Bounds representing the parent-relative layout bounds of this child.
GetContentBounds() Returns a Bounds representing the parent-relative content bounds of this child.
GetFloatingBounds() Returns a sequence of Bounds representing the parent-relative bounds of this child's own floating elements and those of all its descendants.
IsInDirection(Vector2, Direction) Checks if a view can be reached by travelling from a given point in a given direction.
IsVisible(Vector2) Checks if the visible area of this child contains a point relative to the view's parent.
Offset(Vector2) Offsets the position by a given distance.

Details

Constructors

ViewChild(IView, Vector2)

Provides information about a view that is the child of another view. Used for interactions.

public ViewChild(StardewUI.IView View, Microsoft.Xna.Framework.Vector2 Position);
Parameters

View   IView
The child view.

Position   Vector2
The position of the View, relative to the parent.


Properties

EqualityContract

protected System.Type EqualityContract { get; }
Property Value

Type


Position

The position of the View, relative to the parent.

public Microsoft.Xna.Framework.Vector2 Position { get; set; }
Property Value

Vector2


View

The child view.

public StardewUI.IView View { get; set; }
Property Value

IView


Methods

Center()

Gets the point at the exact center of the view.

public Microsoft.Xna.Framework.Vector2 Center();
Returns

Vector2


CenterPoint()

Gets the nearest whole pixel point at the exact center of the view.

public Microsoft.Xna.Framework.Point CenterPoint();
Returns

Point


ContainsPoint(Vector2)

Checks if a given point, relative to the view's parent, is within the bounds of this child.

public bool ContainsPoint(Microsoft.Xna.Framework.Vector2 point);
Parameters

point   Vector2
The point to test.

Returns

Boolean

true if point is within the parent-relative bounds of this child; otherwise false.


FocusSearch(Vector2, Direction)

Performs a focus search on the referenced view.

public StardewUI.Input.FocusSearchResult FocusSearch(Microsoft.Xna.Framework.Vector2 contentPosition, StardewUI.Direction direction);
Parameters

contentPosition   Vector2
The current position, relative to the parent that owns this child.

direction   Direction
The direction of cursor movement.

Returns

FocusSearchResult

The next focusable view reached by moving in the specified direction, or null if there are no focusable descendants that are possible to reach in that direction.

Remarks

This is equivalent to FocusSearch(Vector2, Direction) but implicitly handles its own Position, so it can be used recursively without directly adjusting any coordinates.


GetActualBounds()

Returns a Bounds representing the parent-relative layout bounds of this child.

public StardewUI.Layout.Bounds GetActualBounds();
Returns

Bounds

Remarks

Equivalent to the ActualBounds offset by this child's Position.


GetContentBounds()

Returns a Bounds representing the parent-relative content bounds of this child.

public StardewUI.Layout.Bounds GetContentBounds();
Returns

Bounds

Remarks

Equivalent to the ContentBounds offset by this child's Position.


GetFloatingBounds()

Returns a sequence of Bounds representing the parent-relative bounds of this child's own floating elements and those of all its descendants.

public System.Collections.Generic.IEnumerable<StardewUI.Layout.Bounds> GetFloatingBounds();
Returns

IEnumerable<Bounds>


IsInDirection(Vector2, Direction)

Checks if a view can be reached by travelling from a given point in a given direction.

public bool IsInDirection(Microsoft.Xna.Framework.Vector2 origin, StardewUI.Direction direction);
Parameters

origin   Vector2
The origin point.

direction   Direction
The direction from origin.

Returns

Boolean

true if the view's boundaries either already contain the origin or are in the specified direction from the origin; otherwise false.


IsVisible(Vector2)

Checks if the visible area of this child contains a point relative to the view's parent.

public bool IsVisible(Microsoft.Xna.Framework.Vector2 point);
Parameters

point   Vector2
The point to test.

Returns

Boolean

true if point is within the visible, parent-relative bounds of this child; otherwise false.


Offset(Vector2)

Offsets the position by a given distance.

public StardewUI.ViewChild Offset(Microsoft.Xna.Framework.Vector2 distance);
Parameters

distance   Vector2
The offset distance.

Returns

ViewChild

A copy of the current ViewChild having the same View and a Position offset by distance.