Skip to content

Class Overlay

Definition

Namespace: StardewUI.Overlays
Assembly: StardewUI.dll

A basic overlay with immutable properties.

public class Overlay : StardewUI.Overlays.IOverlay

Inheritance
Object ⇦ Overlay

Implements
IOverlay

Members

Constructors

Name Description
Overlay(IView, IView, Alignment, Alignment, Alignment, Alignment, Vector2) A basic overlay with immutable properties.

Properties

Name Description
HorizontalAlignment Horizontal alignment of the overlay relative to the Parent edge.
HorizontalParentAlignment Specifies which edge of the Parent (or screen, if no parent is specified) will be used to align the overlay edge denoted by its HorizontalAlignment.
Parent The parent of this overlay, used for positioning. If not specified, then the overlay will be positioned relative to the entire UI viewport.
ParentOffset Additional pixel offset to apply to the overlay's position, after alignments.
VerticalAlignment Vertical alignment of the overlay relative to the Parent edge.
VerticalParentAlignment Specifies which edge of the Parent (or screen, if no parent is specified) will be used to align the overlay edge denoted by its VerticalAlignment.
View The view to be displayed/interacted with as an overlay.

Methods

Name Description
OnClose() Runs when the overlay is removed from the active stack.
OnClose(Action) Registers an action to be run when the overlay is closed.
Pop() Removes the front-most overlay.
Push(IOverlay) Pushes an overlay to the front.
Remove(IOverlay) Removes a specific overlay from the stack, regardless of its position.

Events

Name Description
Close Raised when the overlay is removed from the active stack.

Details

Constructors

Overlay(IView, IView, Alignment, Alignment, Alignment, Alignment, Vector2)

A basic overlay with immutable properties.

public Overlay(StardewUI.IView view, StardewUI.IView parent, StardewUI.Layout.Alignment horizontalAlignment, StardewUI.Layout.Alignment horizontalParentAlignment, StardewUI.Layout.Alignment verticalAlignment, StardewUI.Layout.Alignment verticalParentAlignment, Microsoft.Xna.Framework.Vector2 parentOffset);
Parameters

view   IView
The View.

parent   IView
The Parent.

horizontalAlignment   Alignment
The HorizontalAlignment.

horizontalParentAlignment   Alignment
The HorizontalParentAlignment.

verticalAlignment   Alignment
The VerticalAlignment.

verticalParentAlignment   Alignment
The VerticalParentAlignment.

parentOffset   Vector2
The ParentOffset.


Properties

HorizontalAlignment

Horizontal alignment of the overlay relative to the Parent edge.

public StardewUI.Layout.Alignment HorizontalAlignment { get; }
Property Value

Alignment

Remarks

Specifies which edge of the overlay is used for positioning, regardless of which parent edge it is aligning to. For example, a HorizontalAlignment of Start and a HorizontalParentAlignment of End means that the overlay's left edge will be aligned to the parent's right edge; similarly, if both are set to Start, then the overlay's left edge is aligned to the parent's left edge.


HorizontalParentAlignment

Specifies which edge of the Parent (or screen, if no parent is specified) will be used to align the overlay edge denoted by its HorizontalAlignment.

public StardewUI.Layout.Alignment HorizontalParentAlignment { get; }
Property Value

Alignment

Remarks

For example, a HorizontalAlignment of Start and a HorizontalParentAlignment of End means that the overlay's left edge will be aligned to the parent's right edge; similarly, if both are set to Start, then the overlay's left edge is aligned to the parent's left edge.


Parent

The parent of this overlay, used for positioning. If not specified, then the overlay will be positioned relative to the entire UI viewport.

public StardewUI.IView Parent { get; }
Property Value

IView


ParentOffset

Additional pixel offset to apply to the overlay's position, after alignments.

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

Vector2


VerticalAlignment

Vertical alignment of the overlay relative to the Parent edge.

public StardewUI.Layout.Alignment VerticalAlignment { get; }
Property Value

Alignment

Remarks

Specifies which edge of the overlay is used for positioning, regardless of which parent edge it is aligning to. For example, a VerticalAlignment of Start and a VerticalParentAlignment of End means that the overlay's top edge will be aligned to the parent's bottom edge; similarly, if both are set to Start, then the overlay's top edge is aligned to the parent's top edge.


VerticalParentAlignment

Specifies which edge of the Parent (or screen, if no parent is specified) will be used to align the overlay edge denoted by its VerticalAlignment.

public StardewUI.Layout.Alignment VerticalParentAlignment { get; }
Property Value

Alignment

Remarks

For example, a VerticalAlignment of Start and a VerticalParentAlignment of End means that the overlay's top edge will be aligned to the parent's bottom edge; similarly, if both are set to Start, then the overlay's top edge is aligned to the parent's top edge.


View

The view to be displayed/interacted with as an overlay.

public StardewUI.IView View { get; }
Property Value

IView


Methods

OnClose()

Runs when the overlay is removed from the active stack.

public void OnClose();

OnClose(Action)

Registers an action to be run when the overlay is closed.

public StardewUI.Overlays.Overlay OnClose(System.Action onClose);
Parameters

onClose   Action
The action to run on close.

Returns

Overlay

The current Overlay instance.

Remarks

Typically chained to the constructor when creating a new overlay.


Pop()

Removes the front-most overlay.

public static StardewUI.Overlays.IOverlay Pop();
Returns

IOverlay

Remarks

Applies to the ambient OverlayContext, and is ignored if no context is available.


Push(IOverlay)

Pushes an overlay to the front.

public static void Push(StardewUI.Overlays.IOverlay overlay);
Parameters

overlay   IOverlay

Remarks

If the specified overlay is already in the stack, then it will be moved from its previous position to the front.

Applies to the ambient OverlayContext, and is ignored if no context is available.


Remove(IOverlay)

Removes a specific overlay from the stack, regardless of its position.

public static bool Remove(StardewUI.Overlays.IOverlay overlay);
Parameters

overlay   IOverlay
The overlay to remove.

Returns

Boolean

true if the overlay was removed; false if it was not active.

Remarks

This is most often invoked by an overlay needing to dismiss itself, e.g. an overlay with an "OK" or "Close" button.

Applies to the ambient OverlayContext, and is ignored if no context is available.


Events

Close

Raised when the overlay is removed from the active stack.

public event EventHandler<System.EventArgs>? Close;
Event Type

EventHandler<EventArgs>