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
| Member | Summary |
|---|---|
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
| Member | Summary |
|---|---|
Bottom | Frame row just past the bottom edge. |
Height | Height in rows. |
IsEmpty | Whether the region has no room to draw in. |
Left | Frame column of the left edge. |
Right | Frame column just past the right edge. |
Surface | The surface drawn into. |
Top | Frame row of the top edge. |
Width | Width in cells. |
Methods
| Member | Summary |
|---|---|
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
| Name | Type | Description |
|---|---|---|
Surface | Surface | The surface drawn into. |
Left | int | Frame column of the left edge. |
Top | int | Frame row of the top edge. |
Width | int | Width in cells. |
Height | int | Height 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
Right
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
| Name | Type | Description |
|---|---|---|
style | IArlecchinoColor | Style for the frame. |
title | string | Optional 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
| Name | Type | Description |
|---|---|---|
frameRow | int | Row in frame coordinates. |
frameColumn | int | Column in frame coordinates. |
Returns bool — true 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
| Name | Type | Description |
|---|---|---|
Surface | Surface | |
Left | int | |
Top | int | |
Width | int | |
Height | int |
Fill(IArlecchinoColor, char)
public void Fill(IArlecchinoColor style, char character = ' ');
Paints every cell of the region.
Parameters
| Name | Type | Description |
|---|---|---|
style | IArlecchinoColor | Style to paint with. |
character | char | Character 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
| Name | Type | Description |
|---|---|---|
margin | Margin | Space 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
| Name | Type | Description |
|---|---|---|
size | int | Cells 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
| Name | Type | Description |
|---|---|---|
row | int | First row, local to this region. |
count | int | How 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
| Name | Type | Description |
|---|---|---|
width | int | Cells 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
| Name | Type | Description |
|---|---|---|
height | int | Rows 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
| Name | Type | Description |
|---|---|---|
frameRow | int | Row in frame coordinates. |
frameColumn | int | Column 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
| Name | Type | Description |
|---|---|---|
row | int | Row inside the region. |
column | int | Column inside the region. |
text | string | Text to draw. |
style | IArlecchinoColor | Style 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
| Name | Type | Description |
|---|---|---|
row | int | Row inside the region. |
text | string | Text to draw. |
style | IArlecchinoColor | Style for the text. |
align | Align | Horizontal alignment inside the region. |