Add Layout widget (#1041)

* Add width to panels
* Add height to panels
* Replace RenderContext with RenderOptions
* Remove exclusivity from alternative buffer
* Add Layout widget
* Add Align widget
This commit is contained in:
Patrik Svensson
2022-11-15 10:12:17 +01:00
committed by GitHub
parent 9ce3b99cd6
commit c3ec6a7363
137 changed files with 2651 additions and 387 deletions

View File

@ -3,7 +3,7 @@ namespace Spectre.Console;
/// <summary>
/// Represents text rendered with a FIGlet font.
/// </summary>
public sealed class FigletText : Renderable, IAlignable
public sealed class FigletText : Renderable, IHasJustification
{
private readonly FigletFont _font;
private readonly string _text;
@ -14,7 +14,7 @@ public sealed class FigletText : Renderable, IAlignable
public Color? Color { get; set; }
/// <inheritdoc/>
public Justify? Alignment { get; set; }
public Justify? Justification { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="FigletText"/> class.
@ -37,10 +37,10 @@ public sealed class FigletText : Renderable, IAlignable
}
/// <inheritdoc/>
protected override IEnumerable<Segment> Render(RenderContext context, int maxWidth)
protected override IEnumerable<Segment> Render(RenderOptions options, int maxWidth)
{
var style = new Style(Color ?? Console.Color.Default);
var alignment = Alignment ?? Justify.Left;
var alignment = Justification ?? Console.Justify.Left;
foreach (var row in GetRows(maxWidth))
{
@ -49,7 +49,7 @@ public sealed class FigletText : Renderable, IAlignable
var line = new Segment(string.Concat(row.Select(x => x.Lines[index])), style);
var lineWidth = line.CellCount();
if (alignment == Justify.Left)
if (alignment == Console.Justify.Left)
{
yield return line;
@ -58,7 +58,7 @@ public sealed class FigletText : Renderable, IAlignable
yield return Segment.Padding(maxWidth - lineWidth);
}
}
else if (alignment == Justify.Center)
else if (alignment == Console.Justify.Center)
{
var left = (maxWidth - lineWidth) / 2;
var right = left + ((maxWidth - lineWidth) % 2);
@ -67,7 +67,7 @@ public sealed class FigletText : Renderable, IAlignable
yield return line;
yield return Segment.Padding(right);
}
else if (alignment == Justify.Right)
else if (alignment == Console.Justify.Right)
{
if (lineWidth < maxWidth)
{