Table of Contents

Class Pos

Namespace
Terminal.Gui.ViewBase
Assembly
Terminal.Gui.dll

Describes a declarative, responsive position for a View. A Pos can be absolute, percentage-based, centered, anchored to an edge, or relative to another View. Integer values are implicitly convertible to an absolute Pos.

public abstract record Pos : IEquatable<Pos>
Inheritance
Pos
Implements
Derived
Inherited Members

Remarks

To describe where a view should be, relative to its SuperView, its available space, or its sibling views, use Pos with X and Y.

To define responsive horizontal and vertical placement in Terminal.Gui, describe the relationship that should be maintained and let the layout engine resolve the final Frame whenever layout runs.

Pos values can be combined to produce more useful layouts, such as Pos.Center () - 3, which shifts the resolved position of the View 3 cells earlier on the axis after centering.

To reference coordinates of another view, use Left(View), Right(View), Bottom(View), and Top(View). X(View) and Y(View) are aliases to Left(View) and Top(View) respectively.

Pos ObjectDescription
Align(Alignment, AlignmentModes, int) Creates a Pos object that aligns a set of views.
Func(Func<View?, int>, View?) Creates a Pos object that computes the position by executing the provided function. The function will be called every time the position is needed.
Percent(int) Creates a Pos object that is a percentage of the width or height of the SuperView.
AnchorEnd() Creates a Pos object that is anchored to the end (right side or bottom) of the dimension, useful to flush the layout from the right or bottom.
Center() Creates a Pos object that can be used to center the View.
Absolute(int) Creates a Pos object that is an absolute position based on the specified integer value.
Left(View) Creates a Pos object that tracks the Left (X) position of the specified View.
X(View) Creates a Pos object that tracks the Left (X) position of the specified View.
Top(View) Creates a Pos object that tracks the Top (Y) position of the specified View.
Y(View) Creates a Pos object that tracks the Top (Y) position of the specified View.
Right(View) Creates a Pos object that tracks the Right (X+Width) coordinate of the specified View.
Bottom(View) Creates a Pos object that tracks the Bottom (Y+Height) coordinate of the specified View

Constructors

Pos()
Pos(Pos)

Properties

EqualityContract

Methods

Absolute(int)

Creates a Pos object that is an absolute position based on the specified integer value.

Align(Alignment, AlignmentModes, int)

Creates a Pos object that aligns a set of views according to the specified Alignment and AlignmentModes.

AnchorEnd()

Creates a Pos object that is anchored to the end (right side or bottom) of the SuperView's content area. The view will be positioned so its right/bottom edge aligns with the SuperView's right/bottom edge.

AnchorEnd(int)

Creates a Pos object that is anchored to the end (right side or bottom) of the SuperView's content area, with a specified offset from the edge.

Bottom(View)

Creates a Pos object that tracks the Bottom (Y+Height) coordinate of the specified View

Center()

Creates a Pos object that can be used to center the View.

Equals(object?)
Equals(Pos?)
Func(Func<View?, int>, View?)

Creates a Pos object that computes the position based on the passed view and by executing the provided function. The function will be called every time the position is needed.

GetHashCode()
HasInner<TPos>(out TPos)

Searches nested Pos objects for the specified type. Override in subclasses that contain other Pos objects to enable Has<TPos>(out TPos) to find nested types.

Has<TPos>(out TPos)

Indicates whether the specified type TPos is in the hierarchy of this Pos object.

Left(View)

Creates a Pos object that tracks the Left (X) position of the specified View.

Percent(int)

Creates a percentage Pos object

PrintMembers(StringBuilder)
Right(View)

Creates a Pos object that tracks the Right (X+Width) coordinate of the specified View.

ToString()
Top(View)

Creates a Pos object that tracks the Top (Y) position of the specified View.

X(View)

Creates a Pos object that tracks the Left (X) position of the specified View.

Y(View)

Creates a Pos object that tracks the Top (Y) position of the specified View.

Operators

operator +(Pos, Pos)

Adds a Pos to a Pos, yielding a new Pos.

operator ==(Pos?, Pos?)
implicit operator Pos(int)

Creates an Absolute Pos from the specified integer value.

operator !=(Pos?, Pos?)
operator -(Pos, Pos)

Subtracts a Pos from a Pos, yielding a new Pos.