Skip to content

Refactor Border to use subviews for title, lines, and close button #3407

Open
@tig

Description

@tig

Related:

Requires

Will enable

Design

Subviews

public Label TitleLabel { get; set; };
public Button CloseButton { get ; set; }
public Line Top { get; set; }
public Line Left { get; set; }
public Line Right{ get; set; }
public Line Bottom{ get; set; }

Layout

This also indicates the order the views should be added; The label & button must be added after the lines so that they occlude them.

Top.X = Pos.Function (Thickness.Left/ 2);
Top.Y = Pos.Function (Thickness.Top / 2);
Top.Width = Dim.Fill () - Dim.Function (Thickness.Right / 2);

Left.X = Pos.Left (Top);
Left.Y = Pos.Top (Top);
Left.Height = Dim.Fill () - Dim.Function (Thickness.Bottom / 2);

Right.X = Pos.Right (Top);
Right.Y = Pos.Top (Top);
Right.Height = Dim.Fill () - Dim.Function (Thickness.Bottom / 2);

Bottom.X = Pos.Left (Top);
Bottom.Y= Pos.Bottom (Left);
Bottom.Width = Dim.Fill () - Dim.Function (Thickness.Right / 2);

TitleLabel.X = Pos.Right (Left) + 1;
TitleLabelY = Pos.Top (Top);

CloseButton .X = Pos.Left (Right) - 1;
CloseButton .Y = Pos.Top (Top);

Example usage:

view.Border.TitleLabel.X = Pos.Center (); // centers title (default is X = 1)
view.Border.TitleLabel.Visible = false; // Turn off the Title.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

🏗 Approved - In progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions