Terminal.Gui v2 supports the following View layout systems (controlled by the View.LayoutStyle):
Frame
property on the View.X
, Y
, Width
and Height
properties after the object has been created. Views laid out using the Computed Layout system can be resized with the mouse or keyboard, enabling tiled window managers and dynamic terminal UIs.Examples:
// Absolute layout using a provided rectangle
var label1 = new Label (new Rect (1, 1, 20, 1), "Hello")
// Computed Layout
var label2 = new Label ("Hello") {
X = Pos.Right (label2),
Y = Pos.Center (),
Width = Dim.Fill (),
Height = 1
};
When using Computed Layout the X
and Y
properties are of type Pos and the Width
and Height
properties are of type Dim both of which can be created implicitly from integer values.
Pos
TypeThe Pos
type on X
and Y
offers a few options:
Pos.Percent(n)
AnchorEnd(int margin=0)
Center()
The Pos
values can be added or subtracted, like this:
// Set the X coordinate to 10 characters left from the center
view.X = Pos.Center () - 10;
view.Y = Pos.Percent (20);
anotherView.X = AnchorEnd (10);
anotherView.Width = 9;
myView.X = Pos.X (view);
myView.Y = Pos.Bottom (anotherView);
Dim
TypeThe Dim
type is used for the Width
and Height
properties on the View and offers
the following options:
Dim.Percent(n)
Dim.Fill ()
Like, Pos
, objects of type Dim
can be added an subtracted, like this:
// Set the Width to be 10 characters less than filling
// the remaining portion of the screen
view.Width = Dim.Fill () - 10;
view.Height = Dim.Percent(20) - 1;
anotherView.Height = Dim.Height (view)+1