#nullable enable
namespace Terminal.Gui;
///
/// Tracks the region that has been drawn during . This is primarily
/// in support of .
///
public class DrawContext
{
private readonly Region _drawnRegion = new Region ();
///
/// Gets a copy of the region drawn so far in this context.
///
public Region GetDrawnRegion () => _drawnRegion.Clone ();
///
/// Reports that a rectangle has been drawn.
///
/// The rectangle that was drawn.
public void AddDrawnRectangle (Rectangle rect)
{
_drawnRegion.Combine (rect, RegionOp.Union);
}
///
/// Reports that a region has been drawn.
///
/// The region that was drawn.
public void AddDrawnRegion (Region region)
{
_drawnRegion.Combine (region, RegionOp.Union);
}
///
/// Clips (intersects) the drawn region with the specified rectangle.
/// This modifies the internal drawn region directly.
///
/// The clipping rectangle.
public void ClipDrawnRegion (Rectangle clipRect)
{
_drawnRegion.Intersect (clipRect);
}
///
/// Clips (intersects) the drawn region with the specified region.
/// This modifies the internal drawn region directly.
///
/// The clipping region.
public void ClipDrawnRegion (Region clipRegion)
{
_drawnRegion.Intersect (clipRegion);
}
}