Skip to main content

SurfaceRegion struct

Namespace: Arlecchino.Rendering · Assembly: Arlecchino.Core

A rectangle on a SurfaceRegion.Surface with its own coordinates and clipping, so writing outside it is dropped. The same geometry answers where a click landed.

public readonly struct SurfaceRegion : IEquatable<SurfaceRegion>

Implements IEquatable<T><SurfaceRegion>

Constructors

MemberSummary
SurfaceRegion(Surface, int, int, int, int)A rectangle on a SurfaceRegion.Surface with its own coordinates and clipping, so writing outside it is dropped. The same geometry answers where a click landed.

Properties

MemberSummary
BottomFrame row just past the bottom edge.
HeightHeight in rows.
IsEmptyWhether the region has no room to draw in.
LeftFrame column of the left edge.
RightFrame column just past the right edge.
SurfaceThe surface drawn into.
TopFrame row of the top edge.
WidthWidth in cells.

Methods

MemberSummary
Border(IArlecchinoColor, string)Draws a box around the region and hands back the space inside it, so panes and dialogs are one call rather than four loops.
Contains(int, int)Whether a frame cell falls inside this region — the hit test for mouse events.
Deconstruct(out Surface, out int, out int, out int, out int)
Fill(IArlecchinoColor, char)Paints every cell of the region.
Flow()A cursor that writes the next line of this region and remembers where the one after it goes. The flow calls on SurfaceRegion.Surface belong to the whole frame; this one stays inside the region.
Inset(Margin)A smaller region inside this one.
Inset(int)A smaller region with the same space kept free on every side.
Rows(int, int)A horizontal band of this region, clamped to its bounds.
SplitLeft(int)Cuts a column off the left. The split is clamped to what the region actually has.
SplitTop(int)Cuts a band off the top. The split is clamped to what the region actually has.
ToLocal(int, int)Converts a frame cell into coordinates local to this region.
Write(int, int, string, IArlecchinoColor)Writes text in region coordinates, clipped to the region. A negative column starts the text off the left edge and shows what fits.
WriteLine(int, string, IArlecchinoColor, Align)Writes a whole line, aligned inside the region and clipped to its width.

Constructors in detail

SurfaceRegion(Surface, int, int, int, int)

public SurfaceRegion(Surface Surface, int Left, int Top, int Width, int Height);

A rectangle on a SurfaceRegion.Surface with its own coordinates and clipping, so writing outside it is dropped. The same geometry answers where a click landed.

Parameters

NameTypeDescription
SurfaceSurfaceThe surface drawn into.
LeftintFrame column of the left edge.
TopintFrame row of the top edge.
WidthintWidth in cells.
HeightintHeight in rows.

Properties in detail

Bottom

public int Bottom { get; }

Frame row just past the bottom edge.

Type int

Height

public int Height { get; init; }

Height in rows.

Type int

IsEmpty

public bool IsEmpty { get; }

Whether the region has no room to draw in.

Type bool

Left

public int Left { get; init; }

Frame column of the left edge.

Type int

public int Right { get; }

Frame column just past the right edge.

Type int

Surface

public Surface Surface { get; init; }

The surface drawn into.

Type Surface

Top

public int Top { get; init; }

Frame row of the top edge.

Type int

Width

public int Width { get; init; }

Width in cells.

Type int

Methods in detail

Border(IArlecchinoColor, string)

public SurfaceRegion Border(IArlecchinoColor style, string title = "");

Draws a box around the region and hands back the space inside it, so panes and dialogs are one call rather than four loops.

Parameters

NameTypeDescription
styleIArlecchinoColorStyle for the frame.
titlestringOptional title written into the top edge.

Returns SurfaceRegion — The region inside the frame, or this region when it is too small for one.

Contains(int, int)

public bool Contains(int frameRow, int frameColumn);

Whether a frame cell falls inside this region — the hit test for mouse events.

Parameters

NameTypeDescription
frameRowintRow in frame coordinates.
frameColumnintColumn in frame coordinates.

Returns booltrue when the cell is inside.

Deconstruct(out Surface, out int, out int, out int, out int)

public void Deconstruct(
out Surface Surface,
out int Left,
out int Top,
out int Width,
out int Height);

Parameters

NameTypeDescription
SurfaceSurface
Leftint
Topint
Widthint
Heightint

Fill(IArlecchinoColor, char)

public void Fill(IArlecchinoColor style, char character = ' ');

Paints every cell of the region.

Parameters

NameTypeDescription
styleIArlecchinoColorStyle to paint with.
charactercharCharacter to fill with; a space by default.

Flow()

public PaneFlow Flow();

A cursor that writes the next line of this region and remembers where the one after it goes. The flow calls on SurfaceRegion.Surface belong to the whole frame; this one stays inside the region.

Returns PaneFlow — A flow starting at the first row of the region.

Inset(Margin)

public SurfaceRegion Inset(Margin margin);

A smaller region inside this one.

Parameters

NameTypeDescription
marginMarginSpace to keep free on each side.

Returns SurfaceRegion — The region that is left.

Inset(int)

public SurfaceRegion Inset(int size);

A smaller region with the same space kept free on every side.

Parameters

NameTypeDescription
sizeintCells to keep free.

Returns SurfaceRegion — The region that is left.

Rows(int, int)

public SurfaceRegion Rows(int row, int count);

A horizontal band of this region, clamped to its bounds.

Parameters

NameTypeDescription
rowintFirst row, local to this region.
countintHow many rows to take.

Returns SurfaceRegion — The band.

SplitLeft(int)

public ValueTuple<SurfaceRegion, SurfaceRegion> SplitLeft(int width);

Cuts a column off the left. The split is clamped to what the region actually has.

Parameters

NameTypeDescription
widthintCells to give to the left part.

Returns ValueTuple<T1, T2><SurfaceRegion, SurfaceRegion> — The left part and the rest.

SplitTop(int)

public ValueTuple<SurfaceRegion, SurfaceRegion> SplitTop(int height);

Cuts a band off the top. The split is clamped to what the region actually has.

Parameters

NameTypeDescription
heightintRows to give to the top part.

Returns ValueTuple<T1, T2><SurfaceRegion, SurfaceRegion> — The top part and the rest.

ToLocal(int, int)

public ValueTuple<int, int> ToLocal(int frameRow, int frameColumn);

Converts a frame cell into coordinates local to this region.

Parameters

NameTypeDescription
frameRowintRow in frame coordinates.
frameColumnintColumn in frame coordinates.

Returns ValueTuple<T1, T2><int, int> — The same cell as a row and column inside the region.

Write(int, int, string, IArlecchinoColor)

public void Write(int row, int column, string text, IArlecchinoColor style);

Writes text in region coordinates, clipped to the region. A negative column starts the text off the left edge and shows what fits.

Parameters

NameTypeDescription
rowintRow inside the region.
columnintColumn inside the region.
textstringText to draw.
styleIArlecchinoColorStyle for the text.

WriteLine(int, string, IArlecchinoColor, Align)

public void WriteLine(int row, string text, IArlecchinoColor style, Align align = Left);

Writes a whole line, aligned inside the region and clipped to its width.

Parameters

NameTypeDescription
rowintRow inside the region.
textstringText to draw.
styleIArlecchinoColorStyle for the text.
alignAlignHorizontal alignment inside the region.