Procházet zdrojové kódy

Merge pull request #3415 from tig/v2_1785-PosJustify

Fixes #1785. Adds `Pos.Align` - Align sets of views horizontally or vertically
Tig před 1 rokem
rodič
revize
38ad450dde
91 změnil soubory, kde provedl 3219 přidání a 2648 odebrání
  1. 369 0
      Terminal.Gui/Drawing/Aligner.cs
  2. 82 0
      Terminal.Gui/Drawing/Alignment.cs
  3. 52 0
      Terminal.Gui/Drawing/AlignmentModes.cs
  4. 0 333
      Terminal.Gui/Drawing/Justification.cs
  5. 2 2
      Terminal.Gui/Drawing/Thickness.cs
  6. 2 1
      Terminal.Gui/Resources/config.json
  7. 0 20
      Terminal.Gui/Text/TextAlignment.cs
  8. 52 49
      Terminal.Gui/Text/TextFormatter.cs
  9. 0 20
      Terminal.Gui/Text/VerticalTextAlignment.cs
  10. 1 1
      Terminal.Gui/View/Layout/Dim.cs
  11. 66 13
      Terminal.Gui/View/Layout/DimAuto.cs
  12. 2 2
      Terminal.Gui/View/Layout/DimAutoStyle.cs
  13. 33 2
      Terminal.Gui/View/Layout/Pos.cs
  14. 169 0
      Terminal.Gui/View/Layout/PosAlign.cs
  15. 4 4
      Terminal.Gui/View/ViewText.cs
  16. 2 2
      Terminal.Gui/Views/Button.cs
  17. 4 4
      Terminal.Gui/Views/CheckBox.cs
  18. 2 4
      Terminal.Gui/Views/DatePicker.cs
  19. 47 168
      Terminal.Gui/Views/Dialog.cs
  20. 1 1
      Terminal.Gui/Views/ListView.cs
  21. 1 1
      Terminal.Gui/Views/Menu/Menu.cs
  22. 112 94
      Terminal.Gui/Views/MessageBox.cs
  23. 19 0
      Terminal.Gui/Views/OrientationEventArgs.cs
  24. 1 1
      Terminal.Gui/Views/ProgressBar.cs
  25. 8 219
      Terminal.Gui/Views/Slider.cs
  26. 14 0
      Terminal.Gui/Views/SliderAttributes.cs
  27. 19 0
      Terminal.Gui/Views/SliderConfiguration.cs
  28. 24 0
      Terminal.Gui/Views/SliderEventArgs.cs
  29. 50 0
      Terminal.Gui/Views/SliderOption.cs
  30. 12 0
      Terminal.Gui/Views/SliderOptionEventArgs.cs
  31. 35 0
      Terminal.Gui/Views/SliderStyle.cs
  32. 40 0
      Terminal.Gui/Views/SliderType.cs
  33. 13 13
      Terminal.Gui/Views/TableView/ColumnStyle.cs
  34. 2 2
      Terminal.Gui/Views/TableView/TableStyle.cs
  35. 5 5
      Terminal.Gui/Views/TableView/TableView.cs
  36. 7 7
      Terminal.Gui/Views/TextValidateField.cs
  37. 5 2
      Terminal.Gui/Views/TextView.cs
  38. 3 20
      Terminal.Gui/Views/Wizard/Wizard.cs
  39. 2 0
      Terminal.sln.DotSettings
  40. 1 0
      UICatalog/Resources/config.json
  41. 16 12
      UICatalog/Scenarios/AllViewsTester.cs
  42. 2 2
      UICatalog/Scenarios/BasicColors.cs
  43. 28 29
      UICatalog/Scenarios/Buttons.cs
  44. 3 2
      UICatalog/Scenarios/CharacterMap.cs
  45. 2 2
      UICatalog/Scenarios/CollectionNavigatorTester.cs
  46. 2 2
      UICatalog/Scenarios/ColorPicker.cs
  47. 34 25
      UICatalog/Scenarios/ComputedLayout.cs
  48. 11 11
      UICatalog/Scenarios/CsvEditor.cs
  49. 25 29
      UICatalog/Scenarios/Dialogs.cs
  50. 2 2
      UICatalog/Scenarios/DynamicMenuBar.cs
  51. 9 9
      UICatalog/Scenarios/Editor.cs
  52. 1 1
      UICatalog/Scenarios/ListColumns.cs
  53. 10 13
      UICatalog/Scenarios/MessageBoxes.cs
  54. 2 2
      UICatalog/Scenarios/Mouse.cs
  55. 423 0
      UICatalog/Scenarios/PosAlignDemo.cs
  56. 19 11
      UICatalog/Scenarios/ProgressBarStyles.cs
  57. 7 7
      UICatalog/Scenarios/TableEditor.cs
  58. 1 1
      UICatalog/Scenarios/Text.cs
  59. 156 139
      UICatalog/Scenarios/TextAlignmentAndDirection.cs
  60. 0 142
      UICatalog/Scenarios/TextAlignments.cs
  61. 32 20
      UICatalog/Scenarios/TextFormatterDemo.cs
  62. 6 6
      UICatalog/Scenarios/TimeAndDate.cs
  63. 2 2
      UICatalog/Scenarios/Unicode.cs
  64. 5 5
      UICatalog/Scenarios/ViewExperiments.cs
  65. 4 4
      UICatalog/Scenarios/Wizards.cs
  66. 14 15
      UICatalog/UICatalog.cs
  67. 1 2
      UnitTests/Configuration/ConfigurationMangerTests.cs
  68. 3 3
      UnitTests/Configuration/ThemeScopeTests.cs
  69. 3 3
      UnitTests/Configuration/ThemeTests.cs
  70. 256 252
      UnitTests/Dialogs/DialogTests.cs
  71. 16 16
      UnitTests/Dialogs/MessageBoxTests.cs
  72. 480 0
      UnitTests/Drawing/AlignerTests.cs
  73. 0 426
      UnitTests/Drawing/JustifierTests.cs
  74. 1 13
      UnitTests/Drawing/ThicknessTests.cs
  75. 120 325
      UnitTests/Text/TextFormatterTests.cs
  76. 2 2
      UnitTests/View/DrawTests.cs
  77. 6 6
      UnitTests/View/Layout/Dim.AutoTests.cs
  78. 0 2
      UnitTests/View/Layout/Dim.PercentTests.cs
  79. 112 0
      UnitTests/View/Layout/Pos.AlignTests.cs
  80. 1 1
      UnitTests/View/Layout/Pos.Tests.cs
  81. 1 1
      UnitTests/View/NeedsDisplayTests.cs
  82. 7 7
      UnitTests/View/TextTests.cs
  83. 4 4
      UnitTests/Views/ButtonTests.cs
  84. 9 10
      UnitTests/Views/CheckBoxTests.cs
  85. 1 1
      UnitTests/Views/LabelTests.cs
  86. 20 20
      UnitTests/Views/TextValidateFieldTests.cs
  87. 2 2
      UnitTests/Views/ToplevelTests.cs
  88. 23 23
      docfx/docs/drawing.md
  89. 1 0
      docfx/docs/layout.md
  90. 62 37
      docfx/docs/migratingfromv1.md
  91. 9 9
      docfx/docs/newinv2.md

+ 369 - 0
Terminal.Gui/Drawing/Aligner.cs

@@ -0,0 +1,369 @@
+using System.ComponentModel;
+
+namespace Terminal.Gui;
+
+/// <summary>
+///     Aligns items within a container based on the specified <see cref="Gui.Alignment"/>. Both horizontal and vertical
+///     alignments are supported.
+/// </summary>
+public class Aligner : INotifyPropertyChanged
+{
+    private Alignment _alignment;
+
+    /// <summary>
+    ///     Gets or sets how the <see cref="Aligner"/> aligns items within a container.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         <see cref="AlignmentModes"/> provides additional options for aligning items in a container.
+    ///     </para>
+    /// </remarks>
+    public Alignment Alignment
+    {
+        get => _alignment;
+        set
+        {
+            _alignment = value;
+            PropertyChanged?.Invoke (this, new (nameof (Alignment)));
+        }
+    }
+
+    private AlignmentModes _alignmentMode = AlignmentModes.StartToEnd;
+
+    /// <summary>
+    ///     Gets or sets the modes controlling <see cref="Alignment"/>.
+    /// </summary>
+    public AlignmentModes AlignmentModes
+    {
+        get => _alignmentMode;
+        set
+        {
+            _alignmentMode = value;
+            PropertyChanged?.Invoke (this, new (nameof (AlignmentModes)));
+        }
+    }
+
+    private int _containerSize;
+
+    /// <summary>
+    ///     The size of the container.
+    /// </summary>
+    public int ContainerSize
+    {
+        get => _containerSize;
+        set
+        {
+            _containerSize = value;
+            PropertyChanged?.Invoke (this, new (nameof (ContainerSize)));
+        }
+    }
+
+    /// <inheritdoc/>
+    public event PropertyChangedEventHandler PropertyChanged;
+
+    /// <summary>
+    ///     Takes a list of item sizes and returns a list of the positions of those items when aligned within
+    ///     <see name="ContainerSize"/>
+    ///     using the <see cref="Alignment"/> and <see cref="AlignmentModes"/> settings.
+    /// </summary>
+    /// <param name="sizes">The sizes of the items to align.</param>
+    /// <returns>The locations of the items, from left/top to right/bottom.</returns>
+    public int [] Align (int [] sizes) { return Align (Alignment, AlignmentModes, ContainerSize, sizes); }
+
+    /// <summary>
+    ///     Takes a list of item sizes and returns a list of the  positions of those items when aligned within
+    ///     <paramref name="containerSize"/>
+    ///     using specified parameters.
+    /// </summary>
+    /// <param name="alignment">Specifies how the items will be aligned.</param>
+    /// <param name="alignmentMode"></param>
+    /// <param name="containerSize">The size of the container.</param>
+    /// <param name="sizes">The sizes of the items to align.</param>
+    /// <returns>The positions of the items, from left/top to right/bottom.</returns>
+    public static int [] Align (in Alignment alignment, in AlignmentModes alignmentMode, in int containerSize, in int [] sizes)
+    {
+        if (sizes.Length == 0)
+        {
+            return [];
+        }
+
+        var sizesCopy = sizes;
+        if (alignmentMode.FastHasFlags (AlignmentModes.EndToStart))
+        {
+            sizesCopy = sizes.Reverse ().ToArray ();
+        }
+
+        int maxSpaceBetweenItems = alignmentMode.FastHasFlags (AlignmentModes.AddSpaceBetweenItems) ? 1 : 0;
+        int totalItemsSize = sizes.Sum ();
+        int totalGaps = sizes.Length - 1; // total gaps between items
+        int totalItemsAndSpaces = totalItemsSize + totalGaps * maxSpaceBetweenItems; // total size of items and spacesToGive if we had enough room
+        int spacesToGive = totalGaps * maxSpaceBetweenItems; // We'll decrement this below to place one space between each item until we run out
+
+        if (totalItemsSize >= containerSize)
+        {
+            spacesToGive = 0;
+        }
+        else if (totalItemsAndSpaces > containerSize)
+        {
+            spacesToGive = containerSize - totalItemsSize;
+        }
+
+        switch (alignment)
+        {
+            case Alignment.Start:
+                switch (alignmentMode & ~AlignmentModes.AddSpaceBetweenItems)
+                {
+                    case AlignmentModes.StartToEnd:
+                        return Start (in sizesCopy, maxSpaceBetweenItems, spacesToGive);
+
+                    case AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast:
+                        return IgnoreLast (in sizesCopy, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive);
+
+                    case AlignmentModes.EndToStart:
+                        return End (in sizesCopy, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive).Reverse ().ToArray ();
+
+                    case AlignmentModes.EndToStart | AlignmentModes.IgnoreFirstOrLast:
+                        return IgnoreFirst (in sizesCopy, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive).Reverse ().ToArray (); ;
+                }
+
+                break;
+
+            case Alignment.End:
+                switch (alignmentMode & ~AlignmentModes.AddSpaceBetweenItems)
+                {
+                    case AlignmentModes.StartToEnd:
+                        return End (in sizesCopy, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive);
+
+                    case AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast:
+                        return IgnoreFirst (in sizesCopy, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive);
+
+                    case AlignmentModes.EndToStart:
+                        return Start (in sizesCopy, maxSpaceBetweenItems, spacesToGive).Reverse ().ToArray ();
+
+                    case AlignmentModes.EndToStart | AlignmentModes.IgnoreFirstOrLast:
+                        return IgnoreLast (in sizesCopy, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive).Reverse ().ToArray (); ;
+                }
+
+                break;
+
+            case Alignment.Center:
+                switch (alignmentMode & ~AlignmentModes.AddSpaceBetweenItems)
+                {
+                    case AlignmentModes.StartToEnd:
+                        return Center (in sizesCopy, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive);
+
+                    case AlignmentModes.EndToStart:
+                        return Center (in sizesCopy, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive).Reverse ().ToArray ();
+                }
+
+                break;
+
+            case Alignment.Fill:
+                switch (alignmentMode & ~AlignmentModes.AddSpaceBetweenItems)
+                {
+                    case AlignmentModes.StartToEnd:
+                        return Fill (in sizesCopy, containerSize, totalItemsSize);
+
+                    case AlignmentModes.EndToStart:
+                        return Fill (in sizesCopy, containerSize, totalItemsSize).Reverse ().ToArray ();
+                }
+
+                break;
+
+            default:
+                throw new ArgumentOutOfRangeException (nameof (alignment), alignment, null);
+        }
+
+        return [];
+    }
+
+    internal static int [] Start (ref readonly int [] sizes, int maxSpaceBetweenItems, int spacesToGive)
+    {
+        var positions = new int [sizes.Length]; // positions of the items. the return value.
+
+        for (var i = 0; i < sizes.Length; i++)
+        {
+            CheckSizeCannotBeNegative (i, in sizes);
+
+            if (i == 0)
+            {
+                positions [0] = 0; // first item position
+
+                continue;
+            }
+
+            int spaceBefore = spacesToGive-- > 0 ? maxSpaceBetweenItems : 0;
+
+            // subsequent items are placed one space after the previous item
+            positions [i] = positions [i - 1] + sizes [i - 1] + spaceBefore;
+        }
+
+        return positions;
+    }
+
+    internal static int [] IgnoreFirst (
+        ref readonly int [] sizes,
+        int containerSize,
+        int totalItemsSize,
+        int maxSpaceBetweenItems,
+        int spacesToGive
+    )
+    {
+        var positions = new int [sizes.Length]; // positions of the items. the return value.
+
+        if (sizes.Length > 1)
+        {
+            var currentPosition = 0;
+            positions [0] = currentPosition; // first item is flush left
+
+            for (int i = sizes.Length - 1; i >= 0; i--)
+            {
+                CheckSizeCannotBeNegative (i, in sizes);
+
+                if (i == sizes.Length - 1)
+                {
+                    // start at right
+                    currentPosition = Math.Max (totalItemsSize, containerSize) - sizes [i];
+                    positions [i] = currentPosition;
+                }
+
+                if (i < sizes.Length - 1 && i > 0)
+                {
+                    int spaceBefore = spacesToGive-- > 0 ? maxSpaceBetweenItems : 0;
+
+                    positions [i] = currentPosition - sizes [i] - spaceBefore;
+                    currentPosition = positions [i];
+                }
+            }
+        }
+        else if (sizes.Length == 1)
+        {
+            CheckSizeCannotBeNegative (0, in sizes);
+            positions [0] = 0; // single item is flush left
+        }
+
+        return positions;
+    }
+
+    internal static int [] IgnoreLast (
+        ref readonly int [] sizes,
+        int containerSize,
+        int totalItemsSize,
+        int maxSpaceBetweenItems,
+        int spacesToGive
+    )
+    {
+        var positions = new int [sizes.Length]; // positions of the items. the return value.
+
+        if (sizes.Length > 1)
+        {
+            var currentPosition = 0;
+            if (totalItemsSize > containerSize)
+            {
+                currentPosition = containerSize - totalItemsSize - spacesToGive;
+            }
+
+            for (var i = 0; i < sizes.Length; i++)
+            {
+                CheckSizeCannotBeNegative (i, in sizes);
+
+                if (i < sizes.Length - 1)
+                {
+                    int spaceBefore = spacesToGive-- > 0 ? maxSpaceBetweenItems : 0;
+
+                    positions [i] = currentPosition;
+                    currentPosition += sizes [i] + spaceBefore;
+                }
+            }
+
+            positions [sizes.Length - 1] = containerSize - sizes [^1];
+        }
+        else if (sizes.Length == 1)
+        {
+            CheckSizeCannotBeNegative (0, in sizes);
+
+            positions [0] = containerSize - sizes [0]; // single item is flush right
+        }
+
+        return positions;
+    }
+
+    internal static int [] Fill (ref readonly int [] sizes, int containerSize, int totalItemsSize)
+    {
+        var positions = new int [sizes.Length]; // positions of the items. the return value.
+
+        int spaceBetween = sizes.Length > 1 ? (containerSize - totalItemsSize) / (sizes.Length - 1) : 0;
+        int remainder = sizes.Length > 1 ? (containerSize - totalItemsSize) % (sizes.Length - 1) : 0;
+        var currentPosition = 0;
+
+        for (var i = 0; i < sizes.Length; i++)
+        {
+            CheckSizeCannotBeNegative (i, in sizes);
+            positions [i] = currentPosition;
+            int extraSpace = i < remainder ? 1 : 0;
+            currentPosition += sizes [i] + spaceBetween + extraSpace;
+        }
+
+        return positions;
+    }
+
+    internal static int [] Center (ref readonly int [] sizes, int containerSize, int totalItemsSize, int maxSpaceBetweenItems, int spacesToGive)
+    {
+        var positions = new int [sizes.Length]; // positions of the items. the return value.
+
+        if (sizes.Length > 1)
+        {
+            // remaining space to be distributed before first and after the items
+            int remainingSpace = containerSize - totalItemsSize - spacesToGive;
+
+            for (var i = 0; i < sizes.Length; i++)
+            {
+                CheckSizeCannotBeNegative (i, in sizes);
+
+                if (i == 0)
+                {
+                    positions [i] = remainingSpace / 2; // first item position
+
+                    continue;
+                }
+
+                int spaceBefore = spacesToGive-- > 0 ? maxSpaceBetweenItems : 0;
+
+                // subsequent items are placed one space after the previous item
+                positions [i] = positions [i - 1] + sizes [i - 1] + spaceBefore;
+            }
+        }
+        else if (sizes.Length == 1)
+        {
+            CheckSizeCannotBeNegative (0, in sizes);
+            positions [0] = (containerSize - sizes [0]) / 2; // single item is centered
+        }
+
+        return positions;
+    }
+
+    internal static int [] End (ref readonly int [] sizes, int containerSize, int totalItemsSize, int maxSpaceBetweenItems, int spacesToGive)
+    {
+        var positions = new int [sizes.Length]; // positions of the items. the return value.
+        int currentPosition = containerSize - totalItemsSize - spacesToGive;
+
+        for (var i = 0; i < sizes.Length; i++)
+        {
+            CheckSizeCannotBeNegative (i, in sizes);
+            int spaceBefore = spacesToGive-- > 0 ? maxSpaceBetweenItems : 0;
+
+            positions [i] = currentPosition;
+            currentPosition += sizes [i] + spaceBefore;
+        }
+
+        return positions;
+    }
+
+    private static void CheckSizeCannotBeNegative (int i, ref readonly int [] sizes)
+    {
+        if (sizes [i] < 0)
+        {
+            throw new ArgumentException ("The size of an item cannot be negative.");
+        }
+    }
+}

+ 82 - 0
Terminal.Gui/Drawing/Alignment.cs

@@ -0,0 +1,82 @@
+using Terminal.Gui.Analyzers.Internal.Attributes;
+
+namespace Terminal.Gui;
+
+/// <summary>
+///     Determines the position of items when arranged in a container.
+/// </summary>
+[GenerateEnumExtensionMethods (FastHasFlags = true)]
+
+public enum Alignment
+{
+    /// <summary>
+    ///     The items will be aligned to the start (left or top) of the container.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the end items will be clipped (their locations
+    ///         will be greater than the container size).
+    ///     </para>
+    ///     <para>
+    ///         The <see cref="AlignmentModes"/> enumeration provides additional options for aligning items in a container.
+    ///     </para>
+    /// </remarks>
+    /// <example>
+    ///     <c>
+    ///         |111 2222 33333    |
+    ///     </c>
+    /// </example>
+    Start = 0,
+
+    /// <summary>
+    ///     The items will be aligned to the end (right or bottom) of the container.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the start items will be clipped (their locations
+    ///         will be negative).
+    ///     </para>
+    ///     <para>
+    ///         The <see cref="AlignmentModes"/> enumeration provides additional options for aligning items in a container.
+    ///     </para>
+    /// </remarks>
+    /// <example>
+    ///     <c>
+    ///         |    111 2222 33333|
+    ///     </c>
+    /// </example>
+    End,
+
+    /// <summary>
+    ///     Center in the available space.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///     If centering is not possible, the group will be left-aligned.
+    ///     </para>
+    ///     <para>
+    ///         Extra space will be distributed between the items, biased towards the left.
+    ///     </para>
+    /// </remarks>
+    /// <example>
+    ///     <c>
+    ///         |  111 2222 33333  |
+    ///     </c>
+    /// </example>
+    Center,
+
+    /// <summary>
+    ///     The items will fill the available space.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         Extra space will be distributed between the items, biased towards the end.
+    ///     </para>
+    /// </remarks>
+    /// <example>
+    ///     <c>
+    ///        |111  2222    33333|
+    ///     </c>
+    /// </example>
+    Fill,
+}

+ 52 - 0
Terminal.Gui/Drawing/AlignmentModes.cs

@@ -0,0 +1,52 @@
+using Terminal.Gui.Analyzers.Internal.Attributes;
+
+namespace Terminal.Gui;
+
+/// <summary>
+///     Determines alignment modes for <see cref="Alignment"/>.
+/// </summary>
+[Flags]
+[GenerateEnumExtensionMethods (FastHasFlags = true)]
+public enum AlignmentModes
+{
+    /// <summary>
+    ///     The items will be arranged from start (left/top) to end (right/bottom).
+    /// </summary>
+    StartToEnd = 0,
+
+    /// <summary>
+    ///     The items will be arranged from end (right/bottom) to start (left/top).
+    /// </summary>
+    /// <remarks>
+    ///     Not implemented.
+    /// </remarks>
+    EndToStart = 1,
+
+    /// <summary>
+    ///     At least one space will be added between items. Useful for justifying text where at least one space is needed.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the total size of the items is greater than the container size, the space between items will be ignored
+    ///         starting from the end.
+    ///     </para>
+    /// </remarks>
+    AddSpaceBetweenItems = 2,
+
+    /// <summary>
+    ///    When aligning via <see cref="Alignment.Start"/> or <see cref="Alignment.End"/>, the item opposite to the alignment (the first or last item) will be ignored.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the end items will be clipped (their locations
+    ///         will be greater than the container size).
+    ///     </para>
+    /// </remarks>
+    /// <example>
+    ///     <c>
+    ///         Start: |111 2222     33333|
+    ///         End:   |111     2222 33333|
+    ///     </c>
+    /// </example>
+    IgnoreFirstOrLast = 4,
+}

+ 0 - 333
Terminal.Gui/Drawing/Justification.cs

@@ -1,333 +0,0 @@
-namespace Terminal.Gui;
-
-/// <summary>
-///     Controls how the <see cref="Justifier"/> justifies items within a container. 
-/// </summary>
-public enum Justification
-{
-    /// <summary>
-    ///     The items will be aligned to the left.
-    ///     Set <see cref="Justifier.PutSpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
-    ///     each item.
-    /// </summary>
-    /// <example>
-    ///     <c>
-    ///         111 2222 33333
-    ///     </c>
-    /// </example>
-    Left,
-
-    /// <summary>
-    ///     The items will be aligned to the right.
-    ///     Set <see cref="Justifier.PutSpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
-    ///     each item.
-    /// </summary>
-    /// <example>
-    ///     <c>
-    ///         111 2222 33333
-    ///     </c>
-    /// </example>
-    Right,
-
-    /// <summary>
-    ///     The group will be centered in the container.
-    ///     If centering is not possible, the group will be left-justified.
-    ///     Set <see cref="Justifier.PutSpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
-    ///     each item.
-    /// </summary>
-    /// <example>
-    ///     <c>
-    ///         111 2222 33333
-    ///     </c>
-    /// </example>
-    Centered,
-
-    /// <summary>
-    ///     The items will be justified. Space will be added between the items such that the first item
-    ///     is at the start and the right side of the last item against the end.
-    ///     Set <see cref="Justifier.PutSpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
-    ///     each item.
-    /// </summary>
-    /// <example>
-    ///     <c>
-    ///         111    2222     33333
-    ///     </c>
-    /// </example>
-    Justified,
-
-    /// <summary>
-    ///     The first item will be aligned to the left and the remaining will aligned to the right.
-    ///     Set <see cref="Justifier.PutSpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
-    ///     each item.
-    /// </summary>
-    /// <example>
-    ///     <c>
-    ///         111        2222 33333
-    ///     </c>
-    /// </example>
-    FirstLeftRestRight,
-
-    /// <summary>
-    ///     The last item will be aligned to the right and the remaining will aligned to the left.
-    ///     Set <see cref="Justifier.PutSpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
-    ///     each item.
-    /// </summary>
-    /// <example>
-    ///     <c>
-    ///         111 2222        33333
-    ///     </c>
-    /// </example>
-    LastRightRestLeft
-}
-
-/// <summary>
-///     Justifies items within a container based on the specified <see cref="Justification"/>.
-/// </summary>
-public class Justifier
-{
-    /// <summary>
-    /// Gets or sets how the <see cref="Justifier"/> justifies items within a container.
-    /// </summary>
-    public Justification Justification { get; set; }
-
-    /// <summary>
-    /// The size of the container.
-    /// </summary>
-    public int ContainerSize { get; set; }
-
-    /// <summary>
-    ///     Gets or sets whether <see cref="Justify(int[])"/> puts a space is placed between items. Default is <see langword="false"/>. If <see langword="true"/>, a space will be
-    ///     placed between each item, which is useful for justifying text.
-    /// </summary>
-    public bool PutSpaceBetweenItems { get; set; }
-
-    /// <summary>
-    ///     Takes a list of items and returns their positions when justified within a container <see name="ContainerSize"/> wide based on the specified
-    ///     <see cref="Justification"/>.
-    /// </summary>
-    /// <param name="sizes">The sizes of the items to justify.</param>
-    /// <returns>The locations of the items, from left to right.</returns>
-    public int [] Justify (int [] sizes)
-    {
-        return Justify (Justification, PutSpaceBetweenItems, ContainerSize, sizes);
-    }
-
-    /// <summary>
-    ///     Takes a list of items and returns their positions when justified within a container <paramref name="containerSize"/> wide based on the specified
-    ///     <see cref="Justification"/>.
-    /// </summary>
-    /// <param name="sizes">The sizes of the items to justify.</param>
-    /// <param name="justification">The justification style.</param>
-    /// <param name="putSpaceBetweenItems"></param>
-    /// <param name="containerSize">The size of the container.</param>
-    /// <returns>The locations of the items, from left to right.</returns>
-    public static int [] Justify (Justification justification, bool putSpaceBetweenItems, int containerSize, int [] sizes)
-    {
-        if (sizes.Length == 0)
-        {
-            return new int [] { };
-        }
-
-        int maxSpaceBetweenItems = putSpaceBetweenItems ? 1 : 0;
-
-        var positions = new int [sizes.Length]; // positions of the items. the return value.
-        int totalItemsSize = sizes.Sum ();
-        int totalGaps = sizes.Length - 1; // total gaps between items
-        int totalItemsAndSpaces = totalItemsSize + totalGaps * maxSpaceBetweenItems; // total size of items and spaces if we had enough room
-
-        int spaces = totalGaps * maxSpaceBetweenItems; // We'll decrement this below to place one space between each item until we run out
-        if (totalItemsSize >= containerSize)
-        {
-            spaces = 0;
-        }
-        else if (totalItemsAndSpaces > containerSize)
-        {
-            spaces = containerSize - totalItemsSize;
-        }
-
-        switch (justification)
-        {
-            case Justification.Left:
-                var currentPosition = 0;
-
-                for (var i = 0; i < sizes.Length; i++)
-                {
-                    if (sizes [i] < 0)
-                    {
-                        throw new ArgumentException ("The size of an item cannot be negative.");
-                    }
-
-                    if (i == 0)
-                    {
-                        positions [0] = 0; // first item position
-
-                        continue;
-                    }
-
-                    int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
-
-                    // subsequent items are placed one space after the previous item
-                    positions [i] = positions [i - 1] + sizes [i - 1] + spaceBefore;
-                }
-
-                break;
-            case Justification.Right:
-                currentPosition = Math.Max (0, containerSize - totalItemsSize - spaces);
-
-                for (var i = 0; i < sizes.Length; i++)
-                {
-                    if (sizes [i] < 0)
-                    {
-                        throw new ArgumentException ("The size of an item cannot be negative.");
-                    }
-
-                    int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
-
-                    positions [i] = currentPosition;
-                    currentPosition += sizes [i] + spaceBefore;
-                }
-
-                break;
-
-            case Justification.Centered:
-                if (sizes.Length > 1)
-                {
-                    // remaining space to be distributed before first and after the items
-                    int remainingSpace = Math.Max (0, containerSize - totalItemsSize - spaces);
-
-                    for (var i = 0; i < sizes.Length; i++)
-                    {
-                        if (sizes [i] < 0)
-                        {
-                            throw new ArgumentException ("The size of an item cannot be negative.");
-                        }
-
-                        if (i == 0)
-                        {
-                            positions [i] = remainingSpace / 2; // first item position
-
-                            continue;
-                        }
-
-                        int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
-
-                        // subsequent items are placed one space after the previous item
-                        positions [i] = positions [i - 1] + sizes [i - 1] + spaceBefore;
-                    }
-                }
-                else if (sizes.Length == 1)
-                {
-                    if (sizes [0] < 0)
-                    {
-                        throw new ArgumentException ("The size of an item cannot be negative.");
-                    }
-
-                    positions [0] = (containerSize - sizes [0]) / 2; // single item is centered
-                }
-
-                break;
-
-            case Justification.Justified:
-                int spaceBetween = sizes.Length > 1 ? (containerSize - totalItemsSize) / (sizes.Length - 1) : 0;
-                int remainder = sizes.Length > 1 ? (containerSize - totalItemsSize) % (sizes.Length - 1) : 0;
-                currentPosition = 0;
-
-                for (var i = 0; i < sizes.Length; i++)
-                {
-                    if (sizes [i] < 0)
-                    {
-                        throw new ArgumentException ("The size of an item cannot be negative.");
-                    }
-
-                    positions [i] = currentPosition;
-                    int extraSpace = i < remainder ? 1 : 0;
-                    currentPosition += sizes [i] + spaceBetween + extraSpace;
-                }
-
-                break;
-
-            // 111 2222        33333
-            case Justification.LastRightRestLeft:
-                if (sizes.Length > 1)
-                {
-                    currentPosition = 0;
-
-                    for (var i = 0; i < sizes.Length; i++)
-                    {
-                        if (sizes [i] < 0)
-                        {
-                            throw new ArgumentException ("The size of an item cannot be negative.");
-                        }
-
-                        if (i < sizes.Length - 1)
-                        {
-                            int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
-
-                            positions [i] = currentPosition;
-                            currentPosition += sizes [i] + spaceBefore;
-                        }
-                    }
-
-                    positions [sizes.Length - 1] = containerSize - sizes [sizes.Length - 1];
-                }
-                else if (sizes.Length == 1)
-                {
-                    if (sizes [0] < 0)
-                    {
-                        throw new ArgumentException ("The size of an item cannot be negative.");
-                    }
-
-                    positions [0] = containerSize - sizes [0]; // single item is flush right
-                }
-
-                break;
-
-            // 111        2222 33333
-            case Justification.FirstLeftRestRight:
-                if (sizes.Length > 1)
-                {
-                    currentPosition = 0;
-                    positions [0] = currentPosition; // first item is flush left
-
-                    for (int i = sizes.Length - 1; i >= 0; i--)
-                    {
-                        if (sizes [i] < 0)
-                        {
-                            throw new ArgumentException ("The size of an item cannot be negative.");
-                        }
-
-                        if (i == sizes.Length - 1)
-                        {
-                            // start at right
-                            currentPosition = containerSize - sizes [i];
-                            positions [i] = currentPosition;
-                        }
-
-                        if (i < sizes.Length - 1 && i > 0)
-                        {
-                            int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
-
-                            positions [i] = currentPosition - sizes [i] - spaceBefore;
-                            currentPosition = positions [i];
-                        }
-                    }
-                }
-                else if (sizes.Length == 1)
-                {
-                    if (sizes [0] < 0)
-                    {
-                        throw new ArgumentException ("The size of an item cannot be negative.");
-                    }
-
-                    positions [0] = 0; // single item is flush left
-                }
-
-                break;
-
-            default:
-                throw new ArgumentOutOfRangeException (nameof (justification), justification, null);
-        }
-
-        return positions;
-    }
-}

+ 2 - 2
Terminal.Gui/Drawing/Thickness.cs

@@ -230,8 +230,8 @@ public class Thickness : IEquatable<Thickness>
             var tf = new TextFormatter
             var tf = new TextFormatter
             {
             {
                 Text = label is null ? string.Empty : $"{label} {this}",
                 Text = label is null ? string.Empty : $"{label} {this}",
-                Alignment = TextAlignment.Centered,
-                VerticalAlignment = VerticalTextAlignment.Bottom,
+                Alignment = Alignment.Center,
+                VerticalAlignment = Alignment.End,
                 AutoSize = true
                 AutoSize = true
             };
             };
             tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute, rect);
             tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute, rect);

+ 2 - 1
Terminal.Gui/Resources/config.json

@@ -24,7 +24,8 @@
   "Themes": [
   "Themes": [
     {
     {
       "Default": {
       "Default": {
-        "Dialog.DefaultButtonAlignment": "Center",
+        "Dialog.DefaultButtonAlignment": "End",
+        "Dialog.DefaultButtonAlignmentModes": "AddSpaceBetweenItems",
         "FrameView.DefaultBorderStyle": "Single",
         "FrameView.DefaultBorderStyle": "Single",
         "Window.DefaultBorderStyle": "Single",
         "Window.DefaultBorderStyle": "Single",
         "ColorSchemes": [
         "ColorSchemes": [

+ 0 - 20
Terminal.Gui/Text/TextAlignment.cs

@@ -1,20 +0,0 @@
-namespace Terminal.Gui;
-
-/// <summary>Text alignment enumeration, controls how text is displayed.</summary>
-public enum TextAlignment
-{
-    /// <summary>The text will be left-aligned.</summary>
-    Left,
-
-    /// <summary>The text will be right-aligned.</summary>
-    Right,
-
-    /// <summary>The text will be centered horizontally.</summary>
-    Centered,
-
-    /// <summary>
-    ///     The text will be justified (spaces will be added to existing spaces such that the text fills the container
-    ///     horizontally).
-    /// </summary>
-    Justified
-}

+ 52 - 49
Terminal.Gui/Text/TextFormatter.cs

@@ -1,3 +1,5 @@
+using System.Diagnostics;
+
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
 /// <summary>
 /// <summary>
@@ -15,14 +17,14 @@ public class TextFormatter
     private Size _size;
     private Size _size;
     private int _tabWidth = 4;
     private int _tabWidth = 4;
     private string _text;
     private string _text;
-    private TextAlignment _textAlignment;
+    private Alignment _textAlignment = Alignment.Start;
     private TextDirection _textDirection;
     private TextDirection _textDirection;
-    private VerticalTextAlignment _textVerticalAlignment;
+    private Alignment _textVerticalAlignment = Alignment.Start;
     private bool _wordWrap = true;
     private bool _wordWrap = true;
 
 
-    /// <summary>Controls the horizontal text-alignment property.</summary>
+    /// <summary>Get or sets the horizontal text alignment.</summary>
     /// <value>The text alignment.</value>
     /// <value>The text alignment.</value>
-    public TextAlignment Alignment
+    public Alignment Alignment
     {
     {
         get => _textAlignment;
         get => _textAlignment;
         set => _textAlignment = EnableNeedsFormat (value);
         set => _textAlignment = EnableNeedsFormat (value);
@@ -32,8 +34,7 @@ public class TextFormatter
     /// <remarks>
     /// <remarks>
     ///     <para>Used when <see cref="View"/> is using <see cref="Dim.Auto"/> to resize the view's <see cref="View.Viewport"/> to fit <see cref="Size"/>.</para>
     ///     <para>Used when <see cref="View"/> is using <see cref="Dim.Auto"/> to resize the view's <see cref="View.Viewport"/> to fit <see cref="Size"/>.</para>
     ///     <para>
     ///     <para>
-    ///         AutoSize is ignored if <see cref="TextAlignment.Justified"/> and
-    ///         <see cref="VerticalTextAlignment.Justified"/> are used.
+    ///         AutoSize is ignored if <see cref="Gui.Alignment.Fill"/> is used.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
     public bool AutoSize
     public bool AutoSize
@@ -68,9 +69,8 @@ public class TextFormatter
     ///     Only the first HotKey specifier found in <see cref="Text"/> is supported.
     ///     Only the first HotKey specifier found in <see cref="Text"/> is supported.
     /// </remarks>
     /// </remarks>
     /// <param name="isWidth">
     /// <param name="isWidth">
-    ///     If <see langword="true"/> (the default) the width required for the HotKey specifier is returned. Otherwise the
-    ///     height
-    ///     is returned.
+    ///     If <see langword="true"/> (the default) the width required for the HotKey specifier is returned. Otherwise, the
+    ///     height is returned.
     /// </param>
     /// </param>
     /// <returns>
     /// <returns>
     ///     The number of characters required for the <see cref="TextFormatter.HotKeySpecifier"/>. If the text
     ///     The number of characters required for the <see cref="TextFormatter.HotKeySpecifier"/>. If the text
@@ -97,8 +97,8 @@ public class TextFormatter
     /// </summary>
     /// </summary>
     public int CursorPosition { get; internal set; }
     public int CursorPosition { get; internal set; }
 
 
-    /// <summary>Controls the text-direction property.</summary>
-    /// <value>The text vertical alignment.</value>
+    /// <summary>Gets or sets the text-direction.</summary>
+    /// <value>The text direction.</value>
     public TextDirection Direction
     public TextDirection Direction
     {
     {
         get => _textDirection;
         get => _textDirection;
@@ -112,8 +112,7 @@ public class TextFormatter
             }
             }
         }
         }
     }
     }
-
-
+    
     /// <summary>
     /// <summary>
     ///     Determines if the viewport width will be used or only the text width will be used,
     ///     Determines if the viewport width will be used or only the text width will be used,
     ///     If <see langword="true"/> all the viewport area will be filled with whitespaces and the same background color
     ///     If <see langword="true"/> all the viewport area will be filled with whitespaces and the same background color
@@ -223,9 +222,9 @@ public class TextFormatter
         }
         }
     }
     }
 
 
-    /// <summary>Controls the vertical text-alignment property.</summary>
+    /// <summary>Gets or sets the vertical text-alignment.</summary>
     /// <value>The text vertical alignment.</value>
     /// <value>The text vertical alignment.</value>
-    public VerticalTextAlignment VerticalAlignment
+    public Alignment VerticalAlignment
     {
     {
         get => _textVerticalAlignment;
         get => _textVerticalAlignment;
         set => _textVerticalAlignment = EnableNeedsFormat (value);
         set => _textVerticalAlignment = EnableNeedsFormat (value);
@@ -318,10 +317,10 @@ public class TextFormatter
 
 
             // When text is justified, we lost left or right, so we use the direction to align. 
             // When text is justified, we lost left or right, so we use the direction to align. 
 
 
-            int x, y;
+            int x = 0, y = 0;
 
 
             // Horizontal Alignment
             // Horizontal Alignment
-            if (Alignment is TextAlignment.Right)
+            if (Alignment is Alignment.End)
             {
             {
                 if (isVertical)
                 if (isVertical)
                 {
                 {
@@ -336,7 +335,7 @@ public class TextFormatter
                     CursorPosition = screen.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0);
                     CursorPosition = screen.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0);
                 }
                 }
             }
             }
-            else if (Alignment is TextAlignment.Left)
+            else if (Alignment is Alignment.Start)
             {
             {
                 if (isVertical)
                 if (isVertical)
                 {
                 {
@@ -352,7 +351,7 @@ public class TextFormatter
 
 
                 CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0;
                 CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0;
             }
             }
-            else if (Alignment is TextAlignment.Justified)
+            else if (Alignment is Alignment.Fill)
             {
             {
                 if (isVertical)
                 if (isVertical)
                 {
                 {
@@ -375,7 +374,7 @@ public class TextFormatter
 
 
                 CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0;
                 CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0;
             }
             }
-            else if (Alignment is TextAlignment.Centered)
+            else if (Alignment is Alignment.Center)
             {
             {
                 if (isVertical)
                 if (isVertical)
                 {
                 {
@@ -395,11 +394,13 @@ public class TextFormatter
             }
             }
             else
             else
             {
             {
-                throw new ArgumentOutOfRangeException ($"{nameof (Alignment)}");
+                Debug.WriteLine ($"Unsupported Alignment: {nameof (VerticalAlignment)}");
+
+                return;
             }
             }
 
 
             // Vertical Alignment
             // Vertical Alignment
-            if (VerticalAlignment is VerticalTextAlignment.Bottom)
+            if (VerticalAlignment is Alignment.End)
             {
             {
                 if (isVertical)
                 if (isVertical)
                 {
                 {
@@ -410,7 +411,7 @@ public class TextFormatter
                     y = screen.Bottom - linesFormatted.Count + line;
                     y = screen.Bottom - linesFormatted.Count + line;
                 }
                 }
             }
             }
-            else if (VerticalAlignment is VerticalTextAlignment.Top)
+            else if (VerticalAlignment is Alignment.Start)
             {
             {
                 if (isVertical)
                 if (isVertical)
                 {
                 {
@@ -421,7 +422,7 @@ public class TextFormatter
                     y = screen.Top + line;
                     y = screen.Top + line;
                 }
                 }
             }
             }
-            else if (VerticalAlignment is VerticalTextAlignment.Justified)
+            else if (VerticalAlignment is Alignment.Fill)
             {
             {
                 if (isVertical)
                 if (isVertical)
                 {
                 {
@@ -435,7 +436,7 @@ public class TextFormatter
                         line < linesFormatted.Count - 1 ? screen.Height - interval <= 1 ? screen.Top + 1 : screen.Top + line * interval : screen.Bottom - 1;
                         line < linesFormatted.Count - 1 ? screen.Height - interval <= 1 ? screen.Top + 1 : screen.Top + line * interval : screen.Bottom - 1;
                 }
                 }
             }
             }
-            else if (VerticalAlignment is VerticalTextAlignment.Middle)
+            else if (VerticalAlignment is Alignment.Center)
             {
             {
                 if (isVertical)
                 if (isVertical)
                 {
                 {
@@ -450,7 +451,9 @@ public class TextFormatter
             }
             }
             else
             else
             {
             {
-                throw new ArgumentOutOfRangeException ($"{nameof (VerticalAlignment)}");
+               Debug.WriteLine ($"Unsupported Alignment: {nameof (VerticalAlignment)}");
+
+               return;
             }
             }
 
 
             int colOffset = screen.X < 0 ? Math.Abs (screen.X) : 0;
             int colOffset = screen.X < 0 ? Math.Abs (screen.X) : 0;
@@ -471,8 +474,8 @@ public class TextFormatter
                 {
                 {
                     if (idx < 0
                     if (idx < 0
                         || (isVertical
                         || (isVertical
-                                ? VerticalAlignment != VerticalTextAlignment.Bottom && current < 0
-                                : Alignment != TextAlignment.Right && x + current + colOffset < 0))
+                                ? VerticalAlignment != Alignment.End && current < 0
+                                : Alignment != Alignment.End && x + current + colOffset < 0))
                     {
                     {
                         current++;
                         current++;
 
 
@@ -561,7 +564,7 @@ public class TextFormatter
 
 
                 if (HotKeyPos > -1 && idx == HotKeyPos)
                 if (HotKeyPos > -1 && idx == HotKeyPos)
                 {
                 {
-                    if ((isVertical && VerticalAlignment == VerticalTextAlignment.Justified) || (!isVertical && Alignment == TextAlignment.Justified))
+                    if ((isVertical && VerticalAlignment == Alignment.Fill) || (!isVertical && Alignment == Alignment.Fill))
                     {
                     {
                         CursorPosition = idx - start;
                         CursorPosition = idx - start;
                     }
                     }
@@ -699,7 +702,7 @@ public class TextFormatter
                 _lines = Format (
                 _lines = Format (
                                  text,
                                  text,
                                  Size.Height,
                                  Size.Height,
-                                 VerticalAlignment == VerticalTextAlignment.Justified,
+                                 VerticalAlignment == Alignment.Fill,
                                  Size.Width > colsWidth && WordWrap,
                                  Size.Width > colsWidth && WordWrap,
                                  PreserveTrailingSpaces,
                                  PreserveTrailingSpaces,
                                  TabWidth,
                                  TabWidth,
@@ -723,7 +726,7 @@ public class TextFormatter
                 _lines = Format (
                 _lines = Format (
                                  text,
                                  text,
                                  Size.Width,
                                  Size.Width,
-                                 Alignment == TextAlignment.Justified,
+                                 Alignment == Alignment.Fill,
                                  Size.Height > 1 && WordWrap,
                                  Size.Height > 1 && WordWrap,
                                  PreserveTrailingSpaces,
                                  PreserveTrailingSpaces,
                                  TabWidth,
                                  TabWidth,
@@ -977,7 +980,7 @@ public class TextFormatter
         // if value is not wide enough
         // if value is not wide enough
         if (text.EnumerateRunes ().Sum (c => c.GetColumns ()) < width)
         if (text.EnumerateRunes ().Sum (c => c.GetColumns ()) < width)
         {
         {
-            // pad it out with spaces to the given alignment
+            // pad it out with spaces to the given Alignment
             int toPad = width - text.EnumerateRunes ().Sum (c => c.GetColumns ());
             int toPad = width - text.EnumerateRunes ().Sum (c => c.GetColumns ());
 
 
             return text + new string (' ', toPad);
             return text + new string (' ', toPad);
@@ -999,7 +1002,7 @@ public class TextFormatter
     /// <param name="textFormatter"><see cref="TextFormatter"/> instance to access any of his objects.</param>
     /// <param name="textFormatter"><see cref="TextFormatter"/> instance to access any of his objects.</param>
     /// <returns>A list of word wrapped lines.</returns>
     /// <returns>A list of word wrapped lines.</returns>
     /// <remarks>
     /// <remarks>
-    ///     <para>This method does not do any justification.</para>
+    ///     <para>This method does not do any alignment.</para>
     ///     <para>This method strips Newline ('\n' and '\r\n') sequences before processing.</para>
     ///     <para>This method strips Newline ('\n' and '\r\n') sequences before processing.</para>
     ///     <para>
     ///     <para>
     ///         If <paramref name="preserveTrailingSpaces"/> is <see langword="false"/> at most one space will be preserved
     ///         If <paramref name="preserveTrailingSpaces"/> is <see langword="false"/> at most one space will be preserved
@@ -1031,7 +1034,7 @@ public class TextFormatter
         List<Rune> runes = StripCRLF (text).ToRuneList ();
         List<Rune> runes = StripCRLF (text).ToRuneList ();
 
 
         int start = Math.Max (
         int start = Math.Max (
-                              !runes.Contains ((Rune)' ') && textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom } && IsVerticalDirection (textDirection)
+                              !runes.Contains ((Rune)' ') && textFormatter is { VerticalAlignment: Alignment.End } && IsVerticalDirection (textDirection)
                                   ? runes.Count - width
                                   ? runes.Count - width
                                   : 0,
                                   : 0,
                               0);
                               0);
@@ -1249,7 +1252,7 @@ public class TextFormatter
     ///     The number of columns to clip the text to. Text longer than <paramref name="width"/> will be
     ///     The number of columns to clip the text to. Text longer than <paramref name="width"/> will be
     ///     clipped.
     ///     clipped.
     /// </param>
     /// </param>
-    /// <param name="talign">Alignment.</param>
+    /// <param name="textAlignment">Alignment.</param>
     /// <param name="textDirection">The text direction.</param>
     /// <param name="textDirection">The text direction.</param>
     /// <param name="tabWidth">The number of columns used for a tab.</param>
     /// <param name="tabWidth">The number of columns used for a tab.</param>
     /// <param name="textFormatter"><see cref="TextFormatter"/> instance to access any of his objects.</param>
     /// <param name="textFormatter"><see cref="TextFormatter"/> instance to access any of his objects.</param>
@@ -1257,13 +1260,13 @@ public class TextFormatter
     public static string ClipAndJustify (
     public static string ClipAndJustify (
         string text,
         string text,
         int width,
         int width,
-        TextAlignment talign,
+        Alignment textAlignment,
         TextDirection textDirection = TextDirection.LeftRight_TopBottom,
         TextDirection textDirection = TextDirection.LeftRight_TopBottom,
         int tabWidth = 0,
         int tabWidth = 0,
         TextFormatter textFormatter = null
         TextFormatter textFormatter = null
     )
     )
     {
     {
-        return ClipAndJustify (text, width, talign == TextAlignment.Justified, textDirection, tabWidth, textFormatter);
+        return ClipAndJustify (text, width, textAlignment == Alignment.Fill, textDirection, tabWidth, textFormatter);
     }
     }
 
 
     /// <summary>Justifies text within a specified width.</summary>
     /// <summary>Justifies text within a specified width.</summary>
@@ -1304,12 +1307,12 @@ public class TextFormatter
         {
         {
             if (IsHorizontalDirection (textDirection))
             if (IsHorizontalDirection (textDirection))
             {
             {
-                if (textFormatter is { Alignment: TextAlignment.Right })
+                if (textFormatter is { Alignment: Alignment.End })
                 {
                 {
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                 }
                 }
 
 
-                if (textFormatter is { Alignment: TextAlignment.Centered })
+                if (textFormatter is { Alignment: Alignment.Center })
                 {
                 {
                     return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
                     return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
                 }
                 }
@@ -1319,12 +1322,12 @@ public class TextFormatter
 
 
             if (IsVerticalDirection (textDirection))
             if (IsVerticalDirection (textDirection))
             {
             {
-                if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom })
+                if (textFormatter is { VerticalAlignment: Alignment.End })
                 {
                 {
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                 }
                 }
 
 
-                if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Middle })
+                if (textFormatter is { VerticalAlignment: Alignment.Center })
                 {
                 {
                     return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
                     return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
                 }
                 }
@@ -1342,14 +1345,14 @@ public class TextFormatter
 
 
         if (IsHorizontalDirection (textDirection))
         if (IsHorizontalDirection (textDirection))
         {
         {
-            if (textFormatter is { Alignment: TextAlignment.Right })
+            if (textFormatter is { Alignment: Alignment.End })
             {
             {
                 if (GetRuneWidth (text, tabWidth, textDirection) > width)
                 if (GetRuneWidth (text, tabWidth, textDirection) > width)
                 {
                 {
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                 }
                 }
             }
             }
-            else if (textFormatter is { Alignment: TextAlignment.Centered })
+            else if (textFormatter is { Alignment: Alignment.Center })
             {
             {
                 return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
                 return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
             }
             }
@@ -1361,14 +1364,14 @@ public class TextFormatter
 
 
         if (IsVerticalDirection (textDirection))
         if (IsVerticalDirection (textDirection))
         {
         {
-            if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom })
+            if (textFormatter is { VerticalAlignment: Alignment.End })
             {
             {
                 if (runes.Count - zeroLength > width)
                 if (runes.Count - zeroLength > width)
                 {
                 {
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                 }
                 }
             }
             }
-            else if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Middle })
+            else if (textFormatter is { VerticalAlignment: Alignment.Center })
             {
             {
                 return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
                 return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
             }
             }
@@ -1475,7 +1478,7 @@ public class TextFormatter
     /// <summary>Formats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries.</summary>
     /// <summary>Formats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries.</summary>
     /// <param name="text"></param>
     /// <param name="text"></param>
     /// <param name="width">The number of columns to constrain the text to for word wrapping and clipping.</param>
     /// <param name="width">The number of columns to constrain the text to for word wrapping and clipping.</param>
-    /// <param name="talign">Specifies how the text will be aligned horizontally.</param>
+    /// <param name="textAlignment">Specifies how the text will be aligned horizontally.</param>
     /// <param name="wordWrap">
     /// <param name="wordWrap">
     ///     If <see langword="true"/>, the text will be wrapped to new lines no longer than
     ///     If <see langword="true"/>, the text will be wrapped to new lines no longer than
     ///     <paramref name="width"/>. If <see langword="false"/>, forces text to fit a single line. Line breaks are converted
     ///     <paramref name="width"/>. If <see langword="false"/>, forces text to fit a single line. Line breaks are converted
@@ -1498,7 +1501,7 @@ public class TextFormatter
     public static List<string> Format (
     public static List<string> Format (
         string text,
         string text,
         int width,
         int width,
-        TextAlignment talign,
+        Alignment textAlignment,
         bool wordWrap,
         bool wordWrap,
         bool preserveTrailingSpaces = false,
         bool preserveTrailingSpaces = false,
         int tabWidth = 0,
         int tabWidth = 0,
@@ -1510,7 +1513,7 @@ public class TextFormatter
         return Format (
         return Format (
                        text,
                        text,
                        width,
                        width,
-                       talign == TextAlignment.Justified,
+                       textAlignment == Alignment.Fill,
                        wordWrap,
                        wordWrap,
                        preserveTrailingSpaces,
                        preserveTrailingSpaces,
                        tabWidth,
                        tabWidth,
@@ -1884,7 +1887,7 @@ public class TextFormatter
         return lineIdx;
         return lineIdx;
     }
     }
 
 
-    /// <summary>Calculates the rectangle required to hold text, assuming no word wrapping or justification.</summary>
+    /// <summary>Calculates the rectangle required to hold text, assuming no word wrapping or alignment.</summary>
     /// <remarks>
     /// <remarks>
     ///     This API will return incorrect results if the text includes glyphs who's width is dependent on surrounding
     ///     This API will return incorrect results if the text includes glyphs who's width is dependent on surrounding
     ///     glyphs (e.g. Arabic).
     ///     glyphs (e.g. Arabic).

+ 0 - 20
Terminal.Gui/Text/VerticalTextAlignment.cs

@@ -1,20 +0,0 @@
-namespace Terminal.Gui;
-
-/// <summary>Vertical text alignment enumeration, controls how text is displayed.</summary>
-public enum VerticalTextAlignment
-{
-    /// <summary>The text will be top-aligned.</summary>
-    Top,
-
-    /// <summary>The text will be bottom-aligned.</summary>
-    Bottom,
-
-    /// <summary>The text will centered vertically.</summary>
-    Middle,
-
-    /// <summary>
-    ///     The text will be justified (spaces will be added to existing spaces such that the text fills the container
-    ///     vertically).
-    /// </summary>
-    Justified
-}

+ 1 - 1
Terminal.Gui/View/Layout/Dim.cs

@@ -150,7 +150,7 @@ public abstract class Dim
     /// <summary>Creates a percentage <see cref="Dim"/> object that is a percentage of the width or height of the SuperView.</summary>
     /// <summary>Creates a percentage <see cref="Dim"/> object that is a percentage of the width or height of the SuperView.</summary>
     /// <returns>The percent <see cref="Dim"/> object.</returns>
     /// <returns>The percent <see cref="Dim"/> object.</returns>
     /// <param name="percent">A value between 0 and 100 representing the percentage.</param>
     /// <param name="percent">A value between 0 and 100 representing the percentage.</param>
-    /// <param name="mode"></param>
+    /// <param name="mode">the mode. Defaults to <see cref="DimPercentMode.ContentSize"/>.</param>
     /// <example>
     /// <example>
     ///     This initializes a <see cref="TextField"/> that will be centered horizontally, is 50% of the way down, is 30% the
     ///     This initializes a <see cref="TextField"/> that will be centered horizontally, is 50% of the way down, is 30% the
     ///     height,
     ///     height,

+ 66 - 13
Terminal.Gui/View/Layout/DimAuto.cs

@@ -60,7 +60,8 @@ public class DimAuto () : Dim
         var subviewsSize = 0;
         var subviewsSize = 0;
 
 
         int autoMin = MinimumContentDim?.GetAnchor (superviewContentSize) ?? 0;
         int autoMin = MinimumContentDim?.GetAnchor (superviewContentSize) ?? 0;
-        
+        int autoMax = MaximumContentDim?.GetAnchor (superviewContentSize) ?? int.MaxValue;
+
         if (Style.FastHasFlags (DimAutoStyle.Text))
         if (Style.FastHasFlags (DimAutoStyle.Text))
         {
         {
             textSize = int.Max (autoMin, dimension == Dimension.Width ? us.TextFormatter.Size.Width : us.TextFormatter.Size.Height);
             textSize = int.Max (autoMin, dimension == Dimension.Width ? us.TextFormatter.Size.Width : us.TextFormatter.Size.Height);
@@ -79,13 +80,31 @@ public class DimAuto () : Dim
 
 
                 List<View> subviews;
                 List<View> subviews;
 
 
+                #region Not Anchored and Are Not Dependent
+                // Start with subviews that are not anchored to the end, aligned, or dependent on content size
+                // [x] PosAnchorEnd
+                // [x] PosAlign
+                // [ ] PosCenter
+                // [ ] PosPercent
+                // [ ] PosView
+                // [ ] PosFunc
+                // [x] DimFill
+                // [ ] DimPercent
+                // [ ] DimFunc
+                // [ ] DimView
                 if (dimension == Dimension.Width)
                 if (dimension == Dimension.Width)
                 {
                 {
-                    subviews = us.Subviews.Where (v => v.X is not PosAnchorEnd && v.Width is not DimFill).ToList ();
+                    subviews = us.Subviews.Where (v => v.X is not PosAnchorEnd
+                                                       && v.X is not PosAlign
+                                                       && v.X is not PosCenter
+                                                       && v.Width is not DimFill).ToList ();
                 }
                 }
                 else
                 else
                 {
                 {
-                    subviews = us.Subviews.Where (v => v.Y is not PosAnchorEnd && v.Height is not DimFill).ToList ();
+                    subviews = us.Subviews.Where (v => v.Y is not PosAnchorEnd
+                                                       && v.Y is not PosAlign
+                                                       && v.Y is not PosCenter
+                                                       && v.Height is not DimFill).ToList ();
                 }
                 }
 
 
                 for (var i = 0; i < subviews.Count; i++)
                 for (var i = 0; i < subviews.Count; i++)
@@ -96,10 +115,15 @@ public class DimAuto () : Dim
 
 
                     if (size > subviewsSize)
                     if (size > subviewsSize)
                     {
                     {
+                        // BUGBUG: Should we break here? Or choose min/max?
                         subviewsSize = size;
                         subviewsSize = size;
                     }
                     }
                 }
                 }
+                #endregion Not Anchored and Are Not Dependent
 
 
+                #region Anchored
+                // Now, handle subviews that are anchored to the end
+                // [x] PosAnchorEnd
                 if (dimension == Dimension.Width)
                 if (dimension == Dimension.Width)
                 {
                 {
                     subviews = us.Subviews.Where (v => v.X is PosAnchorEnd).ToList ();
                     subviews = us.Subviews.Where (v => v.X is PosAnchorEnd).ToList ();
@@ -117,8 +141,33 @@ public class DimAuto () : Dim
                 }
                 }
 
 
                 subviewsSize += maxAnchorEnd;
                 subviewsSize += maxAnchorEnd;
+                #endregion Anchored
 
 
+                #region Center
+                // Now, handle subviews that are Centered
+                if (dimension == Dimension.Width)
+                {
+                    subviews = us.Subviews.Where (v => v.X is PosCenter).ToList ();
+                }
+                else
+                {
+                    subviews = us.Subviews.Where (v => v.Y is PosCenter).ToList ();
+                }
 
 
+                int maxCenter = 0;
+                for (var i = 0; i < subviews.Count; i++)
+                {
+                    View v = subviews [i];
+                    maxCenter = dimension == Dimension.Width ? v.Frame.Width : v.Frame.Height;
+                }
+
+                subviewsSize += maxCenter;
+                #endregion Center
+
+                #region Are Dependent
+                // Now, go back to those that are dependent on content size
+                // [x] DimFill
+                // [ ] DimPercent
                 if (dimension == Dimension.Width)
                 if (dimension == Dimension.Width)
                 {
                 {
                     subviews = us.Subviews.Where (v => v.Width is DimFill).ToList ();
                     subviews = us.Subviews.Where (v => v.Width is DimFill).ToList ();
@@ -128,20 +177,24 @@ public class DimAuto () : Dim
                     subviews = us.Subviews.Where (v => v.Height is DimFill).ToList ();
                     subviews = us.Subviews.Where (v => v.Height is DimFill).ToList ();
                 }
                 }
 
 
+                int maxFill = 0;
                 for (var i = 0; i < subviews.Count; i++)
                 for (var i = 0; i < subviews.Count; i++)
                 {
                 {
                     View v = subviews [i];
                     View v = subviews [i];
 
 
                     if (dimension == Dimension.Width)
                     if (dimension == Dimension.Width)
                     {
                     {
-                        v.SetRelativeLayout (new Size (autoMin - subviewsSize, 0));
+                        v.SetRelativeLayout (new Size (autoMax - subviewsSize, 0));
                     }
                     }
                     else
                     else
                     {
                     {
-                        v.SetRelativeLayout (new Size (0, autoMin - subviewsSize));
+                        v.SetRelativeLayout (new Size (0, autoMax - subviewsSize));
                     }
                     }
+                    maxFill = dimension == Dimension.Width ? v.Frame.Width : v.Frame.Height;
                 }
                 }
 
 
+                subviewsSize += maxFill;
+                #endregion Are Dependent
             }
             }
         }
         }
 
 
@@ -156,14 +209,14 @@ public class DimAuto () : Dim
         Thickness thickness = us.GetAdornmentsThickness ();
         Thickness thickness = us.GetAdornmentsThickness ();
 
 
         max += dimension switch
         max += dimension switch
-               {
-                   Dimension.Width => thickness.Horizontal,
-                   Dimension.Height => thickness.Vertical,
-                   Dimension.None => 0,
-                   _ => throw new ArgumentOutOfRangeException (nameof (dimension), dimension, null)
-               };
-
-        return int.Min (max, MaximumContentDim?.GetAnchor (superviewContentSize) ?? max);
+        {
+            Dimension.Width => thickness.Horizontal,
+            Dimension.Height => thickness.Vertical,
+            Dimension.None => 0,
+            _ => throw new ArgumentOutOfRangeException (nameof (dimension), dimension, null)
+        };
+
+        return int.Min (max, autoMax);
     }
     }
 
 
     internal override bool ReferencesOtherViews ()
     internal override bool ReferencesOtherViews ()

+ 2 - 2
Terminal.Gui/View/Layout/DimAutoStyle.cs

@@ -24,7 +24,7 @@ public enum DimAutoStyle
     ///         The corresponding dimension of the view's <see cref="View.Text"/> will be ignored.
     ///         The corresponding dimension of the view's <see cref="View.Text"/> will be ignored.
     ///     </para>
     ///     </para>
     /// </summary>
     /// </summary>
-    Content = 0,
+    Content = 1,
 
 
     /// <summary>
     /// <summary>
     ///     <para>
     ///     <para>
@@ -36,7 +36,7 @@ public enum DimAutoStyle
     ///         The corresponding dimensions of the <see cref="View.Subviews"/> will be ignored.
     ///         The corresponding dimensions of the <see cref="View.Subviews"/> will be ignored.
     ///     </para>
     ///     </para>
     /// </summary>
     /// </summary>
-    Text = 1,
+    Text = 2,
 
 
     /// <summary>
     /// <summary>
     ///     The dimension will be computed using both the view's <see cref="View.Text"/> and
     ///     The dimension will be computed using both the view's <see cref="View.Text"/> and

+ 33 - 2
Terminal.Gui/View/Layout/Pos.cs

@@ -26,6 +26,14 @@ namespace Terminal.Gui;
 ///             </listheader>
 ///             </listheader>
 ///             <item>
 ///             <item>
 ///                 <term>
 ///                 <term>
+///                     <see cref="Pos.Align"/>
+///                 </term>
+///                 <description>
+///                     Creates a <see cref="Pos"/> object that aligns a set of views.
+///                 </description>
+///             </item>
+///             <item>
+///                 <term>
 ///                     <see cref="Func"/>
 ///                     <see cref="Func"/>
 ///                 </term>
 ///                 </term>
 ///                 <description>
 ///                 <description>
@@ -132,6 +140,30 @@ public abstract class Pos
     /// <param name="position">The value to convert to the <see cref="Pos"/>.</param>
     /// <param name="position">The value to convert to the <see cref="Pos"/>.</param>
     public static Pos Absolute (int position) { return new PosAbsolute (position); }
     public static Pos Absolute (int position) { return new PosAbsolute (position); }
 
 
+    /// <summary>
+    ///     Creates a <see cref="Pos"/> object that aligns a set of views according to the specified <see cref="Alignment"/>
+    ///     and <see cref="AlignmentModes"/>.
+    /// </summary>
+    /// <param name="alignment">The alignment. The default includes <see cref="AlignmentModes.AddSpaceBetweenItems"/>.</param>
+    /// <param name="modes">The optional alignment modes.</param>
+    /// <param name="groupId">
+    ///     The optional identifier of a set of views that should be aligned together. When only a single
+    ///     set of views in a SuperView is aligned, this parameter is optional.
+    /// </param>
+    /// <returns></returns>
+    public static Pos Align (Alignment alignment, AlignmentModes modes = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, int groupId = 0)
+    {
+        return new PosAlign
+        {
+            Aligner = new ()
+            {
+                Alignment = alignment,
+                AlignmentModes = modes
+            },
+            GroupId = groupId
+        };
+    }
+
     /// <summary>
     /// <summary>
     ///     Creates a <see cref="Pos"/> object that is anchored to the end (right side or
     ///     Creates a <see cref="Pos"/> object that is anchored to the end (right side or
     ///     bottom) of the SuperView's Content Area, minus the respective size of the View. This is equivalent to using
     ///     bottom) of the SuperView's Content Area, minus the respective size of the View. This is equivalent to using
@@ -359,5 +391,4 @@ public abstract class Pos
     }
     }
 
 
     #endregion operators
     #endregion operators
-
-}
+}

+ 169 - 0
Terminal.Gui/View/Layout/PosAlign.cs

@@ -0,0 +1,169 @@
+#nullable enable
+
+using System.ComponentModel;
+
+namespace Terminal.Gui;
+
+/// <summary>
+///     Enables alignment of a set of views.
+/// </summary>
+/// <remarks>
+///     <para>
+///         Updating the properties of <see cref="Aligner"/> is supported, but will not automatically cause re-layout to
+///         happen. <see cref="View.LayoutSubviews"/>
+///         must be called on the SuperView.
+///     </para>
+///     <para>
+///         Views that should be aligned together must have a distinct <see cref="GroupId"/>. When only a single
+///         set of views is aligned within a SuperView, setting <see cref="GroupId"/> is optional because it defaults to 0.
+///     </para>
+///     <para>
+///         The first view added to the Superview with a given <see cref="GroupId"/> is used to determine the alignment of
+///         the group.
+///         The alignment is applied to all views with the same <see cref="GroupId"/>.
+///     </para>
+/// </remarks>
+public class PosAlign : Pos
+{
+    /// <summary>
+    ///     The cached location. Used to store the calculated location to minimize recalculating it.
+    /// </summary>
+    private int? _cachedLocation;
+
+    /// <summary>
+    ///     Gets the identifier of a set of views that should be aligned together. When only a single
+    ///     set of views in a SuperView is aligned, setting <see cref="GroupId"/> is not needed because it defaults to 0.
+    /// </summary>
+    public int GroupId { get; init; }
+
+    private readonly Aligner? _aligner;
+
+    /// <summary>
+    ///     Gets the alignment settings.
+    /// </summary>
+    public required Aligner Aligner
+    {
+        get => _aligner!;
+        init
+        {
+            if (_aligner is { })
+            {
+                _aligner.PropertyChanged -= Aligner_PropertyChanged;
+            }
+
+            _aligner = value;
+            _aligner.PropertyChanged += Aligner_PropertyChanged;
+        }
+    }
+
+    /// <summary>
+    ///     Aligns the views in <paramref name="views"/> that have the same group ID as <paramref name="groupId"/>.
+    ///     Updates each view's cached _location.
+    /// </summary>
+    /// <param name="groupId"></param>
+    /// <param name="views"></param>
+    /// <param name="dimension"></param>
+    /// <param name="size"></param>
+    private static void AlignAndUpdateGroup (int groupId, IList<View> views, Dimension dimension, int size)
+    {
+        List<int> dimensionsList = new ();
+
+        // PERF: If this proves a perf issue, consider caching a ref to this list in each item
+        List<View> viewsInGroup = views.Where (
+                                               v =>
+                                               {
+                                                   return dimension switch
+                                                   {
+                                                       Dimension.Width when v.X is PosAlign alignX => alignX.GroupId == groupId,
+                                                       Dimension.Height when v.Y is PosAlign alignY => alignY.GroupId == groupId,
+                                                       _ => false
+                                                   };
+                                               })
+                                       .ToList ();
+
+        if (viewsInGroup.Count == 0)
+        {
+            return;
+        }
+
+        // PERF: We iterate over viewsInGroup multiple times here.
+
+        Aligner? firstInGroup = null;
+
+        // Update the dimensionList with the sizes of the views
+        for (var index = 0; index < viewsInGroup.Count; index++)
+        {
+            View view = viewsInGroup [index];
+            PosAlign? posAlign = dimension == Dimension.Width ? view.X as PosAlign : view.Y as PosAlign;
+
+            if (posAlign is { })
+            {
+                if (index == 0)
+                {
+                    firstInGroup = posAlign.Aligner;
+                }
+
+                dimensionsList.Add (dimension == Dimension.Width ? view.Frame.Width : view.Frame.Height);
+            }
+        }
+
+        // Update the first item in the group with the new container size.
+        firstInGroup!.ContainerSize = size;
+
+        // Align
+        int [] locations = firstInGroup.Align (dimensionsList.ToArray ());
+
+        // Update the cached location for each item
+        for (var index = 0; index < viewsInGroup.Count; index++)
+        {
+            View view = viewsInGroup [index];
+            PosAlign? align = dimension == Dimension.Width ? view.X as PosAlign : view.Y as PosAlign;
+
+            if (align is { })
+            {
+                align._cachedLocation = locations [index];
+            }
+        }
+    }
+
+    private void Aligner_PropertyChanged (object? sender, PropertyChangedEventArgs e) { _cachedLocation = null; }
+
+    /// <inheritdoc/>
+    public override bool Equals (object? other)
+    {
+        return other is PosAlign align
+               && GroupId == align.GroupId
+               && align.Aligner.Alignment == Aligner.Alignment
+               && align.Aligner.AlignmentModes == Aligner.AlignmentModes;
+    }
+
+    /// <inheritdoc/>
+    public override int GetHashCode () { return HashCode.Combine (Aligner, GroupId); }
+
+    /// <inheritdoc/>
+    public override string ToString () { return $"Align(alignment={Aligner.Alignment},modes={Aligner.AlignmentModes},groupId={GroupId})"; }
+
+    internal override int GetAnchor (int width) { return _cachedLocation ?? 0 - width; }
+
+    internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
+    {
+        if (_cachedLocation.HasValue && Aligner.ContainerSize == superviewDimension)
+        {
+            return _cachedLocation.Value;
+        }
+
+        if (us?.SuperView is null)
+        {
+            return 0;
+        }
+
+        AlignAndUpdateGroup (GroupId, us.SuperView.Subviews, dimension, superviewDimension);
+
+        if (_cachedLocation.HasValue)
+        {
+            return _cachedLocation.Value;
+        }
+
+        return 0;
+    }
+}

+ 4 - 4
Terminal.Gui/View/ViewText.cs

@@ -87,7 +87,7 @@ public partial class View
     ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     /// </remarks>
     /// </remarks>
     /// <value>The text alignment.</value>
     /// <value>The text alignment.</value>
-    public virtual TextAlignment TextAlignment
+    public virtual Alignment TextAlignment
     {
     {
         get => TextFormatter.Alignment;
         get => TextFormatter.Alignment;
         set
         set
@@ -105,7 +105,7 @@ public partial class View
     /// <remarks>
     /// <remarks>
     ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     /// </remarks>
     /// </remarks>
-    /// <value>The text alignment.</value>
+    /// <value>The text direction.</value>
     public virtual TextDirection TextDirection
     public virtual TextDirection TextDirection
     {
     {
         get => TextFormatter.Direction;
         get => TextFormatter.Direction;
@@ -129,8 +129,8 @@ public partial class View
     /// <remarks>
     /// <remarks>
     ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
     /// </remarks>
     /// </remarks>
-    /// <value>The text alignment.</value>
-    public virtual VerticalTextAlignment VerticalTextAlignment
+    /// <value>The vertical text alignment.</value>
+    public virtual Alignment VerticalTextAlignment
     {
     {
         get => TextFormatter.VerticalAlignment;
         get => TextFormatter.VerticalAlignment;
         set
         set

+ 2 - 2
Terminal.Gui/Views/Button.cs

@@ -37,8 +37,8 @@ public class Button : View
     /// <remarks>The width of the <see cref="Button"/> is computed based on the text length. The height will always be 1.</remarks>
     /// <remarks>The width of the <see cref="Button"/> is computed based on the text length. The height will always be 1.</remarks>
     public Button ()
     public Button ()
     {
     {
-        TextAlignment = TextAlignment.Centered;
-        VerticalTextAlignment = VerticalTextAlignment.Middle;
+        TextAlignment = Alignment.Center;
+        VerticalTextAlignment = Alignment.Center;
 
 
         _leftBracket = Glyphs.LeftBracket;
         _leftBracket = Glyphs.LeftBracket;
         _rightBracket = Glyphs.RightBracket;
         _rightBracket = Glyphs.RightBracket;

+ 4 - 4
Terminal.Gui/Views/CheckBox.cs

@@ -155,13 +155,13 @@ public class CheckBox : View
     {
     {
         switch (TextAlignment)
         switch (TextAlignment)
         {
         {
-            case TextAlignment.Left:
-            case TextAlignment.Centered:
-            case TextAlignment.Justified:
+            case Alignment.Start:
+            case Alignment.Center:
+            case Alignment.Fill:
                 TextFormatter.Text = $"{GetCheckedState ()} {Text}";
                 TextFormatter.Text = $"{GetCheckedState ()} {Text}";
 
 
                 break;
                 break;
-            case TextAlignment.Right:
+            case Alignment.End:
                 TextFormatter.Text = $"{Text} {GetCheckedState ()}";
                 TextFormatter.Text = $"{Text} {GetCheckedState ()}";
 
 
                 break;
                 break;

+ 2 - 4
Terminal.Gui/Views/DatePicker.cs

@@ -215,7 +215,6 @@ public class DatePicker : View
         {
         {
             X = Pos.Center () - 2,
             X = Pos.Center () - 2,
             Y = Pos.Bottom (_calendar) - 1,
             Y = Pos.Bottom (_calendar) - 1,
-            Height = 1,
             Width = 2,
             Width = 2,
             Text = GetBackButtonText (),
             Text = GetBackButtonText (),
             WantContinuousButtonPressed = true,
             WantContinuousButtonPressed = true,
@@ -234,7 +233,6 @@ public class DatePicker : View
         {
         {
             X = Pos.Right (_previousMonthButton) + 2,
             X = Pos.Right (_previousMonthButton) + 2,
             Y = Pos.Bottom (_calendar) - 1,
             Y = Pos.Bottom (_calendar) - 1,
-            Height = 1,
             Width = 2,
             Width = 2,
             Text = GetForwardButtonText (),
             Text = GetForwardButtonText (),
             WantContinuousButtonPressed = true,
             WantContinuousButtonPressed = true,
@@ -273,8 +271,8 @@ public class DatePicker : View
                                        Text = _date.ToString (Format);
                                        Text = _date.ToString (Format);
                                    };
                                    };
 
 
-        Height = Dim.Auto ();
-        Width = Dim.Auto ();
+        Width = Dim.Auto (DimAutoStyle.Content);
+        Height = Dim.Auto (DimAutoStyle.Content);
 
 
         // BUGBUG: Remove when Dim.Auto(subviews) fully works
         // BUGBUG: Remove when Dim.Auto(subviews) fully works
         SetContentSize (new (_calendar.Style.ColumnStyles.Sum (c => c.Value.MinWidth) + 7, _calendar.Frame.Height + 1));
         SetContentSize (new (_calendar.Style.ColumnStyles.Sum (c => c.Value.MinWidth) + 7, _calendar.Frame.Height + 1));

+ 47 - 168
Terminal.Gui/Views/Dialog.cs

@@ -15,21 +15,32 @@ namespace Terminal.Gui;
 /// </remarks>
 /// </remarks>
 public class Dialog : Window
 public class Dialog : Window
 {
 {
-    /// <summary>Determines the horizontal alignment of the Dialog buttons.</summary>
-    public enum ButtonAlignments
-    {
-        /// <summary>Center-aligns the buttons (the default).</summary>
-        Center = 0,
+    /// <summary>The default <see cref="Alignment"/> for <see cref="Dialog"/>.</summary>
+    /// <remarks>This property can be set in a Theme.</remarks>
+    [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
+    [JsonConverter (typeof (JsonStringEnumConverter))]
+    public static Alignment DefaultButtonAlignment { get; set; } = Alignment.End;
 
 
-        /// <summary>Justifies the buttons</summary>
-        Justify,
+    /// <summary>The default <see cref="Alignment"/> for <see cref="Dialog"/>.</summary>
+    /// <remarks>This property can be set in a Theme.</remarks>
+    [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
+    [JsonConverter (typeof (JsonStringEnumConverter))]
+    public static AlignmentModes DefaultButtonAlignmentModes { get; set; } = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems;
+
+    /// <summary>
+    ///     Defines the default minimum Dialog width, as a percentage of the container width. Can be configured via
+    ///     <see cref="ConfigurationManager"/>.
+    /// </summary>
+    [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
+    public static int DefaultMinimumWidth { get; set; } = 25;
 
 
-        /// <summary>Left-aligns the buttons</summary>
-        Left,
+    /// <summary>
+    ///     Defines the default minimum Dialog height, as a percentage of the container width. Can be configured via
+    ///     <see cref="ConfigurationManager"/>.
+    /// </summary>
+    [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
+    public static int DefaultMinimumHeight { get; set; } = 25;
 
 
-        /// <summary>Right-aligns the buttons</summary>
-        Right
-    }
 
 
     // TODO: Reenable once border/borderframe design is settled
     // TODO: Reenable once border/borderframe design is settled
     /// <summary>
     /// <summary>
@@ -57,29 +68,26 @@ public class Dialog : Window
         Arrangement = ViewArrangement.Movable;
         Arrangement = ViewArrangement.Movable;
         X = Pos.Center ();
         X = Pos.Center ();
         Y = Pos.Center ();
         Y = Pos.Center ();
-        //ValidatePosDim = true;
 
 
-        Width = Dim.Percent (85); 
-        Height = Dim.Percent (85);
+        Width = Dim.Auto (DimAutoStyle.Content, minimumContentDim: Dim.Percent (DefaultMinimumWidth), Dim.Percent (90));
+        Height = Dim.Auto (DimAutoStyle.Content, minimumContentDim: Dim.Percent (DefaultMinimumHeight), Dim.Percent (90));
         ColorScheme = Colors.ColorSchemes ["Dialog"];
         ColorScheme = Colors.ColorSchemes ["Dialog"];
 
 
         Modal = true;
         Modal = true;
         ButtonAlignment = DefaultButtonAlignment;
         ButtonAlignment = DefaultButtonAlignment;
+        ButtonAlignmentModes = DefaultButtonAlignmentModes;
 
 
-        AddCommand (Command.QuitToplevel, () =>
-                                          {
-                                              Canceled = true;
-                                              RequestStop ();
-                                              return true;
-                                          });
-        KeyBindings.Add (Key.Esc, Command.QuitToplevel);
+        AddCommand (
+                    Command.QuitToplevel,
+                    () =>
+                    {
+                        Canceled = true;
+                        RequestStop ();
 
 
-        Initialized += Dialog_Initialized; ;
-    }
+                        return true;
+                    });
+        KeyBindings.Add (Key.Esc, Command.QuitToplevel);
 
 
-    private void Dialog_Initialized (object sender, EventArgs e)
-    {
-        LayoutButtons ();
     }
     }
 
 
     private bool _canceled;
     private bool _canceled;
@@ -107,12 +115,19 @@ public class Dialog : Window
             }
             }
 #endif
 #endif
             _canceled = value;
             _canceled = value;
+
             return;
             return;
         }
         }
     }
     }
 
 
+    // TODO: Update button.X = Pos.Justify when alignment changes
     /// <summary>Determines how the <see cref="Dialog"/> <see cref="Button"/>s are aligned along the bottom of the dialog.</summary>
     /// <summary>Determines how the <see cref="Dialog"/> <see cref="Button"/>s are aligned along the bottom of the dialog.</summary>
-    public ButtonAlignments ButtonAlignment { get; set; }
+    public Alignment ButtonAlignment { get; set; }
+
+    /// <summary>
+    /// Gets or sets the alignment modes for the dialog's buttons.
+    /// </summary>
+    public AlignmentModes ButtonAlignmentModes { get; set; }
 
 
     /// <summary>Optional buttons to lay out at the bottom of the dialog.</summary>
     /// <summary>Optional buttons to lay out at the bottom of the dialog.</summary>
     public Button [] Buttons
     public Button [] Buttons
@@ -132,12 +147,6 @@ public class Dialog : Window
         }
         }
     }
     }
 
 
-    /// <summary>The default <see cref="ButtonAlignments"/> for <see cref="Dialog"/>.</summary>
-    /// <remarks>This property can be set in a Theme.</remarks>
-    [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
-    [JsonConverter (typeof (JsonStringEnumConverter))]
-    public static ButtonAlignments DefaultButtonAlignment { get; set; } = ButtonAlignments.Center;
-
     /// <summary>
     /// <summary>
     ///     Adds a <see cref="Button"/> to the <see cref="Dialog"/>, its layout will be controlled by the
     ///     Adds a <see cref="Button"/> to the <see cref="Dialog"/>, its layout will be controlled by the
     ///     <see cref="Dialog"/>
     ///     <see cref="Dialog"/>
@@ -150,6 +159,10 @@ public class Dialog : Window
             return;
             return;
         }
         }
 
 
+        // Use a distinct GroupId so users can use Pos.Align for other views in the Dialog
+        button.X = Pos.Align (ButtonAlignment, ButtonAlignmentModes, groupId: GetHashCode ());
+        button.Y = Pos.AnchorEnd ();
+
         _buttons.Add (button);
         _buttons.Add (button);
         Add (button);
         Add (button);
 
 
@@ -160,138 +173,4 @@ public class Dialog : Window
             LayoutSubviews ();
             LayoutSubviews ();
         }
         }
     }
     }
-
-    /// <inheritdoc/>
-    //public override void LayoutSubviews ()
-    //{
-    //    if (_inLayout)
-    //    {
-    //        return;
-    //    }
-
-    //    _inLayout = true;
-    //    SetRelativeLayout(SuperView?.ContentSize ?? Driver.Screen.Size);
-    //    LayoutButtons ();
-    //    base.LayoutSubviews ();
-    //    _inLayout = false;
-    //}
-
-    // Get the width of all buttons, not including any Margin.
-    internal int GetButtonsWidth ()
-    {
-        if (_buttons.Count == 0)
-        {
-            return 0;
-        }
-
-        //var widths = buttons.Select (b => b.TextFormatter.GetFormattedSize ().Width + b.BorderFrame.Thickness.Horizontal + b.Padding.Thickness.Horizontal);
-        IEnumerable<int> widths = _buttons.Select (b => b.Frame.Width);
-
-        return widths.Sum ();
-    }
-
-    private void LayoutButtons ()
-    {
-        if (_buttons.Count == 0 || !IsInitialized)
-        {
-            return;
-        }
-
-        var shiftLeft = 0;
-
-        int buttonsWidth = GetButtonsWidth ();
-
-        switch (ButtonAlignment)
-        {
-            case ButtonAlignments.Center:
-                // Center Buttons
-                shiftLeft = (Viewport.Width - buttonsWidth - _buttons.Count - 1) / 2 + 1;
-
-                for (int i = _buttons.Count - 1; i >= 0; i--)
-                {
-                    Button button = _buttons [i];
-                    shiftLeft += button.Frame.Width + (i == _buttons.Count - 1 ? 0 : 1);
-
-                    if (shiftLeft > -1)
-                    {
-                        button.X = Pos.AnchorEnd (shiftLeft);
-                    }
-                    else
-                    {
-                        button.X = Viewport.Width - shiftLeft;
-                    }
-
-                    button.Y = Pos.AnchorEnd ();
-                }
-
-                break;
-
-            case ButtonAlignments.Justify:
-                // Justify Buttons
-                // leftmost and rightmost buttons are hard against edges. The rest are evenly spaced.
-
-                var spacing = (int)Math.Ceiling ((double)(Viewport.Width - buttonsWidth) / (_buttons.Count - 1));
-
-                for (int i = _buttons.Count - 1; i >= 0; i--)
-                {
-                    Button button = _buttons [i];
-
-                    if (i == _buttons.Count - 1)
-                    {
-                        shiftLeft += button.Frame.Width;
-                        button.X = Pos.AnchorEnd (shiftLeft);
-                    }
-                    else
-                    {
-                        if (i == 0)
-                        {
-                            // first (leftmost) button 
-                            int left = Viewport.Width;
-                            button.X = Pos.AnchorEnd (left);
-                        }
-                        else
-                        {
-                            shiftLeft += button.Frame.Width + spacing;
-                            button.X = Pos.AnchorEnd (shiftLeft);
-                        }
-                    }
-
-                    button.Y = Pos.AnchorEnd ();
-                }
-
-                break;
-
-            case ButtonAlignments.Left:
-                // Left Align Buttons
-                Button prevButton = _buttons [0];
-                prevButton.X = 0;
-                prevButton.Y = Pos.AnchorEnd (1);
-
-                for (var i = 1; i < _buttons.Count; i++)
-                {
-                    Button button = _buttons [i];
-                    button.X = Pos.Right (prevButton) + 1;
-                    button.Y = Pos.AnchorEnd (1);
-                    prevButton = button;
-                }
-
-                break;
-
-            case ButtonAlignments.Right:
-                // Right align buttons
-                shiftLeft = _buttons [_buttons.Count - 1].Frame.Width;
-                _buttons [_buttons.Count - 1].X = Pos.AnchorEnd (shiftLeft);
-                _buttons [_buttons.Count - 1].Y = Pos.AnchorEnd (1);
-
-                for (int i = _buttons.Count - 2; i >= 0; i--)
-                {
-                    Button button = _buttons [i];
-                    shiftLeft += button.Frame.Width + 1;
-                    button.X = Pos.AnchorEnd (shiftLeft);
-                    button.Y = Pos.AnchorEnd ();
-                }
-
-                break;
-        }
-    }
 }
 }

+ 1 - 1
Terminal.Gui/Views/ListView.cs

@@ -1002,7 +1002,7 @@ public class ListWrapper : IListDataSource
     private void RenderUstr (ConsoleDriver driver, string ustr, int col, int line, int width, int start = 0)
     private void RenderUstr (ConsoleDriver driver, string ustr, int col, int line, int width, int start = 0)
     {
     {
         string str = start > ustr.GetColumns () ? string.Empty : ustr.Substring (Math.Min (start, ustr.ToRunes ().Length - 1));
         string str = start > ustr.GetColumns () ? string.Empty : ustr.Substring (Math.Min (start, ustr.ToRunes ().Length - 1));
-        string u = TextFormatter.ClipAndJustify (str, width, TextAlignment.Left);
+        string u = TextFormatter.ClipAndJustify (str, width, Alignment.Start);
         driver.AddStr (u);
         driver.AddStr (u);
         width -= u.GetColumns ();
         width -= u.GetColumns ();
 
 

+ 1 - 1
Terminal.Gui/Views/Menu/Menu.cs

@@ -890,7 +890,7 @@ internal sealed class Menu : View
                     var tf = new TextFormatter
                     var tf = new TextFormatter
                     {
                     {
                         AutoSize = true,
                         AutoSize = true,
-                        Alignment = TextAlignment.Centered, HotKeySpecifier = MenuBar.HotKeySpecifier, Text = textToDraw
+                        Alignment = Alignment.Center, HotKeySpecifier = MenuBar.HotKeySpecifier, Text = textToDraw
                     };
                     };
 
 
                     // The -3 is left/right border + one space (not sure what for)
                     // The -3 is left/right border + one space (not sure what for)

+ 112 - 94
Terminal.Gui/Views/MessageBox.cs

@@ -25,27 +25,42 @@
 public static class MessageBox
 public static class MessageBox
 {
 {
     /// <summary>
     /// <summary>
-    ///     The index of the selected button, or -1 if the user pressed ESC to close the dialog. This is useful for web
-    ///     based console where by default there is no SynchronizationContext or TaskScheduler.
+    ///     Defines the default border styling for <see cref="MessageBox"/>. Can be configured via
+    ///     <see cref="ConfigurationManager"/>.
     /// </summary>
     /// </summary>
-    public static int Clicked { get; private set; } = -1;
+    [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
+    public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single;
 
 
     /// <summary>
     /// <summary>
-    ///     Defines the default border styling for <see cref="Dialog"/>. Can be configured via
+    ///     Defines the default minimum MessageBox width, as a percentage of the container width. Can be configured via
     ///     <see cref="ConfigurationManager"/>.
     ///     <see cref="ConfigurationManager"/>.
     /// </summary>
     /// </summary>
     [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
     [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
-    public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single;
+    public static int DefaultMinimumWidth { get; set; } = 60;
 
 
     /// <summary>
     /// <summary>
-    ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
-    ///     to the user.
+    ///     Defines the default minimum Dialog height, as a percentage of the container width. Can be configured via
+    ///     <see cref="ConfigurationManager"/>.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
-    /// <param name="width">Width for the window.</param>
-    /// <param name="height">Height for the window.</param>
-    /// <param name="title">Title for the query.</param>
-    /// <param name="message">Message to display, might contain multiple lines.</param>
+    [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
+    public static int DefaultMinimumHeight { get; set; } = 5;
+    /// <summary>
+    ///     The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox. This is useful for web
+    ///     based console where there is no SynchronizationContext or TaskScheduler.
+    /// </summary>
+    /// <remarks>
+    ///     Warning: This is a global variable and should be used with caution. It is not thread safe.
+    /// </remarks>
+    public static int Clicked { get; private set; } = -1;
+
+    /// <summary>
+    ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons.
+    /// </summary>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
+    /// <param name="width">Width for the MessageBox.</param>
+    /// <param name="height">Height for the MessageBox.</param>
+    /// <param name="title">Title for the MessageBox.</param>
+    /// <param name="message">Message to display; might contain multiple lines. The message will be word=wrapped by default.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
     ///     Use <see cref="ErrorQuery(string, string, string[])"/> instead; it automatically sizes the MessageBox based on
     ///     Use <see cref="ErrorQuery(string, string, string[])"/> instead; it automatically sizes the MessageBox based on
@@ -60,9 +75,9 @@ public static class MessageBox
     ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
     ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
     ///     to the user.
     ///     to the user.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
     /// <param name="title">Title for the query.</param>
     /// <param name="title">Title for the query.</param>
-    /// <param name="message">Message to display, might contain multiple lines.</param>
+    /// <param name="message">Message to display; might contain multiple lines. The message will be word=wrapped by default.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
     ///     The message box will be vertically and horizontally centered in the container and the size will be
     ///     The message box will be vertically and horizontally centered in the container and the size will be
@@ -71,14 +86,13 @@ public static class MessageBox
     public static int ErrorQuery (string title, string message, params string [] buttons) { return QueryFull (true, 0, 0, title, message, 0, true, buttons); }
     public static int ErrorQuery (string title, string message, params string [] buttons) { return QueryFull (true, 0, 0, title, message, 0, true, buttons); }
 
 
     /// <summary>
     /// <summary>
-    ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
-    ///     to the user.
+    ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
-    /// <param name="width">Width for the window.</param>
-    /// <param name="height">Height for the window.</param>
-    /// <param name="title">Title for the query.</param>
-    /// <param name="message">Message to display, might contain multiple lines.</param>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
+    /// <param name="width">Width for the MessageBox.</param>
+    /// <param name="height">Height for the MessageBox.</param>
+    /// <param name="title">Title for the MessageBox.</param>
+    /// <param name="message">Message to display; might contain multiple lines. The message will be word=wrapped by default.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
@@ -101,9 +115,9 @@ public static class MessageBox
     ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
     ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
     ///     to the user.
     ///     to the user.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
-    /// <param name="title">Title for the query.</param>
-    /// <param name="message">Message to display, might contain multiple lines.</param>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
+    /// <param name="title">Title for the MessageBox.</param>
+    /// <param name="message">Message to display; might contain multiple lines. The message will be word=wrapped by default.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
@@ -119,13 +133,13 @@ public static class MessageBox
     ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
     ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
     ///     to the user.
     ///     to the user.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
     /// <param name="width">Width for the window.</param>
     /// <param name="width">Width for the window.</param>
     /// <param name="height">Height for the window.</param>
     /// <param name="height">Height for the window.</param>
     /// <param name="title">Title for the query.</param>
     /// <param name="title">Title for the query.</param>
-    /// <param name="message">Message to display, might contain multiple lines.</param>
+    /// <param name="message">Message to display; might contain multiple lines. The message will be word=wrapped by default.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="defaultButton">Index of the default button.</param>
-    /// <param name="wrapMessagge">If wrap the message or not.</param>
+    /// <param name="wrapMessage">If wrap the message or not.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
     ///     Use <see cref="ErrorQuery(string, string, string[])"/> instead; it automatically sizes the MessageBox based on
     ///     Use <see cref="ErrorQuery(string, string, string[])"/> instead; it automatically sizes the MessageBox based on
@@ -137,22 +151,22 @@ public static class MessageBox
         string title,
         string title,
         string message,
         string message,
         int defaultButton = 0,
         int defaultButton = 0,
-        bool wrapMessagge = true,
+        bool wrapMessage = true,
         params string [] buttons
         params string [] buttons
     )
     )
     {
     {
-        return QueryFull (true, width, height, title, message, defaultButton, wrapMessagge, buttons);
+        return QueryFull (true, width, height, title, message, defaultButton, wrapMessage, buttons);
     }
     }
 
 
     /// <summary>
     /// <summary>
     ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
     ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
     ///     to the user.
     ///     to the user.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
     /// <param name="title">Title for the query.</param>
     /// <param name="title">Title for the query.</param>
-    /// <param name="message">Message to display, might contain multiple lines.</param>
+    /// <param name="message">Message to display; might contain multiple lines. The message will be word=wrapped by default.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="defaultButton">Index of the default button.</param>
-    /// <param name="wrapMessagge">If wrap the message or not.</param>
+    /// <param name="wrapMessage">If wrap the message or not. The default is <see langword="true"/></param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
     ///     The message box will be vertically and horizontally centered in the container and the size will be
     ///     The message box will be vertically and horizontally centered in the container and the size will be
@@ -162,26 +176,25 @@ public static class MessageBox
         string title,
         string title,
         string message,
         string message,
         int defaultButton = 0,
         int defaultButton = 0,
-        bool wrapMessagge = true,
+        bool wrapMessage = true,
         params string [] buttons
         params string [] buttons
     )
     )
     {
     {
-        return QueryFull (true, 0, 0, title, message, defaultButton, wrapMessagge, buttons);
+        return QueryFull (true, 0, 0, title, message, defaultButton, wrapMessage, buttons);
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Presents a normal <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
-    ///     to the user.
+    ///     Presents a <see cref="MessageBox"/> with the specified title and message and a list of buttons.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
-    /// <param name="width">Width for the window.</param>
-    /// <param name="height">Height for the window.</param>
-    /// <param name="title">Title for the query.</param>
-    /// <param name="message">Message to display, might contain multiple lines.</param>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
+    /// <param name="width">Width for the MessageBox.</param>
+    /// <param name="height">Height for the MessageBox.</param>
+    /// <param name="title">Title for the MessageBox.</param>
+    /// <param name="message">Message to display; might contain multiple lines. The message will be word=wrapped by default.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
-    ///     Use <see cref="Query(string, string, string[])"/> instead; it automatically sizes the MessageBox based on the
-    ///     contents.
+    ///     Use <see cref="Query(string, string, string[])"/> instead; it automatically sizes the MessageBox based on
+    ///     the contents.
     /// </remarks>
     /// </remarks>
     public static int Query (int width, int height, string title, string message, params string [] buttons)
     public static int Query (int width, int height, string title, string message, params string [] buttons)
     {
     {
@@ -189,33 +202,43 @@ public static class MessageBox
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
-    ///     to the user.
+    ///     Presents a <see cref="MessageBox"/> with the specified title and message and a list of buttons.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
-    /// <param name="title">Title for the query.</param>
-    /// <param name="message">Message to display, might contain multiple lines.</param>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
+    /// <param name="title">Title for the MessageBox.</param>
+    /// <param name="message">Message to display; might contain multiple lines. The message will be word=wrapped by default.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
+    /// <para>
     ///     The message box will be vertically and horizontally centered in the container and the size will be
     ///     The message box will be vertically and horizontally centered in the container and the size will be
-    ///     automatically determined from the size of the message and buttons.
+    ///     automatically determined from the size of the title, message. and buttons.
+    /// </para>
+    /// <para>
+    ///     Use <see cref="Query(string, string, string[])"/> instead; it automatically sizes the MessageBox based on
+    ///     the contents.
+    /// </para>
     /// </remarks>
     /// </remarks>
     public static int Query (string title, string message, params string [] buttons) { return QueryFull (false, 0, 0, title, message, 0, true, buttons); }
     public static int Query (string title, string message, params string [] buttons) { return QueryFull (false, 0, 0, title, message, 0, true, buttons); }
 
 
     /// <summary>
     /// <summary>
-    ///     Presents a normal <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
-    ///     to the user.
+    ///     Presents a <see cref="MessageBox"/> with the specified title and message and a list of buttons.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
     /// <param name="width">Width for the window.</param>
     /// <param name="width">Width for the window.</param>
     /// <param name="height">Height for the window.</param>
     /// <param name="height">Height for the window.</param>
-    /// <param name="title">Title for the query.</param>
-    /// <param name="message">Message to display, might contain multiple lines.</param>
+    /// <param name="title">Title for the MessageBox.</param>
+    /// <param name="message">Message to display; might contain multiple lines. The message will be word=wrapped by default.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
-    ///     Use <see cref="Query(string, string, string[])"/> instead; it automatically sizes the MessageBox based on the
-    ///     contents.
+    /// <para>
+    ///     The message box will be vertically and horizontally centered in the container and the size will be
+    ///     automatically determined from the size of the title, message. and buttons.
+    /// </para>
+    /// <para>
+    ///     Use <see cref="Query(string, string, string[])"/> instead; it automatically sizes the MessageBox based on
+    ///     the contents.
+    /// </para>
     /// </remarks>
     /// </remarks>
     public static int Query (
     public static int Query (
         int width,
         int width,
@@ -230,12 +253,11 @@ public static class MessageBox
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
-    ///     to the user.
+    ///     Presents a <see cref="MessageBox"/> with the specified title and message and a list of buttons.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
-    /// <param name="title">Title for the query.</param>
-    /// <param name="message">Message to display, might contain multiple lines.</param>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
+    /// <param name="title">Title for the MessageBox.</param>
+    /// <param name="message">Message to display; might contain multiple lines. The message will be word=wrapped by default.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
@@ -248,16 +270,16 @@ public static class MessageBox
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Presents a normal <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
+    ///     Presents a <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
     ///     to the user.
     ///     to the user.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
     /// <param name="width">Width for the window.</param>
     /// <param name="width">Width for the window.</param>
     /// <param name="height">Height for the window.</param>
     /// <param name="height">Height for the window.</param>
     /// <param name="title">Title for the query.</param>
     /// <param name="title">Title for the query.</param>
     /// <param name="message">Message to display, might contain multiple lines.</param>
     /// <param name="message">Message to display, might contain multiple lines.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="defaultButton">Index of the default button.</param>
-    /// <param name="wrapMessagge">If wrap the message or not.</param>
+    /// <param name="wrapMessage">If wrap the message or not.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <remarks>
     /// <remarks>
     ///     Use <see cref="Query(string, string, string[])"/> instead; it automatically sizes the MessageBox based on the
     ///     Use <see cref="Query(string, string, string[])"/> instead; it automatically sizes the MessageBox based on the
@@ -269,27 +291,23 @@ public static class MessageBox
         string title,
         string title,
         string message,
         string message,
         int defaultButton = 0,
         int defaultButton = 0,
-        bool wrapMessagge = true,
+        bool wrapMessage = true,
         params string [] buttons
         params string [] buttons
     )
     )
     {
     {
-        return QueryFull (false, width, height, title, message, defaultButton, wrapMessagge, buttons);
+        return QueryFull (false, width, height, title, message, defaultButton, wrapMessage, buttons);
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
+    ///     Presents a <see cref="MessageBox"/> with the specified title and message and a list of buttons to show
     ///     to the user.
     ///     to the user.
     /// </summary>
     /// </summary>
-    /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
+    /// <returns>The index of the selected button, or -1 if the user pressed <see cref="Application.QuitKey"/> to close the MessageBox.</returns>
     /// <param name="title">Title for the query.</param>
     /// <param name="title">Title for the query.</param>
     /// <param name="message">Message to display, might contain multiple lines.</param>
     /// <param name="message">Message to display, might contain multiple lines.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="defaultButton">Index of the default button.</param>
     /// <param name="wrapMessage">If wrap the message or not.</param>
     /// <param name="wrapMessage">If wrap the message or not.</param>
     /// <param name="buttons">Array of buttons to add.</param>
     /// <param name="buttons">Array of buttons to add.</param>
-    /// <remarks>
-    ///     The message box will be vertically and horizontally centered in the container and the size will be
-    ///     automatically determined from the size of the message and buttons.
-    /// </remarks>
     public static int Query (
     public static int Query (
         string title,
         string title,
         string message,
         string message,
@@ -325,7 +343,10 @@ public static class MessageBox
 
 
             foreach (string s in buttons)
             foreach (string s in buttons)
             {
             {
-                var b = new Button { Text = s };
+                var b = new Button
+                {
+                    Text = s,
+                };
 
 
                 if (count == defaultButton)
                 if (count == defaultButton)
                 {
                 {
@@ -337,15 +358,15 @@ public static class MessageBox
             }
             }
         }
         }
 
 
-        Dialog d;
-
-        d = new Dialog
+        var d = new Dialog
         {
         {
-            Buttons = buttonList.ToArray (),
             Title = title,
             Title = title,
+            Buttons = buttonList.ToArray (),
+            ButtonAlignment = Alignment.Center,
+            ButtonAlignmentModes = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems,
             BorderStyle = DefaultBorderStyle,
             BorderStyle = DefaultBorderStyle,
-            Width = Dim.Auto (DimAutoStyle.Content, minimumContentDim: Dim.Percent(60)),
-            Height = Dim.Auto (DimAutoStyle.Content),
+            Width = Dim.Auto (DimAutoStyle.Content, minimumContentDim: 1, Dim.Percent (90)),
+            Height = Dim.Auto (DimAutoStyle.Content, minimumContentDim: 1, Dim.Percent (90)),
         };
         };
 
 
         if (width != 0)
         if (width != 0)
@@ -358,22 +379,18 @@ public static class MessageBox
             d.Height = height;
             d.Height = height;
         }
         }
 
 
-        if (useErrorColors)
-        {
-            d.ColorScheme = Colors.ColorSchemes ["Error"];
-        }
-        else
-        {
-            d.ColorScheme = Colors.ColorSchemes ["Dialog"];
-        }
+        d.ColorScheme = useErrorColors ? Colors.ColorSchemes ["Error"] : Colors.ColorSchemes ["Dialog"];
 
 
         var messageLabel = new Label
         var messageLabel = new Label
         {
         {
+            HotKeySpecifier = new Rune ('\xFFFF'),
+            Width = Dim.Auto (DimAutoStyle.Text),
+            Height = Dim.Auto (DimAutoStyle.Text),
             Text = message,
             Text = message,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             X = Pos.Center (),
             X = Pos.Center (),
             Y = 0,
             Y = 0,
-           // ColorScheme = Colors.ColorSchemes ["Error"]
+            //ColorScheme = Colors.ColorSchemes ["Error"],
         };
         };
 
 
         messageLabel.TextFormatter.WordWrap = wrapMessage;
         messageLabel.TextFormatter.WordWrap = wrapMessage;
@@ -381,15 +398,16 @@ public static class MessageBox
 
 
         if (wrapMessage)
         if (wrapMessage)
         {
         {
+            int buttonHeight = buttonList.Count > 0 ? buttonList [0].Frame.Height : 0;
+
             messageLabel.Width = Dim.Fill ();
             messageLabel.Width = Dim.Fill ();
-            messageLabel.Height = Dim.Fill (1);
-            int GetWrapSize ()
+            messageLabel.Height = Dim.Func (() => GetWrapSize ().Height);
+            Size GetWrapSize ()
             {
             {
                 // A bit of a hack to get the height of the wrapped text.
                 // A bit of a hack to get the height of the wrapped text.
-                messageLabel.TextFormatter.Size = new (d.ContentSize.Width, 1000);
-                return messageLabel.TextFormatter.FormatAndGetSize ().Height;
+                messageLabel.TextFormatter.Size = d.ContentSize with { Height = 1000 };
+                return messageLabel.TextFormatter.FormatAndGetSize ();
             }
             }
-            d.Height = Dim.Auto (DimAutoStyle.Content, minimumContentDim: Dim.Func (GetWrapSize) + 1);
         }
         }
 
 
         d.Add (messageLabel);
         d.Add (messageLabel);

+ 19 - 0
Terminal.Gui/Views/OrientationEventArgs.cs

@@ -0,0 +1,19 @@
+namespace Terminal.Gui;
+
+/// <summary><see cref="EventArgs"/> for <see cref="Orientation"/> events.</summary>
+public class OrientationEventArgs : EventArgs
+{
+    /// <summary>Constructs a new instance.</summary>
+    /// <param name="orientation">the new orientation</param>
+    public OrientationEventArgs (Orientation orientation)
+    {
+        Orientation = orientation;
+        Cancel = false;
+    }
+
+    /// <summary>If set to true, the orientation change operation will be canceled, if applicable.</summary>
+    public bool Cancel { get; set; }
+
+    /// <summary>The new orientation.</summary>
+    public Orientation Orientation { get; set; }
+}

+ 1 - 1
Terminal.Gui/Views/ProgressBar.cs

@@ -175,7 +175,7 @@ public class ProgressBar : View
 
 
         if (ProgressBarFormat != ProgressBarFormat.Simple && !_isActivity)
         if (ProgressBarFormat != ProgressBarFormat.Simple && !_isActivity)
         {
         {
-            var tf = new TextFormatter { Alignment = TextAlignment.Centered, Text = Text, AutoSize = true };
+            var tf = new TextFormatter { Alignment = Alignment.Center, Text = Text, AutoSize = true };
             var attr = new Attribute (ColorScheme.HotNormal.Foreground, ColorScheme.HotNormal.Background);
             var attr = new Attribute (ColorScheme.HotNormal.Foreground, ColorScheme.HotNormal.Background);
 
 
             if (_fraction > .5)
             if (_fraction > .5)

+ 8 - 219
Terminal.Gui/Views/Slider.cs

@@ -1,210 +1,5 @@
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
-/// <summary><see cref="EventArgs"/> for <see cref="Slider{T}"/> <see cref="SliderOption{T}"/> events.</summary>
-public class SliderOptionEventArgs : EventArgs
-{
-    /// <summary>Initializes a new instance of <see cref="SliderOptionEventArgs"/></summary>
-    /// <param name="isSet"> indicates whether the option is set</param>
-    public SliderOptionEventArgs (bool isSet) { IsSet = isSet; }
-
-    /// <summary>Gets whether the option is set or not.</summary>
-    public bool IsSet { get; }
-}
-
-/// <summary>Represents an option in a <see cref="Slider{T}"/> .</summary>
-/// <typeparam name="T">Data type of the option.</typeparam>
-public class SliderOption<T>
-{
-    /// <summary>Creates a new empty instance of the <see cref="SliderOption{T}"/> class.</summary>
-    public SliderOption () { }
-
-    /// <summary>Creates a new instance of the <see cref="SliderOption{T}"/> class with values for each property.</summary>
-    public SliderOption (string legend, Rune legendAbbr, T data)
-    {
-        Legend = legend;
-        LegendAbbr = legendAbbr;
-        Data = data;
-    }
-
-    /// <summary>Event fired when the an option has changed.</summary>
-    public event EventHandler<SliderOptionEventArgs> Changed;
-
-    /// <summary>Custom data of the option.</summary>
-    public T Data { get; set; }
-
-    /// <summary>Legend of the option.</summary>
-    public string Legend { get; set; }
-
-    /// <summary>
-    ///     Abbreviation of the Legend. When the <see cref="Slider{T}.MinimumInnerSpacing"/> too small to fit
-    ///     <see cref="Legend"/>.
-    /// </summary>
-    public Rune LegendAbbr { get; set; }
-
-    /// <summary>Event Raised when this option is set.</summary>
-    public event EventHandler<SliderOptionEventArgs> Set;
-
-    /// <summary>Creates a human-readable string that represents this <see cref="SliderOption{T}"/>.</summary>
-    public override string ToString () { return "{Legend=" + Legend + ", LegendAbbr=" + LegendAbbr + ", Data=" + Data + "}"; }
-
-    /// <summary>Event Raised when this option is unset.</summary>
-    public event EventHandler<SliderOptionEventArgs> UnSet;
-
-    /// <summary>To Raise the <see cref="Changed"/> event from the Slider.</summary>
-    internal void OnChanged (bool isSet) { Changed?.Invoke (this, new (isSet)); }
-
-    /// <summary>To Raise the <see cref="Set"/> event from the Slider.</summary>
-    internal void OnSet () { Set?.Invoke (this, new (true)); }
-
-    /// <summary>To Raise the <see cref="UnSet"/> event from the Slider.</summary>
-    internal void OnUnSet () { UnSet?.Invoke (this, new (false)); }
-}
-
-/// <summary><see cref="Slider{T}"/>  Types</summary>
-public enum SliderType
-{
-    /// <summary>
-    ///     <code>
-    /// ├─┼─┼─┼─┼─█─┼─┼─┼─┼─┼─┼─┤
-    /// </code>
-    /// </summary>
-    Single,
-
-    /// <summary>
-    ///     <code>
-    /// ├─┼─█─┼─┼─█─┼─┼─┼─┼─█─┼─┤
-    /// </code>
-    /// </summary>
-    Multiple,
-
-    /// <summary>
-    ///     <code>
-    /// ├▒▒▒▒▒▒▒▒▒█─┼─┼─┼─┼─┼─┼─┤
-    /// </code>
-    /// </summary>
-    LeftRange,
-
-    /// <summary>
-    ///     <code>
-    /// ├─┼─┼─┼─┼─█▒▒▒▒▒▒▒▒▒▒▒▒▒┤
-    /// </code>
-    /// </summary>
-    RightRange,
-
-    /// <summary>
-    ///     <code>
-    /// ├─┼─┼─┼─┼─█▒▒▒▒▒▒▒█─┼─┼─┤
-    /// </code>
-    /// </summary>
-    Range
-}
-
-/// <summary><see cref="Slider{T}"/> Legend Style</summary>
-public class SliderAttributes
-{
-    /// <summary>Attribute for the Legends Container.</summary>
-    public Attribute? EmptyAttribute { get; set; }
-
-    /// <summary>Attribute for when the respective Option is NOT Set.</summary>
-    public Attribute? NormalAttribute { get; set; }
-
-    /// <summary>Attribute for when the respective Option is Set.</summary>
-    public Attribute? SetAttribute { get; set; }
-}
-
-/// <summary><see cref="Slider{T}"/> Style</summary>
-public class SliderStyle
-{
-    /// <summary>Constructs a new instance.</summary>
-    public SliderStyle () { LegendAttributes = new (); }
-
-    /// <summary>The glyph and the attribute to indicate mouse dragging.</summary>
-    public Cell DragChar { get; set; }
-
-    /// <summary>The glyph and the attribute used for empty spaces on the slider.</summary>
-    public Cell EmptyChar { get; set; }
-
-    /// <summary>The glyph and the attribute used for the end of ranges on the slider.</summary>
-    public Cell EndRangeChar { get; set; }
-
-    /// <summary>Legend attributes</summary>
-    public SliderAttributes LegendAttributes { get; set; }
-
-    /// <summary>The glyph and the attribute used for each option (tick) on the slider.</summary>
-    public Cell OptionChar { get; set; }
-
-    /// <summary>The glyph and the attribute used for filling in ranges on the slider.</summary>
-    public Cell RangeChar { get; set; }
-
-    /// <summary>The glyph and the attribute used for options (ticks) that are set on the slider.</summary>
-    public Cell SetChar { get; set; }
-
-    /// <summary>The glyph and the attribute used for spaces between options (ticks) on the slider.</summary>
-    public Cell SpaceChar { get; set; }
-
-    /// <summary>The glyph and the attribute used for the start of ranges on the slider.</summary>
-    public Cell StartRangeChar { get; set; }
-}
-
-/// <summary>All <see cref="Slider{T}"/> configuration are grouped in this class.</summary>
-internal class SliderConfiguration
-{
-    internal bool _allowEmpty;
-    internal int _endSpacing;
-    internal int _minInnerSpacing = 1;
-    internal int _cachedInnerSpacing; // Currently calculated
-    internal Orientation _legendsOrientation = Orientation.Horizontal;
-    internal bool _rangeAllowSingle;
-    internal bool _showEndSpacing;
-    internal bool _showLegends;
-    internal bool _showLegendsAbbr;
-    internal Orientation _sliderOrientation = Orientation.Horizontal;
-    internal int _startSpacing;
-    internal SliderType _type = SliderType.Single;
-    internal bool _useMinimumSize;
-}
-
-/// <summary><see cref="EventArgs"/> for <see cref="Slider{T}"/> events.</summary>
-public class SliderEventArgs<T> : EventArgs
-{
-    /// <summary>Initializes a new instance of <see cref="SliderEventArgs{T}"/></summary>
-    /// <param name="options">The current options.</param>
-    /// <param name="focused">Index of the option that is focused. -1 if no option has the focus.</param>
-    public SliderEventArgs (Dictionary<int, SliderOption<T>> options, int focused = -1)
-    {
-        Options = options;
-        Focused = focused;
-        Cancel = false;
-    }
-
-    /// <summary>If set to true, the focus operation will be canceled, if applicable.</summary>
-    public bool Cancel { get; set; }
-
-    /// <summary>Gets or sets the index of the option that is focused.</summary>
-    public int Focused { get; set; }
-
-    /// <summary>Gets/sets whether the option is set or not.</summary>
-    public Dictionary<int, SliderOption<T>> Options { get; set; }
-}
-
-/// <summary><see cref="EventArgs"/> for <see cref="Orientation"/> events.</summary>
-public class OrientationEventArgs : EventArgs
-{
-    /// <summary>Constructs a new instance.</summary>
-    /// <param name="orientation">the new orientation</param>
-    public OrientationEventArgs (Orientation orientation)
-    {
-        Orientation = orientation;
-        Cancel = false;
-    }
-
-    /// <summary>If set to true, the orientation change operation will be canceled, if applicable.</summary>
-    public bool Cancel { get; set; }
-
-    /// <summary>The new orientation.</summary>
-    public Orientation Orientation { get; set; }
-}
-
 /// <summary>Slider control.</summary>
 /// <summary>Slider control.</summary>
 public class Slider : Slider<object>
 public class Slider : Slider<object>
 {
 {
@@ -1002,7 +797,7 @@ public class Slider<T> : View
         }
         }
     }
     }
 
 
-    private string AlignText (string text, int width, TextAlignment textAlignment)
+    private string AlignText (string text, int width, Alignment alignment)
     {
     {
         if (text is null)
         if (text is null)
         {
         {
@@ -1019,20 +814,20 @@ public class Slider<T> : View
         string s2 = new (' ', w % 2);
         string s2 = new (' ', w % 2);
 
 
         // Note: The formatter doesn't handle all of this ???
         // Note: The formatter doesn't handle all of this ???
-        switch (textAlignment)
+        switch (alignment)
         {
         {
-            case TextAlignment.Justified:
+            case Alignment.Fill:
                 return TextFormatter.Justify (text, width);
                 return TextFormatter.Justify (text, width);
-            case TextAlignment.Left:
+            case Alignment.Start:
                 return text + s1 + s1 + s2;
                 return text + s1 + s1 + s2;
-            case TextAlignment.Centered:
+            case Alignment.Center:
                 if (text.Length % 2 != 0)
                 if (text.Length % 2 != 0)
                 {
                 {
                     return s1 + text + s1 + s2;
                     return s1 + text + s1 + s2;
                 }
                 }
 
 
                 return s1 + s2 + text + s1;
                 return s1 + s2 + text + s1;
-            case TextAlignment.Right:
+            case Alignment.End:
                 return s1 + s1 + s2 + text;
                 return s1 + s1 + s2 + text;
             default:
             default:
                 return text;
                 return text;
@@ -1139,12 +934,6 @@ public class Slider<T> : View
                             }
                             }
 
 
                             break;
                             break;
-                        case SliderType.Single:
-                            break;
-                        case SliderType.Multiple:
-                            break;
-                        default:
-                            throw new ArgumentOutOfRangeException ();
                     }
                     }
                 }
                 }
 
 
@@ -1365,7 +1154,7 @@ public class Slider<T> : View
                     switch (_config._legendsOrientation)
                     switch (_config._legendsOrientation)
                     {
                     {
                         case Orientation.Horizontal:
                         case Orientation.Horizontal:
-                            text = AlignText (text, _config._cachedInnerSpacing + 1, TextAlignment.Centered);
+                            text = AlignText (text, _config._cachedInnerSpacing + 1, Alignment.Center);
 
 
                             break;
                             break;
                         case Orientation.Vertical:
                         case Orientation.Vertical:
@@ -1383,7 +1172,7 @@ public class Slider<T> : View
 
 
                             break;
                             break;
                         case Orientation.Vertical:
                         case Orientation.Vertical:
-                            text = AlignText (text, _config._cachedInnerSpacing + 1, TextAlignment.Centered);
+                            text = AlignText (text, _config._cachedInnerSpacing + 1, Alignment.Center);
 
 
                             break;
                             break;
                     }
                     }

+ 14 - 0
Terminal.Gui/Views/SliderAttributes.cs

@@ -0,0 +1,14 @@
+namespace Terminal.Gui;
+
+/// <summary><see cref="Slider{T}"/> Legend Style</summary>
+public class SliderAttributes
+{
+    /// <summary>Attribute for the Legends Container.</summary>
+    public Attribute? EmptyAttribute { get; set; }
+
+    /// <summary>Attribute for when the respective Option is NOT Set.</summary>
+    public Attribute? NormalAttribute { get; set; }
+
+    /// <summary>Attribute for when the respective Option is Set.</summary>
+    public Attribute? SetAttribute { get; set; }
+}

+ 19 - 0
Terminal.Gui/Views/SliderConfiguration.cs

@@ -0,0 +1,19 @@
+namespace Terminal.Gui;
+
+/// <summary>All <see cref="Slider{T}"/> configuration are grouped in this class.</summary>
+internal class SliderConfiguration
+{
+    internal bool _allowEmpty;
+    internal int _endSpacing;
+    internal int _minInnerSpacing = 1;
+    internal int _cachedInnerSpacing; // Currently calculated
+    internal Orientation _legendsOrientation = Orientation.Horizontal;
+    internal bool _rangeAllowSingle;
+    internal bool _showEndSpacing;
+    internal bool _showLegends;
+    internal bool _showLegendsAbbr;
+    internal Orientation _sliderOrientation = Orientation.Horizontal;
+    internal int _startSpacing;
+    internal SliderType _type = SliderType.Single;
+    internal bool _useMinimumSize;
+}

+ 24 - 0
Terminal.Gui/Views/SliderEventArgs.cs

@@ -0,0 +1,24 @@
+namespace Terminal.Gui;
+
+/// <summary><see cref="EventArgs"/> for <see cref="Slider{T}"/> events.</summary>
+public class SliderEventArgs<T> : EventArgs
+{
+    /// <summary>Initializes a new instance of <see cref="SliderEventArgs{T}"/></summary>
+    /// <param name="options">The current options.</param>
+    /// <param name="focused">Index of the option that is focused. -1 if no option has the focus.</param>
+    public SliderEventArgs (Dictionary<int, SliderOption<T>> options, int focused = -1)
+    {
+        Options = options;
+        Focused = focused;
+        Cancel = false;
+    }
+
+    /// <summary>If set to true, the focus operation will be canceled, if applicable.</summary>
+    public bool Cancel { get; set; }
+
+    /// <summary>Gets or sets the index of the option that is focused.</summary>
+    public int Focused { get; set; }
+
+    /// <summary>Gets/sets whether the option is set or not.</summary>
+    public Dictionary<int, SliderOption<T>> Options { get; set; }
+}

+ 50 - 0
Terminal.Gui/Views/SliderOption.cs

@@ -0,0 +1,50 @@
+namespace Terminal.Gui;
+
+/// <summary>Represents an option in a <see cref="Slider{T}"/> .</summary>
+/// <typeparam name="T">Data type of the option.</typeparam>
+public class SliderOption<T>
+{
+    /// <summary>Creates a new empty instance of the <see cref="SliderOption{T}"/> class.</summary>
+    public SliderOption () { }
+
+    /// <summary>Creates a new instance of the <see cref="SliderOption{T}"/> class with values for each property.</summary>
+    public SliderOption (string legend, Rune legendAbbr, T data)
+    {
+        Legend = legend;
+        LegendAbbr = legendAbbr;
+        Data = data;
+    }
+
+    /// <summary>Event fired when the an option has changed.</summary>
+    public event EventHandler<SliderOptionEventArgs> Changed;
+
+    /// <summary>Custom data of the option.</summary>
+    public T Data { get; set; }
+
+    /// <summary>Legend of the option.</summary>
+    public string Legend { get; set; }
+
+    /// <summary>
+    ///     Abbreviation of the Legend. When the <see cref="Slider{T}.MinimumInnerSpacing"/> too small to fit
+    ///     <see cref="Legend"/>.
+    /// </summary>
+    public Rune LegendAbbr { get; set; }
+
+    /// <summary>Event Raised when this option is set.</summary>
+    public event EventHandler<SliderOptionEventArgs> Set;
+
+    /// <summary>Creates a human-readable string that represents this <see cref="SliderOption{T}"/>.</summary>
+    public override string ToString () { return "{Legend=" + Legend + ", LegendAbbr=" + LegendAbbr + ", Data=" + Data + "}"; }
+
+    /// <summary>Event Raised when this option is unset.</summary>
+    public event EventHandler<SliderOptionEventArgs> UnSet;
+
+    /// <summary>To Raise the <see cref="Changed"/> event from the Slider.</summary>
+    internal void OnChanged (bool isSet) { Changed?.Invoke (this, new (isSet)); }
+
+    /// <summary>To Raise the <see cref="Set"/> event from the Slider.</summary>
+    internal void OnSet () { Set?.Invoke (this, new (true)); }
+
+    /// <summary>To Raise the <see cref="UnSet"/> event from the Slider.</summary>
+    internal void OnUnSet () { UnSet?.Invoke (this, new (false)); }
+}

+ 12 - 0
Terminal.Gui/Views/SliderOptionEventArgs.cs

@@ -0,0 +1,12 @@
+namespace Terminal.Gui;
+
+/// <summary><see cref="EventArgs"/> for <see cref="Slider{T}"/> <see cref="SliderOption{T}"/> events.</summary>
+public class SliderOptionEventArgs : EventArgs
+{
+    /// <summary>Initializes a new instance of <see cref="SliderOptionEventArgs"/></summary>
+    /// <param name="isSet"> indicates whether the option is set</param>
+    public SliderOptionEventArgs (bool isSet) { IsSet = isSet; }
+
+    /// <summary>Gets whether the option is set or not.</summary>
+    public bool IsSet { get; }
+}

+ 35 - 0
Terminal.Gui/Views/SliderStyle.cs

@@ -0,0 +1,35 @@
+namespace Terminal.Gui;
+
+/// <summary><see cref="Slider{T}"/> Style</summary>
+public class SliderStyle
+{
+    /// <summary>Constructs a new instance.</summary>
+    public SliderStyle () { LegendAttributes = new (); }
+
+    /// <summary>The glyph and the attribute to indicate mouse dragging.</summary>
+    public Cell DragChar { get; set; }
+
+    /// <summary>The glyph and the attribute used for empty spaces on the slider.</summary>
+    public Cell EmptyChar { get; set; }
+
+    /// <summary>The glyph and the attribute used for the end of ranges on the slider.</summary>
+    public Cell EndRangeChar { get; set; }
+
+    /// <summary>Legend attributes</summary>
+    public SliderAttributes LegendAttributes { get; set; }
+
+    /// <summary>The glyph and the attribute used for each option (tick) on the slider.</summary>
+    public Cell OptionChar { get; set; }
+
+    /// <summary>The glyph and the attribute used for filling in ranges on the slider.</summary>
+    public Cell RangeChar { get; set; }
+
+    /// <summary>The glyph and the attribute used for options (ticks) that are set on the slider.</summary>
+    public Cell SetChar { get; set; }
+
+    /// <summary>The glyph and the attribute used for spaces between options (ticks) on the slider.</summary>
+    public Cell SpaceChar { get; set; }
+
+    /// <summary>The glyph and the attribute used for the start of ranges on the slider.</summary>
+    public Cell StartRangeChar { get; set; }
+}

+ 40 - 0
Terminal.Gui/Views/SliderType.cs

@@ -0,0 +1,40 @@
+namespace Terminal.Gui;
+
+/// <summary><see cref="Slider{T}"/>  Types</summary>
+public enum SliderType
+{
+    /// <summary>
+    ///     <code>
+    /// ├─┼─┼─┼─┼─█─┼─┼─┼─┼─┼─┼─┤
+    /// </code>
+    /// </summary>
+    Single,
+
+    /// <summary>
+    ///     <code>
+    /// ├─┼─█─┼─┼─█─┼─┼─┼─┼─█─┼─┤
+    /// </code>
+    /// </summary>
+    Multiple,
+
+    /// <summary>
+    ///     <code>
+    /// ├▒▒▒▒▒▒▒▒▒█─┼─┼─┼─┼─┼─┼─┤
+    /// </code>
+    /// </summary>
+    LeftRange,
+
+    /// <summary>
+    ///     <code>
+    /// ├─┼─┼─┼─┼─█▒▒▒▒▒▒▒▒▒▒▒▒▒┤
+    /// </code>
+    /// </summary>
+    RightRange,
+
+    /// <summary>
+    ///     <code>
+    /// ├─┼─┼─┼─┼─█▒▒▒▒▒▒▒█─┼─┼─┤
+    /// </code>
+    /// </summary>
+    Range
+}

+ 13 - 13
Terminal.Gui/Views/TableView/ColumnStyle.cs

@@ -8,10 +8,10 @@
 public class ColumnStyle
 public class ColumnStyle
 {
 {
     /// <summary>
     /// <summary>
-    ///     Defines a delegate for returning custom alignment per cell based on cell values.  When specified this will
+    ///     Defines a delegate for returning custom alignment per cell based on cell values. When specified this will
     ///     override <see cref="Alignment"/>
     ///     override <see cref="Alignment"/>
     /// </summary>
     /// </summary>
-    public Func<object, TextAlignment> AlignmentGetter;
+    public Func<object, Alignment> AlignmentGetter;
 
 
     /// <summary>
     /// <summary>
     ///     Defines a delegate for returning a custom color scheme per cell based on cell values. Return null for the
     ///     Defines a delegate for returning a custom color scheme per cell based on cell values. Return null for the
@@ -20,26 +20,26 @@ public class ColumnStyle
     public CellColorGetterDelegate ColorGetter;
     public CellColorGetterDelegate ColorGetter;
 
 
     /// <summary>
     /// <summary>
-    ///     Defines a delegate for returning custom representations of cell values.  If not set then
-    ///     <see cref="object.ToString()"/> is used.  Return values from your delegate may be truncated e.g. based on
+    ///     Defines a delegate for returning custom representations of cell values. If not set then
+    ///     <see cref="object.ToString()"/> is used. Return values from your delegate may be truncated e.g. based on
     ///     <see cref="MaxWidth"/>
     ///     <see cref="MaxWidth"/>
     /// </summary>
     /// </summary>
     public Func<object, string> RepresentationGetter;
     public Func<object, string> RepresentationGetter;
 
 
-    private bool visible = true;
+    private bool _visible = true;
 
 
     /// <summary>
     /// <summary>
-    ///     Defines the default alignment for all values rendered in this column.  For custom alignment based on cell
+    ///     Defines the default alignment for all values rendered in this column. For custom alignment based on cell
     ///     contents use <see cref="AlignmentGetter"/>.
     ///     contents use <see cref="AlignmentGetter"/>.
     /// </summary>
     /// </summary>
-    public TextAlignment Alignment { get; set; }
+    public Alignment Alignment { get; set; }
 
 
     /// <summary>Defines the format for values e.g. "yyyy-MM-dd" for dates</summary>
     /// <summary>Defines the format for values e.g. "yyyy-MM-dd" for dates</summary>
     public string Format { get; set; }
     public string Format { get; set; }
 
 
     /// <summary>
     /// <summary>
-    ///     Set the maximum width of the column in characters.  This value will be ignored if more than the tables
-    ///     <see cref="TableView.MaxCellWidth"/>.  Defaults to <see cref="TableView.DefaultMaxCellWidth"/>
+    ///     Set the maximum width of the column in characters. This value will be ignored if more than the tables
+    ///     <see cref="TableView.MaxCellWidth"/>. Defaults to <see cref="TableView.DefaultMaxCellWidth"/>
     /// </summary>
     /// </summary>
     public int MaxWidth { get; set; } = TableView.DefaultMaxCellWidth;
     public int MaxWidth { get; set; } = TableView.DefaultMaxCellWidth;
 
 
@@ -47,7 +47,7 @@ public class ColumnStyle
     public int MinAcceptableWidth { get; set; } = TableView.DefaultMinAcceptableWidth;
     public int MinAcceptableWidth { get; set; } = TableView.DefaultMinAcceptableWidth;
 
 
     /// <summary>
     /// <summary>
-    ///     Set the minimum width of the column in characters.  Setting this will ensure that even when a column has short
+    ///     Set the minimum width of the column in characters. Setting this will ensure that even when a column has short
     ///     content/header it still fills a given width of the control.
     ///     content/header it still fills a given width of the control.
     ///     <para>
     ///     <para>
     ///         This value will be ignored if more than the tables <see cref="TableView.MaxCellWidth"/> or the
     ///         This value will be ignored if more than the tables <see cref="TableView.MaxCellWidth"/> or the
@@ -64,8 +64,8 @@ public class ColumnStyle
     /// <remarks>If <see cref="MaxWidth"/> is 0 then <see cref="Visible"/> will always return false.</remarks>
     /// <remarks>If <see cref="MaxWidth"/> is 0 then <see cref="Visible"/> will always return false.</remarks>
     public bool Visible
     public bool Visible
     {
     {
-        get => MaxWidth >= 0 && visible;
-        set => visible = value;
+        get => MaxWidth >= 0 && _visible;
+        set => _visible = value;
     }
     }
 
 
     /// <summary>
     /// <summary>
@@ -74,7 +74,7 @@ public class ColumnStyle
     /// </summary>
     /// </summary>
     /// <param name="cellValue"></param>
     /// <param name="cellValue"></param>
     /// <returns></returns>
     /// <returns></returns>
-    public TextAlignment GetAlignment (object cellValue)
+    public Alignment GetAlignment (object cellValue)
     {
     {
         if (AlignmentGetter is { })
         if (AlignmentGetter is { })
         {
         {

+ 2 - 2
Terminal.Gui/Views/TableView/TableStyle.cs

@@ -15,11 +15,11 @@ public class TableStyle
     /// </summary>
     /// </summary>
     public bool AlwaysUseNormalColorForVerticalCellLines { get; set; } = false;
     public bool AlwaysUseNormalColorForVerticalCellLines { get; set; } = false;
 
 
-    /// <summary>Collection of columns for which you want special rendering (e.g. custom column lengths, text alignment etc)</summary>
+    /// <summary>Collection of columns for which you want special rendering (e.g. custom column lengths, text justification, etc.)</summary>
     public Dictionary<int, ColumnStyle> ColumnStyles { get; set; } = new ();
     public Dictionary<int, ColumnStyle> ColumnStyles { get; set; } = new ();
 
 
     /// <summary>
     /// <summary>
-    ///     Determines rendering when the last column in the table is visible but it's content or
+    ///     Determines rendering when the last column in the table is visible, but it's content or
     ///     <see cref="ColumnStyle.MaxWidth"/> is less than the remaining space in the control.  True (the default) will expand
     ///     <see cref="ColumnStyle.MaxWidth"/> is less than the remaining space in the control.  True (the default) will expand
     ///     the column to fill the remaining bounds of the control.  False will draw a column ending line and leave a blank
     ///     the column to fill the remaining bounds of the control.  False will draw a column ending line and leave a blank
     ///     column that cannot be selected in the remaining space.
     ///     column that cannot be selected in the remaining space.

+ 5 - 5
Terminal.Gui/Views/TableView/TableView.cs

@@ -2116,16 +2116,16 @@ public class TableView : View
                         - (representation.EnumerateRunes ().Sum (c => c.GetColumns ())
                         - (representation.EnumerateRunes ().Sum (c => c.GetColumns ())
                            + 1 /*leave 1 space for cell boundary*/);
                            + 1 /*leave 1 space for cell boundary*/);
 
 
-            switch (colStyle?.GetAlignment (originalCellValue) ?? TextAlignment.Left)
+            switch (colStyle?.GetAlignment (originalCellValue) ?? Alignment.Start)
             {
             {
-                case TextAlignment.Left:
+                case Alignment.Start:
                     return representation + new string (' ', toPad);
                     return representation + new string (' ', toPad);
-                case TextAlignment.Right:
+                case Alignment.End:
                     return new string (' ', toPad) + representation;
                     return new string (' ', toPad) + representation;
 
 
                 // TODO: With single line cells, centered and justified are the same right?
                 // TODO: With single line cells, centered and justified are the same right?
-                case TextAlignment.Centered:
-                case TextAlignment.Justified:
+                case Alignment.Center:
+                case Alignment.Fill:
                     return
                     return
                         new string (' ', (int)Math.Floor (toPad / 2.0))
                         new string (' ', (int)Math.Floor (toPad / 2.0))
                         + // round down
                         + // round down

+ 7 - 7
Terminal.Gui/Views/TextValidateField.cs

@@ -539,7 +539,7 @@ namespace Terminal.Gui
             {
             {
                 int c = _provider.Cursor (mouseEvent.Position.X - GetMargins (Viewport.Width).left);
                 int c = _provider.Cursor (mouseEvent.Position.X - GetMargins (Viewport.Width).left);
 
 
-                if (_provider.Fixed == false && TextAlignment == TextAlignment.Right && Text.Length > 0)
+                if (_provider.Fixed == false && TextAlignment == Alignment.End && Text.Length > 0)
                 {
                 {
                     c++;
                     c++;
                 }
                 }
@@ -633,7 +633,7 @@ namespace Terminal.Gui
             // When it's right-aligned and it's a normal input, the cursor behaves differently.
             // When it's right-aligned and it's a normal input, the cursor behaves differently.
             int curPos;
             int curPos;
 
 
-            if (_provider?.Fixed == false && TextAlignment == TextAlignment.Right)
+            if (_provider?.Fixed == false && TextAlignment == Alignment.End)
             {
             {
                 curPos = _cursorPosition + left - 1;
                 curPos = _cursorPosition + left - 1;
             }
             }
@@ -650,7 +650,7 @@ namespace Terminal.Gui
         /// <returns></returns>
         /// <returns></returns>
         private bool BackspaceKeyHandler ()
         private bool BackspaceKeyHandler ()
         {
         {
-            if (_provider.Fixed == false && TextAlignment == TextAlignment.Right && _cursorPosition <= 1)
+            if (_provider.Fixed == false && TextAlignment == Alignment.End && _cursorPosition <= 1)
             {
             {
                 return false;
                 return false;
             }
             }
@@ -688,7 +688,7 @@ namespace Terminal.Gui
         /// <returns></returns>
         /// <returns></returns>
         private bool DeleteKeyHandler ()
         private bool DeleteKeyHandler ()
         {
         {
-            if (_provider.Fixed == false && TextAlignment == TextAlignment.Right)
+            if (_provider.Fixed == false && TextAlignment == Alignment.End)
             {
             {
                 _cursorPosition = _provider.CursorLeft (_cursorPosition);
                 _cursorPosition = _provider.CursorLeft (_cursorPosition);
             }
             }
@@ -719,11 +719,11 @@ namespace Terminal.Gui
 
 
             switch (TextAlignment)
             switch (TextAlignment)
             {
             {
-                case TextAlignment.Left:
+                case Alignment.Start:
                     return (0, total);
                     return (0, total);
-                case TextAlignment.Centered:
+                case Alignment.Center:
                     return (total / 2, total / 2 + total % 2);
                     return (total / 2, total / 2 + total % 2);
-                case TextAlignment.Right:
+                case Alignment.End:
                     return (total, 0);
                     return (total, 0);
                 default:
                 default:
                     return (0, total);
                     return (0, total);

+ 5 - 2
Terminal.Gui/Views/TextView.cs

@@ -1784,7 +1784,7 @@ internal class WordWrapManager
                                                             TextFormatter.Format (
                                                             TextFormatter.Format (
                                                                                   TextModel.ToString (line),
                                                                                   TextModel.ToString (line),
                                                                                   width,
                                                                                   width,
-                                                                                  TextAlignment.Left,
+                                                                                  Alignment.Start,
                                                                                   true,
                                                                                   true,
                                                                                   preserveTrailingSpaces,
                                                                                   preserveTrailingSpaces,
                                                                                   tabWidth
                                                                                   tabWidth
@@ -4161,7 +4161,10 @@ public class TextView : View
         }
         }
         else
         else
         {
         {
-            PositionCursor ();
+            if (IsInitialized)
+            {
+                PositionCursor ();
+            }
         }
         }
 
 
         OnUnwrappedCursorPosition ();
         OnUnwrappedCursorPosition ();

+ 3 - 20
Terminal.Gui/Views/Wizard/Wizard.cs

@@ -54,23 +54,6 @@ public class Wizard : Dialog
     private readonly LinkedList<WizardStep> _steps = new ();
     private readonly LinkedList<WizardStep> _steps = new ();
     private WizardStep _currentStep;
     private WizardStep _currentStep;
     private bool _finishedPressed;
     private bool _finishedPressed;
-
-    ///// <summary>
-    ///// The title of the Wizard, shown at the top of the Wizard with " - currentStep.Title" appended.
-    ///// </summary>
-    ///// <remarks>
-    ///// The Title is only displayed when the <see cref="Wizard"/> <see cref="Wizard.Modal"/> is set to <c>false</c>.
-    ///// </remarks>
-    //public new string Title {
-    //	get {
-    //		// The base (Dialog) Title holds the full title ("Wizard Title - Step Title")
-    //		return base.Title;
-    //	}
-    //	set {
-    //		wizardTitle = value;
-    //		base.Title = $"{wizardTitle}{(steps.Count > 0 && currentStep is { } ? " - " + currentStep.Title : string.Empty)}";
-    //	}
-    //}
     private string _wizardTitle = string.Empty;
     private string _wizardTitle = string.Empty;
 
 
     /// <summary>
     /// <summary>
@@ -83,9 +66,9 @@ public class Wizard : Dialog
     /// </remarks>
     /// </remarks>
     public Wizard ()
     public Wizard ()
     {
     {
-        // Using Justify causes the Back and Next buttons to be hard justified against
-        // the left and right edge
-        ButtonAlignment = ButtonAlignments.Justify;
+        // TODO: LastEndRestStart will enable a "Quit" button to always appear at the far left
+        ButtonAlignment = Alignment.Start;
+        ButtonAlignmentModes |= AlignmentModes.IgnoreFirstOrLast;
         BorderStyle = LineStyle.Double;
         BorderStyle = LineStyle.Double;
 
 
         //// Add a horiz separator
         //// Add a horiz separator

+ 2 - 0
Terminal.sln.DotSettings

@@ -391,6 +391,7 @@
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=53eecf85_002Dd821_002D40e8_002Dac97_002Dfdb734542b84/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=53eecf85_002Dd821_002D40e8_002Dac97_002Dfdb734542b84/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=70345118_002D4b40_002D4ece_002D937c_002Dbbeb7a0b2e70/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=70345118_002D4b40_002D4ece_002D937c_002Dbbeb7a0b2e70/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=c873eafb_002Dd57f_002D481d_002D8c93_002D77f6863c2f88/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=c873eafb_002Dd57f_002D481d_002D8c93_002D77f6863c2f88/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
+	<s:String x:Key="/Default/Environment/InlayHints/GeneralInlayHintsOptions/DefaultMode/@EntryValue">PushToShowHints</s:String>
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
@@ -439,5 +440,6 @@
 	<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B0C2F2A1AF61DA42BBF270980E3DCEF7/Name/@EntryValue">Concurrency Issue</s:String>
 	<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B0C2F2A1AF61DA42BBF270980E3DCEF7/Name/@EntryValue">Concurrency Issue</s:String>
 	<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B0C2F2A1AF61DA42BBF270980E3DCEF7/Pattern/@EntryValue">(?&lt;=\W|^)(?&lt;TAG&gt;CONCURRENCY:)(\W|$)(.*)</s:String>
 	<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B0C2F2A1AF61DA42BBF270980E3DCEF7/Pattern/@EntryValue">(?&lt;=\W|^)(?&lt;TAG&gt;CONCURRENCY:)(\W|$)(.*)</s:String>
 	<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B0C2F2A1AF61DA42BBF270980E3DCEF7/TodoIconStyle/@EntryValue">Warning</s:String>
 	<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B0C2F2A1AF61DA42BBF270980E3DCEF7/TodoIconStyle/@EntryValue">Warning</s:String>
+	<s:Boolean x:Key="/Default/UserDictionary/Words/=Justifier/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=unsynchronized/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=unsynchronized/@EntryIndexedValue">True</s:Boolean>
 </wpf:ResourceDictionary>
 </wpf:ResourceDictionary>

+ 1 - 0
UICatalog/Resources/config.json

@@ -32,6 +32,7 @@
   "Themes": [
   "Themes": [
     {
     {
       "UI Catalog Theme": {
       "UI Catalog Theme": {
+        "Dialog.DefaultButtonAlignment": "Fill",
         "ColorSchemes": [
         "ColorSchemes": [
           {
           {
             "UI Catalog Scheme": {
             "UI Catalog Scheme": {

+ 16 - 12
UICatalog/Scenarios/AllViewsTester.cs

@@ -42,14 +42,14 @@ public class AllViewsTester : Scenario
     private string _demoText = "This, that, and the other thing.";
     private string _demoText = "This, that, and the other thing.";
     private TextView _demoTextView;
     private TextView _demoTextView;
 
 
-    public override void Init ()
+    public override void Main ()
     {
     {
         // Don't create a sub-win (Scenario.Win); just use Application.Top
         // Don't create a sub-win (Scenario.Win); just use Application.Top
         Application.Init ();
         Application.Init ();
-        ConfigurationManager.Themes.Theme = Theme;
         ConfigurationManager.Apply ();
         ConfigurationManager.Apply ();
-        Top = new ();
-        Top.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
+
+        var app = new Window ();
+        app.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
 
 
         var statusBar = new StatusBar (
         var statusBar = new StatusBar (
                                        new StatusItem []
                                        new StatusItem []
@@ -66,7 +66,7 @@ public class AllViewsTester : Scenario
                                                 {
                                                 {
                                                     View.Diagnostics ^=
                                                     View.Diagnostics ^=
                                                         ViewDiagnosticFlags.Ruler;
                                                         ViewDiagnosticFlags.Ruler;
-                                                    Top.SetNeedsDisplay ();
+                                                    app.SetNeedsDisplay ();
                                                 }
                                                 }
                                                ),
                                                ),
                                            new (
                                            new (
@@ -76,12 +76,12 @@ public class AllViewsTester : Scenario
                                                 {
                                                 {
                                                     View.Diagnostics ^=
                                                     View.Diagnostics ^=
                                                         ViewDiagnosticFlags.Padding;
                                                         ViewDiagnosticFlags.Padding;
-                                                    Top.SetNeedsDisplay ();
+                                                    app.SetNeedsDisplay ();
                                                 }
                                                 }
                                                )
                                                )
                                        }
                                        }
                                       );
                                       );
-        Top.Add (statusBar);
+        app.Add (statusBar);
 
 
         _viewClasses = GetAllViewClassesCollection ()
         _viewClasses = GetAllViewClassesCollection ()
                        .OrderBy (t => t.Name)
                        .OrderBy (t => t.Name)
@@ -145,7 +145,7 @@ public class AllViewsTester : Scenario
         {
         {
             X = 0,
             X = 0,
             Y = 0,
             Y = 0,
-            Height = Dim.Auto (), 
+            Height = Dim.Auto (),
             Width = Dim.Auto (),
             Width = Dim.Auto (),
             Title = "Location (Pos)"
             Title = "Location (Pos)"
         };
         };
@@ -279,7 +279,7 @@ public class AllViewsTester : Scenario
         };
         };
         _orientation.SelectedItemChanged += (s, selected) =>
         _orientation.SelectedItemChanged += (s, selected) =>
                                             {
                                             {
-                                                if (_curView?.GetType ().GetProperty ("Orientation") is {} prop)
+                                                if (_curView?.GetType ().GetProperty ("Orientation") is { } prop)
                                                 {
                                                 {
                                                     prop.GetSetMethod ()?.Invoke (_curView, new object [] { _orientation.SelectedItem });
                                                     prop.GetSetMethod ()?.Invoke (_curView, new object [] { _orientation.SelectedItem });
                                                 }
                                                 }
@@ -312,9 +312,13 @@ public class AllViewsTester : Scenario
             ColorScheme = Colors.ColorSchemes ["Dialog"]
             ColorScheme = Colors.ColorSchemes ["Dialog"]
         };
         };
 
 
-        Top.Add (_leftPane, _settingsPane, _hostPane);
+        app.Add (_leftPane, _settingsPane, _hostPane);
 
 
         _curView = CreateClass (_viewClasses.First ().Value);
         _curView = CreateClass (_viewClasses.First ().Value);
+
+        Application.Run (app);
+        app.Dispose ();
+        Application.Shutdown ();
     }
     }
 
 
     // TODO: Add Command.HotKey handler (pop a message box?)
     // TODO: Add Command.HotKey handler (pop a message box?)
@@ -389,9 +393,9 @@ public class AllViewsTester : Scenario
         }
         }
 
 
         // If the view supports a Title property, set it so we have something to look at
         // If the view supports a Title property, set it so we have something to look at
-        if (view?.GetType ().GetProperty ("Orientation") is {} prop)
+        if (view?.GetType ().GetProperty ("Orientation") is { } prop)
         {
         {
-            _orientation.SelectedItem = (int)prop.GetGetMethod()!.Invoke (view, null)!;
+            _orientation.SelectedItem = (int)prop.GetGetMethod ()!.Invoke (view, null)!;
             _orientation.Enabled = true;
             _orientation.Enabled = true;
         }
         }
         else
         else

+ 2 - 2
UICatalog/Scenarios/BasicColors.cs

@@ -32,7 +32,7 @@ public class BasicColors : Scenario
                 Y = 0,
                 Y = 0,
                 Width = 1,
                 Width = 1,
                 Height = 13,
                 Height = 13,
-                VerticalTextAlignment = VerticalTextAlignment.Bottom,
+                VerticalTextAlignment = Alignment.End,
                 ColorScheme = new ColorScheme { Normal = attr },
                 ColorScheme = new ColorScheme { Normal = attr },
                 Text = bg.ToString (),
                 Text = bg.ToString (),
                 TextDirection = TextDirection.TopBottom_LeftRight
                 TextDirection = TextDirection.TopBottom_LeftRight
@@ -45,7 +45,7 @@ public class BasicColors : Scenario
                 Y = y,
                 Y = y,
                 Width = 13,
                 Width = 13,
                 Height = 1,
                 Height = 1,
-                TextAlignment = TextAlignment.Right,
+                TextAlignment = Alignment.End,
                 ColorScheme = new ColorScheme { Normal = attr },
                 ColorScheme = new ColorScheme { Normal = attr },
                 Text = bg.ToString ()
                 Text = bg.ToString ()
             };
             };

+ 28 - 29
UICatalog/Scenarios/Buttons.cs

@@ -218,7 +218,7 @@ public class Buttons : Scenario
             X = 4,
             X = 4,
             Y = Pos.Bottom (label) + 1,
             Y = Pos.Bottom (label) + 1,
             SelectedItem = 2,
             SelectedItem = 2,
-            RadioLabels = new [] { "Left", "Right", "Centered", "Justified" }
+            RadioLabels = new [] { "Start", "End", "Center", "Fill" }
         };
         };
         main.Add (radioGroup);
         main.Add (radioGroup);
 
 
@@ -287,39 +287,39 @@ public class Buttons : Scenario
                                               switch (args.SelectedItem)
                                               switch (args.SelectedItem)
                                               {
                                               {
                                                   case 0:
                                                   case 0:
-                                                      moveBtn.TextAlignment = TextAlignment.Left;
-                                                      sizeBtn.TextAlignment = TextAlignment.Left;
-                                                      moveBtnA.TextAlignment = TextAlignment.Left;
-                                                      sizeBtnA.TextAlignment = TextAlignment.Left;
-                                                      moveHotKeyBtn.TextAlignment = TextAlignment.Left;
-                                                      moveUnicodeHotKeyBtn.TextAlignment = TextAlignment.Left;
+                                                      moveBtn.TextAlignment = Alignment.Start;
+                                                      sizeBtn.TextAlignment = Alignment.Start;
+                                                      moveBtnA.TextAlignment = Alignment.Start;
+                                                      sizeBtnA.TextAlignment = Alignment.Start;
+                                                      moveHotKeyBtn.TextAlignment = Alignment.Start;
+                                                      moveUnicodeHotKeyBtn.TextAlignment = Alignment.Start;
 
 
                                                       break;
                                                       break;
                                                   case 1:
                                                   case 1:
-                                                      moveBtn.TextAlignment = TextAlignment.Right;
-                                                      sizeBtn.TextAlignment = TextAlignment.Right;
-                                                      moveBtnA.TextAlignment = TextAlignment.Right;
-                                                      sizeBtnA.TextAlignment = TextAlignment.Right;
-                                                      moveHotKeyBtn.TextAlignment = TextAlignment.Right;
-                                                      moveUnicodeHotKeyBtn.TextAlignment = TextAlignment.Right;
+                                                      moveBtn.TextAlignment = Alignment.End;
+                                                      sizeBtn.TextAlignment = Alignment.End;
+                                                      moveBtnA.TextAlignment = Alignment.End;
+                                                      sizeBtnA.TextAlignment = Alignment.End;
+                                                      moveHotKeyBtn.TextAlignment = Alignment.End;
+                                                      moveUnicodeHotKeyBtn.TextAlignment = Alignment.End;
 
 
                                                       break;
                                                       break;
                                                   case 2:
                                                   case 2:
-                                                      moveBtn.TextAlignment = TextAlignment.Centered;
-                                                      sizeBtn.TextAlignment = TextAlignment.Centered;
-                                                      moveBtnA.TextAlignment = TextAlignment.Centered;
-                                                      sizeBtnA.TextAlignment = TextAlignment.Centered;
-                                                      moveHotKeyBtn.TextAlignment = TextAlignment.Centered;
-                                                      moveUnicodeHotKeyBtn.TextAlignment = TextAlignment.Centered;
+                                                      moveBtn.TextAlignment = Alignment.Center;
+                                                      sizeBtn.TextAlignment = Alignment.Center;
+                                                      moveBtnA.TextAlignment = Alignment.Center;
+                                                      sizeBtnA.TextAlignment = Alignment.Center;
+                                                      moveHotKeyBtn.TextAlignment = Alignment.Center;
+                                                      moveUnicodeHotKeyBtn.TextAlignment = Alignment.Center;
 
 
                                                       break;
                                                       break;
                                                   case 3:
                                                   case 3:
-                                                      moveBtn.TextAlignment = TextAlignment.Justified;
-                                                      sizeBtn.TextAlignment = TextAlignment.Justified;
-                                                      moveBtnA.TextAlignment = TextAlignment.Justified;
-                                                      sizeBtnA.TextAlignment = TextAlignment.Justified;
-                                                      moveHotKeyBtn.TextAlignment = TextAlignment.Justified;
-                                                      moveUnicodeHotKeyBtn.TextAlignment = TextAlignment.Justified;
+                                                      moveBtn.TextAlignment = Alignment.Fill;
+                                                      sizeBtn.TextAlignment = Alignment.Fill;
+                                                      moveBtnA.TextAlignment = Alignment.Fill;
+                                                      sizeBtnA.TextAlignment = Alignment.Fill;
+                                                      moveHotKeyBtn.TextAlignment = Alignment.Fill;
+                                                      moveUnicodeHotKeyBtn.TextAlignment = Alignment.Fill;
 
 
                                                       break;
                                                       break;
                                               }
                                               }
@@ -418,9 +418,8 @@ public class Buttons : Scenario
                 throw new InvalidOperationException ("T must be a numeric type that supports addition and subtraction.");
                 throw new InvalidOperationException ("T must be a numeric type that supports addition and subtraction.");
             }
             }
 
 
-            // TODO: Use Dim.Auto for the Width and Height
-            Height = 1;
-            Width = Dim.Func (() => Digits + 2); // button + 3 for number + button
+            Width = Dim.Auto (DimAutoStyle.Content); //Dim.Function (() => Digits + 2); // button + 3 for number + button
+            Height = Dim.Auto (DimAutoStyle.Content);
 
 
             _down = new ()
             _down = new ()
             {
             {
@@ -440,7 +439,7 @@ public class Buttons : Scenario
                 Y = Pos.Top (_down),
                 Y = Pos.Top (_down),
                 Width = Dim.Func (() => Digits),
                 Width = Dim.Func (() => Digits),
                 Height = 1,
                 Height = 1,
-                TextAlignment = TextAlignment.Centered,
+                TextAlignment = Alignment.Center,
                 CanFocus = true
                 CanFocus = true
             };
             };
 
 

+ 3 - 2
UICatalog/Scenarios/CharacterMap.cs

@@ -958,7 +958,7 @@ internal class CharMap : View
             Y = 1,
             Y = 1,
             Width = Dim.Fill (),
             Width = Dim.Fill (),
             Height = Dim.Fill (1),
             Height = Dim.Fill (1),
-            TextAlignment = TextAlignment.Centered
+            TextAlignment = Alignment.Center
         };
         };
         var spinner = new SpinnerView { X = Pos.Center (), Y = Pos.Center (), Style = new Aesthetic () };
         var spinner = new SpinnerView { X = Pos.Center (), Y = Pos.Center (), Style = new Aesthetic () };
         spinner.AutoSpin = true;
         spinner.AutoSpin = true;
@@ -1081,7 +1081,7 @@ internal class CharMap : View
             };
             };
             dlg.Add (label);
             dlg.Add (label);
 
 
-            var json = new TextView
+            var json = new TextView ()
             {
             {
                 X = 0,
                 X = 0,
                 Y = Pos.Bottom (label),
                 Y = Pos.Bottom (label),
@@ -1090,6 +1090,7 @@ internal class CharMap : View
                 ReadOnly = true,
                 ReadOnly = true,
                 Text = decResponse
                 Text = decResponse
             };
             };
+
             dlg.Add (json);
             dlg.Add (json);
 
 
             Application.Run (dlg);
             Application.Run (dlg);

+ 2 - 2
UICatalog/Scenarios/CollectionNavigatorTester.cs

@@ -142,7 +142,7 @@ public class CollectionNavigatorTester : Scenario
         var label = new Label
         var label = new Label
         {
         {
             Text = "ListView",
             Text = "ListView",
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             X = 0,
             X = 0,
             Y = 1, // for menu
             Y = 1, // for menu
             Width = Dim.Percent (50),
             Width = Dim.Percent (50),
@@ -171,7 +171,7 @@ public class CollectionNavigatorTester : Scenario
         var label = new Label
         var label = new Label
         {
         {
             Text = "TreeView",
             Text = "TreeView",
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             X = Pos.Right (_listView) + 2,
             X = Pos.Right (_listView) + 2,
             Y = 1, // for menu
             Y = 1, // for menu
             Width = Dim.Percent (50),
             Width = Dim.Percent (50),

+ 2 - 2
UICatalog/Scenarios/ColorPicker.cs

@@ -69,8 +69,8 @@ public class ColorPickers : Scenario
         {
         {
             Title = "Color Sample",
             Title = "Color Sample",
             Text = "Lorem Ipsum",
             Text = "Lorem Ipsum",
-            TextAlignment = TextAlignment.Centered,
-            VerticalTextAlignment = VerticalTextAlignment.Middle,
+            TextAlignment = Alignment.Center,
+            VerticalTextAlignment = Alignment.Center,
             BorderStyle = LineStyle.Heavy,
             BorderStyle = LineStyle.Heavy,
             X = Pos.Center (),
             X = Pos.Center (),
             Y = Pos.Center (),
             Y = Pos.Center (),

+ 34 - 25
UICatalog/Scenarios/ComputedLayout.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using Terminal.Gui;
 using Terminal.Gui;
+using static Terminal.Gui.Dialog;
 
 
 namespace UICatalog.Scenarios;
 namespace UICatalog.Scenarios;
 
 
@@ -85,12 +86,12 @@ public class ComputedLayout : Scenario
         var i = 1;
         var i = 1;
         var txt = "Resize the terminal to see computed layout in action.";
         var txt = "Resize the terminal to see computed layout in action.";
         List<Label> labelList = new ();
         List<Label> labelList = new ();
-        labelList.Add (new Label { Text = "The lines below show different TextAlignments" });
+        labelList.Add (new Label { Text = "The lines below show different alignment" });
 
 
         labelList.Add (
         labelList.Add (
                        new Label
                        new Label
                        {
                        {
-                           TextAlignment = TextAlignment.Left,
+                           TextAlignment = Alignment.Start,
                            Width = Dim.Fill (),
                            Width = Dim.Fill (),
                            X = 0,
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -102,7 +103,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
         labelList.Add (
                        new Label
                        new Label
                        {
                        {
-                           TextAlignment = TextAlignment.Right,
+                           TextAlignment = Alignment.End,
                            Width = Dim.Fill (),
                            Width = Dim.Fill (),
                            X = 0,
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -114,7 +115,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
         labelList.Add (
                        new Label
                        new Label
                        {
                        {
-                           TextAlignment = TextAlignment.Centered,
+                           TextAlignment = Alignment.Center,
                            Width = Dim.Fill (),
                            Width = Dim.Fill (),
                            X = 0,
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -126,7 +127,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
         labelList.Add (
                        new Label
                        new Label
                        {
                        {
-                           TextAlignment = TextAlignment.Justified,
+                           TextAlignment = Alignment.Fill,
                            Width = Dim.Fill (),
                            Width = Dim.Fill (),
                            X = 0,
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -147,12 +148,12 @@ public class ComputedLayout : Scenario
                                  };
                                  };
         i = 1;
         i = 1;
         labelList = new List<Label> ();
         labelList = new List<Label> ();
-        labelList.Add (new Label { Text = "The lines below show different TextAlignments" });
+        labelList.Add (new Label { Text = "The lines below show different alignment" });
 
 
         labelList.Add (
         labelList.Add (
                        new Label
                        new Label
                        {
                        {
-                           TextAlignment = TextAlignment.Left,
+                           TextAlignment = Alignment.Start,
                            Width = Dim.Fill (),
                            Width = Dim.Fill (),
                            X = 0,
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -164,7 +165,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
         labelList.Add (
                        new Label
                        new Label
                        {
                        {
-                           TextAlignment = TextAlignment.Right,
+                           TextAlignment = Alignment.End,
                            Width = Dim.Fill (),
                            Width = Dim.Fill (),
                            X = 0,
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -176,7 +177,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
         labelList.Add (
                        new Label
                        new Label
                        {
                        {
-                           TextAlignment = TextAlignment.Centered,
+                           TextAlignment = Alignment.Center,
                            Width = Dim.Fill (),
                            Width = Dim.Fill (),
                            X = 0,
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -188,7 +189,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
         labelList.Add (
                        new Label
                        new Label
                        {
                        {
-                           TextAlignment = TextAlignment.Justified,
+                           TextAlignment = Alignment.Fill,
                            Width = Dim.Fill (),
                            Width = Dim.Fill (),
                            X = 0,
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -304,7 +305,7 @@ public class ComputedLayout : Scenario
         app.Add (oddballButton);
         app.Add (oddballButton);
 
 
         // Demonstrate AnchorEnd - Button is anchored to bottom/right
         // Demonstrate AnchorEnd - Button is anchored to bottom/right
-        var anchorButton = new Button { Text = "Button using AnchorEnd", Y = Pos.AnchorEnd ()};
+        var anchorButton = new Button { Text = "Button using AnchorEnd", Y = Pos.AnchorEnd () };
         anchorButton.X = Pos.AnchorEnd ();
         anchorButton.X = Pos.AnchorEnd ();
 
 
         anchorButton.Accept += (s, e) =>
         anchorButton.Accept += (s, e) =>
@@ -322,12 +323,12 @@ public class ComputedLayout : Scenario
         // This is intentionally convoluted to illustrate potential bugs.
         // This is intentionally convoluted to illustrate potential bugs.
         var anchorEndLabel1 = new Label
         var anchorEndLabel1 = new Label
         {
         {
-            Text = "This Label should be the 2nd to last line (AnchorEnd (2)).",
-            TextAlignment = TextAlignment.Centered,
+            Text = "This Label should be the 3rd to last line (AnchorEnd (3)).",
+            TextAlignment = Alignment.Center,
             ColorScheme = Colors.ColorSchemes ["Menu"],
             ColorScheme = Colors.ColorSchemes ["Menu"],
             Width = Dim.Fill (5),
             Width = Dim.Fill (5),
             X = 5,
             X = 5,
-            Y = Pos.AnchorEnd (2)
+            Y = Pos.AnchorEnd (3)
         };
         };
         app.Add (anchorEndLabel1);
         app.Add (anchorEndLabel1);
 
 
@@ -336,19 +337,23 @@ public class ComputedLayout : Scenario
         var anchorEndLabel2 = new TextField
         var anchorEndLabel2 = new TextField
         {
         {
             Text =
             Text =
-                "This TextField should be the 3rd to last line (AnchorEnd (2) - 1).",
-            TextAlignment = TextAlignment.Left,
+                "This TextField should be the 4th to last line (AnchorEnd (3) - 1).",
+            TextAlignment = Alignment.Start,
             ColorScheme = Colors.ColorSchemes ["Menu"],
             ColorScheme = Colors.ColorSchemes ["Menu"],
             Width = Dim.Fill (5),
             Width = Dim.Fill (5),
             X = 5,
             X = 5,
-            Y = Pos.AnchorEnd (2) - 1 // Pos.Combine
+            Y = Pos.AnchorEnd (3) - 1 // Pos.Combine
         };
         };
         app.Add (anchorEndLabel2);
         app.Add (anchorEndLabel2);
 
 
-        // Show positioning vertically using Pos.AnchorEnd via Pos.Combine
+        // Demonstrate AnchorEnd() in combination with Pos.Align to align a set of buttons centered across the
+        // bottom - 1
+        // This is intentionally convoluted to illustrate potential bugs.
         var leftButton = new Button
         var leftButton = new Button
         {
         {
-            Text = "Left", Y = Pos.AnchorEnd (0) - 1 // Pos.Combine
+            Text = "Left",
+            X = Pos.Align (Alignment.Center),
+            Y = Pos.AnchorEnd () - 1
         };
         };
 
 
         leftButton.Accept += (s, e) =>
         leftButton.Accept += (s, e) =>
@@ -364,7 +369,9 @@ public class ComputedLayout : Scenario
         // show positioning vertically using Pos.AnchorEnd
         // show positioning vertically using Pos.AnchorEnd
         var centerButton = new Button
         var centerButton = new Button
         {
         {
-            Text = "Center", X = Pos.Center (), Y = Pos.AnchorEnd (1) // Pos.AnchorEnd(1)
+            Text = "Center",
+            X = Pos.Align (Alignment.Center),
+            Y = Pos.AnchorEnd (2),
         };
         };
 
 
         centerButton.Accept += (s, e) =>
         centerButton.Accept += (s, e) =>
@@ -378,7 +385,12 @@ public class ComputedLayout : Scenario
                                 };
                                 };
 
 
         // show positioning vertically using another window and Pos.Bottom
         // show positioning vertically using another window and Pos.Bottom
-        var rightButton = new Button { Text = "Right", Y = Pos.Y (centerButton) };
+        var rightButton = new Button
+        {
+            Text = "Right",
+            X = Pos.Align (Alignment.Center),
+            Y = Pos.Y (centerButton)
+        };
 
 
         rightButton.Accept += (s, e) =>
         rightButton.Accept += (s, e) =>
                                {
                                {
@@ -390,10 +402,7 @@ public class ComputedLayout : Scenario
                                    app.LayoutSubviews ();
                                    app.LayoutSubviews ();
                                };
                                };
 
 
-        // Center three buttons with 5 spaces between them
-        leftButton.X = Pos.Left (centerButton) - (Pos.Right (leftButton) - Pos.Left (leftButton)) - 5;
-        rightButton.X = Pos.Right (centerButton) + 5;
-
+        View [] buttons = { leftButton, centerButton, rightButton };
         app.Add (leftButton);
         app.Add (leftButton);
         app.Add (centerButton);
         app.Add (centerButton);
         app.Add (rightButton);
         app.Add (rightButton);

+ 11 - 11
UICatalog/Scenarios/CsvEditor.cs

@@ -78,17 +78,17 @@ public class CsvEditor : Scenario
                                      _miLeft = new MenuItem (
                                      _miLeft = new MenuItem (
                                                              "_Align Left",
                                                              "_Align Left",
                                                              "",
                                                              "",
-                                                             () => Align (TextAlignment.Left)
+                                                             () => Align (Alignment.Start)
                                                             ),
                                                             ),
                                      _miRight = new MenuItem (
                                      _miRight = new MenuItem (
                                                               "_Align Right",
                                                               "_Align Right",
                                                               "",
                                                               "",
-                                                              () => Align (TextAlignment.Right)
+                                                              () => Align (Alignment.End)
                                                              ),
                                                              ),
                                      _miCentered = new MenuItem (
                                      _miCentered = new MenuItem (
                                                                  "_Align Centered",
                                                                  "_Align Centered",
                                                                  "",
                                                                  "",
-                                                                 () => Align (TextAlignment.Centered)
+                                                                 () => Align (Alignment.Center)
                                                                 ),
                                                                 ),
 
 
                                      // Format requires hard typed data table, when we read a CSV everything is untyped (string) so this only works for new columns in this demo
                                      // Format requires hard typed data table, when we read a CSV everything is untyped (string) so this only works for new columns in this demo
@@ -133,7 +133,7 @@ public class CsvEditor : Scenario
             Y = Pos.Bottom (_tableView),
             Y = Pos.Bottom (_tableView),
             Text = "0,0",
             Text = "0,0",
             Width = Dim.Fill (),
             Width = Dim.Fill (),
-            TextAlignment = TextAlignment.Right
+            TextAlignment = Alignment.End
         };
         };
         _selectedCellLabel.TextChanged += SelectedCellLabel_TextChanged;
         _selectedCellLabel.TextChanged += SelectedCellLabel_TextChanged;
 
 
@@ -218,7 +218,7 @@ public class CsvEditor : Scenario
         _tableView.Update ();
         _tableView.Update ();
     }
     }
 
 
-    private void Align (TextAlignment newAlignment)
+    private void Align (Alignment newAlignment)
     {
     {
         if (NoTableLoaded ())
         if (NoTableLoaded ())
         {
         {
@@ -228,9 +228,9 @@ public class CsvEditor : Scenario
         ColumnStyle style = _tableView.Style.GetOrCreateColumnStyle (_tableView.SelectedColumn);
         ColumnStyle style = _tableView.Style.GetOrCreateColumnStyle (_tableView.SelectedColumn);
         style.Alignment = newAlignment;
         style.Alignment = newAlignment;
 
 
-        _miLeft.Checked = style.Alignment == TextAlignment.Left;
-        _miRight.Checked = style.Alignment == TextAlignment.Right;
-        _miCentered.Checked = style.Alignment == TextAlignment.Centered;
+        _miLeft.Checked = style.Alignment == Alignment.Start;
+        _miRight.Checked = style.Alignment == Alignment.End;
+        _miCentered.Checked = style.Alignment == Alignment.Center;
 
 
         _tableView.Update ();
         _tableView.Update ();
     }
     }
@@ -437,9 +437,9 @@ public class CsvEditor : Scenario
 
 
         ColumnStyle style = _tableView.Style.GetColumnStyleIfAny (_tableView.SelectedColumn);
         ColumnStyle style = _tableView.Style.GetColumnStyleIfAny (_tableView.SelectedColumn);
 
 
-        _miLeft.Checked = style?.Alignment == TextAlignment.Left;
-        _miRight.Checked = style?.Alignment == TextAlignment.Right;
-        _miCentered.Checked = style?.Alignment == TextAlignment.Centered;
+        _miLeft.Checked = style?.Alignment == Alignment.Start;
+        _miRight.Checked = style?.Alignment == Alignment.End;
+        _miCentered.Checked = style?.Alignment == Alignment.Center;
     }
     }
 
 
     private void Open ()
     private void Open ()

+ 25 - 29
UICatalog/Scenarios/Dialogs.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Linq;
 using Terminal.Gui;
 using Terminal.Gui;
 
 
 namespace UICatalog.Scenarios;
 namespace UICatalog.Scenarios;
@@ -31,7 +32,7 @@ public class Dialogs : Scenario
         var numButtonsLabel = new Label
         var numButtonsLabel = new Label
         {
         {
             X = 0,
             X = 0,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "_Number of Buttons:"
             Text = "_Number of Buttons:"
         };
         };
 
 
@@ -41,7 +42,7 @@ public class Dialogs : Scenario
             Y = 0,
             Y = 0,
             Width = Dim.Width (numButtonsLabel),
             Width = Dim.Width (numButtonsLabel),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "_Width:"
             Text = "_Width:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -62,7 +63,7 @@ public class Dialogs : Scenario
             Y = Pos.Bottom (label),
             Y = Pos.Bottom (label),
             Width = Dim.Width (numButtonsLabel),
             Width = Dim.Width (numButtonsLabel),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "_Height:"
             Text = "_Height:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -96,7 +97,7 @@ public class Dialogs : Scenario
             Y = Pos.Bottom (label),
             Y = Pos.Bottom (label),
             Width = Dim.Width (numButtonsLabel),
             Width = Dim.Width (numButtonsLabel),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "_Title:"
             Text = "_Title:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -128,7 +129,7 @@ public class Dialogs : Scenario
         {
         {
             X = Pos.Right (numButtonsLabel) + 1,
             X = Pos.Right (numButtonsLabel) + 1,
             Y = Pos.Bottom (numButtonsLabel),
             Y = Pos.Bottom (numButtonsLabel),
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = $"_Add {char.ConvertFromUtf32 (CODE_POINT)} to button text to stress wide char support",
             Text = $"_Add {char.ConvertFromUtf32 (CODE_POINT)} to button text to stress wide char support",
             Checked = false
             Checked = false
         };
         };
@@ -140,18 +141,20 @@ public class Dialogs : Scenario
             Y = Pos.Bottom (glyphsNotWords),
             Y = Pos.Bottom (glyphsNotWords),
             Width = Dim.Width (numButtonsLabel),
             Width = Dim.Width (numButtonsLabel),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
-            Text = "Button St_yle:"
+            TextAlignment = Alignment.End,
+            Text = "Button A_lignment:"
         };
         };
         frame.Add (label);
         frame.Add (label);
 
 
-        var styleRadioGroup = new RadioGroup
+        var labels = Enum.GetNames<Alignment> ();
+        var alignmentGroup = new RadioGroup
         {
         {
             X = Pos.Right (label) + 1,
             X = Pos.Right (label) + 1,
             Y = Pos.Top (label),
             Y = Pos.Top (label),
-            RadioLabels = new [] { "_Center", "_Justify", "_Left", "_Right" }
+            RadioLabels = labels.ToArray (),
         };
         };
-        frame.Add (styleRadioGroup);
+        frame.Add (alignmentGroup);
+        alignmentGroup.SelectedItem = labels.ToList ().IndexOf (Dialog.DefaultButtonAlignment.ToString ());
 
 
         frame.ValidatePosDim = true;
         frame.ValidatePosDim = true;
 
 
@@ -159,7 +162,7 @@ public class Dialogs : Scenario
 
 
         label = new ()
         label = new ()
         {
         {
-            X = Pos.Center (), Y = Pos.Bottom (frame) + 4, TextAlignment = TextAlignment.Right, Text = "Button Pressed:"
+            X = Pos.Center (), Y = Pos.Bottom (frame) + 4, TextAlignment = Alignment.End, Text = "Button Pressed:"
         };
         };
         app.Add (label);
         app.Add (label);
 
 
@@ -168,11 +171,6 @@ public class Dialogs : Scenario
             X = Pos.Center (), Y = Pos.Bottom (frame) + 5, ColorScheme = Colors.ColorSchemes ["Error"], Text = " "
             X = Pos.Center (), Y = Pos.Bottom (frame) + 5, ColorScheme = Colors.ColorSchemes ["Error"], Text = " "
         };
         };
 
 
-        // glyphsNotWords
-        // false:var btnText = new [] { "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" };
-        // true: var btnText = new [] { "0", "\u2780", "➁", "\u2783", "\u2784", "\u2785", "\u2786", "\u2787", "\u2788", "\u2789" };
-        // \u2781 is ➁ dingbats \ufb70 is	
-
         var showDialogButton = new Button
         var showDialogButton = new Button
         {
         {
             X = Pos.Center (), Y = Pos.Bottom (frame) + 2, IsDefault = true, Text = "_Show Dialog"
             X = Pos.Center (), Y = Pos.Bottom (frame) + 2, IsDefault = true, Text = "_Show Dialog"
@@ -186,7 +184,7 @@ public class Dialogs : Scenario
                                                                       titleEdit,
                                                                       titleEdit,
                                                                       numButtonsEdit,
                                                                       numButtonsEdit,
                                                                       glyphsNotWords,
                                                                       glyphsNotWords,
-                                                                      styleRadioGroup,
+                                                                      alignmentGroup,
                                                                       buttonPressedLabel
                                                                       buttonPressedLabel
                                                                      );
                                                                      );
                                        Application.Run (dlg);
                                        Application.Run (dlg);
@@ -209,7 +207,7 @@ public class Dialogs : Scenario
         TextField titleEdit,
         TextField titleEdit,
         TextField numButtonsEdit,
         TextField numButtonsEdit,
         CheckBox glyphsNotWords,
         CheckBox glyphsNotWords,
-        RadioGroup styleRadioGroup,
+        RadioGroup alignmentRadioGroup,
         Label buttonPressedLabel
         Label buttonPressedLabel
     )
     )
     {
     {
@@ -255,20 +253,13 @@ public class Dialogs : Scenario
                 buttons.Add (button);
                 buttons.Add (button);
             }
             }
 
 
-            //if (buttons.Count > 1) {
-            //	buttons [1].Text = "Accept";
-            //	buttons [1].IsDefault = true;
-            //	buttons [0].Visible = false;
-            //	buttons [0].Text = "_Back";
-            //	buttons [0].IsDefault = false;
-            //}
-
             // This tests dynamically adding buttons; ensuring the dialog resizes if needed and 
             // This tests dynamically adding buttons; ensuring the dialog resizes if needed and 
             // the buttons are laid out correctly
             // the buttons are laid out correctly
             dialog = new ()
             dialog = new ()
             {
             {
                 Title = titleEdit.Text,
                 Title = titleEdit.Text,
-                ButtonAlignment = (Dialog.ButtonAlignments)styleRadioGroup.SelectedItem,
+                ButtonAlignment = (Alignment)Enum.Parse (typeof (Alignment), alignmentRadioGroup.RadioLabels [alignmentRadioGroup.SelectedItem]),
+
                 Buttons = buttons.ToArray ()
                 Buttons = buttons.ToArray ()
             };
             };
 
 
@@ -278,7 +269,12 @@ public class Dialogs : Scenario
                 dialog.Width = width;
                 dialog.Width = width;
             }
             }
 
 
-            var add = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "_Add a button" };
+            var add = new Button
+            {
+                X = Pos.Center (),
+                Y = Pos.Center (),
+                Text = "_Add a button"
+            };
 
 
             add.Accept += (s, e) =>
             add.Accept += (s, e) =>
                           {
                           {
@@ -317,7 +313,7 @@ public class Dialogs : Scenario
             {
             {
                 X = Pos.Center (),
                 X = Pos.Center (),
                 Y = Pos.Center () + 1,
                 Y = Pos.Center () + 1,
-                Text = $"A_dd a {char.ConvertFromUtf32 (CODE_POINT)} to each button"
+                Text = $"A_dd a {char.ConvertFromUtf32 (CODE_POINT)} to each button. This text is really long for a reason."
             };
             };
 
 
             addChar.Accept += (s, e) =>
             addChar.Accept += (s, e) =>

+ 2 - 2
UICatalog/Scenarios/DynamicMenuBar.cs

@@ -623,7 +623,7 @@ public class DynamicMenuBar : Scenario
             var _lblMenuBar = new Label
             var _lblMenuBar = new Label
             {
             {
                 ColorScheme = Colors.ColorSchemes ["Dialog"],
                 ColorScheme = Colors.ColorSchemes ["Dialog"],
-                TextAlignment = TextAlignment.Centered,
+                TextAlignment = Alignment.Center,
                 X = Pos.Right (_btnPrevious) + 1,
                 X = Pos.Right (_btnPrevious) + 1,
                 Y = Pos.Top (_btnPrevious),
                 Y = Pos.Top (_btnPrevious),
 
 
@@ -636,7 +636,7 @@ public class DynamicMenuBar : Scenario
 
 
             var _lblParent = new Label
             var _lblParent = new Label
             {
             {
-                TextAlignment = TextAlignment.Centered,
+                TextAlignment = Alignment.Center,
                 X = Pos.Right (_btnPrevious) + 1,
                 X = Pos.Right (_btnPrevious) + 1,
                 Y = Pos.Top (_btnPrevious) + 1,
                 Y = Pos.Top (_btnPrevious) + 1,
 
 

+ 9 - 9
UICatalog/Scenarios/Editor.cs

@@ -882,7 +882,7 @@ public class Editor : Scenario
         {
         {
             Y = 1,
             Y = 1,
             Width = lblWidth,
             Width = lblWidth,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
 
 
             Text = "Find:"
             Text = "Find:"
         };
         };
@@ -903,7 +903,7 @@ public class Editor : Scenario
             Y = Pos.Top (label),
             Y = Pos.Top (label),
             Width = 20,
             Width = 20,
             Enabled = !string.IsNullOrEmpty (txtToFind.Text),
             Enabled = !string.IsNullOrEmpty (txtToFind.Text),
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             IsDefault = true,
             IsDefault = true,
 
 
             Text = "Find _Next"
             Text = "Find _Next"
@@ -917,7 +917,7 @@ public class Editor : Scenario
             Y = Pos.Top (btnFindNext) + 1,
             Y = Pos.Top (btnFindNext) + 1,
             Width = 20,
             Width = 20,
             Enabled = !string.IsNullOrEmpty (txtToFind.Text),
             Enabled = !string.IsNullOrEmpty (txtToFind.Text),
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Text = "Find _Previous"
             Text = "Find _Previous"
         };
         };
@@ -937,7 +937,7 @@ public class Editor : Scenario
             X = Pos.Right (txtToFind) + 1,
             X = Pos.Right (txtToFind) + 1,
             Y = Pos.Top (btnFindPrevious) + 2,
             Y = Pos.Top (btnFindPrevious) + 2,
             Width = 20,
             Width = 20,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Text = "Cancel"
             Text = "Cancel"
         };
         };
@@ -1134,7 +1134,7 @@ public class Editor : Scenario
         {
         {
             Y = 1,
             Y = 1,
             Width = lblWidth,
             Width = lblWidth,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
 
 
             Text = "Find:"
             Text = "Find:"
         };
         };
@@ -1155,7 +1155,7 @@ public class Editor : Scenario
             Y = Pos.Top (label),
             Y = Pos.Top (label),
             Width = 20,
             Width = 20,
             Enabled = !string.IsNullOrEmpty (txtToFind.Text),
             Enabled = !string.IsNullOrEmpty (txtToFind.Text),
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             IsDefault = true,
             IsDefault = true,
 
 
             Text = "Replace _Next"
             Text = "Replace _Next"
@@ -1181,7 +1181,7 @@ public class Editor : Scenario
             Y = Pos.Top (btnFindNext) + 1,
             Y = Pos.Top (btnFindNext) + 1,
             Width = 20,
             Width = 20,
             Enabled = !string.IsNullOrEmpty (txtToFind.Text),
             Enabled = !string.IsNullOrEmpty (txtToFind.Text),
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Text = "Replace _Previous"
             Text = "Replace _Previous"
         };
         };
@@ -1194,7 +1194,7 @@ public class Editor : Scenario
             Y = Pos.Top (btnFindPrevious) + 1,
             Y = Pos.Top (btnFindPrevious) + 1,
             Width = 20,
             Width = 20,
             Enabled = !string.IsNullOrEmpty (txtToFind.Text),
             Enabled = !string.IsNullOrEmpty (txtToFind.Text),
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Text = "Replace _All"
             Text = "Replace _All"
         };
         };
@@ -1215,7 +1215,7 @@ public class Editor : Scenario
             X = Pos.Right (txtToFind) + 1,
             X = Pos.Right (txtToFind) + 1,
             Y = Pos.Top (btnReplaceAll) + 1,
             Y = Pos.Top (btnReplaceAll) + 1,
             Width = 20,
             Width = 20,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Text = "Cancel"
             Text = "Cancel"
         };
         };

+ 1 - 1
UICatalog/Scenarios/ListColumns.cs

@@ -247,7 +247,7 @@ public class ListColumns : Scenario
             Text = "0,0",
             Text = "0,0",
 
 
             Width = Dim.Fill (),
             Width = Dim.Fill (),
-            TextAlignment = TextAlignment.Right
+            TextAlignment = Alignment.End
         };
         };
 
 
         Win.Add (selectedCellLabel);
         Win.Add (selectedCellLabel);

+ 10 - 13
UICatalog/Scenarios/MessageBoxes.cs

@@ -30,7 +30,7 @@ public class MessageBoxes : Scenario
         app.Add (frame);
         app.Add (frame);
 
 
         // TODO: Use Pos.Align her to demo aligning labels and fields
         // TODO: Use Pos.Align her to demo aligning labels and fields
-        var label = new Label { X = 0, Y = 0, Width = 15, TextAlignment = TextAlignment.Right, Text = "Width:" };
+        var label = new Label { X = 0, Y = 0, Width = 15, TextAlignment = Alignment.End, Text = "Width:" };
         frame.Add (label);
         frame.Add (label);
 
 
         var widthEdit = new TextField
         var widthEdit = new TextField
@@ -50,7 +50,7 @@ public class MessageBoxes : Scenario
 
 
             Width = Dim.Width (label),
             Width = Dim.Width (label),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "Height:"
             Text = "Height:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -85,7 +85,7 @@ public class MessageBoxes : Scenario
 
 
             Width = Dim.Width (label),
             Width = Dim.Width (label),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "Title:"
             Text = "Title:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -107,7 +107,7 @@ public class MessageBoxes : Scenario
 
 
             Width = Dim.Width (label),
             Width = Dim.Width (label),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "Message:"
             Text = "Message:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -129,7 +129,7 @@ public class MessageBoxes : Scenario
 
 
             Width = Dim.Width (label),
             Width = Dim.Width (label),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "Num Buttons:"
             Text = "Num Buttons:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -151,7 +151,7 @@ public class MessageBoxes : Scenario
 
 
             Width = Dim.Width (label),
             Width = Dim.Width (label),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "Default Button:"
             Text = "Default Button:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -173,7 +173,7 @@ public class MessageBoxes : Scenario
 
 
             Width = Dim.Width (label),
             Width = Dim.Width (label),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "Style:"
             Text = "Style:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -186,7 +186,7 @@ public class MessageBoxes : Scenario
 
 
         var ckbWrapMessage = new CheckBox
         var ckbWrapMessage = new CheckBox
         {
         {
-            X = Pos.Right (label) + 1, Y = Pos.Bottom (styleRadioGroup), Text = "_Wrap Message", Checked = false
+            X = Pos.Right (label) + 1, Y = Pos.Bottom (styleRadioGroup), Text = "_Wrap Message", Checked = true
         };
         };
         frame.Add (ckbWrapMessage);
         frame.Add (ckbWrapMessage);
 
 
@@ -194,7 +194,7 @@ public class MessageBoxes : Scenario
 
 
         label = new ()
         label = new ()
         {
         {
-            X = Pos.Center (), Y = Pos.Bottom (frame) + 2, TextAlignment = TextAlignment.Right, Text = "Button Pressed:"
+            X = Pos.Center (), Y = Pos.Bottom (frame) + 2, TextAlignment = Alignment.End, Text = "Button Pressed:"
         };
         };
         app.Add (label);
         app.Add (label);
 
 
@@ -203,12 +203,10 @@ public class MessageBoxes : Scenario
             X = Pos.Center (),
             X = Pos.Center (),
             Y = Pos.Bottom (label) + 1,
             Y = Pos.Bottom (label) + 1,
             ColorScheme = Colors.ColorSchemes ["Error"],
             ColorScheme = Colors.ColorSchemes ["Error"],
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Text = " "
             Text = " "
         };
         };
 
 
-        //var btnText = new [] { "_Zero", "_One", "T_wo", "_Three", "_Four", "Fi_ve", "Si_x", "_Seven", "_Eight", "_Nine" };
-
         var showMessageBoxButton = new Button
         var showMessageBoxButton = new Button
         {
         {
             X = Pos.Center (), Y = Pos.Bottom (frame) + 2, IsDefault = true, Text = "_Show MessageBox"
             X = Pos.Center (), Y = Pos.Bottom (frame) + 2, IsDefault = true, Text = "_Show MessageBox"
@@ -227,7 +225,6 @@ public class MessageBoxes : Scenario
 
 
                                                for (var i = 0; i < numButtons; i++)
                                                for (var i = 0; i < numButtons; i++)
                                                {
                                                {
-                                                   //btns.Add(btnText[i % 10]);
                                                    btns.Add (NumberToWords.Convert (i));
                                                    btns.Add (NumberToWords.Convert (i));
                                                }
                                                }
 
 

+ 2 - 2
UICatalog/Scenarios/Mouse.cs

@@ -100,8 +100,8 @@ public class Mouse : Scenario
             Width = 20,
             Width = 20,
             Height = 3,
             Height = 3,
             Text = "Enter/Leave Demo",
             Text = "Enter/Leave Demo",
-            TextAlignment = TextAlignment.Centered,
-            VerticalTextAlignment = VerticalTextAlignment.Middle,
+            TextAlignment = Alignment.Center,
+            VerticalTextAlignment = Alignment.Center,
             ColorScheme = Colors.ColorSchemes ["Dialog"]
             ColorScheme = Colors.ColorSchemes ["Dialog"]
         };
         };
         win.Add (demo);
         win.Add (demo);

+ 423 - 0
UICatalog/Scenarios/PosAlignDemo.cs

@@ -0,0 +1,423 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Terminal.Gui;
+
+namespace UICatalog.Scenarios;
+
+[ScenarioMetadata ("Pos.Align", "Demonstrates Pos.Align")]
+[ScenarioCategory ("Layout")]
+public sealed class PosAlignDemo : Scenario
+{
+    private readonly Aligner _horizAligner = new () { AlignmentModes = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems};
+    private int _leftMargin;
+    private readonly Aligner _vertAligner = new () { AlignmentModes = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems };
+    private int _topMargin;
+
+    public override void Main ()
+    {
+        // Init
+        Application.Init ();
+
+        // Setup - Create a top-level application window and configure it.
+        Window appWindow = new ()
+        {
+            Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()} - {GetDescription ()}"
+        };
+
+        SetupControls (appWindow, Dimension.Width, Colors.ColorSchemes ["TopLevel"]);
+
+        SetupControls (appWindow, Dimension.Height, Colors.ColorSchemes ["Error"]);
+
+        Setup3By3Grid (appWindow);
+
+        // Run - Start the application.
+        Application.Run (appWindow);
+        appWindow.Dispose ();
+
+        // Shutdown - Calling Application.Shutdown is required.
+        Application.Shutdown ();
+    }
+
+    private void SetupControls (Window appWindow, Dimension dimension, ColorScheme colorScheme)
+    {
+        RadioGroup alignRadioGroup = new ()
+        {
+            RadioLabels = Enum.GetNames<Alignment> (),
+            ColorScheme = colorScheme
+        };
+
+        if (dimension == Dimension.Width)
+        {
+            alignRadioGroup.X = Pos.Align (_horizAligner.Alignment);
+            alignRadioGroup.Y = Pos.Center ();
+        }
+        else
+        {
+            alignRadioGroup.X = Pos.Center ();
+            alignRadioGroup.Y = Pos.Align (_vertAligner.Alignment);
+        }
+
+        alignRadioGroup.SelectedItemChanged += (s, e) =>
+                                               {
+                                                   if (dimension == Dimension.Width)
+                                                   {
+                                                       _horizAligner.Alignment =
+                                                           (Alignment)Enum.Parse (
+                                                                                  typeof (Alignment),
+                                                                                  alignRadioGroup.RadioLabels [alignRadioGroup.SelectedItem]);
+                                                       UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
+                                                   }
+                                                   else
+                                                   {
+                                                       _vertAligner.Alignment =
+                                                           (Alignment)Enum.Parse (
+                                                                                  typeof (Alignment),
+                                                                                  alignRadioGroup.RadioLabels [alignRadioGroup.SelectedItem]);
+                                                       UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
+                                                   }
+                                               };
+        appWindow.Add (alignRadioGroup);
+
+        CheckBox endToStartCheckBox = new ()
+        {
+            ColorScheme = colorScheme,
+            Text = "EndToStart"
+        };
+
+        if (dimension == Dimension.Width)
+        {
+            endToStartCheckBox.Checked = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.EndToStart);
+            endToStartCheckBox.X = Pos.Align (_horizAligner.Alignment);
+            endToStartCheckBox.Y = Pos.Top (alignRadioGroup);
+        }
+        else
+        {
+            endToStartCheckBox.Checked = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.EndToStart);
+            endToStartCheckBox.X = Pos.Left (alignRadioGroup);
+            endToStartCheckBox.Y = Pos.Align (_vertAligner.Alignment);
+        }
+
+        endToStartCheckBox.Toggled += (s, e) =>
+                                      {
+                                          if (dimension == Dimension.Width)
+                                          {
+                                              _horizAligner.AlignmentModes =
+                                                  e.NewValue is { } && e.NewValue.Value
+                                                      ? _horizAligner.AlignmentModes | AlignmentModes.EndToStart
+                                                      : _horizAligner.AlignmentModes & ~AlignmentModes.EndToStart;
+                                              UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
+                                          }
+                                          else
+                                          {
+                                              _vertAligner.AlignmentModes =
+                                                  e.NewValue is { } && e.NewValue.Value
+                                                      ? _vertAligner.AlignmentModes | AlignmentModes.EndToStart
+                                                      : _vertAligner.AlignmentModes & ~AlignmentModes.EndToStart;
+                                              UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
+                                          }
+                                      };
+        appWindow.Add (endToStartCheckBox);
+
+        CheckBox ignoreFirstOrLast = new ()
+        {
+            ColorScheme = colorScheme,
+            Text = "IgnoreFirstOrLast"
+        };
+
+        if (dimension == Dimension.Width)
+        {
+            ignoreFirstOrLast.Checked = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.IgnoreFirstOrLast);
+            ignoreFirstOrLast.X = Pos.Align (_horizAligner.Alignment);
+            ignoreFirstOrLast.Y = Pos.Top (alignRadioGroup);
+        }
+        else
+        {
+            ignoreFirstOrLast.Checked = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.IgnoreFirstOrLast);
+            ignoreFirstOrLast.X = Pos.Left (alignRadioGroup);
+            ignoreFirstOrLast.Y = Pos.Align (_vertAligner.Alignment);
+        }
+
+        ignoreFirstOrLast.Toggled += (s, e) =>
+                                     {
+                                         if (dimension == Dimension.Width)
+                                         {
+                                             _horizAligner.AlignmentModes =
+                                                 e.NewValue is { } && e.NewValue.Value
+                                                     ? _horizAligner.AlignmentModes | AlignmentModes.IgnoreFirstOrLast
+                                                     : _horizAligner.AlignmentModes & ~AlignmentModes.IgnoreFirstOrLast;
+                                             UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
+                                         }
+                                         else
+                                         {
+                                             _vertAligner.AlignmentModes =
+                                                 e.NewValue is { } && e.NewValue.Value
+                                                     ? _vertAligner.AlignmentModes | AlignmentModes.IgnoreFirstOrLast
+                                                     : _vertAligner.AlignmentModes & ~AlignmentModes.IgnoreFirstOrLast;
+                                             UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
+                                         }
+                                     };
+        appWindow.Add (ignoreFirstOrLast);
+
+        CheckBox addSpacesBetweenItems = new ()
+        {
+            ColorScheme = colorScheme,
+            Text = "AddSpaceBetweenItems"
+        };
+
+        if (dimension == Dimension.Width)
+        {
+            addSpacesBetweenItems.Checked = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.AddSpaceBetweenItems);
+            addSpacesBetweenItems.X = Pos.Align (_horizAligner.Alignment);
+            addSpacesBetweenItems.Y = Pos.Top (alignRadioGroup);
+        }
+        else
+        {
+            addSpacesBetweenItems.Checked = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.AddSpaceBetweenItems);
+            addSpacesBetweenItems.X = Pos.Left (alignRadioGroup);
+            addSpacesBetweenItems.Y = Pos.Align (_vertAligner.Alignment);
+        }
+
+        addSpacesBetweenItems.Toggled += (s, e) =>
+                                         {
+                                             if (dimension == Dimension.Width)
+                                             {
+                                                 _horizAligner.AlignmentModes =
+                                                     e.NewValue is { } && e.NewValue.Value
+                                                         ? _horizAligner.AlignmentModes | AlignmentModes.AddSpaceBetweenItems
+                                                         : _horizAligner.AlignmentModes & ~AlignmentModes.AddSpaceBetweenItems;
+                                                 UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
+                                             }
+                                             else
+                                             {
+                                                 _vertAligner.AlignmentModes =
+                                                     e.NewValue is { } && e.NewValue.Value
+                                                         ? _vertAligner.AlignmentModes | AlignmentModes.AddSpaceBetweenItems
+                                                         : _vertAligner.AlignmentModes & ~AlignmentModes.AddSpaceBetweenItems;
+                                                 UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
+                                             }
+                                         };
+
+        appWindow.Add (addSpacesBetweenItems);
+
+        CheckBox margin = new ()
+        {
+            ColorScheme = colorScheme,
+            Text = "Margin"
+        };
+
+        if (dimension == Dimension.Width)
+        {
+            margin.X = Pos.Align (_horizAligner.Alignment);
+            margin.Y = Pos.Top (alignRadioGroup);
+        }
+        else
+        {
+            margin.X = Pos.Left (addSpacesBetweenItems);
+            margin.Y = Pos.Align (_vertAligner.Alignment);
+        }
+
+        margin.Toggled += (s, e) =>
+                          {
+                              if (dimension == Dimension.Width)
+                              {
+                                  _leftMargin = e.NewValue is { } && e.NewValue.Value ? 1 : 0;
+                                  UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
+                              }
+                              else
+                              {
+                                  _topMargin = e.NewValue is { } && e.NewValue.Value ? 1 : 0;
+                                  UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
+                              }
+                          };
+        appWindow.Add (margin);
+
+        List<Button> addedViews =
+        [
+            new ()
+            {
+                X = dimension == Dimension.Width ? Pos.Align (_horizAligner.Alignment) : Pos.Left (alignRadioGroup),
+                Y = dimension == Dimension.Width ? Pos.Top (alignRadioGroup) : Pos.Align (_vertAligner.Alignment),
+                Text = NumberToWords.Convert (0)
+            }
+        ];
+
+        Buttons.NumericUpDown<int> addedViewsUpDown = new()
+        {
+            Width = 9,
+            Title = "Added",
+            ColorScheme = colorScheme,
+            BorderStyle = LineStyle.None,
+            Value = addedViews.Count
+        };
+
+        if (dimension == Dimension.Width)
+        {
+            addedViewsUpDown.X = Pos.Align (_horizAligner.Alignment);
+            addedViewsUpDown.Y = Pos.Top (alignRadioGroup);
+            addedViewsUpDown.Border.Thickness = new (0, 1, 0, 0);
+        }
+        else
+        {
+            addedViewsUpDown.X = Pos.Left (alignRadioGroup);
+            addedViewsUpDown.Y = Pos.Align (_vertAligner.Alignment);
+            addedViewsUpDown.Border.Thickness = new (1, 0, 0, 0);
+        }
+
+        addedViewsUpDown.ValueChanging += (s, e) =>
+                                          {
+                                              if (e.NewValue < 0)
+                                              {
+                                                  e.Cancel = true;
+
+                                                  return;
+                                              }
+
+                                              // Add or remove buttons
+                                              if (e.NewValue < e.OldValue)
+                                              {
+                                                  // Remove buttons
+                                                  for (int i = e.OldValue - 1; i >= e.NewValue; i--)
+                                                  {
+                                                      Button button = addedViews [i];
+                                                      appWindow.Remove (button);
+                                                      addedViews.RemoveAt (i);
+                                                      button.Dispose ();
+                                                  }
+                                              }
+
+                                              if (e.NewValue > e.OldValue)
+                                              {
+                                                  // Add buttons
+                                                  for (int i = e.OldValue; i < e.NewValue; i++)
+                                                  {
+                                                      var button = new Button
+                                                      {
+                                                          X = dimension == Dimension.Width ? Pos.Align (_horizAligner.Alignment) : Pos.Left (alignRadioGroup),
+                                                          Y = dimension == Dimension.Width ? Pos.Top (alignRadioGroup) : Pos.Align (_vertAligner.Alignment),
+                                                          Text = NumberToWords.Convert (i + 1)
+                                                      };
+                                                      appWindow.Add (button);
+                                                      addedViews.Add (button);
+                                                  }
+                                              }
+                                          };
+        appWindow.Add (addedViewsUpDown);
+
+        appWindow.Add (addedViews [0]);
+    }
+
+    private void UpdatePosAlignObjects (View superView, Dimension dimension, Aligner aligner)
+    {
+        foreach (View view in superView.Subviews.Where (v => dimension == Dimension.Width ? v.X is PosAlign : v.Y is PosAlign))
+        {
+            if (dimension == Dimension.Width ? view.X is PosAlign : view.Y is PosAlign)
+            {
+                //posAlign.Aligner.Alignment = _horizAligner.Alignment;
+                //posAlign.Aligner.AlignmentMode = _horizAligner.AlignmentMode;
+
+                // BUGBUG: Create and assign a new Pos object because we currently have no way for X to be notified
+                // BUGBUG: of changes in the Pos object. See https://github.com/gui-cs/Terminal.Gui/issues/3485
+                if (dimension == Dimension.Width)
+                {
+                    var posAlign = view.X as PosAlign;
+
+                    view.X = Pos.Align (
+                                        aligner.Alignment,
+                                        aligner.AlignmentModes,
+                                        posAlign!.GroupId);
+                    view.Margin.Thickness = new (_leftMargin, 0, 0, 0);
+                }
+                else
+                {
+                    var posAlign = view.Y as PosAlign;
+
+                    view.Y = Pos.Align (
+                                        aligner.Alignment,
+                                        aligner.AlignmentModes,
+                                        posAlign!.GroupId);
+
+                    view.Margin.Thickness = new (0, _topMargin, 0, 0);
+                }
+            }
+        }
+
+        superView.LayoutSubviews ();
+    }
+
+    /// <summary>
+    ///     Creates a 3x3 grid of views with two GroupIds: One for aligning X and one for aligning Y.
+    ///     Demonstrates using PosAlign to create a grid of views that flow.
+    /// </summary>
+    /// <param name="appWindow"></param>
+    private void Setup3By3Grid (View appWindow)
+    {
+        var container = new FrameView
+        {
+            Title = "3 by 3",
+            X = Pos.AnchorEnd (),
+            Y = Pos.AnchorEnd (),
+            Width = Dim.Percent (40),
+            Height = Dim.Percent (40)
+        };
+        container.Padding.Thickness = new (8, 1, 0, 0);
+        container.Padding.ColorScheme = Colors.ColorSchemes ["error"];
+
+        Aligner widthAligner = new () { AlignmentModes = AlignmentModes.StartToEnd };
+
+        RadioGroup widthAlignRadioGroup = new ()
+        {
+            RadioLabels = Enum.GetNames<Alignment> (),
+            Orientation = Orientation.Horizontal,
+            X = Pos.Center ()
+        };
+        container.Padding.Add (widthAlignRadioGroup);
+
+        widthAlignRadioGroup.SelectedItemChanged += (sender, e) =>
+                                                    {
+                                                        widthAligner.Alignment =
+                                                            (Alignment)Enum.Parse (
+                                                                                   typeof (Alignment),
+                                                                                   widthAlignRadioGroup.RadioLabels [widthAlignRadioGroup.SelectedItem]);
+                                                        UpdatePosAlignObjects (container, Dimension.Width, widthAligner);
+                                                    };
+
+        Aligner heightAligner = new () { AlignmentModes = AlignmentModes.StartToEnd };
+
+        RadioGroup heightAlignRadioGroup = new ()
+        {
+            RadioLabels = Enum.GetNames<Alignment> (),
+            Orientation = Orientation.Vertical,
+            Y = Pos.Center ()
+        };
+        container.Padding.Add (heightAlignRadioGroup);
+
+        heightAlignRadioGroup.SelectedItemChanged += (sender, e) =>
+                                                     {
+                                                         heightAligner.Alignment =
+                                                             (Alignment)Enum.Parse (
+                                                                                    typeof (Alignment),
+                                                                                    heightAlignRadioGroup.RadioLabels [heightAlignRadioGroup.SelectedItem]);
+                                                         UpdatePosAlignObjects (container, Dimension.Height, heightAligner);
+                                                     };
+
+        for (var i = 0; i < 9; i++)
+
+        {
+            var v = new View
+            {
+                Title = $"{i}",
+                BorderStyle = LineStyle.Dashed,
+                Height = 3,
+                Width = 5
+            };
+
+            v.X = Pos.Align (widthAligner.Alignment, widthAligner.AlignmentModes, i / 3);
+            v.Y = Pos.Align (heightAligner.Alignment, heightAligner.AlignmentModes, i % 3 + 10);
+
+            container.Add (v);
+        }
+
+        appWindow.Add (container);
+    }
+}

+ 19 - 11
UICatalog/Scenarios/ProgressBarStyles.cs

@@ -50,13 +50,12 @@ public class ProgressBarStyles : Scenario
         var pbList = new ListView
         var pbList = new ListView
         {
         {
             Title = "Focused ProgressBar",
             Title = "Focused ProgressBar",
-            Y = 0,
+            Y = Pos.Align (Alignment.Start),
             X = Pos.Center (),
             X = Pos.Center (),
             Width = Dim.Auto (),
             Width = Dim.Auto (),
             Height = Dim.Auto (),
             Height = Dim.Auto (),
             BorderStyle = LineStyle.Single
             BorderStyle = LineStyle.Single
         };
         };
-
         container.Add (pbList);
         container.Add (pbList);
 
 
         #region ColorPicker
         #region ColorPicker
@@ -97,7 +96,9 @@ public class ProgressBarStyles : Scenario
 
 
         var fgColorPickerBtn = new Button
         var fgColorPickerBtn = new Button
         {
         {
-            Text = "Foreground HotNormal Color", X = Pos.Center (), Y = Pos.Bottom (pbList)
+            Text = "Foreground HotNormal Color",
+            X = Pos.Center (),
+            Y = Pos.Align (Alignment.Start),
         };
         };
         container.Add (fgColorPickerBtn);
         container.Add (fgColorPickerBtn);
 
 
@@ -122,7 +123,9 @@ public class ProgressBarStyles : Scenario
 
 
         var bgColorPickerBtn = new Button
         var bgColorPickerBtn = new Button
         {
         {
-            X = Pos.Center (), Y = Pos.Bottom (fgColorPickerBtn), Text = "Background HotNormal Color"
+            X = Pos.Center (),
+            Y = Pos.Align (Alignment.Start),
+            Text = "Background HotNormal Color"
         };
         };
         container.Add (bgColorPickerBtn);
         container.Add (bgColorPickerBtn);
 
 
@@ -154,20 +157,25 @@ public class ProgressBarStyles : Scenario
         {
         {
             BorderStyle = LineStyle.Single,
             BorderStyle = LineStyle.Single,
             Title = "ProgressBarFormat",
             Title = "ProgressBarFormat",
-            X = Pos.Left (pbList),
-            Y = Pos.Bottom (bgColorPickerBtn) + 1,
+            X = Pos.Center (),
+            Y = Pos.Align (Alignment.Start),
             RadioLabels = pbFormatEnum.Select (e => e.ToString ()).ToArray ()
             RadioLabels = pbFormatEnum.Select (e => e.ToString ()).ToArray ()
         };
         };
         container.Add (rbPBFormat);
         container.Add (rbPBFormat);
 
 
-        var button = new Button { X = Pos.Center (), Y = Pos.Bottom (rbPBFormat) + 1, Text = "Start timer" };
+        var button = new Button
+        {
+            X = Pos.Center (),
+            Y = Pos.Align (Alignment.Start),
+            Text = "Start timer"
+        };
         container.Add (button);
         container.Add (button);
 
 
         var blocksPB = new ProgressBar
         var blocksPB = new ProgressBar
         {
         {
             Title = "Blocks",
             Title = "Blocks",
             X = Pos.Center (),
             X = Pos.Center (),
-            Y = Pos.Bottom (button) + 1,
+            Y = Pos.Align (Alignment.Start),
             Width = Dim.Percent (50),
             Width = Dim.Percent (50),
             BorderStyle = LineStyle.Single,
             BorderStyle = LineStyle.Single,
             CanFocus = true
             CanFocus = true
@@ -180,7 +188,7 @@ public class ProgressBarStyles : Scenario
         {
         {
             Title = "Continuous",
             Title = "Continuous",
             X = Pos.Center (),
             X = Pos.Center (),
-            Y = Pos.Bottom (blocksPB) + 1,
+            Y = Pos.Align (Alignment.Start),
             Width = Dim.Percent (50),
             Width = Dim.Percent (50),
             ProgressBarStyle = ProgressBarStyle.Continuous,
             ProgressBarStyle = ProgressBarStyle.Continuous,
             BorderStyle = LineStyle.Single,
             BorderStyle = LineStyle.Single,
@@ -230,7 +238,7 @@ public class ProgressBarStyles : Scenario
         {
         {
             Title = "Marquee Blocks",
             Title = "Marquee Blocks",
             X = Pos.Center (),
             X = Pos.Center (),
-            Y = Pos.Bottom (ckbBidirectional) + 1,
+            Y = Pos.Align (Alignment.Start),
             Width = Dim.Percent (50),
             Width = Dim.Percent (50),
             ProgressBarStyle = ProgressBarStyle.MarqueeBlocks,
             ProgressBarStyle = ProgressBarStyle.MarqueeBlocks,
             BorderStyle = LineStyle.Single,
             BorderStyle = LineStyle.Single,
@@ -242,7 +250,7 @@ public class ProgressBarStyles : Scenario
         {
         {
             Title = "Marquee Continuous",
             Title = "Marquee Continuous",
             X = Pos.Center (),
             X = Pos.Center (),
-            Y = Pos.Bottom (marqueesBlocksPB) + 1,
+            Y = Pos.Align (Alignment.Start),
             Width = Dim.Percent (50),
             Width = Dim.Percent (50),
             ProgressBarStyle = ProgressBarStyle.MarqueeContinuous,
             ProgressBarStyle = ProgressBarStyle.MarqueeContinuous,
             BorderStyle = LineStyle.Single,
             BorderStyle = LineStyle.Single,

+ 7 - 7
UICatalog/Scenarios/TableEditor.cs

@@ -707,7 +707,7 @@ public class TableEditor : Scenario
             Text = "0,0",
             Text = "0,0",
 
 
             Width = Dim.Fill (),
             Width = Dim.Fill (),
-            TextAlignment = TextAlignment.Right
+            TextAlignment = Alignment.End
         };
         };
 
 
         Win.Add (selectedCellLabel);
         Win.Add (selectedCellLabel);
@@ -1107,12 +1107,12 @@ public class TableEditor : Scenario
     {
     {
         _tableView.Style.ColumnStyles.Clear ();
         _tableView.Style.ColumnStyles.Clear ();
 
 
-        var alignMid = new ColumnStyle { Alignment = TextAlignment.Centered };
-        var alignRight = new ColumnStyle { Alignment = TextAlignment.Right };
+        var alignMid = new ColumnStyle { Alignment = Alignment.Center };
+        var alignRight = new ColumnStyle { Alignment = Alignment.End };
 
 
         var dateFormatStyle = new ColumnStyle
         var dateFormatStyle = new ColumnStyle
         {
         {
-            Alignment = TextAlignment.Right,
+            Alignment = Alignment.End,
             RepresentationGetter = v =>
             RepresentationGetter = v =>
                                        v is DateTime d ? d.ToString ("yyyy-MM-dd") : v.ToString ()
                                        v is DateTime d ? d.ToString ("yyyy-MM-dd") : v.ToString ()
         };
         };
@@ -1126,15 +1126,15 @@ public class TableEditor : Scenario
 
 
                                        // align negative values right
                                        // align negative values right
                                        d < 0
                                        d < 0
-                                           ? TextAlignment.Right
+                                           ? Alignment.End
                                            :
                                            :
 
 
                                            // align positive values left
                                            // align positive values left
-                                           TextAlignment.Left
+                                           Alignment.Start
                                        :
                                        :
 
 
                                        // not a double
                                        // not a double
-                                       TextAlignment.Left,
+                                       Alignment.Start,
             ColorGetter = a => a.CellValue is double d
             ColorGetter = a => a.CellValue is double d
                                    ?
                                    ?
 
 

+ 1 - 1
UICatalog/Scenarios/Text.cs

@@ -290,7 +290,7 @@ public class Text : Scenario
             X = Pos.Right (regexProvider) + 1,
             X = Pos.Right (regexProvider) + 1,
             Y = Pos.Y (regexProvider),
             Y = Pos.Y (regexProvider),
             Width = 30,
             Width = 30,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Provider = provider2
             Provider = provider2
         };
         };
         Win.Add (regexProviderField);
         Win.Add (regexProviderField);

+ 156 - 139
UICatalog/Scenarios/TextAlignmentsAndDirection.cs → UICatalog/Scenarios/TextAlignmentAndDirection.cs

@@ -6,9 +6,9 @@ using Terminal.Gui;
 
 
 namespace UICatalog.Scenarios;
 namespace UICatalog.Scenarios;
 
 
-[ScenarioMetadata ("Text Alignment and Direction", "Demos horizontal and vertical text alignment and text direction.")]
+[ScenarioMetadata ("Text Alignment and Direction", "Demos horizontal and vertical text alignment and direction.")]
 [ScenarioCategory ("Text and Formatting")]
 [ScenarioCategory ("Text and Formatting")]
-public class TextAlignmentsAndDirections : Scenario
+public class TextAlignmentAndDirection : Scenario
 {
 {
     public override void Main ()
     public override void Main ()
     {
     {
@@ -24,63 +24,63 @@ public class TextAlignmentsAndDirections : Scenario
         var color1 = new ColorScheme { Normal = new (Color.Black, Color.Gray) };
         var color1 = new ColorScheme { Normal = new (Color.Black, Color.Gray) };
         var color2 = new ColorScheme { Normal = new (Color.Black, Color.DarkGray) };
         var color2 = new ColorScheme { Normal = new (Color.Black, Color.DarkGray) };
 
 
-        List<Label> txts = new (); // single line
-        List<Label> mtxts = new (); // multi line
+        List<Label> singleLineLabels = new (); // single line
+        List<Label> multiLineLabels = new (); // multi line
 
 
         // Horizontal Single-Line 
         // Horizontal Single-Line 
 
 
         var labelHL = new Label
         var labelHL = new Label
         {
         {
-            X = 1,
-            Y = 1,
-            Width = 9,
+            X = 0,
+            Y = 0,
+            Width = 6,
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             ColorScheme = Colors.ColorSchemes ["Dialog"],
             ColorScheme = Colors.ColorSchemes ["Dialog"],
-            Text = "Left"
+            Text = "Start"
         };
         };
 
 
         var labelHC = new Label
         var labelHC = new Label
         {
         {
-            X = 1,
-            Y = 2,
-            Width = 9,
+            X = 0,
+            Y = 1,
+            Width = 6,
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             ColorScheme = Colors.ColorSchemes ["Dialog"],
             ColorScheme = Colors.ColorSchemes ["Dialog"],
-            Text = "Centered"
+            Text = "Center"
         };
         };
 
 
         var labelHR = new Label
         var labelHR = new Label
         {
         {
-            X = 1,
-            Y = 3,
-            Width = 9,
+            X = 0,
+            Y = 2,
+            Width = 6,
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             ColorScheme = Colors.ColorSchemes ["Dialog"],
             ColorScheme = Colors.ColorSchemes ["Dialog"],
-            Text = "Right"
+            Text = "End"
         };
         };
 
 
         var labelHJ = new Label
         var labelHJ = new Label
         {
         {
-            X = 1,
-            Y = 4,
-            Width = 9,
+            X = 0,
+            Y = 3,
+            Width = 6,
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             ColorScheme = Colors.ColorSchemes ["Dialog"],
             ColorScheme = Colors.ColorSchemes ["Dialog"],
-            Text = "Justified"
+            Text = "Fill"
         };
         };
 
 
         var txtLabelHL = new Label
         var txtLabelHL = new Label
         {
         {
             X = Pos.Right (labelHL) + 1,
             X = Pos.Right (labelHL) + 1,
             Y = Pos.Y (labelHL),
             Y = Pos.Y (labelHL),
-            Width = Dim.Fill (1) - 9,
+            Width = Dim.Fill (9),
             Height = 1,
             Height = 1,
             ColorScheme = color1,
             ColorScheme = color1,
-            TextAlignment = TextAlignment.Left,
+            TextAlignment = Alignment.Start,
             Text = txt
             Text = txt
         };
         };
 
 
@@ -88,10 +88,10 @@ public class TextAlignmentsAndDirections : Scenario
         {
         {
             X = Pos.Right (labelHC) + 1,
             X = Pos.Right (labelHC) + 1,
             Y = Pos.Y (labelHC),
             Y = Pos.Y (labelHC),
-            Width = Dim.Fill (1) - 9,
+            Width = Dim.Fill (9),
             Height = 1,
             Height = 1,
             ColorScheme = color2,
             ColorScheme = color2,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Text = txt
             Text = txt
         };
         };
 
 
@@ -99,10 +99,10 @@ public class TextAlignmentsAndDirections : Scenario
         {
         {
             X = Pos.Right (labelHR) + 1,
             X = Pos.Right (labelHR) + 1,
             Y = Pos.Y (labelHR),
             Y = Pos.Y (labelHR),
-            Width = Dim.Fill (1) - 9,
+            Width = Dim.Fill (9),
             Height = 1,
             Height = 1,
             ColorScheme = color1,
             ColorScheme = color1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = txt
             Text = txt
         };
         };
 
 
@@ -110,17 +110,17 @@ public class TextAlignmentsAndDirections : Scenario
         {
         {
             X = Pos.Right (labelHJ) + 1,
             X = Pos.Right (labelHJ) + 1,
             Y = Pos.Y (labelHJ),
             Y = Pos.Y (labelHJ),
-            Width = Dim.Fill (1) - 9,
+            Width = Dim.Fill (9),
             Height = 1,
             Height = 1,
             ColorScheme = color2,
             ColorScheme = color2,
-            TextAlignment = TextAlignment.Justified,
+            TextAlignment = Alignment.Fill,
             Text = txt
             Text = txt
         };
         };
 
 
-        txts.Add (txtLabelHL);
-        txts.Add (txtLabelHC);
-        txts.Add (txtLabelHR);
-        txts.Add (txtLabelHJ);
+        singleLineLabels.Add (txtLabelHL);
+        singleLineLabels.Add (txtLabelHC);
+        singleLineLabels.Add (txtLabelHR);
+        singleLineLabels.Add (txtLabelHJ);
 
 
         app.Add (labelHL);
         app.Add (labelHL);
         app.Add (txtLabelHL);
         app.Add (txtLabelHL);
@@ -135,53 +135,53 @@ public class TextAlignmentsAndDirections : Scenario
 
 
         var labelVT = new Label
         var labelVT = new Label
         {
         {
-            X = Pos.AnchorEnd (8),
-            Y = 1,
+            X = Pos.AnchorEnd () - 6,
+            Y = 0,
             Width = 2,
             Width = 2,
-            Height = 9,
+            Height = 6,
             ColorScheme = color1,
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
-            Text = "Top"
+            VerticalTextAlignment = Alignment.End,
+            Text = "Start"
         };
         };
         labelVT.TextFormatter.WordWrap = false;
         labelVT.TextFormatter.WordWrap = false;
 
 
         var labelVM = new Label
         var labelVM = new Label
         {
         {
-            X = Pos.AnchorEnd (6),
-            Y = 1,
+            X = Pos.AnchorEnd () - 4,
+            Y = 0,
             Width = 2,
             Width = 2,
-            Height = 9,
+            Height = 6,
             ColorScheme = color1,
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
-            Text = "Middle"
+            VerticalTextAlignment = Alignment.End,
+            Text = "Center"
         };
         };
         labelVM.TextFormatter.WordWrap = false;
         labelVM.TextFormatter.WordWrap = false;
 
 
         var labelVB = new Label
         var labelVB = new Label
         {
         {
-            X = Pos.AnchorEnd (4),
-            Y = 1,
+            X = Pos.AnchorEnd () - 2,
+            Y = 0,
             Width = 2,
             Width = 2,
-            Height = 9,
+            Height = 6,
             ColorScheme = color1,
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
-            Text = "Bottom"
+            VerticalTextAlignment = Alignment.End,
+            Text = "End"
         };
         };
         labelVB.TextFormatter.WordWrap = false;
         labelVB.TextFormatter.WordWrap = false;
 
 
         var labelVJ = new Label
         var labelVJ = new Label
         {
         {
-            X = Pos.AnchorEnd (2),
-            Y = 1,
+            X = Pos.AnchorEnd (),
+            Y = 0,
             Width = 2,
             Width = 2,
-            Height = 9,
+            Height = 6,
             ColorScheme = color1,
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
-            Text = "Justified"
+            VerticalTextAlignment = Alignment.End,
+            Text = "Fill"
         };
         };
         labelVJ.TextFormatter.WordWrap = false;
         labelVJ.TextFormatter.WordWrap = false;
 
 
@@ -190,10 +190,10 @@ public class TextAlignmentsAndDirections : Scenario
             X = Pos.X (labelVT),
             X = Pos.X (labelVT),
             Y = Pos.Bottom (labelVT) + 1,
             Y = Pos.Bottom (labelVT) + 1,
             Width = 2,
             Width = 2,
-            Height = Dim.Fill (1),
+            Height = Dim.Fill (),
             ColorScheme = color1,
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Top,
+            VerticalTextAlignment = Alignment.Start,
             Text = txt
             Text = txt
         };
         };
         txtLabelVT.TextFormatter.WordWrap = false;
         txtLabelVT.TextFormatter.WordWrap = false;
@@ -203,10 +203,10 @@ public class TextAlignmentsAndDirections : Scenario
             X = Pos.X (labelVM),
             X = Pos.X (labelVM),
             Y = Pos.Bottom (labelVM) + 1,
             Y = Pos.Bottom (labelVM) + 1,
             Width = 2,
             Width = 2,
-            Height = Dim.Fill (1),
+            Height = Dim.Fill (),
             ColorScheme = color2,
             ColorScheme = color2,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Middle,
+            VerticalTextAlignment = Alignment.Center,
             Text = txt
             Text = txt
         };
         };
         txtLabelVM.TextFormatter.WordWrap = false;
         txtLabelVM.TextFormatter.WordWrap = false;
@@ -216,10 +216,10 @@ public class TextAlignmentsAndDirections : Scenario
             X = Pos.X (labelVB),
             X = Pos.X (labelVB),
             Y = Pos.Bottom (labelVB) + 1,
             Y = Pos.Bottom (labelVB) + 1,
             Width = 2,
             Width = 2,
-            Height = Dim.Fill (1),
+            Height = Dim.Fill (),
             ColorScheme = color1,
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            VerticalTextAlignment = Alignment.End,
             Text = txt
             Text = txt
         };
         };
         txtLabelVB.TextFormatter.WordWrap = false;
         txtLabelVB.TextFormatter.WordWrap = false;
@@ -229,18 +229,18 @@ public class TextAlignmentsAndDirections : Scenario
             X = Pos.X (labelVJ),
             X = Pos.X (labelVJ),
             Y = Pos.Bottom (labelVJ) + 1,
             Y = Pos.Bottom (labelVJ) + 1,
             Width = 2,
             Width = 2,
-            Height = Dim.Fill (1),
+            Height = Dim.Fill (),
             ColorScheme = color2,
             ColorScheme = color2,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Justified,
+            VerticalTextAlignment = Alignment.Fill,
             Text = txt
             Text = txt
         };
         };
         txtLabelVJ.TextFormatter.WordWrap = false;
         txtLabelVJ.TextFormatter.WordWrap = false;
 
 
-        txts.Add (txtLabelVT);
-        txts.Add (txtLabelVM);
-        txts.Add (txtLabelVB);
-        txts.Add (txtLabelVJ);
+        singleLineLabels.Add (txtLabelVT);
+        singleLineLabels.Add (txtLabelVM);
+        singleLineLabels.Add (txtLabelVB);
+        singleLineLabels.Add (txtLabelVJ);
 
 
         app.Add (labelVT);
         app.Add (labelVT);
         app.Add (txtLabelVT);
         app.Add (txtLabelVT);
@@ -258,18 +258,19 @@ public class TextAlignmentsAndDirections : Scenario
             X = 0,
             X = 0,
             Y = Pos.Bottom (txtLabelHJ),
             Y = Pos.Bottom (txtLabelHJ),
             Width = Dim.Fill (31),
             Width = Dim.Fill (31),
-            Height = Dim.Fill (4),
-            ColorScheme = color2
+            Height = Dim.Fill (4)
+
+            //ColorScheme = color2
         };
         };
 
 
         var txtLabelTL = new Label
         var txtLabelTL = new Label
         {
         {
-            X = 1 /*                    */,
+            X = 0 /*                    */,
             Y = 1,
             Y = 1,
             Width = Dim.Percent (100 / 3),
             Width = Dim.Percent (100 / 3),
             Height = Dim.Percent (100 / 3),
             Height = Dim.Percent (100 / 3),
-            TextAlignment = TextAlignment.Left,
-            VerticalTextAlignment = VerticalTextAlignment.Top,
+            TextAlignment = Alignment.Start,
+            VerticalTextAlignment = Alignment.Start,
             ColorScheme = color1,
             ColorScheme = color1,
             Text = txt
             Text = txt
         };
         };
@@ -281,8 +282,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = 1,
             Y = 1,
             Width = Dim.Percent (33),
             Width = Dim.Percent (33),
             Height = Dim.Percent (33),
             Height = Dim.Percent (33),
-            TextAlignment = TextAlignment.Centered,
-            VerticalTextAlignment = VerticalTextAlignment.Top,
+            TextAlignment = Alignment.Center,
+            VerticalTextAlignment = Alignment.Start,
             ColorScheme = color1,
             ColorScheme = color1,
             Text = txt
             Text = txt
         };
         };
@@ -294,8 +295,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = 1,
             Y = 1,
             Width = Dim.Percent (100, DimPercentMode.Position),
             Width = Dim.Percent (100, DimPercentMode.Position),
             Height = Dim.Percent (33),
             Height = Dim.Percent (33),
-            TextAlignment = TextAlignment.Right,
-            VerticalTextAlignment = VerticalTextAlignment.Top,
+            TextAlignment = Alignment.End,
+            VerticalTextAlignment = Alignment.Start,
             ColorScheme = color1,
             ColorScheme = color1,
             Text = txt
             Text = txt
         };
         };
@@ -307,8 +308,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelTL) + 1,
             Y = Pos.Bottom (txtLabelTL) + 1,
             Width = Dim.Width (txtLabelTL),
             Width = Dim.Width (txtLabelTL),
             Height = Dim.Percent (33),
             Height = Dim.Percent (33),
-            TextAlignment = TextAlignment.Left,
-            VerticalTextAlignment = VerticalTextAlignment.Middle,
+            TextAlignment = Alignment.Start,
+            VerticalTextAlignment = Alignment.Center,
             ColorScheme = color1,
             ColorScheme = color1,
             Text = txt
             Text = txt
         };
         };
@@ -320,8 +321,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelTC) + 1,
             Y = Pos.Bottom (txtLabelTC) + 1,
             Width = Dim.Width (txtLabelTC),
             Width = Dim.Width (txtLabelTC),
             Height = Dim.Percent (33),
             Height = Dim.Percent (33),
-            TextAlignment = TextAlignment.Centered,
-            VerticalTextAlignment = VerticalTextAlignment.Middle,
+            TextAlignment = Alignment.Center,
+            VerticalTextAlignment = Alignment.Center,
             ColorScheme = color1,
             ColorScheme = color1,
             Text = txt
             Text = txt
         };
         };
@@ -333,8 +334,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelTR) + 1,
             Y = Pos.Bottom (txtLabelTR) + 1,
             Width = Dim.Percent (100, DimPercentMode.Position),
             Width = Dim.Percent (100, DimPercentMode.Position),
             Height = Dim.Percent (33),
             Height = Dim.Percent (33),
-            TextAlignment = TextAlignment.Right,
-            VerticalTextAlignment = VerticalTextAlignment.Middle,
+            TextAlignment = Alignment.End,
+            VerticalTextAlignment = Alignment.Center,
             ColorScheme = color1,
             ColorScheme = color1,
             Text = txt
             Text = txt
         };
         };
@@ -346,8 +347,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelML) + 1,
             Y = Pos.Bottom (txtLabelML) + 1,
             Width = Dim.Width (txtLabelML),
             Width = Dim.Width (txtLabelML),
             Height = Dim.Percent (100, DimPercentMode.Position),
             Height = Dim.Percent (100, DimPercentMode.Position),
-            TextAlignment = TextAlignment.Left,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            TextAlignment = Alignment.Start,
+            VerticalTextAlignment = Alignment.End,
             ColorScheme = color1,
             ColorScheme = color1,
             Text = txt
             Text = txt
         };
         };
@@ -359,8 +360,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelMC) + 1,
             Y = Pos.Bottom (txtLabelMC) + 1,
             Width = Dim.Width (txtLabelMC),
             Width = Dim.Width (txtLabelMC),
             Height = Dim.Percent (100, DimPercentMode.Position),
             Height = Dim.Percent (100, DimPercentMode.Position),
-            TextAlignment = TextAlignment.Centered,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            TextAlignment = Alignment.Center,
+            VerticalTextAlignment = Alignment.End,
             ColorScheme = color1,
             ColorScheme = color1,
             Text = txt
             Text = txt
         };
         };
@@ -372,25 +373,25 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelMR) + 1,
             Y = Pos.Bottom (txtLabelMR) + 1,
             Width = Dim.Percent (100, DimPercentMode.Position),
             Width = Dim.Percent (100, DimPercentMode.Position),
             Height = Dim.Percent (100, DimPercentMode.Position),
             Height = Dim.Percent (100, DimPercentMode.Position),
-            TextAlignment = TextAlignment.Right,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            TextAlignment = Alignment.End,
+            VerticalTextAlignment = Alignment.End,
             ColorScheme = color1,
             ColorScheme = color1,
             Text = txt
             Text = txt
         };
         };
         txtLabelBR.TextFormatter.MultiLine = true;
         txtLabelBR.TextFormatter.MultiLine = true;
 
 
-        mtxts.Add (txtLabelTL);
-        mtxts.Add (txtLabelTC);
-        mtxts.Add (txtLabelTR);
-        mtxts.Add (txtLabelML);
-        mtxts.Add (txtLabelMC);
-        mtxts.Add (txtLabelMR);
-        mtxts.Add (txtLabelBL);
-        mtxts.Add (txtLabelBC);
-        mtxts.Add (txtLabelBR);
+        multiLineLabels.Add (txtLabelTL);
+        multiLineLabels.Add (txtLabelTC);
+        multiLineLabels.Add (txtLabelTR);
+        multiLineLabels.Add (txtLabelML);
+        multiLineLabels.Add (txtLabelMC);
+        multiLineLabels.Add (txtLabelMR);
+        multiLineLabels.Add (txtLabelBL);
+        multiLineLabels.Add (txtLabelBC);
+        multiLineLabels.Add (txtLabelBR);
 
 
-        // Save Alignments in Data
-        foreach (Label t in mtxts)
+        // Save Alignment in Data
+        foreach (Label t in multiLineLabels)
         {
         {
             t.Data = new { h = t.TextAlignment, v = t.VerticalTextAlignment };
             t.Data = new { h = t.TextAlignment, v = t.VerticalTextAlignment };
         }
         }
@@ -411,24 +412,32 @@ public class TextAlignmentsAndDirections : Scenario
 
 
         // Edit Text
         // Edit Text
 
 
-        var editText = new TextView
+        var label = new Label
         {
         {
             X = 1,
             X = 1,
             Y = Pos.Bottom (container) + 1,
             Y = Pos.Bottom (container) + 1,
-            Width = Dim.Fill (10),
-            Height = Dim.Fill (1),
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            Width = 10,
+            Height = 1,
+            Text = "Edit Text:"
+        };
+
+        var editText = new TextView
+        {
+            X = Pos.Right (label) + 1,
+            Y = Pos.Top (label),
+            Width = Dim.Fill (31),
+            Height = 3,
             Text = txt
             Text = txt
         };
         };
 
 
         editText.MouseClick += (s, m) =>
         editText.MouseClick += (s, m) =>
                                {
                                {
-                                   foreach (Label v in txts)
+                                   foreach (Label v in singleLineLabels)
                                    {
                                    {
                                        v.Text = editText.Text;
                                        v.Text = editText.Text;
                                    }
                                    }
 
 
-                                   foreach (Label v in mtxts)
+                                   foreach (Label v in multiLineLabels)
                                    {
                                    {
                                        v.Text = editText.Text;
                                        v.Text = editText.Text;
                                    }
                                    }
@@ -436,12 +445,12 @@ public class TextAlignmentsAndDirections : Scenario
 
 
         app.KeyUp += (s, m) =>
         app.KeyUp += (s, m) =>
                      {
                      {
-                         foreach (Label v in txts)
+                         foreach (Label v in singleLineLabels)
                          {
                          {
                              v.Text = editText.Text;
                              v.Text = editText.Text;
                          }
                          }
 
 
-                         foreach (Label v in mtxts)
+                         foreach (Label v in multiLineLabels)
                          {
                          {
                              v.Text = editText.Text;
                              v.Text = editText.Text;
                          }
                          }
@@ -449,7 +458,7 @@ public class TextAlignmentsAndDirections : Scenario
 
 
         editText.SetFocus ();
         editText.SetFocus ();
 
 
-        app.Add (editText);
+        app.Add (label, editText);
 
 
         // JUSTIFY CHECKBOX
         // JUSTIFY CHECKBOX
 
 
@@ -459,7 +468,7 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Y (container) + 1,
             Y = Pos.Y (container) + 1,
             Width = Dim.Fill (10),
             Width = Dim.Fill (10),
             Height = 1,
             Height = 1,
-            Text = "Justify"
+            Text = "Fill"
         };
         };
 
 
         app.Add (justifyCheckbox);
         app.Add (justifyCheckbox);
@@ -470,17 +479,14 @@ public class TextAlignmentsAndDirections : Scenario
         {
         {
             X = Pos.Left (justifyCheckbox) + 1,
             X = Pos.Left (justifyCheckbox) + 1,
             Y = Pos.Y (justifyCheckbox) + 1,
             Y = Pos.Y (justifyCheckbox) + 1,
-            Width = Dim.Fill (11),
-            RadioLabels = ["Current direction", "Opposite direction", "Justify Both"],
+            Width = Dim.Fill (9),
+            RadioLabels = ["Current direction", "Opposite direction", "FIll Both"],
             Enabled = false
             Enabled = false
         };
         };
 
 
         justifyCheckbox.Toggled += (s, e) => ToggleJustify (e.OldValue is { } && (bool)e.OldValue);
         justifyCheckbox.Toggled += (s, e) => ToggleJustify (e.OldValue is { } && (bool)e.OldValue);
 
 
-        justifyOptions.SelectedItemChanged += (s, e) =>
-                                              {
-                                                  ToggleJustify (false, true);
-                                              };
+        justifyOptions.SelectedItemChanged += (s, e) => { ToggleJustify (false, true); };
 
 
         app.Add (justifyOptions);
         app.Add (justifyOptions);
 
 
@@ -492,21 +498,22 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (justifyOptions),
             Y = Pos.Bottom (justifyOptions),
             Width = Dim.Fill (10),
             Width = Dim.Fill (10),
             Height = 1,
             Height = 1,
-            Text = "Word Wrap",
+            Text = "Word Wrap"
         };
         };
         wrapCheckbox.Checked = wrapCheckbox.TextFormatter.WordWrap;
         wrapCheckbox.Checked = wrapCheckbox.TextFormatter.WordWrap;
+
         wrapCheckbox.Toggled += (s, e) =>
         wrapCheckbox.Toggled += (s, e) =>
                                 {
                                 {
                                     if (e.OldValue == true)
                                     if (e.OldValue == true)
                                     {
                                     {
-                                        foreach (Label t in mtxts)
+                                        foreach (Label t in multiLineLabels)
                                         {
                                         {
                                             t.TextFormatter.WordWrap = false;
                                             t.TextFormatter.WordWrap = false;
                                         }
                                         }
                                     }
                                     }
                                     else
                                     else
                                     {
                                     {
-                                        foreach (Label t in mtxts)
+                                        foreach (Label t in multiLineLabels)
                                         {
                                         {
                                             t.TextFormatter.WordWrap = true;
                                             t.TextFormatter.WordWrap = true;
                                         }
                                         }
@@ -523,21 +530,22 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Y (wrapCheckbox) + 1,
             Y = Pos.Y (wrapCheckbox) + 1,
             Width = Dim.Fill (10),
             Width = Dim.Fill (10),
             Height = 1,
             Height = 1,
-            Text = "AutoSize",
+            Text = "AutoSize"
         };
         };
         autoSizeCheckbox.Checked = autoSizeCheckbox.TextFormatter.AutoSize;
         autoSizeCheckbox.Checked = autoSizeCheckbox.TextFormatter.AutoSize;
+
         autoSizeCheckbox.Toggled += (s, e) =>
         autoSizeCheckbox.Toggled += (s, e) =>
                                     {
                                     {
                                         if (e.OldValue == true)
                                         if (e.OldValue == true)
                                         {
                                         {
-                                            foreach (Label t in mtxts)
+                                            foreach (Label t in multiLineLabels)
                                             {
                                             {
                                                 t.TextFormatter.AutoSize = false;
                                                 t.TextFormatter.AutoSize = false;
                                             }
                                             }
                                         }
                                         }
                                         else
                                         else
                                         {
                                         {
-                                            foreach (Label t in mtxts)
+                                            foreach (Label t in multiLineLabels)
                                             {
                                             {
                                                 t.TextFormatter.AutoSize = true;
                                                 t.TextFormatter.AutoSize = true;
                                             }
                                             }
@@ -562,15 +570,18 @@ public class TextAlignmentsAndDirections : Scenario
 
 
         directionOptions.SelectedItemChanged += (s, ev) =>
         directionOptions.SelectedItemChanged += (s, ev) =>
                                                 {
                                                 {
-                                                    var justChecked = justifyCheckbox.Checked is { } && (bool)justifyCheckbox.Checked;
+                                                    bool justChecked = justifyCheckbox.Checked is { } && (bool)justifyCheckbox.Checked;
+
                                                     if (justChecked)
                                                     if (justChecked)
                                                     {
                                                     {
                                                         ToggleJustify (true);
                                                         ToggleJustify (true);
                                                     }
                                                     }
-                                                    foreach (Label v in mtxts)
+
+                                                    foreach (Label v in multiLineLabels)
                                                     {
                                                     {
                                                         v.TextDirection = (TextDirection)ev.SelectedItem;
                                                         v.TextDirection = (TextDirection)ev.SelectedItem;
                                                     }
                                                     }
+
                                                     if (justChecked)
                                                     if (justChecked)
                                                     {
                                                     {
                                                         ToggleJustify (false);
                                                         ToggleJustify (false);
@@ -584,22 +595,22 @@ public class TextAlignmentsAndDirections : Scenario
 
 
         void ToggleJustify (bool oldValue, bool wasJustOptions = false)
         void ToggleJustify (bool oldValue, bool wasJustOptions = false)
         {
         {
-            if (oldValue == true)
+            if (oldValue)
             {
             {
                 if (!wasJustOptions)
                 if (!wasJustOptions)
                 {
                 {
                     justifyOptions.Enabled = false;
                     justifyOptions.Enabled = false;
                 }
                 }
 
 
-                foreach (Label t in mtxts)
+                foreach (Label t in multiLineLabels)
                 {
                 {
-                    t.TextAlignment = (TextAlignment)((dynamic)t.Data).h;
-                    t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v;
+                    t.TextAlignment = (Alignment)((dynamic)t.Data).h;
+                    t.VerticalTextAlignment = (Alignment)((dynamic)t.Data).v;
                 }
                 }
             }
             }
             else
             else
             {
             {
-                foreach (Label t in mtxts)
+                foreach (Label t in multiLineLabels)
                 {
                 {
                     if (!wasJustOptions)
                     if (!wasJustOptions)
                     {
                     {
@@ -611,16 +622,19 @@ public class TextAlignmentsAndDirections : Scenario
                         switch (justifyOptions.SelectedItem)
                         switch (justifyOptions.SelectedItem)
                         {
                         {
                             case 0:
                             case 0:
-                                t.VerticalTextAlignment = VerticalTextAlignment.Justified;
+                                t.VerticalTextAlignment = Alignment.Fill;
                                 t.TextAlignment = ((dynamic)t.Data).h;
                                 t.TextAlignment = ((dynamic)t.Data).h;
+
                                 break;
                                 break;
                             case 1:
                             case 1:
-                                t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v;
-                                t.TextAlignment = TextAlignment.Justified;
+                                t.VerticalTextAlignment = (Alignment)((dynamic)t.Data).v;
+                                t.TextAlignment = Alignment.Fill;
+
                                 break;
                                 break;
                             case 2:
                             case 2:
-                                t.VerticalTextAlignment = VerticalTextAlignment.Justified;
-                                t.TextAlignment = TextAlignment.Justified;
+                                t.VerticalTextAlignment = Alignment.Fill;
+                                t.TextAlignment = Alignment.Fill;
+
                                 break;
                                 break;
                         }
                         }
                     }
                     }
@@ -629,16 +643,19 @@ public class TextAlignmentsAndDirections : Scenario
                         switch (justifyOptions.SelectedItem)
                         switch (justifyOptions.SelectedItem)
                         {
                         {
                             case 0:
                             case 0:
-                                t.TextAlignment = TextAlignment.Justified;
+                                t.TextAlignment = Alignment.Fill;
                                 t.VerticalTextAlignment = ((dynamic)t.Data).v;
                                 t.VerticalTextAlignment = ((dynamic)t.Data).v;
+
                                 break;
                                 break;
                             case 1:
                             case 1:
-                                t.TextAlignment = (TextAlignment)((dynamic)t.Data).h;
-                                t.VerticalTextAlignment = VerticalTextAlignment.Justified;
+                                t.TextAlignment = (Alignment)((dynamic)t.Data).h;
+                                t.VerticalTextAlignment = Alignment.Fill;
+
                                 break;
                                 break;
                             case 2:
                             case 2:
-                                t.TextAlignment = TextAlignment.Justified;
-                                t.VerticalTextAlignment = VerticalTextAlignment.Justified;
+                                t.TextAlignment = Alignment.Fill;
+                                t.VerticalTextAlignment = Alignment.Fill;
+
                                 break;
                                 break;
                         }
                         }
                     }
                     }

+ 0 - 142
UICatalog/Scenarios/TextAlignments.cs

@@ -1,142 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Terminal.Gui;
-
-namespace UICatalog.Scenarios;
-
-[ScenarioMetadata ("Simple Text Alignment", "Demonstrates horizontal text alignment")]
-[ScenarioCategory ("Text and Formatting")]
-public class TextAlignments : Scenario
-{
-    public override void Setup ()
-    {
-        Win.X = 10;
-        Win.Width = Dim.Fill (10);
-
-        var txt = "Hello world, how are you today? Pretty neat!";
-        var unicodeSampleText = "A Unicode sentence (пÑРвеÑ) has words.";
-
-        List<TextAlignment> alignments = Enum.GetValues (typeof (TextAlignment)).Cast<TextAlignment> ().ToList ();
-        Label [] singleLines = new Label [alignments.Count];
-        Label [] multipleLines = new Label [alignments.Count];
-
-        var multiLineHeight = 5;
-
-        foreach (TextAlignment alignment in alignments)
-        {
-            singleLines [(int)alignment] = new()
-            {
-                TextAlignment = alignment,
-                X = 1,
-
-                Width = Dim.Fill (1),
-                Height = 1,
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
-                Text = txt
-            };
-
-            multipleLines [(int)alignment] = new()
-            {
-                TextAlignment = alignment,
-                X = 1,
-
-                Width = Dim.Fill (1),
-                Height = multiLineHeight,
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
-                Text = txt
-            };
-        }
-
-        // Add a label & text field so we can demo IsDefault
-        var editLabel = new Label { X = 0, Y = 0, Text = "Text:" };
-        Win.Add (editLabel);
-
-        var edit = new TextView
-        {
-            X = Pos.Right (editLabel) + 1,
-            Y = Pos.Y (editLabel),
-            Width = Dim.Fill ("Text:".Length + "  Unicode Sample".Length + 2),
-            Height = 4,
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
-            Text = txt
-        };
-
-        edit.TextChanged += (s, e) =>
-                            {
-                                foreach (TextAlignment alignment in alignments)
-                                {
-                                    singleLines [(int)alignment].Text = edit.Text;
-                                    multipleLines [(int)alignment].Text = edit.Text;
-                                }
-                            };
-        Win.Add (edit);
-
-        var unicodeSample = new Button { X = Pos.Right (edit) + 1, Y = 0, Text = "Unicode Sample" };
-        unicodeSample.Accept += (s, e) => { edit.Text = unicodeSampleText; };
-        Win.Add (unicodeSample);
-
-        var update = new Button { X = Pos.Right (edit) + 1, Y = Pos.Bottom (edit) - 1, Text = "_Update" };
-
-        update.Accept += (s, e) =>
-                         {
-                             foreach (TextAlignment alignment in alignments)
-                             {
-                                 singleLines [(int)alignment].Text = edit.Text;
-                                 multipleLines [(int)alignment].Text = edit.Text;
-                             }
-                         };
-        Win.Add (update);
-
-        var enableHotKeyCheckBox = new CheckBox
-        {
-            X = 0, Y = Pos.Bottom (edit), Text = "Enable Hotkey (_)", Checked = false
-        };
-
-        Win.Add (enableHotKeyCheckBox);
-
-        var label = new Label
-        {
-            Y = Pos.Bottom (enableHotKeyCheckBox) + 1, Text = "Demonstrating single-line (should clip):"
-        };
-        Win.Add (label);
-
-        foreach (TextAlignment alignment in alignments)
-        {
-            label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" };
-            Win.Add (label);
-            singleLines [(int)alignment].Y = Pos.Bottom (label);
-            Win.Add (singleLines [(int)alignment]);
-            label = singleLines [(int)alignment];
-        }
-
-        txt += "\nSecond line\n\nFourth Line.";
-        label = new() { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" };
-        Win.Add (label);
-
-        foreach (TextAlignment alignment in alignments)
-        {
-            label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" };
-            Win.Add (label);
-            multipleLines [(int)alignment].Y = Pos.Bottom (label);
-            Win.Add (multipleLines [(int)alignment]);
-            label = multipleLines [(int)alignment];
-        }
-
-        enableHotKeyCheckBox.Toggled += (s, e) =>
-                                        {
-                                            foreach (TextAlignment alignment in alignments)
-                                            {
-                                                singleLines [(int)alignment].HotKeySpecifier =
-                                                    e.OldValue == true ? (Rune)0xffff : (Rune)'_';
-
-                                                multipleLines [(int)alignment].HotKeySpecifier =
-                                                    e.OldValue == true ? (Rune)0xffff : (Rune)'_';
-                                            }
-
-                                            Win.SetNeedsDisplay ();
-                                            Win.LayoutSubviews ();
-                                        };
-    }
-}

+ 32 - 20
UICatalog/Scenarios/TextFormatterDemo.cs

@@ -63,17 +63,29 @@ public class TextFormatterDemo : Scenario
 
 
         app.Add (unicodeCheckBox);
         app.Add (unicodeCheckBox);
 
 
-        List<TextAlignment> alignments = Enum.GetValues (typeof (TextAlignment)).Cast<TextAlignment> ().ToList ();
+        static IEnumerable<T> GetUniqueEnumValues<T> () where T : Enum
+        {
+            var values = new HashSet<T> ();
+            foreach (T v in Enum.GetValues (typeof (T)))
+            {
+                if (values.Add (v))
+                {
+                    yield return v;
+                }
+            }
+        }
+
+        List<Alignment> alignments = new () { Alignment.Start, Alignment.End, Alignment.Center, Alignment.Fill };
         Label [] singleLines = new Label [alignments.Count];
         Label [] singleLines = new Label [alignments.Count];
         Label [] multipleLines = new Label [alignments.Count];
         Label [] multipleLines = new Label [alignments.Count];
 
 
         var multiLineHeight = 5;
         var multiLineHeight = 5;
 
 
-        foreach (TextAlignment alignment in alignments)
+        for (int i = 0; i < alignments.Count; i++)
         {
         {
-            singleLines [(int)alignment] = new()
+            singleLines [i] = new ()
             {
             {
-                TextAlignment = alignment,
+                TextAlignment = alignments [i],
                 X = 0,
                 X = 0,
 
 
                 Width = Dim.Fill (),
                 Width = Dim.Fill (),
@@ -82,9 +94,9 @@ public class TextFormatterDemo : Scenario
                 Text = text
                 Text = text
             };
             };
 
 
-            multipleLines [(int)alignment] = new()
+            multipleLines [i] = new ()
             {
             {
-                TextAlignment = alignment,
+                TextAlignment = alignments [i],
                 X = 0,
                 X = 0,
 
 
                 Width = Dim.Fill (),
                 Width = Dim.Fill (),
@@ -100,33 +112,33 @@ public class TextFormatterDemo : Scenario
         };
         };
         app.Add (label);
         app.Add (label);
 
 
-        foreach (TextAlignment alignment in alignments)
+        for (int i = 0; i < alignments.Count; i++)
         {
         {
-            label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" };
+            label = new () { Y = Pos.Bottom (label), Text = $"{alignments [i]}:" };
             app.Add (label);
             app.Add (label);
-            singleLines [(int)alignment].Y = Pos.Bottom (label);
-            app.Add (singleLines [(int)alignment]);
-            label = singleLines [(int)alignment];
+            singleLines [i].Y = Pos.Bottom (label);
+            app.Add (singleLines [i]);
+            label = singleLines [i];
         }
         }
 
 
-        label = new() { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" };
+        label = new () { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" };
         app.Add (label);
         app.Add (label);
 
 
-        foreach (TextAlignment alignment in alignments)
+        for (int i = 0; i < alignments.Count; i++)
         {
         {
-            label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" };
+            label = new () { Y = Pos.Bottom (label), Text = $"{alignments [i]}:" };
             app.Add (label);
             app.Add (label);
-            multipleLines [(int)alignment].Y = Pos.Bottom (label);
-            app.Add (multipleLines [(int)alignment]);
-            label = multipleLines [(int)alignment];
+            multipleLines [i].Y = Pos.Bottom (label);
+            app.Add (multipleLines [i]);
+            label = multipleLines [i];
         }
         }
 
 
         unicodeCheckBox.Toggled += (s, e) =>
         unicodeCheckBox.Toggled += (s, e) =>
                                    {
                                    {
-                                       foreach (TextAlignment alignment in alignments)
+                                       for (int i = 0; i < alignments.Count; i++)
                                        {
                                        {
-                                           singleLines [(int)alignment].Text = e.OldValue == true ? text : unicode;
-                                           multipleLines [(int)alignment].Text = e.OldValue == true ? text : unicode;
+                                           singleLines [i].Text = e.OldValue == true ? text : unicode;
+                                           multipleLines [i].Text = e.OldValue == true ? text : unicode;
                                        }
                                        }
                                    };
                                    };
 
 

+ 6 - 6
UICatalog/Scenarios/TimeAndDate.cs

@@ -57,7 +57,7 @@ public class TimeAndDate : Scenario
         {
         {
             X = Pos.Center (),
             X = Pos.Center (),
             Y = Pos.Bottom (longDate) + 1,
             Y = Pos.Bottom (longDate) + 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Width = Dim.Fill (),
             Width = Dim.Fill (),
             Text = "Old Time: "
             Text = "Old Time: "
@@ -68,7 +68,7 @@ public class TimeAndDate : Scenario
         {
         {
             X = Pos.Center (),
             X = Pos.Center (),
             Y = Pos.Bottom (_lblOldTime) + 1,
             Y = Pos.Bottom (_lblOldTime) + 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Width = Dim.Fill (),
             Width = Dim.Fill (),
             Text = "New Time: "
             Text = "New Time: "
@@ -79,7 +79,7 @@ public class TimeAndDate : Scenario
         {
         {
             X = Pos.Center (),
             X = Pos.Center (),
             Y = Pos.Bottom (_lblNewTime) + 1,
             Y = Pos.Bottom (_lblNewTime) + 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Width = Dim.Fill (),
             Width = Dim.Fill (),
             Text = "Time Format: "
             Text = "Time Format: "
@@ -90,7 +90,7 @@ public class TimeAndDate : Scenario
         {
         {
             X = Pos.Center (),
             X = Pos.Center (),
             Y = Pos.Bottom (_lblTimeFmt) + 2,
             Y = Pos.Bottom (_lblTimeFmt) + 2,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Width = Dim.Fill (),
             Width = Dim.Fill (),
             Text = "Old Date: "
             Text = "Old Date: "
@@ -101,7 +101,7 @@ public class TimeAndDate : Scenario
         {
         {
             X = Pos.Center (),
             X = Pos.Center (),
             Y = Pos.Bottom (_lblOldDate) + 1,
             Y = Pos.Bottom (_lblOldDate) + 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Width = Dim.Fill (),
             Width = Dim.Fill (),
             Text = "New Date: "
             Text = "New Date: "
@@ -112,7 +112,7 @@ public class TimeAndDate : Scenario
         {
         {
             X = Pos.Center (),
             X = Pos.Center (),
             Y = Pos.Bottom (_lblNewDate) + 1,
             Y = Pos.Bottom (_lblNewDate) + 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
 
 
             Width = Dim.Fill (),
             Width = Dim.Fill (),
             Text = "Date Format: "
             Text = "Date Format: "

+ 2 - 2
UICatalog/Scenarios/Unicode.cs

@@ -132,8 +132,8 @@ public class UnicodeInMenu : Scenario
 
 
             Width = Dim.Percent (50),
             Width = Dim.Percent (50),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
-            Text = $"Align Right - {gitString}"
+            TextAlignment = Alignment.End,
+            Text = $"End - {gitString}"
         };
         };
         Win.Add (checkBox, checkBoxRight);
         Win.Add (checkBox, checkBoxRight);
 
 

+ 5 - 5
UICatalog/Scenarios/ViewExperiments.cs

@@ -60,7 +60,7 @@ public class ViewExperiments : Scenario
             Width = 17,
             Width = 17,
             Title = "Window 1",
             Title = "Window 1",
             Text = "Window #2",
             Text = "Window #2",
-            TextAlignment = TextAlignment.Centered
+            TextAlignment = Alignment.Center
         };
         };
 
 
         window1.Margin.Thickness = new (0);
         window1.Margin.Thickness = new (0);
@@ -84,7 +84,7 @@ public class ViewExperiments : Scenario
             Width = 37,
             Width = 37,
             Title = "Window2",
             Title = "Window2",
             Text = "Window #2 (Right(window1)+1",
             Text = "Window #2 (Right(window1)+1",
-            TextAlignment = TextAlignment.Centered
+            TextAlignment = Alignment.Center
         };
         };
 
 
         //view3.InitializeFrames ();
         //view3.InitializeFrames ();
@@ -109,7 +109,7 @@ public class ViewExperiments : Scenario
             Width = 37,
             Width = 37,
             Title = "View4",
             Title = "View4",
             Text = "View #4 (Right(window2)+1",
             Text = "View #4 (Right(window2)+1",
-            TextAlignment = TextAlignment.Centered
+            TextAlignment = Alignment.Center
         };
         };
 
 
         //view4.InitializeFrames ();
         //view4.InitializeFrames ();
@@ -134,7 +134,7 @@ public class ViewExperiments : Scenario
             Width = Dim.Fill (),
             Width = Dim.Fill (),
             Title = "View5",
             Title = "View5",
             Text = "View #5 (Right(view4)+1 Fill",
             Text = "View #5 (Right(view4)+1 Fill",
-            TextAlignment = TextAlignment.Centered
+            TextAlignment = Alignment.Center
         };
         };
 
 
         //view5.InitializeFrames ();
         //view5.InitializeFrames ();
@@ -181,7 +181,7 @@ public class ViewExperiments : Scenario
             X = Pos.Center (),
             X = Pos.Center (),
             Y = Pos.Percent (50),
             Y = Pos.Percent (50),
             Width = 30,
             Width = 30,
-            TextAlignment = TextAlignment.Centered
+            TextAlignment = Alignment.Center
         };
         };
         label50.Border.Thickness = new (1, 3, 1, 1);
         label50.Border.Thickness = new (1, 3, 1, 1);
         label50.Height = 5;
         label50.Height = 5;

+ 4 - 4
UICatalog/Scenarios/Wizards.cs

@@ -21,7 +21,7 @@ public class Wizards : Scenario
         };
         };
         Win.Add (frame);
         Win.Add (frame);
 
 
-        var label = new Label { X = 0, Y = 0, TextAlignment = TextAlignment.Right, Text = "Width:" };
+        var label = new Label { X = 0, Y = 0, TextAlignment = Alignment.End, Text = "Width:" };
         frame.Add (label);
         frame.Add (label);
 
 
         var widthEdit = new TextField
         var widthEdit = new TextField
@@ -41,7 +41,7 @@ public class Wizards : Scenario
 
 
             Width = Dim.Width (label),
             Width = Dim.Width (label),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "Height:"
             Text = "Height:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -63,7 +63,7 @@ public class Wizards : Scenario
 
 
             Width = Dim.Width (label),
             Width = Dim.Width (label),
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Text = "Title:"
             Text = "Title:"
         };
         };
         frame.Add (label);
         frame.Add (label);
@@ -88,7 +88,7 @@ public class Wizards : Scenario
 
 
         label = new()
         label = new()
         {
         {
-            X = Pos.Center (), Y = Pos.AnchorEnd (1), TextAlignment = TextAlignment.Right, Text = "Action:"
+            X = Pos.Center (), Y = Pos.AnchorEnd (1), TextAlignment = Alignment.End, Text = "Action:"
         };
         };
         Win.Add (label);
         Win.Add (label);
 
 

+ 14 - 15
UICatalog/UICatalog.cs

@@ -303,7 +303,7 @@ internal class UICatalogApp
         _aboutMessage = new ();
         _aboutMessage = new ();
         _aboutMessage.AppendLine (@"A comprehensive sample library for");
         _aboutMessage.AppendLine (@"A comprehensive sample library for");
         _aboutMessage.AppendLine (@"");
         _aboutMessage.AppendLine (@"");
-        _aboutMessage.AppendLine (@"  _______                  _             _   _____       _  ");
+        _aboutMessage.AppendLine (@" _______                  _             _   _____       _   ");
         _aboutMessage.AppendLine (@" |__   __|                (_)           | | / ____|     (_) ");
         _aboutMessage.AppendLine (@" |__   __|                (_)           | | / ____|     (_) ");
         _aboutMessage.AppendLine (@"    | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _  ");
         _aboutMessage.AppendLine (@"    | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _  ");
         _aboutMessage.AppendLine (@"    | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | ");
         _aboutMessage.AppendLine (@"    | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | ");
@@ -345,7 +345,6 @@ internal class UICatalogApp
         // 'app' closed cleanly.
         // 'app' closed cleanly.
         foreach (Responder? inst in Responder.Instances)
         foreach (Responder? inst in Responder.Instances)
         {
         {
-            
             Debug.Assert (inst.WasDisposed);
             Debug.Assert (inst.WasDisposed);
         }
         }
 
 
@@ -810,24 +809,24 @@ internal class UICatalogApp
             string GetDiagnosticsTitle (Enum diag)
             string GetDiagnosticsTitle (Enum diag)
             {
             {
                 return Enum.GetName (_diagnosticFlags.GetType (), diag) switch
                 return Enum.GetName (_diagnosticFlags.GetType (), diag) switch
-                       {
-                           "Off" => OFF,
-                           "Ruler" => RULER,
-                           "Padding" => PADDING,
-                           "MouseEnter" => MOUSEENTER,
-                           _ => ""
-                       };
+                {
+                    "Off" => OFF,
+                    "Ruler" => RULER,
+                    "Padding" => PADDING,
+                    "MouseEnter" => MOUSEENTER,
+                    _ => ""
+                };
             }
             }
 
 
             Enum GetDiagnosticsEnumValue (string title)
             Enum GetDiagnosticsEnumValue (string title)
             {
             {
                 return title switch
                 return title switch
-                       {
-                           RULER => ViewDiagnosticFlags.Ruler,
-                           PADDING => ViewDiagnosticFlags.Padding,
-                           MOUSEENTER => ViewDiagnosticFlags.MouseEnter,
-                           _ => null!
-                       };
+                {
+                    RULER => ViewDiagnosticFlags.Ruler,
+                    PADDING => ViewDiagnosticFlags.Padding,
+                    MOUSEENTER => ViewDiagnosticFlags.MouseEnter,
+                    _ => null!
+                };
             }
             }
 
 
             void SetDiagnosticsFlag (Enum diag, bool add)
             void SetDiagnosticsFlag (Enum diag, bool add)

+ 1 - 2
UnitTests/Configuration/ConfigurationMangerTests.cs

@@ -783,8 +783,7 @@ public class ConfigurationManagerTests
               }
               }
             }
             }
           }
           }
-        ],
-        ""Dialog.DefaultButtonAlignment"": ""Center""
+        ]
       }
       }
     }
     }
   ]
   ]

+ 3 - 3
UnitTests/Configuration/ThemeScopeTests.cs

@@ -29,12 +29,12 @@ public class ThemeScopeTests
     {
     {
         Reset ();
         Reset ();
         Assert.NotEmpty (Themes);
         Assert.NotEmpty (Themes);
-        Assert.Equal (Dialog.ButtonAlignments.Center, Dialog.DefaultButtonAlignment);
+        Assert.Equal (Alignment.End, Dialog.DefaultButtonAlignment);
 
 
-        Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = Dialog.ButtonAlignments.Right;
+        Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = Alignment.Center;
 
 
         ThemeManager.Themes! [ThemeManager.SelectedTheme]!.Apply ();
         ThemeManager.Themes! [ThemeManager.SelectedTheme]!.Apply ();
-        Assert.Equal (Dialog.ButtonAlignments.Right, Dialog.DefaultButtonAlignment);
+        Assert.Equal (Alignment.Center, Dialog.DefaultButtonAlignment);
         Reset ();
         Reset ();
     }
     }
 
 

+ 3 - 3
UnitTests/Configuration/ThemeTests.cs

@@ -77,15 +77,15 @@ public class ThemeTests
     public void TestSerialize_RoundTrip ()
     public void TestSerialize_RoundTrip ()
     {
     {
         var theme = new ThemeScope ();
         var theme = new ThemeScope ();
-        theme ["Dialog.DefaultButtonAlignment"].PropertyValue = Dialog.ButtonAlignments.Right;
+        theme ["Dialog.DefaultButtonAlignment"].PropertyValue = Alignment.End;
 
 
         string json = JsonSerializer.Serialize (theme, _jsonOptions);
         string json = JsonSerializer.Serialize (theme, _jsonOptions);
 
 
         var deserialized = JsonSerializer.Deserialize<ThemeScope> (json, _jsonOptions);
         var deserialized = JsonSerializer.Deserialize<ThemeScope> (json, _jsonOptions);
 
 
         Assert.Equal (
         Assert.Equal (
-                      Dialog.ButtonAlignments.Right,
-                      (Dialog.ButtonAlignments)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue
+                      Alignment.End,
+                      (Alignment)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue
                      );
                      );
         Reset ();
         Reset ();
     }
     }

+ 256 - 252
UnitTests/Dialogs/DialogTests.cs

@@ -8,7 +8,7 @@ public class DialogTests
     private readonly ITestOutputHelper _output;
     private readonly ITestOutputHelper _output;
     public DialogTests (ITestOutputHelper output) { _output = output; }
     public DialogTests (ITestOutputHelper output) { _output = output; }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Add_Button_Works ()
     public void Add_Button_Works ()
     {
     {
@@ -32,14 +32,14 @@ public class DialogTests
             Title = title,
             Title = title,
             Width = width,
             Width = width,
             Height = 1,
             Height = 1,
-            ButtonAlignment = Dialog.ButtonAlignments.Center,
-            Buttons = [new () { Text = btn1Text }]
+            ButtonAlignment = Alignment.Center,
+            Buttons = [new Button { Text = btn1Text }]
         };
         };
 
 
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
         dlg.Border.Thickness = new (1, 0, 1, 0);
         dlg.Border.Thickness = new (1, 0, 1, 0);
         runstate = Begin (dlg);
         runstate = Begin (dlg);
-        var buttonRow = $"{CM.Glyphs.VLine}     {btn1}    {CM.Glyphs.VLine}";
+        var buttonRow = $"{CM.Glyphs.VLine}    {btn1}     {CM.Glyphs.VLine}";
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
 
 
         // Now add a second button
         // Now add a second button
@@ -57,14 +57,14 @@ public class DialogTests
             Title = title,
             Title = title,
             Width = width,
             Width = width,
             Height = 1,
             Height = 1,
-            ButtonAlignment = Dialog.ButtonAlignments.Justify,
-            Buttons = [new () { Text = btn1Text }]
+            ButtonAlignment = Alignment.Fill,
+            Buttons = [new Button { Text = btn1Text }]
         };
         };
 
 
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
         dlg.Border.Thickness = new (1, 0, 1, 0);
         dlg.Border.Thickness = new (1, 0, 1, 0);
         runstate = Begin (dlg);
         runstate = Begin (dlg);
-        buttonRow = $"{CM.Glyphs.VLine}         {btn1}{CM.Glyphs.VLine}";
+        buttonRow = $"{CM.Glyphs.VLine}{btn1}         {CM.Glyphs.VLine}";
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
 
 
         // Now add a second button
         // Now add a second button
@@ -82,8 +82,8 @@ public class DialogTests
             Title = title,
             Title = title,
             Width = width,
             Width = width,
             Height = 1,
             Height = 1,
-            ButtonAlignment = Dialog.ButtonAlignments.Right,
-            Buttons = [new () { Text = btn1Text }]
+            ButtonAlignment = Alignment.End,
+            Buttons = [new Button { Text = btn1Text }]
         };
         };
 
 
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -107,8 +107,8 @@ public class DialogTests
             Title = title,
             Title = title,
             Width = width,
             Width = width,
             Height = 1,
             Height = 1,
-            ButtonAlignment = Dialog.ButtonAlignments.Left,
-            Buttons = [new () { Text = btn1Text }]
+            ButtonAlignment = Alignment.Start,
+            Buttons = [new Button { Text = btn1Text }]
         };
         };
 
 
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -153,31 +153,31 @@ public class DialogTests
 
 
         // Default - Center
         // Default - Center
         (runstate, Dialog dlg) = RunButtonTestDialog (
         (runstate, Dialog dlg) = RunButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Dialog.ButtonAlignments.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text },
-                                                      new Button { Text = btn3Text },
-                                                      new Button { Text = btn4Text }
-                                                     );
+                                                    title,
+                                                    width,
+                                                    Alignment.Center,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
 
 
         // Justify
         // Justify
-        buttonRow = $"{CM.Glyphs.VLine}{btn1} {btn2}  {btn3}  {btn4}{CM.Glyphs.VLine}";
+        buttonRow = $"{CM.Glyphs.VLine}{btn1}  {btn2}  {btn3} {btn4}{CM.Glyphs.VLine}";
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                      title,
+                                                      width,
+                                                      Alignment.Fill,
+                                                      new Button { Text = btn1Text },
+                                                      new Button { Text = btn2Text },
+                                                      new Button { Text = btn3Text },
+                                                      new Button { Text = btn4Text }
+                                                     );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -187,14 +187,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                      title,
+                                                      width,
+                                                      Alignment.End,
+                                                      new Button { Text = btn1Text },
+                                                      new Button { Text = btn2Text },
+                                                      new Button { Text = btn3Text },
+                                                      new Button { Text = btn4Text }
+                                                     );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -204,14 +204,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                      title,
+                                                      width,
+                                                      Alignment.Start,
+                                                      new Button { Text = btn1Text },
+                                                      new Button { Text = btn2Text },
+                                                      new Button { Text = btn3Text },
+                                                      new Button { Text = btn4Text }
+                                                     );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -243,12 +243,12 @@ public class DialogTests
 
 
         // Default - Center
         // Default - Center
         buttonRow =
         buttonRow =
-            $"{CM.Glyphs.VLine}es {CM.Glyphs.RightBracket} {btn2} {btn3} {CM.Glyphs.LeftBracket} neve{CM.Glyphs.VLine}";
+            $"{CM.Glyphs.VLine} yes {CM.Glyphs.RightBracket}{btn2}{btn3}{CM.Glyphs.LeftBracket} never{CM.Glyphs.VLine}";
 
 
         (runstate, Dialog dlg) = RunButtonTestDialog (
         (runstate, Dialog dlg) = RunButtonTestDialog (
                                                       title,
                                                       title,
                                                       width,
                                                       width,
-                                                      Dialog.ButtonAlignments.Center,
+                                                      Alignment.Center,
                                                       new Button { Text = btn1Text },
                                                       new Button { Text = btn1Text },
                                                       new Button { Text = btn2Text },
                                                       new Button { Text = btn2Text },
                                                       new Button { Text = btn3Text },
                                                       new Button { Text = btn3Text },
@@ -264,46 +264,47 @@ public class DialogTests
             $"{CM.Glyphs.VLine}{CM.Glyphs.LeftBracket} yes {CM.Glyphs.LeftBracket} no {CM.Glyphs.LeftBracket} maybe {CM.Glyphs.LeftBracket} never {CM.Glyphs.RightBracket}{CM.Glyphs.VLine}";
             $"{CM.Glyphs.VLine}{CM.Glyphs.LeftBracket} yes {CM.Glyphs.LeftBracket} no {CM.Glyphs.LeftBracket} maybe {CM.Glyphs.LeftBracket} never {CM.Glyphs.RightBracket}{CM.Glyphs.VLine}";
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Fill,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
 
 
         // Right
         // Right
-        buttonRow = $"{CM.Glyphs.VLine}{CM.Glyphs.RightBracket} {btn2} {btn3} {btn4}{CM.Glyphs.VLine}";
+        buttonRow = $"{CM.Glyphs.VLine}es {CM.Glyphs.RightBracket}{btn2}{btn3}{btn4}{CM.Glyphs.VLine}";
+        Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.End,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
 
 
         // Left
         // Left
-        buttonRow = $"{CM.Glyphs.VLine}{btn1} {btn2} {btn3} {CM.Glyphs.LeftBracket} n{CM.Glyphs.VLine}";
+        buttonRow = $"{CM.Glyphs.VLine}{btn1}{btn2}{btn3}{CM.Glyphs.LeftBracket} neve{CM.Glyphs.VLine}";
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Start,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -337,14 +338,14 @@ public class DialogTests
 
 
         // Default - Center
         // Default - Center
         (runstate, Dialog dlg) = RunButtonTestDialog (
         (runstate, Dialog dlg) = RunButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Dialog.ButtonAlignments.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text },
-                                                      new Button { Text = btn3Text },
-                                                      new Button { Text = btn4Text }
-                                                     );
+                                                    title,
+                                                    width,
+                                                    Alignment.Center,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -354,14 +355,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Fill,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -371,14 +372,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.End,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -388,14 +389,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Start,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -431,14 +432,14 @@ public class DialogTests
 
 
         // Default - Center
         // Default - Center
         (runstate, Dialog dlg) = RunButtonTestDialog (
         (runstate, Dialog dlg) = RunButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Dialog.ButtonAlignments.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text },
-                                                      new Button { Text = btn3Text },
-                                                      new Button { Text = btn4Text }
-                                                     );
+                                                    title,
+                                                    width,
+                                                    Alignment.Center,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -448,14 +449,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.GetColumns ());
         Assert.Equal (width, buttonRow.GetColumns ());
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Fill,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -465,14 +466,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.GetColumns ());
         Assert.Equal (width, buttonRow.GetColumns ());
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.End,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -482,14 +483,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.GetColumns ());
         Assert.Equal (width, buttonRow.GetColumns ());
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Start,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -514,11 +515,11 @@ public class DialogTests
         d.SetBufferSize (width, 1);
         d.SetBufferSize (width, 1);
 
 
         (runstate, Dialog dlg) = RunButtonTestDialog (
         (runstate, Dialog dlg) = RunButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Dialog.ButtonAlignments.Center,
-                                                      new Button { Text = btnText }
-                                                     );
+                                                    title,
+                                                    width,
+                                                    Alignment.Center,
+                                                    new Button { Text = btnText }
+                                                   );
 
 
         // Center
         // Center
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -527,15 +528,15 @@ public class DialogTests
 
 
         // Justify 
         // Justify 
         buttonRow =
         buttonRow =
-            $"{CM.Glyphs.VLine}    {CM.Glyphs.LeftBracket} {btnText} {CM.Glyphs.RightBracket}{CM.Glyphs.VLine}";
+            $"{CM.Glyphs.VLine}{CM.Glyphs.LeftBracket} {btnText} {CM.Glyphs.RightBracket}    {CM.Glyphs.VLine}";
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Fill,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -546,11 +547,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.End,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -561,11 +562,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Start,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -578,26 +579,26 @@ public class DialogTests
         d.SetBufferSize (width, 1);
         d.SetBufferSize (width, 1);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Center,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Center,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
 
 
         // Justify
         // Justify
         buttonRow =
         buttonRow =
-            $"{CM.Glyphs.VLine}      {CM.Glyphs.LeftBracket} {btnText} {CM.Glyphs.RightBracket}{CM.Glyphs.VLine}";
+            $"{CM.Glyphs.VLine}{CM.Glyphs.LeftBracket} {btnText} {CM.Glyphs.RightBracket}      {CM.Glyphs.VLine}";
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Fill,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -608,11 +609,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.End,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -623,11 +624,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Start,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -657,13 +658,13 @@ public class DialogTests
         d.SetBufferSize (buttonRow.Length, 3);
         d.SetBufferSize (buttonRow.Length, 3);
 
 
         (runstate, Dialog dlg) = RunButtonTestDialog (
         (runstate, Dialog dlg) = RunButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Dialog.ButtonAlignments.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text },
-                                                      new Button { Text = btn3Text }
-                                                     );
+                                                    title,
+                                                    width,
+                                                    Alignment.Center,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -673,13 +674,13 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Fill,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -689,13 +690,13 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.End,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -705,13 +706,13 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Start,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -739,12 +740,12 @@ public class DialogTests
         d.SetBufferSize (buttonRow.Length, 3);
         d.SetBufferSize (buttonRow.Length, 3);
 
 
         (runstate, Dialog dlg) = RunButtonTestDialog (
         (runstate, Dialog dlg) = RunButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Dialog.ButtonAlignments.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text }
-                                                     );
+                                                    title,
+                                                    width,
+                                                    Alignment.Center,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -754,12 +755,12 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Fill,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -769,12 +770,12 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.End,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -784,12 +785,12 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
 
 
         (runstate, dlg) = RunButtonTestDialog (
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Start,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
         dlg.Dispose ();
         dlg.Dispose ();
@@ -821,9 +822,9 @@ public class DialogTests
         Button button1, button2;
         Button button1, button2;
 
 
         // Default (Center)
         // Default (Center)
-        button1 = new () { Text = btn1Text };
-        button2 = new () { Text = btn2Text };
-        (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, button1, button2);
+        button1 = new Button { Text = btn1Text };
+        button2 = new Button { Text = btn2Text };
+        (runstate, dlg) = RunButtonTestDialog (title, width, Alignment.Center, button1, button2);
         button1.Visible = false;
         button1.Visible = false;
         RunIteration (ref runstate, ref firstIteration);
         RunIteration (ref runstate, ref firstIteration);
         buttonRow = $@"{CM.Glyphs.VLine}         {btn2} {CM.Glyphs.VLine}";
         buttonRow = $@"{CM.Glyphs.VLine}         {btn2} {CM.Glyphs.VLine}";
@@ -833,9 +834,9 @@ public class DialogTests
 
 
         // Justify
         // Justify
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
-        button1 = new () { Text = btn1Text };
-        button2 = new () { Text = btn2Text };
-        (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, button1, button2);
+        button1 = new Button { Text = btn1Text };
+        button2 = new Button { Text = btn2Text };
+        (runstate, dlg) = RunButtonTestDialog (title, width, Alignment.Fill, button1, button2);
         button1.Visible = false;
         button1.Visible = false;
         RunIteration (ref runstate, ref firstIteration);
         RunIteration (ref runstate, ref firstIteration);
         buttonRow = $@"{CM.Glyphs.VLine}          {btn2}{CM.Glyphs.VLine}";
         buttonRow = $@"{CM.Glyphs.VLine}          {btn2}{CM.Glyphs.VLine}";
@@ -845,9 +846,9 @@ public class DialogTests
 
 
         // Right
         // Right
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
-        button1 = new () { Text = btn1Text };
-        button2 = new () { Text = btn2Text };
-        (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, button1, button2);
+        button1 = new Button { Text = btn1Text };
+        button2 = new Button { Text = btn2Text };
+        (runstate, dlg) = RunButtonTestDialog (title, width, Alignment.End, button1, button2);
         button1.Visible = false;
         button1.Visible = false;
         RunIteration (ref runstate, ref firstIteration);
         RunIteration (ref runstate, ref firstIteration);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -856,9 +857,9 @@ public class DialogTests
 
 
         // Left
         // Left
         Assert.Equal (width, buttonRow.Length);
         Assert.Equal (width, buttonRow.Length);
-        button1 = new () { Text = btn1Text };
-        button2 = new () { Text = btn2Text };
-        (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, button1, button2);
+        button1 = new Button { Text = btn1Text };
+        button2 = new Button { Text = btn2Text };
+        (runstate, dlg) = RunButtonTestDialog (title, width, Alignment.Start, button1, button2);
         button1.Visible = false;
         button1.Visible = false;
         RunIteration (ref runstate, ref firstIteration);
         RunIteration (ref runstate, ref firstIteration);
         buttonRow = $@"{CM.Glyphs.VLine}        {btn2}  {CM.Glyphs.VLine}";
         buttonRow = $@"{CM.Glyphs.VLine}        {btn2}  {CM.Glyphs.VLine}";
@@ -867,7 +868,7 @@ public class DialogTests
         dlg.Dispose ();
         dlg.Dispose ();
     }
     }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Dialog_In_Window_With_Size_One_Button_Aligns ()
     public void Dialog_In_Window_With_Size_One_Button_Aligns ()
     {
     {
@@ -888,6 +889,7 @@ public class DialogTests
 
 
         win.Loaded += (s, a) =>
         win.Loaded += (s, a) =>
                       {
                       {
+                          Dialog.DefaultButtonAlignment = Alignment.Center;
                           var dlg = new Dialog { Width = 18, Height = 3, Buttons = [new () { Text = "Ok" }] };
                           var dlg = new Dialog { Width = 18, Height = 3, Buttons = [new () { Text = "Ok" }] };
 
 
                           dlg.Loaded += (s, a) =>
                           dlg.Loaded += (s, a) =>
@@ -908,14 +910,14 @@ public class DialogTests
         Run (win);
         Run (win);
     }
     }
 
 
-    [Theory (Skip = "Dim.Auto WIP")]
+    [Theory]
     [AutoInitShutdown]
     [AutoInitShutdown]
     [InlineData (
     [InlineData (
                     5,
                     5,
                     @"
                     @"
 ┌┌───────────────┐─┐
 ┌┌───────────────┐─┐
 ││               │ │
 ││               │ │
-││     ⟦ Ok ⟧    │ │
+││    ⟦ Ok ⟧     │ │
 │└───────────────┘ │
 │└───────────────┘ │
 └──────────────────┘"
 └──────────────────┘"
                 )]
                 )]
@@ -925,7 +927,7 @@ public class DialogTests
 ┌┌───────────────┐─┐
 ┌┌───────────────┐─┐
 ││               │ │
 ││               │ │
 ││               │ │
 ││               │ │
-││     ⟦ Ok ⟧    │ │
+││    ⟦ Ok ⟧     │ │
 │└───────────────┘ │
 │└───────────────┘ │
 └──────────────────┘"
 └──────────────────┘"
                 )]
                 )]
@@ -936,7 +938,7 @@ public class DialogTests
 │┌───────────────┐ │
 │┌───────────────┐ │
 ││               │ │
 ││               │ │
 ││               │ │
 ││               │ │
-││     ⟦ Ok ⟧    │ │
+││    ⟦ Ok ⟧     │ │
 │└───────────────┘ │
 │└───────────────┘ │
 └──────────────────┘"
 └──────────────────┘"
                 )]
                 )]
@@ -948,7 +950,7 @@ public class DialogTests
 ││               │ │
 ││               │ │
 ││               │ │
 ││               │ │
 ││               │ │
 ││               │ │
-││     ⟦ Ok ⟧    │ │
+││    ⟦ Ok ⟧     │ │
 │└───────────────┘ │
 │└───────────────┘ │
 └──────────────────┘"
 └──────────────────┘"
                 )]
                 )]
@@ -961,7 +963,7 @@ public class DialogTests
 ││               │ │
 ││               │ │
 ││               │ │
 ││               │ │
 ││               │ │
 ││               │ │
-││     ⟦ Ok ⟧    │ │
+││    ⟦ Ok ⟧     │ │
 │└───────────────┘ │
 │└───────────────┘ │
 └──────────────────┘"
 └──────────────────┘"
                 )]
                 )]
@@ -971,6 +973,7 @@ public class DialogTests
         var win = new Window ();
         var win = new Window ();
 
 
         int iterations = -1;
         int iterations = -1;
+        Dialog.DefaultButtonAlignment = Alignment.Center;
 
 
         Iteration += (s, a) =>
         Iteration += (s, a) =>
                      {
                      {
@@ -1005,6 +1008,7 @@ public class DialogTests
     public void Dialog_Opened_From_Another_Dialog ()
     public void Dialog_Opened_From_Another_Dialog ()
     {
     {
         ((FakeDriver)Driver).SetBufferSize (30, 10);
         ((FakeDriver)Driver).SetBufferSize (30, 10);
+        Dialog.DefaultButtonAlignment = Alignment.Center;
 
 
         var btn1 = new Button { Text = "press me 1" };
         var btn1 = new Button { Text = "press me 1" };
         Button btn2 = null;
         Button btn2 = null;
@@ -1281,7 +1285,7 @@ public class DialogTests
         (runstate, Dialog _) = RunButtonTestDialog (
         (runstate, Dialog _) = RunButtonTestDialog (
                                                     title,
                                                     title,
                                                     width,
                                                     width,
-                                                    Dialog.ButtonAlignments.Center,
+                                                    Alignment.Center,
                                                     new Button { Text = btnText }
                                                     new Button { Text = btnText }
                                                    );
                                                    );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -1334,7 +1338,7 @@ public class DialogTests
         int width = buttonRow.Length;
         int width = buttonRow.Length;
         d.SetBufferSize (buttonRow.Length, 3);
         d.SetBufferSize (buttonRow.Length, 3);
 
 
-        (runstate, Dialog dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, null);
+        (runstate, Dialog dlg) = RunButtonTestDialog (title, width, Alignment.Center, null);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
 
 
         End (runstate);
         End (runstate);
@@ -1344,7 +1348,7 @@ public class DialogTests
     private (RunState, Dialog) RunButtonTestDialog (
     private (RunState, Dialog) RunButtonTestDialog (
         string title,
         string title,
         int width,
         int width,
-        Dialog.ButtonAlignments align,
+        Alignment align,
         params Button [] btns
         params Button [] btns
     )
     )
     {
     {

+ 16 - 16
UnitTests/Dialogs/MessageBoxTests.cs

@@ -120,7 +120,7 @@ public class MessageBoxTests
         Assert.Equal (1, result);
         Assert.Equal (1, result);
     }
     }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact (Skip = "Pos.Align WIP")]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Location_Default ()
     public void Location_Default ()
     {
     {
@@ -155,7 +155,7 @@ public class MessageBoxTests
         Application.Run ().Dispose ();
         Application.Run ().Dispose ();
     }
     }
 
 
-    [Theory (Skip = "Dim.Auto WIP")]
+    [Theory (Skip = "Pos.Align WIP")]
     [AutoInitShutdown]
     [AutoInitShutdown]
     [InlineData (" ", true, 1)]
     [InlineData (" ", true, 1)]
     [InlineData (" ", false, 1)]
     [InlineData (" ", false, 1)]
@@ -236,7 +236,7 @@ public class MessageBoxTests
         Application.Run ().Dispose ();
         Application.Run ().Dispose ();
     }
     }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact (Skip = "Pos.Align WIP")]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Message_Long_Without_Spaces_WrapMessage_True ()
     public void Message_Long_Without_Spaces_WrapMessage_True ()
     {
     {
@@ -278,7 +278,7 @@ public class MessageBoxTests
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │  ffffffffffffff  │
 │  ffffffffffffff  │
 │                  │
 │                  │
-│     {btn}    │
+│    {btn} 
 └──────────────────┘",
 └──────────────────┘",
                                                                                        _output
                                                                                        _output
                                                                                       );
                                                                                       );
@@ -302,7 +302,7 @@ public class MessageBoxTests
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │ffffffffffffffffff│
-│     {btn}    │",
+│    {btn}     │",
                                                                                        _output
                                                                                        _output
                                                                                       );
                                                                                       );
                                          Application.RequestStop ();
                                          Application.RequestStop ();
@@ -312,7 +312,7 @@ public class MessageBoxTests
         Application.Run (top);
         Application.Run (top);
     }
     }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact (Skip = "Pos.Align WIP")]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Message_With_Spaces_WrapMessage_False ()
     public void Message_With_Spaces_WrapMessage_False ()
     {
     {
@@ -377,7 +377,7 @@ ff ff ff ff ff ff ff
 ────────────────────
 ────────────────────
 ffffffffffffffffffff
 ffffffffffffffffffff
                     
                     
-      ⟦► btn ◄⟧     
+     ⟦► btn ◄⟧      
 ────────────────────
 ────────────────────
 ",
 ",
                                                                                        _output
                                                                                        _output
@@ -389,7 +389,7 @@ ffffffffffffffffffff
         Application.Run (top);
         Application.Run (top);
     }
     }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact (Skip = "Pos.Align WIP")]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Message_With_Spaces_WrapMessage_True ()
     public void Message_With_Spaces_WrapMessage_True ()
     {
     {
@@ -459,7 +459,7 @@ ffffffffffffffffffff
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │ffffffffffffffffff│
-│     {btn}    │",
+│    {btn}     │",
                                                                                        _output
                                                                                        _output
                                                                                       );
                                                                                       );
                                          Application.RequestStop ();
                                          Application.RequestStop ();
@@ -470,7 +470,7 @@ ffffffffffffffffffff
         top.Dispose ();
         top.Dispose ();
     }
     }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact (Skip = "Pos.Align WIP")]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Message_Without_Spaces_WrapMessage_False ()
     public void Message_Without_Spaces_WrapMessage_False ()
     {
     {
@@ -509,7 +509,7 @@ ffffffffffffffffffff
 ────────────────────
 ────────────────────
 ffffffffffffffffffff
 ffffffffffffffffffff
                     
                     
-      ⟦► btn ◄⟧     
+     ⟦► btn ◄⟧      
 ────────────────────
 ────────────────────
 ",
 ",
                                                                                        _output
                                                                                        _output
@@ -529,7 +529,7 @@ ffffffffffffffffffff
 ────────────────────
 ────────────────────
 ffffffffffffffffffff
 ffffffffffffffffffff
                     
                     
-      ⟦► btn ◄⟧     
+     ⟦► btn ◄⟧      
 ────────────────────
 ────────────────────
 ",
 ",
                                                                                        _output
                                                                                        _output
@@ -542,7 +542,7 @@ ffffffffffffffffffff
         Application.Run (top);
         Application.Run (top);
     }
     }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact (Skip = "Pos.Align WIP")]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Size_Default ()
     public void Size_Default ()
     {
     {
@@ -575,7 +575,7 @@ ffffffffffffffffffff
         Application.Run ().Dispose ();
         Application.Run ().Dispose ();
     }
     }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact (Skip = "Pos.Align WIP")]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Size_JustBigEnough_Fixed_Size ()
     public void Size_JustBigEnough_Fixed_Size ()
     {
     {
@@ -626,7 +626,7 @@ ffffffffffffffffffff
         Application.Run ().Dispose ();
         Application.Run ().Dispose ();
     }
     }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact (Skip = "Pos.Align WIP")]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Size_No_With_Button ()
     public void Size_No_With_Button ()
     {
     {
@@ -686,7 +686,7 @@ ffffffffffffffffffff
         top.Dispose ();
         top.Dispose ();
     }
     }
 
 
-    [Fact (Skip = "Dim.Auto WIP")]
+    [Fact (Skip = "Pos.Align WIP")]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Size_None_No_Buttons ()
     public void Size_None_No_Buttons ()
     {
     {

+ 480 - 0
UnitTests/Drawing/AlignerTests.cs

@@ -0,0 +1,480 @@
+using System.Text;
+using System.Text.Json;
+using Xunit.Abstractions;
+
+namespace Terminal.Gui.DrawingTests;
+
+public class AlignerTests (ITestOutputHelper output)
+{
+    private readonly ITestOutputHelper _output = output;
+
+    public static IEnumerable<object []> AlignmentEnumValues ()
+    {
+        foreach (object number in Enum.GetValues (typeof (Alignment)))
+        {
+            yield return new [] { number };
+        }
+    }
+
+    [Theory]
+    [MemberData (nameof (AlignmentEnumValues))]
+    public void Alignment_Round_Trips (Alignment alignment)
+    {
+        string serialized = JsonSerializer.Serialize<Alignment> (alignment);
+        var deserialized = JsonSerializer.Deserialize<Alignment> (serialized);
+
+        Assert.Equal (alignment, deserialized);
+    }
+
+    [Fact]
+    public void Aligner_Defaults ()
+    {
+        var aligner = new Aligner ();
+        Assert.Equal (Alignment.Start, aligner.Alignment);
+        Assert.Equal (AlignmentModes.StartToEnd, aligner.AlignmentModes);
+        Assert.Equal (0, aligner.ContainerSize);
+    }
+
+    [Theory]
+    [MemberData (nameof (AlignmentEnumValues))]
+    public void NoItems_Works (Alignment alignment)
+    {
+        int [] sizes = [];
+        int [] positions = Aligner.Align (alignment, AlignmentModes.StartToEnd, 100, sizes);
+        Assert.Equal (new int [] { }, positions);
+    }
+
+    [Theory]
+    [MemberData (nameof (AlignmentEnumValues))]
+    public void Negative_Widths_Not_Allowed (Alignment alignment)
+    {
+        Assert.Throws<ArgumentException> (
+                                          () => new Aligner
+                                          {
+                                              Alignment = alignment,
+                                              ContainerSize = 100
+                                          }.Align (new [] { -10, 20, 30 }));
+
+        Assert.Throws<ArgumentException> (
+                                          () => new Aligner
+                                          {
+                                              Alignment = alignment,
+                                              ContainerSize = 100
+                                          }.Align (new [] { 10, -20, 30 }));
+
+        Assert.Throws<ArgumentException> (
+                                          () => new Aligner
+                                          {
+                                              Alignment = alignment,
+                                              ContainerSize = 100
+                                          }.Align (new [] { 10, 20, -30 }));
+    }
+
+    // TODO: This test is woefully inadequate. Expand it to cover more cases.
+    [Theory]
+    [InlineData (Alignment.Start, new [] {9, 7, 4})]
+    [InlineData (Alignment.End, new [] { 5, 3, 0 })]
+    [InlineData (Alignment.Center, new [] { 7, 5, 2 })]
+    [InlineData (Alignment.Fill, new [] { 9, 5, 0 })]
+    public void EndToStart_Reverses (Alignment alignment, int [] expected)
+    {
+        int [] sizes = { 1, 2, 3 };
+        //int [] positions = Aligner.Align (alignment, AlignmentModes.StartToEnd, 10, sizes);
+        //Assert.Equal (new [] { 0, 1, 3 }, positions);
+
+        int [] positions = Aligner.Align (alignment, AlignmentModes.EndToStart, 10, sizes);
+        Assert.Equal (expected, positions);
+
+    }
+
+    [Theory]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 2, new [] { 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 3, new [] { 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 4, new [] { 0, 2 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 10, new [] { 0, 2, 5 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 11, new [] { 0, 2, 5 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 12, new [] { 0, 2, 5 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 13, new [] { 0, 2, 5 })]
+    [InlineData (
+                    Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems,
+                    new [] { 1, 2, 3 },
+                    5,
+                    new [] { 0, 1, 3 })] // 5 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20 }, 101, new [] { 0, 11 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 100, new [] { 0, 11, 32 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 101, new [] { 0, 11, 32 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0 }, 1, new [] { 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 10, new [] { 2, 4, 7 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 11, new [] { 3, 5, 8 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 12, new [] { 4, 6, 9 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 13, new [] { 5, 7, 10 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1.
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 100, new [] { 38, 49, 70 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10 }, 101, new [] { 91 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20 }, 101, new [] { 70, 81 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 101, new [] { 39, 50, 71 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 2, new [] { 0 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 3, new [] { 1 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 4, new [] { 0, 2 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 10, new [] { 1, 3, 6 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 11, new [] { 1, 3, 6 })]
+    [InlineData (
+                    Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems,
+                    new [] { 1, 2, 3 },
+                    5,
+                    new [] { 0, 1, 3 })] // 5 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+    [InlineData (
+                    Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems,
+                    new [] { 1, 2, 3 },
+                    4,
+                    new [] { -1, 0, 2 })] // 4 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 9, new [] { 0, 3, 6 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 10, new [] { 0, 4, 7 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 11, new [] { 0, 4, 8 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 12, new [] { 0, 4, 8 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 13, new [] { 1, 5, 9 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 101, new [] { 0, 34, 68 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 102, new [] { 0, 34, 68 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 103, new [] { 1, 35, 69 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 104, new [] { 1, 35, 69 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10 }, 101, new [] { 45 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20 }, 101, new [] { 35, 46 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 100, new [] { 19, 30, 51 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 101, new [] { 19, 30, 51 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40 }, 100, new [] { 0, 10, 30, 60 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5, 6 }, 25, new [] { 2, 6, 11, 17 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 100, new [] { 0, 30, 70 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 101, new [] { 0, 31, 71 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 11, 17, 23 }, 100, new [] { 0, 36, 77 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 11, new [] { 0, 4, 8 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 21, new [] { 0, 9, 18 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5 }, 21, new [] { 0, 8, 16 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5, 6 }, 18, new [] { 0, 3, 7, 12 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5, 6 }, 19, new [] { 0, 4, 8, 13 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5, 6 }, 20, new [] { 0, 4, 9, 14 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5, 6 }, 21, new [] { 0, 4, 9, 15 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 22, new [] { 0, 8, 14, 19 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 23, new [] { 0, 8, 15, 20 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 24, new [] { 0, 8, 15, 21 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 25, new [] { 0, 9, 16, 22 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 26, new [] { 0, 9, 17, 23 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 31, new [] { 0, 11, 20, 28 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0 }, 1, new [] { 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 2, new [] { 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 3, new [] { 2 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 8, new [] { 0, 2, 5 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 9, new [] { 0, 2, 6 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 10, new [] { 0, 2, 7 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 11, new [] { 0, 2, 8 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1.})]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 3, 3 }, 21, new [] { 0, 4, 18 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 4, 5 }, 21, new [] { 0, 4, 16 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10 }, 101, new [] { 91 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 100, new [] { 0, 11, 70 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 101, new [] { 0, 11, 71 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0 }, 1, new [] { 0 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 2, new [] { 0 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 3, new [] { 0 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 4 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 8, new [] { 0, 2, 5 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 9, new [] { 0, 3, 6 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 10, new [] { 0, 4, 7 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 11, new [] { 0, 5, 8 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 5, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 7 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 1, 4, 8 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 3, 3 }, 21, new [] { 0, 14, 18 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 67 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 100, new [] { 0, 49, 70 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 101, new [] { 0, 50, 71 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
+
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 0 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 0, 0 }, 1, new [] { 0, 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 10, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 11, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 12, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 13, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 6 })]
+    [InlineData (
+                    Alignment.Start, AlignmentModes.StartToEnd,
+                    new [] { 1, 2, 3 },
+                    5,
+                    new [] { 0, 1, 3 })] // 5 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 100, new [] { 0, 10, 30 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 66 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10, 20 }, 101, new [] { 0, 10 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 101, new [] { 0, 10, 30 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 60 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 100 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 0 }, 1, new [] { 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 0, 0 }, 1, new [] { 1, 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 0, 0, 0 }, 1, new [] { 1, 1, 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 7, new [] { 1, 2, 4 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 10, new [] { 4, 5, 7 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 11, new [] { 5, 6, 8 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 12, new [] { 6, 7, 9 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 13, new [] { 7, 8, 10 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1.
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 11, new [] { 1, 2, 4, 7 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 100, new [] { 40, 50, 70 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 100, new [] { 1, 34, 67 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10 }, 101, new [] { 91 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10, 20 }, 101, new [] { 71, 81 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 101, new [] { 41, 51, 71 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40 }, 101, new [] { 1, 11, 31, 61 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 1, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1 }, 2, new [] { 0 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1 }, 3, new [] { 1 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 1 }, 3, new [] { 0, 1 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 1 }, 4, new [] { 1, 2 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 10, new [] { 2, 3, 5 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 11, new [] { 2, 3, 5 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 9, new [] { 0, 3, 6 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 10, new [] { 0, 3, 6 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 11, new [] { 1, 4, 7 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 12, new [] { 1, 4, 7 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 13, new [] { 2, 5, 8 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 5, new [] { 0, 1, 3 })] // 5 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 4, new [] { -1, 0, 2 })] // 4 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 66 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 101, new [] { 1, 34, 67 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 102, new [] { 1, 34, 67 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 103, new [] { 2, 35, 68 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 104, new [] { 2, 35, 68 })]
+    [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 4, 5, 6 }, 25, new [] { 3, 6, 10, 15 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 100, new [] { 0, 30, 70 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 101, new [] { 0, 31, 71 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 11, 17, 23 }, 100, new [] { 0, 36, 77 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 11, new [] { 0, 4, 8 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 21, new [] { 0, 9, 18 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 4, 5 }, 21, new [] { 0, 8, 16 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 4, 5, 6 }, 18, new [] { 0, 3, 7, 12 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 4, 5, 6 }, 19, new [] { 0, 4, 8, 13 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 4, 5, 6 }, 20, new [] { 0, 4, 9, 14 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 4, 5, 6 }, 21, new [] { 0, 4, 9, 15 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 22, new [] { 0, 8, 14, 19 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 23, new [] { 0, 8, 15, 20 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 24, new [] { 0, 8, 15, 21 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 25, new [] { 0, 9, 16, 22 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 26, new [] { 0, 9, 17, 23 })]
+    [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 31, new [] { 0, 11, 20, 28 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0 }, 1, new [] { 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 2, new [] { 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 3, new [] { 2 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 4 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 8, new [] { 0, 1, 5 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 9, new [] { 0, 1, 6 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 10, new [] { 0, 1, 7 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 11, new [] { 0, 1, 8 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 7 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 1, 3, 8 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 3, 3 }, 21, new [] { 0, 3, 18 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 4, 5 }, 21, new [] { 0, 3, 16 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 67 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10 }, 101, new [] { 91 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 100, new [] { 0, 10, 70 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 101, new [] { 0, 10, 71 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
+    [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0 }, 1, new [] { 0 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 2, new [] { 0 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 3, new [] { 0 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 8, new [] { 0, 3, 5 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 9, new [] { 0, 4, 6 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 10, new [] { 0, 5, 7 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 11, new [] { 0, 6, 8 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 3, 5, 8 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 3, 3 }, 21, new [] { 0, 15, 18 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 4, 5 }, 21, new [] { 0, 12, 16 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 100, new [] { 0, 50, 70 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 101, new [] { 0, 51, 71 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+
+    public void Alignment_Aligns (Alignment alignment, AlignmentModes modes, int [] sizes, int containerSize, int [] expected)
+    {
+        int [] positions = new Aligner
+        {
+            Alignment = alignment,
+            AlignmentModes = AlignmentModes.StartToEnd | modes,
+            ContainerSize = containerSize
+        }.Align (sizes);
+        AssertAlignment (alignment, sizes, containerSize, positions, expected);
+    }
+
+
+    private void AssertAlignment (Alignment alignment, int [] sizes, int totalSize, int [] positions, int [] expected)
+    {
+        try
+        {
+            _output.WriteLine ($"Testing: {RenderAlignment (alignment, sizes, totalSize, expected)}");
+        }
+        catch (Exception e)
+        {
+            _output.WriteLine ($"Exception rendering expected: {e.Message}");
+            _output.WriteLine ($"Actual: {RenderAlignment (alignment, sizes, totalSize, positions)}");
+        }
+
+        if (!expected.SequenceEqual (positions))
+        {
+            _output.WriteLine ($"Expected: {RenderAlignment (alignment, sizes, totalSize, expected)}");
+            _output.WriteLine ($"Actual: {RenderAlignment (alignment, sizes, totalSize, positions)}");
+            Assert.Fail (" Expected and actual do not match");
+        }
+    }
+
+    private string RenderAlignment (Alignment alignment, int [] sizes, int totalSize, int [] positions)
+    {
+        var output = new StringBuilder ();
+        output.AppendLine ($"Alignment: {alignment}, Positions: {string.Join (", ", positions)}, TotalSize: {totalSize}");
+
+        for (var i = 0; i <= totalSize / 10; i++)
+        {
+            output.Append (i.ToString ().PadRight (9) + " ");
+        }
+
+        output.AppendLine ();
+
+        for (var i = 0; i < totalSize; i++)
+        {
+            output.Append (i % 10);
+        }
+
+        output.AppendLine ();
+
+        var items = new char [totalSize];
+
+        for (var position = 0; position < positions.Length; position++)
+        {
+            // try
+            {
+                for (var j = 0; j < sizes [position] && positions [position] + j < totalSize; j++)
+                {
+                    if (positions [position] + j >= 0)
+                    {
+                        items [positions [position] + j] = (position + 1).ToString () [0];
+                    }
+                }
+            }
+        }
+
+        output.Append (new string (items).Replace ('\0', ' '));
+
+        return output.ToString ();
+    }
+}

+ 0 - 426
UnitTests/Drawing/JustifierTests.cs

@@ -1,426 +0,0 @@
-using System.Text;
-using Xunit.Abstractions;
-
-namespace Terminal.Gui.DrawingTests;
-
-public class JustifierTests (ITestOutputHelper output)
-{
-    private readonly ITestOutputHelper _output = output;
-
-    public static IEnumerable<object []> JustificationEnumValues ()
-    {
-        foreach (object number in Enum.GetValues (typeof (Justification)))
-        {
-            yield return new [] { number };
-        }
-    }
-
-    [Theory]
-    [MemberData (nameof (JustificationEnumValues))]
-    public void NoItems_Works (Justification justification)
-    {
-        int [] sizes = [];
-        int [] positions = Justifier.Justify (justification, false, 100, sizes);
-        Assert.Equal (new int [] { }, positions);
-    }
-
-    [Theory]
-    [MemberData (nameof (JustificationEnumValues))]
-    public void Negative_Widths_Not_Allowed (Justification justification)
-    {
-        Assert.Throws<ArgumentException> (() => new Justifier ()
-        {
-            Justification = justification,
-            ContainerSize = 100
-        }.Justify (new [] { -10, 20, 30 }));
-        Assert.Throws<ArgumentException> (() => new Justifier ()
-        {
-            Justification = justification,
-            ContainerSize = 100
-        }.Justify (new [] { 10, -20, 30 }));
-        Assert.Throws<ArgumentException> (() => new Justifier ()
-        {
-            Justification = justification,
-            ContainerSize = 100
-        }.Justify (new [] { 10, 20, -30 }));
-    }
-
-    [Theory]
-    [InlineData (Justification.Left, new [] { 0 }, 1, new [] { 0 })]
-    [InlineData (Justification.Left, new [] { 0, 0 }, 1, new [] { 0, 1 })]
-    [InlineData (Justification.Left, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
-    [InlineData (Justification.Left, new [] { 1 }, 1, new [] { 0 })]
-    [InlineData (Justification.Left, new [] { 1 }, 2, new [] { 0 })]
-    [InlineData (Justification.Left, new [] { 1 }, 3, new [] { 0 })]
-    [InlineData (Justification.Left, new [] { 1, 1 }, 2, new [] { 0, 1 })]
-    [InlineData (Justification.Left, new [] { 1, 1 }, 3, new [] { 0, 2 })]
-    [InlineData (Justification.Left, new [] { 1, 1 }, 4, new [] { 0, 2 })]
-    [InlineData (Justification.Left, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 10, new [] { 0, 2, 5 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 11, new [] { 0, 2, 5 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 12, new [] { 0, 2, 5 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 13, new [] { 0, 2, 5 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
-    [InlineData (Justification.Left, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
-    [InlineData (Justification.Left, new [] { 10 }, 101, new [] { 0 })]
-    [InlineData (Justification.Left, new [] { 10, 20 }, 101, new [] { 0, 11 })]
-    [InlineData (Justification.Left, new [] { 10, 20, 30 }, 100, new [] { 0, 11, 32 })]
-    [InlineData (Justification.Left, new [] { 10, 20, 30 }, 101, new [] { 0, 11, 32 })]
-    [InlineData (Justification.Left, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
-    [InlineData (Justification.Left, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
-    [InlineData (Justification.Right, new [] { 0 }, 1, new [] { 1 })]
-    [InlineData (Justification.Right, new [] { 0, 0 }, 1, new [] { 0, 1 })]
-    [InlineData (Justification.Right, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 10, new [] { 2, 4, 7 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 11, new [] { 3, 5, 8 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 12, new [] { 4, 6, 9 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 13, new [] { 5, 7, 10 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
-    [InlineData (Justification.Right, new [] { 10, 20, 30 }, 100, new [] { 38, 49, 70 })]
-    [InlineData (Justification.Right, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
-    [InlineData (Justification.Right, new [] { 10 }, 101, new [] { 91 })]
-    [InlineData (Justification.Right, new [] { 10, 20 }, 101, new [] { 70, 81 })]
-    [InlineData (Justification.Right, new [] { 10, 20, 30 }, 101, new [] { 39, 50, 71 })]
-    [InlineData (Justification.Right, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
-    [InlineData (Justification.Right, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
-    [InlineData (Justification.Centered, new [] { 0 }, 1, new [] { 0 })]
-    [InlineData (Justification.Centered, new [] { 0, 0 }, 1, new [] { 0, 1 })]
-    [InlineData (Justification.Centered, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
-    [InlineData (Justification.Centered, new [] { 1 }, 1, new [] { 0 })]
-    [InlineData (Justification.Centered, new [] { 1 }, 2, new [] { 0 })]
-    [InlineData (Justification.Centered, new [] { 1 }, 3, new [] { 1 })]
-    [InlineData (Justification.Centered, new [] { 1, 1 }, 2, new [] { 0, 1 })]
-    [InlineData (Justification.Centered, new [] { 1, 1 }, 3, new [] { 0, 2 })]
-    [InlineData (Justification.Centered, new [] { 1, 1 }, 4, new [] { 0, 2 })]
-    [InlineData (Justification.Centered, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 10, new [] { 1, 3, 6 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 11, new [] { 1, 3, 6 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
-    [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 9, new [] { 0, 3, 6 })]
-    [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 10, new [] { 0, 4, 7 })]
-    [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 11, new [] { 0, 4, 8 })]
-    [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 12, new [] { 0, 4, 8 })]
-    [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 13, new [] { 1, 5, 9 })]
-    [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
-    [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 101, new [] { 0, 34, 68 })]
-    [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 102, new [] { 0, 34, 68 })]
-    [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 103, new [] { 1, 35, 69 })]
-    [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 104, new [] { 1, 35, 69 })]
-    [InlineData (Justification.Centered, new [] { 10 }, 101, new [] { 45 })]
-    [InlineData (Justification.Centered, new [] { 10, 20 }, 101, new [] { 35, 46 })]
-    [InlineData (Justification.Centered, new [] { 10, 20, 30 }, 100, new [] { 19, 30, 51 })]
-    [InlineData (Justification.Centered, new [] { 10, 20, 30 }, 101, new [] { 19, 30, 51 })]
-    [InlineData (Justification.Centered, new [] { 10, 20, 30, 40 }, 100, new [] { 0, 10, 30, 60 })]
-    [InlineData (Justification.Centered, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
-    [InlineData (Justification.Centered, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
-    [InlineData (Justification.Centered, new [] { 3, 4, 5, 6 }, 25, new [] { 2, 6, 11, 17 })]
-    [InlineData (Justification.Justified, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
-    [InlineData (Justification.Justified, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
-    [InlineData (Justification.Justified, new [] { 10, 20, 30 }, 100, new [] { 0, 30, 70 })]
-    [InlineData (Justification.Justified, new [] { 10, 20, 30 }, 101, new [] { 0, 31, 71 })]
-    [InlineData (Justification.Justified, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
-    [InlineData (Justification.Justified, new [] { 11, 17, 23 }, 100, new [] { 0, 36, 77 })]
-    [InlineData (Justification.Justified, new [] { 1, 2, 3 }, 11, new [] { 0, 4, 8 })]
-    [InlineData (Justification.Justified, new [] { 10, 20 }, 101, new [] { 0, 81 })]
-    [InlineData (Justification.Justified, new [] { 10 }, 101, new [] { 0 })]
-    [InlineData (Justification.Justified, new [] { 3, 3, 3 }, 21, new [] { 0, 9, 18 })]
-    [InlineData (Justification.Justified, new [] { 3, 4, 5 }, 21, new [] { 0, 8, 16 })]
-    [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 18, new [] { 0, 3, 7, 12 })]
-    [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 19, new [] { 0, 4, 8, 13 })]
-    [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 20, new [] { 0, 4, 9, 14 })]
-    [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 21, new [] { 0, 4, 9, 15 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 22, new [] { 0, 8, 14, 19 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 23, new [] { 0, 8, 15, 20 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 24, new [] { 0, 8, 15, 21 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 25, new [] { 0, 9, 16, 22 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 26, new [] { 0, 9, 17, 23 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 31, new [] { 0, 11, 20, 28 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 0 }, 1, new [] { 1 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 0, 0 }, 1, new [] { 0, 1 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 1, new [] { 0 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 2, new [] { 1 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 3, new [] { 2 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 2, new [] { 0, 1 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 3, new [] { 0, 2 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 4, new [] { 0, 3 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 8, new [] { 0, 2, 5 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 9, new [] { 0, 2, 6 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 10, new [] { 0, 2, 7 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 11, new [] { 0, 2, 8 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 3, 3, 3 }, 21, new [] { 0, 4, 18 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 3, 4, 5 }, 21, new [] { 0, 4, 16 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10 }, 101, new [] { 91 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10, 20 }, 101, new [] { 0, 81 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30 }, 100, new [] { 0, 11, 70 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30 }, 101, new [] { 0, 11, 71 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 0 }, 1, new [] { 0 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 0, 0 }, 1, new [] { 0, 1 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 1 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 1, new [] { 0 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 2, new [] { 0 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 3, new [] { 0 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 2, new [] { 0, 1 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 3, new [] { 0, 2 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 4, new [] { 0, 3 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 4 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 8, new [] { 0, 2, 5 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 9, new [] { 0, 3, 6 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 10, new [] { 0, 4, 7 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 11, new [] { 0, 5, 8 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 7 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 1, 4, 8 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 3, 3, 3 }, 21, new [] { 0, 14, 18 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 67 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10 }, 101, new [] { 0 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20 }, 101, new [] { 0, 81 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30 }, 100, new [] { 0, 49, 70 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30 }, 101, new [] { 0, 50, 71 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
-    public void TestJustifications_PutSpaceBetweenItems (Justification justification, int [] sizes, int containerSize, int [] expected)
-    {
-        int [] positions = new Justifier
-        {
-            PutSpaceBetweenItems = true,
-            Justification = justification,
-            ContainerSize = containerSize
-        }.Justify (sizes);
-        AssertJustification (justification, sizes, containerSize, positions, expected);
-    }
-
-    [Theory]
-    [InlineData (Justification.Left, new [] { 0 }, 1, new [] { 0 })]
-    [InlineData (Justification.Left, new [] { 0, 0 }, 1, new [] { 0, 0 })]
-    [InlineData (Justification.Left, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 0 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 10, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 11, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 12, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3 }, 13, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.Left, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.Left, new [] { 10, 20, 30 }, 100, new [] { 0, 10, 30 })]
-    [InlineData (Justification.Left, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 66 })]
-    [InlineData (Justification.Left, new [] { 10 }, 101, new [] { 0 })]
-    [InlineData (Justification.Left, new [] { 10, 20 }, 101, new [] { 0, 10 })]
-    [InlineData (Justification.Left, new [] { 10, 20, 30 }, 101, new [] { 0, 10, 30 })]
-    [InlineData (Justification.Left, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 60 })]
-    [InlineData (Justification.Left, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 100 })]
-    [InlineData (Justification.Right, new [] { 0 }, 1, new [] { 1 })]
-    [InlineData (Justification.Right, new [] { 0, 0 }, 1, new [] { 1, 1 })]
-    [InlineData (Justification.Right, new [] { 0, 0, 0 }, 1, new [] { 1, 1, 1 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 7, new [] { 1, 2, 4 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 10, new [] { 4, 5, 7 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 11, new [] { 5, 6, 8 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 12, new [] { 6, 7, 9 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3 }, 13, new [] { 7, 8, 10 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.Right, new [] { 1, 2, 3, 4 }, 11, new [] { 1, 2, 4, 7 })]
-    [InlineData (Justification.Right, new [] { 10, 20, 30 }, 100, new [] { 40, 50, 70 })]
-    [InlineData (Justification.Right, new [] { 33, 33, 33 }, 100, new [] { 1, 34, 67 })]
-    [InlineData (Justification.Right, new [] { 10 }, 101, new [] { 91 })]
-    [InlineData (Justification.Right, new [] { 10, 20 }, 101, new [] { 71, 81 })]
-    [InlineData (Justification.Right, new [] { 10, 20, 30 }, 101, new [] { 41, 51, 71 })]
-    [InlineData (Justification.Right, new [] { 10, 20, 30, 40 }, 101, new [] { 1, 11, 31, 61 })]
-    [InlineData (Justification.Right, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 1, 11, 31, 61, 101 })]
-    [InlineData (Justification.Centered, new [] { 1 }, 1, new [] { 0 })]
-    [InlineData (Justification.Centered, new [] { 1 }, 2, new [] { 0 })]
-    [InlineData (Justification.Centered, new [] { 1 }, 3, new [] { 1 })]
-    [InlineData (Justification.Centered, new [] { 1, 1 }, 2, new [] { 0, 1 })]
-    [InlineData (Justification.Centered, new [] { 1, 1 }, 3, new [] { 0, 1 })]
-    [InlineData (Justification.Centered, new [] { 1, 1 }, 4, new [] { 1, 2 })]
-    [InlineData (Justification.Centered, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 3 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 10, new [] { 2, 3, 5 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 11, new [] { 2, 3, 5 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.Centered, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 9, new [] { 0, 3, 6 })]
-    [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 10, new [] { 0, 3, 6 })]
-    [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 11, new [] { 1, 4, 7 })]
-    [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 12, new [] { 1, 4, 7 })]
-    [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 13, new [] { 2, 5, 8 })]
-    [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 66 })]
-    [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 101, new [] { 1, 34, 67 })]
-    [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 102, new [] { 1, 34, 67 })]
-    [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 103, new [] { 2, 35, 68 })]
-    [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 104, new [] { 2, 35, 68 })]
-    [InlineData (Justification.Centered, new [] { 3, 4, 5, 6 }, 25, new [] { 3, 6, 10, 15 })]
-    [InlineData (Justification.Justified, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
-    [InlineData (Justification.Justified, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
-    [InlineData (Justification.Justified, new [] { 10, 20, 30 }, 100, new [] { 0, 30, 70 })]
-    [InlineData (Justification.Justified, new [] { 10, 20, 30 }, 101, new [] { 0, 31, 71 })]
-    [InlineData (Justification.Justified, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
-    [InlineData (Justification.Justified, new [] { 11, 17, 23 }, 100, new [] { 0, 36, 77 })]
-    [InlineData (Justification.Justified, new [] { 1, 2, 3 }, 11, new [] { 0, 4, 8 })]
-    [InlineData (Justification.Justified, new [] { 10, 20 }, 101, new [] { 0, 81 })]
-    [InlineData (Justification.Justified, new [] { 10 }, 101, new [] { 0 })]
-    [InlineData (Justification.Justified, new [] { 3, 3, 3 }, 21, new [] { 0, 9, 18 })]
-    [InlineData (Justification.Justified, new [] { 3, 4, 5 }, 21, new [] { 0, 8, 16 })]
-    [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 18, new [] { 0, 3, 7, 12 })]
-    [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 19, new [] { 0, 4, 8, 13 })]
-    [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 20, new [] { 0, 4, 9, 14 })]
-    [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 21, new [] { 0, 4, 9, 15 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 22, new [] { 0, 8, 14, 19 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 23, new [] { 0, 8, 15, 20 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 24, new [] { 0, 8, 15, 21 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 25, new [] { 0, 9, 16, 22 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 26, new [] { 0, 9, 17, 23 })]
-    [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 31, new [] { 0, 11, 20, 28 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 0 }, 1, new [] { 1 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 0, 0 }, 1, new [] { 0, 1 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 1 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 1, new [] { 0 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 2, new [] { 1 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 3, new [] { 2 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 2, new [] { 0, 1 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 3, new [] { 0, 2 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 4, new [] { 0, 3 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 4 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 8, new [] { 0, 1, 5 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 9, new [] { 0, 1, 6 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 10, new [] { 0, 1, 7 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 11, new [] { 0, 1, 8 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 7 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 1, 3, 8 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 3, 3, 3 }, 21, new [] { 0, 3, 18 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 3, 4, 5 }, 21, new [] { 0, 3, 16 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 67 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10 }, 101, new [] { 91 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10, 20 }, 101, new [] { 0, 81 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30 }, 100, new [] { 0, 10, 70 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30 }, 101, new [] { 0, 10, 71 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
-    [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 0 }, 1, new [] { 0 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 0, 0 }, 1, new [] { 0, 1 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 1, new [] { 0 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 2, new [] { 0 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 3, new [] { 0 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 2, new [] { 0, 1 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 3, new [] { 0, 2 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 4, new [] { 0, 3 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 8, new [] { 0, 3, 5 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 9, new [] { 0, 4, 6 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 10, new [] { 0, 5, 7 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 11, new [] { 0, 6, 8 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 3, 5, 8 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 3, 3, 3 }, 21, new [] { 0, 15, 18 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 12, 16 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10 }, 101, new [] { 0 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20 }, 101, new [] { 0, 81 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30 }, 100, new [] { 0, 50, 70 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30 }, 101, new [] { 0, 51, 71 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
-    [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
-    public void TestJustifications_NoSpaceBetweenItems (Justification justification, int [] sizes, int containerSize, int [] expected)
-    {
-        int [] positions = new Justifier
-        {
-            PutSpaceBetweenItems = false,
-            Justification = justification,
-            ContainerSize = containerSize
-        }.Justify (sizes);
-        AssertJustification (justification, sizes, containerSize, positions, expected);
-    }
-
-    public void AssertJustification (Justification justification, int [] sizes, int totalSize, int [] positions, int [] expected)
-    {
-        try
-        {
-            _output.WriteLine ($"Testing: {RenderJustification (justification, sizes, totalSize, expected)}");
-        }
-        catch (Exception e)
-        {
-            _output.WriteLine ($"Exception rendering expected: {e.Message}");
-            _output.WriteLine ($"Actual: {RenderJustification (justification, sizes, totalSize, positions)}");
-        }
-
-        if (!expected.SequenceEqual (positions))
-        {
-            _output.WriteLine ($"Expected: {RenderJustification (justification, sizes, totalSize, expected)}");
-            _output.WriteLine ($"Actual: {RenderJustification (justification, sizes, totalSize, positions)}");
-            Assert.Fail (" Expected and actual do not match");
-        }
-    }
-
-    public string RenderJustification (Justification justification, int [] sizes, int totalSize, int [] positions)
-    {
-        var output = new StringBuilder ();
-        output.AppendLine ($"Justification: {justification}, Positions: {string.Join (", ", positions)}, TotalSize: {totalSize}");
-
-        for (var i = 0; i <= totalSize / 10; i++)
-        {
-            output.Append (i.ToString ().PadRight (9) + " ");
-        }
-
-        output.AppendLine ();
-
-        for (var i = 0; i < totalSize; i++)
-        {
-            output.Append (i % 10);
-        }
-
-        output.AppendLine ();
-
-        var items = new char [totalSize];
-
-        for (var position = 0; position < positions.Length; position++)
-        {
-            // try
-            {
-                for (var j = 0; j < sizes [position] && positions [position] + j < totalSize; j++)
-                {
-                    items [positions [position] + j] = (position + 1).ToString () [0];
-                }
-            }
-
-            //catch (Exception e)
-            //{
-            //    output.AppendLine ($"{e.Message} - position = {position}, positions[{position}]: {positions [position]}, sizes[{position}]: {sizes [position]}, totalSize: {totalSize}");
-            //    output.Append (new string (items).Replace ('\0', ' '));
-
-            //    Assert.Fail (e.Message + output.ToString ());
-            //}
-        }
-
-        output.Append (new string (items).Replace ('\0', ' '));
-
-        return output.ToString ();
-    }
-}

+ 1 - 13
UnitTests/Drawing/ThicknessTests.cs

@@ -841,19 +841,7 @@ public class ThicknessTests
                     3,
                     3,
                     4,
                     4,
                     5)]
                     5)]
-    [InlineData (
-                    1,
-                    2,
-                    3,
-                    4,
-                    1,
-                    1,
-                    1,
-                    1,
-                    2,
-                    3,
-                    4,
-                    5)]
+
     public void AddTest (
     public void AddTest (
         int left,
         int left,
         int top,
         int top,

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 120 - 325
UnitTests/Text/TextFormatterTests.cs


+ 2 - 2
UnitTests/View/DrawTests.cs

@@ -339,7 +339,7 @@ public class DrawTests (ITestOutputHelper _output)
             Text = "Test",
             Text = "Test",
             Width = 6,
             Width = 6,
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             ColorScheme = Colors.ColorSchemes ["Base"]
             ColorScheme = Colors.ColorSchemes ["Base"]
         };
         };
 
 
@@ -350,7 +350,7 @@ public class DrawTests (ITestOutputHelper _output)
             Y = 1,
             Y = 1,
             Width = 1,
             Width = 1,
             Height = 6,
             Height = 6,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            VerticalTextAlignment = Alignment.End,
             ColorScheme = Colors.ColorSchemes ["Base"]
             ColorScheme = Colors.ColorSchemes ["Base"]
         };
         };
         Toplevel top = new ();
         Toplevel top = new ();

+ 6 - 6
UnitTests/View/Layout/Dim.AutoTests.cs

@@ -787,11 +787,11 @@ public class DimAutoTests (ITestOutputHelper output)
         Assert.False (view.TextFormatter.AutoSize);
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
 
-        view.TextFormatter.Alignment = TextAlignment.Justified;
+        view.TextFormatter.Alignment = Alignment.Fill;
         Assert.False (view.TextFormatter.AutoSize);
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
 
-        view.TextFormatter.VerticalAlignment = VerticalTextAlignment.Middle;
+        view.TextFormatter.VerticalAlignment = Alignment.Center;
         Assert.False (view.TextFormatter.AutoSize);
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
 
@@ -815,11 +815,11 @@ public class DimAutoTests (ITestOutputHelper output)
         Assert.False (view.TextFormatter.AutoSize);
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
 
-        view.TextAlignment = TextAlignment.Justified;
+        view.TextAlignment = Alignment.Fill;
         Assert.False (view.TextFormatter.AutoSize);
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
 
-        view.VerticalTextAlignment = VerticalTextAlignment.Middle;
+        view.VerticalTextAlignment = Alignment.Center;
         Assert.False (view.TextFormatter.AutoSize);
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
 
@@ -844,7 +844,7 @@ public class DimAutoTests (ITestOutputHelper output)
         Assert.False (view.TextFormatter.AutoSize);
         Assert.False (view.TextFormatter.AutoSize);
         Assert.NotEqual (Size.Empty, view.Frame.Size);
         Assert.NotEqual (Size.Empty, view.Frame.Size);
 
 
-        view.TextAlignment = TextAlignment.Justified;
+        view.TextAlignment = Alignment.Fill;
         Assert.False (view.TextFormatter.AutoSize);
         Assert.False (view.TextFormatter.AutoSize);
         Assert.NotEqual (Size.Empty, view.Frame.Size);
         Assert.NotEqual (Size.Empty, view.Frame.Size);
 
 
@@ -853,7 +853,7 @@ public class DimAutoTests (ITestOutputHelper output)
             Text = "_1234",
             Text = "_1234",
             Width = Dim.Auto ()
             Width = Dim.Auto ()
         };
         };
-        view.VerticalTextAlignment = VerticalTextAlignment.Middle;
+        view.VerticalTextAlignment = Alignment.Center;
         Assert.False (view.TextFormatter.AutoSize);
         Assert.False (view.TextFormatter.AutoSize);
         Assert.NotEqual (Size.Empty, view.Frame.Size);
         Assert.NotEqual (Size.Empty, view.Frame.Size);
 
 

+ 0 - 2
UnitTests/View/Layout/Dim.PercentTests.cs

@@ -7,8 +7,6 @@ namespace Terminal.Gui.LayoutTests;
 
 
 public class DimPercentTests
 public class DimPercentTests
 {
 {
-    //private readonly ITestOutputHelper _output;
-
     [Fact]
     [Fact]
     public void DimFactor_Calculate_ReturnsCorrectValue ()
     public void DimFactor_Calculate_ReturnsCorrectValue ()
     {
     {

+ 112 - 0
UnitTests/View/Layout/Pos.AlignTests.cs

@@ -0,0 +1,112 @@
+namespace Terminal.Gui.LayoutTests;
+
+public class PosAlignTests
+{
+    [Fact]
+    public void PosAlign_Constructor ()
+    {
+        var posAlign = new PosAlign
+        {
+            Aligner = new ()
+        };
+        Assert.NotNull (posAlign);
+
+        Assert.Equal (Alignment.Start, posAlign.Aligner.Alignment);
+        Assert.Equal (AlignmentModes.StartToEnd, posAlign.Aligner.AlignmentModes);
+        Assert.Equal (0, posAlign.Aligner.ContainerSize);
+    }
+
+    [Fact]
+    public void PosAlign_StaticFactory_Defaults ()
+    {
+        var posAlign = Pos.Align (Alignment.Start) as PosAlign;
+        Assert.NotNull (posAlign);
+
+        Assert.Equal (Alignment.Start, posAlign.Aligner.Alignment);
+        Assert.Equal (AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, posAlign.Aligner.AlignmentModes);
+        Assert.Equal (0, posAlign.Aligner.ContainerSize);
+    }
+
+    [Theory]
+    [InlineData (Alignment.Start, Alignment.Start, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, true)]
+    [InlineData (Alignment.Center, Alignment.Center, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, true)]
+    [InlineData (Alignment.Start, Alignment.Center, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, false)]
+    [InlineData (Alignment.Center, Alignment.Start, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, false)]
+    [InlineData (Alignment.Start, Alignment.Start, AlignmentModes.StartToEnd, AlignmentModes.AddSpaceBetweenItems, false)]
+    public void PosAlign_Equals (Alignment align1, Alignment align2, AlignmentModes mode1, AlignmentModes mode2, bool expectedEquals)
+    {
+        var posAlign1 = new PosAlign
+        {
+            Aligner = new()
+            {
+                Alignment = align1,
+                AlignmentModes = mode1
+            }
+        };
+
+        var posAlign2 = new PosAlign
+        {
+            Aligner = new()
+            {
+                Alignment = align2,
+                AlignmentModes = mode2
+            }
+        };
+
+        Assert.Equal (expectedEquals, posAlign1.Equals (posAlign2));
+        Assert.Equal (expectedEquals, posAlign2.Equals (posAlign1));
+    }
+
+    [Fact]
+    public void PosAlign_Equals_CachedLocation_Not_Used ()
+    {
+        View superView = new ()
+        {
+            Width = 10,
+            Height = 25
+        };
+        View view = new ();
+        superView.Add (view);
+
+        Pos posAlign1 = Pos.Align (Alignment.Center);
+        view.X = posAlign1;
+        int pos1 = posAlign1.Calculate (10, Dim.Absolute (0)!, view, Dimension.Width);
+
+        Pos posAlign2 = Pos.Align (Alignment.Center);
+        view.Y = posAlign2;
+        int pos2 = posAlign2.Calculate (25, Dim.Absolute (0)!, view, Dimension.Height);
+
+        Assert.NotEqual (pos1, pos2);
+        Assert.Equal (posAlign1, posAlign2);
+    }
+
+    [Fact]
+    public void PosAlign_ToString ()
+    {
+        Pos posAlign = Pos.Align (Alignment.Fill);
+        var expectedString = "Align(alignment=Fill,modes=AddSpaceBetweenItems,groupId=0)";
+
+        Assert.Equal (expectedString, posAlign.ToString ());
+    }
+
+    [Fact]
+    public void PosAlign_Anchor ()
+    {
+        Pos posAlign = Pos.Align (Alignment.Start);
+        var width = 50;
+        int expectedAnchor = -width;
+
+        Assert.Equal (expectedAnchor, posAlign.GetAnchor (width));
+    }
+
+    [Fact]
+    public void PosAlign_CreatesCorrectInstance ()
+    {
+        Pos pos = Pos.Align (Alignment.Start);
+        Assert.IsType<PosAlign> (pos);
+    }
+
+    // TODO: Test scenarios where views with matching GroupId's are added/removed from a Superview
+
+    // TODO: Make AlignAndUpdateGroup internal and write low-level unit tests for it
+}

+ 1 - 1
UnitTests/View/Layout/Pos.Tests.cs

@@ -78,7 +78,7 @@ public class PosTests ()
     {
     {
         Application.Init (new FakeDriver ());
         Application.Init (new FakeDriver ());
 
 
-        Toplevel t = new Toplevel();
+        Toplevel t = new Toplevel ();
 
 
         var w = new Window { X = Pos.Left (t) + 2, Y = Pos.Top (t) + 2 };
         var w = new Window { X = Pos.Left (t) + 2, Y = Pos.Top (t) + 2 };
         var f = new FrameView ();
         var f = new FrameView ();

+ 1 - 1
UnitTests/View/NeedsDisplayTests.cs

@@ -5,7 +5,7 @@ using Xunit.Abstractions;
 namespace Terminal.Gui.ViewTests;
 namespace Terminal.Gui.ViewTests;
 
 
 [Trait("Category","Output")]
 [Trait("Category","Output")]
-public class NeedsDisplayTests (ITestOutputHelper output)
+public class NeedsDisplayTests ()
 {
 {
     [Fact]
     [Fact]
     public void NeedsDisplay_False_If_Width_Height_Zero ()
     public void NeedsDisplay_False_If_Width_Height_Zero ()

+ 7 - 7
UnitTests/View/TextTests.cs

@@ -850,7 +850,7 @@ Y
             Y = 1,
             Y = 1,
             Width = width,
             Width = width,
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Centered
+            TextAlignment = Alignment.Center
         };
         };
 
 
         if (autoSize)
         if (autoSize)
@@ -865,7 +865,7 @@ Y
             Y = 2,
             Y = 2,
             Width = width,
             Width = width,
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Right
+            TextAlignment = Alignment.End
         };
         };
 
 
         if (autoSize)
         if (autoSize)
@@ -880,7 +880,7 @@ Y
             Y = 3,
             Y = 3,
             Width = width,
             Width = width,
             Height = 1,
             Height = 1,
-            TextAlignment = TextAlignment.Justified
+            TextAlignment = Alignment.Fill
         };
         };
 
 
         if (autoSize)
         if (autoSize)
@@ -974,7 +974,7 @@ Y
             Width = 1,
             Width = 1,
             Height = height,
             Height = height,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Middle
+            VerticalTextAlignment = Alignment.Center
         };
         };
 
 
         if (autoSize)
         if (autoSize)
@@ -990,7 +990,7 @@ Y
             Width = 1,
             Width = 1,
             Height = height,
             Height = height,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom
+            VerticalTextAlignment = Alignment.End
         };
         };
 
 
         if (autoSize)
         if (autoSize)
@@ -1006,7 +1006,7 @@ Y
             Width = 1,
             Width = 1,
             Height = height,
             Height = height,
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Justified
+            VerticalTextAlignment = Alignment.Fill
         };
         };
 
 
         if (autoSize)
         if (autoSize)
@@ -1227,7 +1227,7 @@ Y
         {
         {
             Text = "01234",
             Text = "01234",
             TextDirection = TextDirection.LeftRight_TopBottom,
             TextDirection = TextDirection.LeftRight_TopBottom,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 10,
             Width = 10,
             Height = Dim.Auto (DimAutoStyle.Text)
             Height = Dim.Auto (DimAutoStyle.Text)
         };
         };

+ 4 - 4
UnitTests/Views/ButtonTests.cs

@@ -155,14 +155,14 @@ public class ButtonTests (ITestOutputHelper output)
 
 
         Assert.Equal ($"{CM.Glyphs.LeftBracket}  {CM.Glyphs.RightBracket}", btn.TextFormatter.Text);
         Assert.Equal ($"{CM.Glyphs.LeftBracket}  {CM.Glyphs.RightBracket}", btn.TextFormatter.Text);
         Assert.False (btn.IsDefault);
         Assert.False (btn.IsDefault);
-        Assert.Equal (TextAlignment.Centered, btn.TextAlignment);
+        Assert.Equal (Alignment.Center, btn.TextAlignment);
         Assert.Equal ('_', btn.HotKeySpecifier.Value);
         Assert.Equal ('_', btn.HotKeySpecifier.Value);
         Assert.True (btn.CanFocus);
         Assert.True (btn.CanFocus);
         Assert.Equal (new (0, 0, 4, 1), btn.Viewport);
         Assert.Equal (new (0, 0, 4, 1), btn.Viewport);
         Assert.Equal (new (0, 0, 4, 1), btn.Frame);
         Assert.Equal (new (0, 0, 4, 1), btn.Frame);
         Assert.Equal ($"{CM.Glyphs.LeftBracket}  {CM.Glyphs.RightBracket}", btn.TextFormatter.Text);
         Assert.Equal ($"{CM.Glyphs.LeftBracket}  {CM.Glyphs.RightBracket}", btn.TextFormatter.Text);
         Assert.False (btn.IsDefault);
         Assert.False (btn.IsDefault);
-        Assert.Equal (TextAlignment.Centered, btn.TextAlignment);
+        Assert.Equal (Alignment.Center, btn.TextAlignment);
         Assert.Equal ('_', btn.HotKeySpecifier.Value);
         Assert.Equal ('_', btn.HotKeySpecifier.Value);
         Assert.True (btn.CanFocus);
         Assert.True (btn.CanFocus);
         Assert.Equal (new (0, 0, 4, 1), btn.Viewport);
         Assert.Equal (new (0, 0, 4, 1), btn.Viewport);
@@ -195,7 +195,7 @@ public class ButtonTests (ITestOutputHelper output)
                       btn.TextFormatter.Format ()
                       btn.TextFormatter.Format ()
                      );
                      );
         Assert.True (btn.IsDefault);
         Assert.True (btn.IsDefault);
-        Assert.Equal (TextAlignment.Centered, btn.TextAlignment);
+        Assert.Equal (Alignment.Center, btn.TextAlignment);
         Assert.True (btn.CanFocus);
         Assert.True (btn.CanFocus);
 
 
         btn.SetRelativeLayout (new (100, 100));
         btn.SetRelativeLayout (new (100, 100));
@@ -222,7 +222,7 @@ public class ButtonTests (ITestOutputHelper output)
                       btn.TextFormatter.Format ()
                       btn.TextFormatter.Format ()
                      );
                      );
         Assert.True (btn.IsDefault);
         Assert.True (btn.IsDefault);
-        Assert.Equal (TextAlignment.Centered, btn.TextAlignment);
+        Assert.Equal (Alignment.Center, btn.TextAlignment);
         Assert.Equal ('_', btn.HotKeySpecifier.Value);
         Assert.Equal ('_', btn.HotKeySpecifier.Value);
         Assert.True (btn.CanFocus);
         Assert.True (btn.CanFocus);
 
 

+ 9 - 10
UnitTests/Views/CheckBoxTests.cs

@@ -28,7 +28,6 @@ public class CheckBoxTests
     [InlineData ("0_12你", 0, 1, 0, 1)]
     [InlineData ("0_12你", 0, 1, 0, 1)]
     [InlineData ("0_12你", 1, 1, 1, 1)]
     [InlineData ("0_12你", 1, 1, 1, 1)]
     [InlineData ("0_12你", 10, 1, 10, 1)]
     [InlineData ("0_12你", 10, 1, 10, 1)]
-    [InlineData ("0_12你", 10, 3, 10, 3)]
     public void CheckBox_AbsoluteSize_Text (string text, int width, int height, int expectedWidth, int expectedHeight)
     public void CheckBox_AbsoluteSize_Text (string text, int width, int height, int expectedWidth, int expectedHeight)
     {
     {
         var checkBox = new CheckBox
         var checkBox = new CheckBox
@@ -251,7 +250,7 @@ public class CheckBoxTests
             X = 1,
             X = 1,
             Y = Pos.Center (),
             Y = Pos.Center (),
             Text = "Check this out 你",
             Text = "Check this out 你",
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 25
             Width = 25
         };
         };
         var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
         var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
@@ -262,7 +261,7 @@ public class CheckBoxTests
         Application.Begin (top);
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 
 
-        Assert.Equal (TextAlignment.Centered, checkBox.TextAlignment);
+        Assert.Equal (Alignment.Center, checkBox.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
         Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
         Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
 
 
@@ -301,7 +300,7 @@ public class CheckBoxTests
             X = 1,
             X = 1,
             Y = Pos.Center (),
             Y = Pos.Center (),
             Text = "Check first out 你",
             Text = "Check first out 你",
-            TextAlignment = TextAlignment.Justified,
+            TextAlignment = Alignment.Fill,
             Width = 25
             Width = 25
         };
         };
 
 
@@ -310,7 +309,7 @@ public class CheckBoxTests
             X = 1,
             X = 1,
             Y = Pos.Bottom (checkBox1),
             Y = Pos.Bottom (checkBox1),
             Text = "Check second out 你",
             Text = "Check second out 你",
-            TextAlignment = TextAlignment.Justified,
+            TextAlignment = Alignment.Fill,
             Width = 25
             Width = 25
         };
         };
         var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
         var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
@@ -321,9 +320,9 @@ public class CheckBoxTests
         Application.Begin (top);
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 6);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 6);
 
 
-        Assert.Equal (TextAlignment.Justified, checkBox1.TextAlignment);
+        Assert.Equal (Alignment.Fill, checkBox1.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
         Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
-        Assert.Equal (TextAlignment.Justified, checkBox2.TextAlignment);
+        Assert.Equal (Alignment.Fill, checkBox2.TextAlignment);
         Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
         Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
  
  
         var expected = @$"
         var expected = @$"
@@ -378,7 +377,7 @@ public class CheckBoxTests
         Application.Begin (top);
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 
 
-        Assert.Equal (TextAlignment.Left, checkBox.TextAlignment);
+        Assert.Equal (Alignment.Start, checkBox.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
         Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
         Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
 
 
@@ -417,7 +416,7 @@ public class CheckBoxTests
             X = 1,
             X = 1,
             Y = Pos.Center (),
             Y = Pos.Center (),
             Text = "Check this out 你",
             Text = "Check this out 你",
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.End,
             Width = 25
             Width = 25
         };
         };
         var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
         var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
@@ -428,7 +427,7 @@ public class CheckBoxTests
         Application.Begin (top);
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 
 
-        Assert.Equal (TextAlignment.Right, checkBox.TextAlignment);
+        Assert.Equal (Alignment.End, checkBox.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
         Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
         Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
 
 

+ 1 - 1
UnitTests/Views/LabelTests.cs

@@ -207,7 +207,7 @@ public class LabelTests
     {
     {
         var label = new Label ();
         var label = new Label ();
         Assert.Equal (string.Empty, label.Text);
         Assert.Equal (string.Empty, label.Text);
-        Assert.Equal (TextAlignment.Left, label.TextAlignment);
+        Assert.Equal (Alignment.Start, label.TextAlignment);
         Assert.False (label.CanFocus);
         Assert.False (label.CanFocus);
         Assert.Equal (new Rectangle (0, 0, 0, 0), label.Frame);
         Assert.Equal (new Rectangle (0, 0, 0, 0), label.Frame);
         Assert.Equal (KeyCode.Null, label.HotKey);
         Assert.Equal (KeyCode.Null, label.HotKey);

+ 20 - 20
UnitTests/Views/TextValidateFieldTests.cs

@@ -10,7 +10,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             ****
             //                                             ****
@@ -44,7 +44,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Left,
+            TextAlignment = Alignment.Start,
             Width = 30,
             Width = 30,
 
 
             //                                             ****
             //                                             ****
@@ -81,7 +81,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             ****
             //                                             ****
@@ -115,7 +115,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             *
             //                                             *
@@ -137,7 +137,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             *
             //                                             *
@@ -161,7 +161,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             ****
             //                                             ****
@@ -179,7 +179,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             ****
             //                                             ****
@@ -196,7 +196,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             ****
             //                                             ****
@@ -214,7 +214,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             *
             //                                             *
@@ -233,7 +233,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             *
             //                                             *
@@ -253,7 +253,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             ** **
             //                                             ** **
@@ -283,7 +283,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             *
             //                                             *
@@ -308,7 +308,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Left,
+            TextAlignment = Alignment.Start,
             Width = 30,
             Width = 30,
 
 
             //                                             ****
             //                                             ****
@@ -338,7 +338,7 @@ public class TextValidateField_NET_Provider_Tests
 
 
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Left, Width = 30, Provider = new NetMaskedTextProvider ("--(0000)--")
+            TextAlignment = Alignment.Start, Width = 30, Provider = new NetMaskedTextProvider ("--(0000)--")
         };
         };
 
 
         field.Provider.TextChanged += (sender, e) => wasTextChanged = true;
         field.Provider.TextChanged += (sender, e) => wasTextChanged = true;
@@ -356,7 +356,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             *
             //                                             *
@@ -381,7 +381,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Left,
+            TextAlignment = Alignment.Start,
             Width = 30,
             Width = 30,
 
 
             //                                             ****
             //                                             ****
@@ -400,7 +400,7 @@ public class TextValidateField_NET_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
 
 
             //                                             ****
             //                                             ****
@@ -540,7 +540,7 @@ public class TextValidateField_Regex_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
             Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false }
             Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false }
         };
         };
@@ -596,7 +596,7 @@ public class TextValidateField_Regex_Provider_Tests
 
 
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
             Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false }
             Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false }
         };
         };
@@ -616,7 +616,7 @@ public class TextValidateField_Regex_Provider_Tests
     {
     {
         var field = new TextValidateField
         var field = new TextValidateField
         {
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Center,
             Width = 20,
             Width = 20,
             Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false }
             Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false }
         };
         };

+ 2 - 2
UnitTests/Views/ToplevelTests.cs

@@ -1453,8 +1453,8 @@ public class ToplevelTests
                         Y = Pos.Center (),
                         Y = Pos.Center (),
                         Width = Dim.Fill (),
                         Width = Dim.Fill (),
                         Height = Dim.Fill (),
                         Height = Dim.Fill (),
-                        TextAlignment = TextAlignment.Centered,
-                        VerticalTextAlignment = VerticalTextAlignment.Middle,
+                        TextAlignment = Alignment.Center,
+                        VerticalTextAlignment = Alignment.Center,
                         Text = "Test"
                         Text = "Test"
                     }
                     }
                    );
                    );

+ 23 - 23
docfx/docs/drawing.md

@@ -1,12 +1,12 @@
 # Drawing (Text, Lines, and Color)
 # Drawing (Text, Lines, and Color)
 
 
-Terminal.Gui provides a set of APIs for formatting text, line drawing, and character-based graphing. The fundamental concept is a `Cell` which ocupises a particular row and column in the terminal. A Cell includes the character (glyph) that should be rendred by the terminal, and attributes that indicate how the glphy should be rendered (e.g. the foreground and background color).
+Terminal.Gui provides a set of APIs for formatting text, line drawing, and character-based graphing. The fundamental concept is a [Cell](~/api/Terminal.Gui.Cell.yml) which ocupises a particular row and column in the terminal. A Cell includes the character (glyph) that should be rendred by the terminal, and attributes that indicate how the glphy should be rendered (e.g. the foreground and background color).
 
 
 Color is supported on all platforms, including Windows, Mac, and Linux. The default colors are 24-bit RGB colors, but the library will gracefully degrade to 16-colors if the terminal does not support 24-bit color, and black and white if the terminal does not support 16-colors.
 Color is supported on all platforms, including Windows, Mac, and Linux. The default colors are 24-bit RGB colors, but the library will gracefully degrade to 16-colors if the terminal does not support 24-bit color, and black and white if the terminal does not support 16-colors.
 
 
 ## View Drawing API
 ## View Drawing API
 
 
-A `View` will typically draw text when the [OnDrawContent](~/api/Terminal.Gui.View.yml#Terminal_Gui_View_OnDrawContent_) is called (or the `DrawContent` event is received).
+A [View](~/api/Terminal.Gui.View.yml) will typically draw text when the [OnDrawContent](~/api/Terminal.Gui.View.yml#Terminal_Gui_View_OnDrawContent_) is called (or the `DrawContent` event is received).
 
 
 Outputting unformatted text involves:
 Outputting unformatted text involves:
 
 
@@ -16,28 +16,28 @@ c) Outputting glyphs by calling `AddRune` or `AddStr`.
 
 
 Outputting formatted text involves:
 Outputting formatted text involves:
 
 
-a) Adding the text to a `TextFormatter` object.
-b) Setting formatting options, such as `TextFormatter.TextAlignment`.
-c) Calling `TextFormatter.Draw`.
+a) Adding the text to a [TextFormatter](~/api/Terminal.Gui.TextFormatter.yml) object.
+b) Setting formatting options, such as [TextFormatter.TextAlignment](~/api/Terminal.Gui.TextFormatter.TextAlignment.yml).
+c) Calling [TextFormatter.Draw](~/api/Terminal.Gui.TextFormatter.Draw.yml).
 
 
-Line drawing is accomplished using the `LineCanvas` API:
+Line drawing is accomplished using the [LineCanvas](~/api/Terminal.Gui.LineCanvas.yml) API:
 
 
-a) Add the lines via `LineCanvas.Add`.
-b) Either render the line canvas via `LineCanvas.Draw` or let the `View` do so automatically (which enables automatic line joining across Views).
+a) Add the lines via [LineCanvas.Add](~/api/Terminal.Gui.LineCanvas.Add.yml).
+b) Either render the line canvas via [LineCanvas.Draw](~/api/Terminal.Gui.LineCanvas.Draw.yml) or let the [View](~/api/Terminal.Gui.View.yml) do so automatically (which enables automatic line joining across Views).
 
 
 ## Coordinate System for Drawing
 ## Coordinate System for Drawing
 
 
-The `View` draw APIs, including the `OnDrawContent` method, the `DrawContent` event, and the `View.Move` method, all take coordinates specified in *Viewport-Relative* coordinates. That is, `0, 0` is the top-left cell visible to the user.
+The [View](~/api/Terminal.Gui.View.yml) draw APIs, including the `OnDrawContent` method, the `DrawContent` event, and the [View.Move](~/api/Terminal.Gui.View.Move.yml) method, all take coordinates specified in *Viewport-Relative* coordinates. That is, `0, 0` is the top-left cell visible to the user.
 
 
 See [Layout](layout.html) for more details of the Terminal.Gui coordinate system.
 See [Layout](layout.html) for more details of the Terminal.Gui coordinate system.
 
 
 ## Cell
 ## Cell
 
 
-The `Cell` class represents a single cell on the screen. It contains a character and an attribute. The character is of type `Rune` and the attribute is of type `Attribute`.
+The [Cell](~/api/Terminal.Gui.Cell.yml) class represents a single cell on the screen. It contains a character and an attribute. The character is of type `Rune` and the attribute is of type [Attribute](~/api/Terminal.Gui.Attribute.yml).
 
 
-`Cell` is not exposed directly to the developer. Instead, the `ConsoleDriver` classes manage the `Cell` array that represents the screen.
+`Cell` is not exposed directly to the developer. Instead, the [ConsoleDriver](~/api/Terminal.Gui.ConsoleDriver.yml) classes manage the `Cell` array that represents the screen.
 
 
-To draw a `Cell` to the screen, use `View.Move` to specify the row and column coordinates and then use the `View.AddRune` method to draw a single glyph. To draw a string, use `View.AddStr`. 
+To draw a `Cell` to the screen, use [View.Move](~/api/Terminal.Gui.View.Move.yml) to specify the row and column coordinates and then use the [View.AddRune](~/api/Terminal.Gui.View.AddRune.yml) method to draw a single glyph. To draw a string, use [View.AddStr](~/api/Terminal.Gui.View.AddStr.yml). 
 
 
 ## Unicode
 ## Unicode
 
 
@@ -47,15 +47,15 @@ See the Character Map sample app in the [UI Catalog](https://gui-cs.github.io/Te
 
 
 ## Attribute 
 ## Attribute 
 
 
-The `Attribute` class represents the formatting attributes of a `Cell`. It exposes properties for the foreground and background colors. The foreground and background colors are of type `Color`. In the future, it will expose properties for bold, underline, and other formatting attributes.
+The [Attribute](~/api/Terminal.Gui.Attribute.yml) class represents the formatting attributes of a `Cell`. It exposes properties for the foreground and background colors. The foreground and background colors are of type [Color](~/api/Terminal.Gui.Color.yml). In the future, it will expose properties for bold, underline, and other formatting attributes.
 
 
 ## Color
 ## Color
 
 
-The `Color` class represents a color. It provides automatic mapping between the legacy 4-bit (16-color) system and 24-bit colors. It contains properties for the red, green, and blue components of the color. The red, green, and blue components are of type `byte`. The `Color` class also contains a static property for each of the 16 ANSI colors.
+The `Color` class represents a color. It provides automatic mapping between the legacy 4-bit (16-color) system and 24-bit colors. It contains properties for the red, green, and blue components of the color. The red, green, and blue components are of type [byte](~/api/Terminal.Gui.byte.yml). The `Color` class also contains a static property for each of the 16 ANSI colors.
 
 
 ## Color Schemes
 ## Color Schemes
 
 
-Terminal.Gui supports named collections of colors called `ColorScheme`s. Three built-in color schemes are provided: "Default", "Dark", and "Light". Additional color schemes can be defined via [Configuration Manager](). 
+Terminal.Gui supports named collections of colors called [ColorScheme](~/api/Terminal.Gui.ColorScheme.yml)s. Three built-in color schemes are provided: "Default", "Dark", and "Light". Additional color schemes can be defined via [Configuration Manager](). 
 
 
 Color schemes support defining colors for various states of a View. The following states are supported:
 Color schemes support defining colors for various states of a View. The following states are supported:
 
 
@@ -65,11 +65,11 @@ Color schemes support defining colors for various states of a View. The followin
 * HotFocus - The color of text indicating a hot key, when the view has focus.
 * HotFocus - The color of text indicating a hot key, when the view has focus.
 * Disabled - The state of a view when it is disabled.
 * Disabled - The state of a view when it is disabled.
 
 
-Change the colors of a view by setting the `View.ColorScheme` property.
+Change the colors of a view by setting the [View.ColorScheme](~/api/Terminal.Gui.View.ColorScheme.yml) property.
 
 
 ## Text Formatting
 ## Text Formatting
 
 
-Terminal.Gui supports text formatting using the [TextFormatter]() class. The `TextFormatter` class provides methods for formatting text using the following formatting options:
+Terminal.Gui supports text formatting using the [TextFormatter]() class. The [TextFormatter](~/api/Terminal.Gui.TextFormatter.yml) class provides methods for formatting text using the following formatting options:
 
 
 * Horizontal Alignment - Left, Center, Right
 * Horizontal Alignment - Left, Center, Right
 * Vertical Alignment - Top, Middle, Bottom
 * Vertical Alignment - Top, Middle, Bottom
@@ -78,19 +78,19 @@ Terminal.Gui supports text formatting using the [TextFormatter]() class. The `Te
 
 
 ## Glyphs
 ## Glyphs
 
 
-Terminal.Gui supports rendering glyphs using the `Glyph` class. The `Glyph` class represents a single glyph. It contains a character and an attribute. The character is of type `Rune` and the attribute is of type `Attribute`. A set of static properties are provided for the standard glyphs used for standard views (e.g. the default indicator for [Button](~/api/Terminal.Gui.Button.yml)) and line drawing (e.g. [LineCanvas](~/api/Terminal.Gui.LineCanvas.yml)).
+Terminal.Gui supports rendering glyphs using the [Glyph](~/api/Terminal.Gui.Glyph.yml) class. The [Glyph](~/api/Terminal.Gui.Glyph.yml) class represents a single glyph. It contains a character and an attribute. The character is of type `Rune` and the attribute is of type [Attribute](~/api/Terminal.Gui.Attribute.yml). A set of static properties are provided for the standard glyphs used for standard views (e.g. the default indicator for [Button](~/api/Terminal.Gui.Button.yml)) and line drawing (e.g. [LineCanvas](~/api/Terminal.Gui.LineCanvas.yml)).
 
 
 ## Line Drawing
 ## Line Drawing
 
 
-Terminal.Gui supports drawing lines and shapes using box-drawing glyphs. The `LineCanvas` class provides *auto join*, a smart TUI drawing system that automatically selects the correct line/box drawing glyphs for intersections making drawing complex shapes easy. See [Line Canvas](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#line-canvas) for details. The `Snake` and `Line Drawing` Scenarios in the [UI Catalog](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#ui-catalog) sample app are both examples of the power of `LineCanvas`.
+Terminal.Gui supports drawing lines and shapes using box-drawing glyphs. The [LineCanvas](~/api/Terminal.Gui.LineCanvas.yml) class provides *auto join*, a smart TUI drawing system that automatically selects the correct line/box drawing glyphs for intersections making drawing complex shapes easy. See [Line Canvas](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#line-canvas) for details. The `Snake` and `Line Drawing` Scenarios in the [UI Catalog](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#ui-catalog) sample app are both examples of the power of [LineCanvas](~/api/Terminal.Gui.LineCanvas.yml).
 
 
 ## Thickness
 ## Thickness
 
 
-Describes the thickness of a frame around a rectangle. The thickness is specified for each side of the rectangle using a `Thickness` object. The `Thickness` object contains properties for the left, top, right, and bottom thickness. The `Frame` class uses `Thickness` to support drawing the frame around a view. The `View` class contains three `Frame`-dervied properties: 
+Describes the thickness of a frame around a rectangle. The thickness is specified for each side of the rectangle using a [Thickness](~/api/Terminal.Gui.Thickness.yml) object. The [Thickness](~/api/Terminal.Gui.Thickness.yml) object contains properties for the left, top, right, and bottom thickness. The [Adornment](~/api/Terminal.Gui.Adornment.yml) class uses [Thickness](~/api/Terminal.Gui.Thickness.yml) to support drawing the frame around a view. The `View` class contains three [Adornment](~/api/Terminal.Gui.Adornment.yml)-dervied properties: 
 
 
-* `Margin` - The space between the view and its peers (other views at the same level in the view hierarchy).
-* `Border` - The space between the view and its Padding. This is where the frame, title, and other "Adornments" are drawn.
-* `Padding` - The space between the view and its content. This is where the text, images, and other content is drawn. The inner rectangle of `Padding` is the `Bounds` of a view. 
+* [View.Margin.$2](~/api/Terminal.Gui.View.Margin.yml) - The space between the view and its peers (other views at the same level in the view hierarchy).
+* [View.Border.$2](~/api/Terminal.Gui.View.Border.yml) - The space between the view and its Padding. This is where the frame, title, and other "Adornments" are drawn.
+* [View.Padding.$2](~/api/Terminal.Gui.View.Padding.yml) - The space between the view and its content. This is where the text, images, and other content is drawn. The inner rectangle of `Padding` is the `Bounds` of a view. 
 
 
 See [View](~/api/Terminal.Gui.View.yml) for details.
 See [View](~/api/Terminal.Gui.View.yml) for details.
 
 

+ 1 - 0
docfx/docs/layout.md

@@ -65,6 +65,7 @@ The [Pos](~/api/Terminal.Gui.Pos.yml) is the type of `View.X` and `View.Y` and s
 * Anchored from the end of the dimension - `Pos.AnchorEnd()`.
 * Anchored from the end of the dimension - `Pos.AnchorEnd()`.
 * Centered, using `Pos.Center()`.
 * Centered, using `Pos.Center()`.
 * The `Pos.Left(otherView)`, `Pos.Top(otherView)`, `Pos.Bottom(otherView)`, `Pos.Right(otherView)` positions of another view.
 * The `Pos.Left(otherView)`, `Pos.Top(otherView)`, `Pos.Bottom(otherView)`, `Pos.Right(otherView)` positions of another view.
+* Aligned (left, right, center, etc...) with other views - `Pos.Justify(Justification)`.
 
 
 All `Pos` coordinates are relative to the Superview's content area.
 All `Pos` coordinates are relative to the Superview's content area.
 
 

+ 62 - 37
docfx/docs/migratingfromv1.md

@@ -4,11 +4,24 @@ This document provides an overview of the changes between Terminal.Gui v1 and v2
 
 
 For detailed breaking change documentation check out this Discussion: https://github.com/gui-cs/Terminal.Gui/discussions/2448
 For detailed breaking change documentation check out this Discussion: https://github.com/gui-cs/Terminal.Gui/discussions/2448
 
 
+## View Constructors -> Initializers
+
+In v1, [View](~/api/Terminal.Gui.View.yml) and most sub-classes, had multiple constructors that took a variety of parameters. In v2, the constructors have been replaced with initializers. This change was made to simplify the API and make it easier to use. In addition, the v1 constructors drove a false (and needlessly complex) distinction between "Absoulte" and "Computed" layout. In v2, the layout system is much simpler and more intuitive.
+
+### How to Fix
+
+Replace the constructor calls with initializer calls.
+
+```diff
+- var myView = new View (new Rect (10, 10, 40, 10));
++ var myView = new View { X = 10, Y = 10, Width = 40, Height = 10 };
+```
+
 ## TrueColor Support - 24-bit Color is the default
 ## TrueColor Support - 24-bit Color is the default
 
 
 Terminal.Gui v2 now supports 24-bit color by default. This means that the colors you use in your application will be more accurate and vibrant. If you are using custom colors in your application, you may need to update them to use the new 24-bit color format.
 Terminal.Gui v2 now supports 24-bit color by default. This means that the colors you use in your application will be more accurate and vibrant. If you are using custom colors in your application, you may need to update them to use the new 24-bit color format.
 
 
-Some methods to do with `Attribute` class have been simplified.  Color names now match the ANSII standard ('Brown' is now called 'Yellow')
+The [Attribute](~/api/Terminal.Gui.Attribute.yml) class has been simplified. Color names now match the ANSI standard ('Brown' is now called 'Yellow')
 
 
 ### How to Fix
 ### How to Fix
 
 
@@ -16,7 +29,7 @@ Static class `Attribute.Make` has been removed. Use constructor instead
 
 
 ```diff
 ```diff
 - var c = Attribute.Make(Color.BrightMagenta, Color.Blue);
 - var c = Attribute.Make(Color.BrightMagenta, Color.Blue);
-+ var c = new Attribute(Color.BrightMagenta, Color.Blue)
++ var c = new Attribute(Color.BrightMagenta, Color.Blue);
 ```
 ```
 
 
 ```diff
 ```diff
@@ -71,23 +84,23 @@ When measuring the screen space taken up by a `string` you can use the extension
 
 
 ## `View Life Cycle Management
 ## `View Life Cycle Management
 
 
-In v1, `View` was derived from `Responder` which supported `IDisposable`. In v2, `Responder` has been removed and `View` is the base-class supporting `IDisposable`. 
+In v1, [View](~/api/Terminal.Gui.View.yml) was derived from `Responder` which supported `IDisposable`. In v2, `Responder` has been removed and [View](~/api/Terminal.Gui.View.yml) is the base-class supporting `IDisposable`. 
 
 
-In v1, `Application.Init` automatically created a toplevel view and set `Applicaton.Top`. In v2, `Application.Init` no longer automatically creates a toplevel or sets `Applicaton.Top`; app developers must explicitly create the toplevel view and pass it to `Appliation.Run` (or use `Application.Run<myTopLevel>`). Developers are responsible for calling `Dispose` on any toplevel they create before exiting. 
+In v1, [Application.Init](~/api/Terminal.Gui./Terminal.Gui.Application.Init) automatically created a toplevel view and set [Applicaton.Top](~/api/Terminal.Gui.Applicaton.Top.yml). In v2, [Application.Init](~/api/Terminal.Gui.Application.Init.yml) no longer automatically creates a toplevel or sets [Applicaton.Top](~/api/Terminal.Gui.Applicaton.Top.yml); app developers must explicitly create the toplevel view and pass it to [Appliation.Run](~/api/Terminal.Gui.Appliation.Run.yml) (or use `Application.Run<myTopLevel>`). Developers are responsible for calling `Dispose` on any toplevel they create before exiting. 
 
 
 ### How to Fix
 ### How to Fix
 
 
-* Replace `Responder` with `View`
-* Update any code that assumed `Application.Init` automatically created a toplevel view and set `Applicaton.Top`.
-* Update any code that assumed `Application.Init` automatically disposed of the toplevel view when the application exited.
+* Replace `Responder` with [View](~/api/Terminal.Gui.View.yml)
+* Update any code that assumes `Application.Init` automatically created a toplevel view and set `Applicaton.Top`.
+* Update any code that assumes `Application.Init` automatically disposed of the toplevel view when the application exited.
 
 
-## `Pos` and `Dim` types now adhere to standard C# idioms
+## [Pos](~/api/Terminal.Gui.Pos.yml) and [Dim](~/api/Terminal.Gui.Dim.yml) types now adhere to standard C# idioms
 
 
-* In v1, the `Pos` and `Dim` types (e.g. `Pos.PosView`) were nested classes and marked `internal`. In v2, they are no longer nested, and have appropriate public APIs. 
+* In v1, the [Pos](~/api/Terminal.Gui.Pos.yml) and [Dim](~/api/Terminal.Gui.Dim.yml) types (e.g. [Pos.PosView](~/api/Terminal.Gui.Pos.PosView.yml)) were nested classes and marked [internal](~/api/Terminal.Gui.internal.yml). In v2, they are no longer nested, and have appropriate public APIs. 
 * Nullabilty is enabled.
 * Nullabilty is enabled.
 * Methods & properties follow standards.
 * Methods & properties follow standards.
-* The static method that creates a `PosAbsolute`, `Pos.At`, was renamed to `Pos.Absolute` for consistency.
-* The static method that crates as `DimAbsoulte`, `Dim.Sized`, was renamed to `Dim.Absolute` for consistency.
+* The static method that creates a [PosAbsolute](~/api/Terminal.Gui.PosAbsolute.yml), `Pos.At`, was renamed to [Pos.Absolute](~/api/Terminal.Gui.Pos.Absolute.yml) for consistency.
+* The static method that crates as [DimAbsoulte](~/api/Terminal.Gui.DimAbsoulte.yml), `Dim.Sized`, was renamed to [Dim.Absolute](~/api/Terminal.Gui.Dim.Absolute.yml) for consistency.
 
 
 ### How to Fix
 ### How to Fix
 
 
@@ -102,9 +115,9 @@ In v1, `Application.Init` automatically created a toplevel view and set `Applica
 
 
 In v2, the layout system has been improved to make it easier to create complex user interfaces. If you are using custom layouts in your application, you may need to update them to use the new layout system.
 In v2, the layout system has been improved to make it easier to create complex user interfaces. If you are using custom layouts in your application, you may need to update them to use the new layout system.
 
 
-* `View.Frame` now represents the position and size of the view in the superview's coordinate system. The `Frame` property is of type `Rectangle`.
-* `View.Bounds` has been replaced by `View.Viewport`. The `Viewport` property represents the visible area of the view in its own coordinate system. The `Viewport` property is of type `Rectangle`.
-* `View.ContentSize` represents the size of the view's content. The `ContentSize` property is of type `Size`. This replaces `ScrollView` and `ScrollBarView` in v1. See more below.
+* [View.Frame](~/api/Terminal.Gui.View.Frame.yml) now represents the position and size of the view in the superview's coordinate system. The `Frame` property is of type `Rectangle`.
+* [View.Bounds](~/api/Terminal.Gui.View.Bounds.yml) has been replaced by [View.Viewport](~/api/Terminal.Gui.View.Viewport.yml). The `Viewport` property represents the visible area of the view in its own coordinate system. The `Viewport` property is of type `Rectangle`.
+* [View.ContentSize](~/api/Terminal.Gui.View.ContentSize.yml) represents the size of the view's content. The `ContentSize` property is of type `Size`. This replaces `ScrollView` and `ScrollBarView` in v1. See more below.
 
 
 ### How to Fix
 ### How to Fix
 
 
@@ -114,13 +127,13 @@ In v2, the layout system has been improved to make it easier to create complex u
 * Update any code that assumed `Bounds.Location` was always `Point.Empty`.
 * Update any code that assumed `Bounds.Location` was always `Point.Empty`.
 * Update any code that used `Bounds` to refer to the size of the view's content. Use `ContentSize` instead.
 * Update any code that used `Bounds` to refer to the size of the view's content. Use `ContentSize` instead.
 * Update any code that assumed `Bounds.Size` was the same as `Frame.Size`. `Frame.Size` defines the size of the view in the superview's coordinate system, while `Viewport.Size` defines the visible area of the view in its own coordinate system.
 * Update any code that assumed `Bounds.Size` was the same as `Frame.Size`. `Frame.Size` defines the size of the view in the superview's coordinate system, while `Viewport.Size` defines the visible area of the view in its own coordinate system.
-* Use `View.GetAdornmentsThickness` to get the total thickness of the view's border, margin, and padding.
+* Use [View.GetAdornmentsThickness](~/api/Terminal.Gui.View.GetAdornmentsThickness.yml) to get the total thickness of the view's border, margin, and padding.
 * Not assume a View can draw outside of 'Viewport'. Use the 'Margin', 'Border', and 'Padding' Adornments to do things outside of `Viewport`. View subclasses should not implement their own concept of padding or margins but leverage these `Adornments` instead. 
 * Not assume a View can draw outside of 'Viewport'. Use the 'Margin', 'Border', and 'Padding' Adornments to do things outside of `Viewport`. View subclasses should not implement their own concept of padding or margins but leverage these `Adornments` instead. 
 * Mouse and draw events now provide coordinates relative to the `Viewport` not the `Frame`.
 * Mouse and draw events now provide coordinates relative to the `Viewport` not the `Frame`.
 
 
-## `View.AutoSize` has been removed. Use `Dim.Auto` for width or height instead.
+## `View.AutoSize` has been removed. Use [Dim.Auto](~/api/Terminal.Gui.Dim.Auto.yml) for width or height instead.
 
 
-In v1, `View.AutoSize` was used to size a view to its `Text`. In v2, `View.AutoSize` has been removed. Use `Dim.Auto` for width or height instead.
+In v1, `View.AutoSize` was used to size a view to its `Text`. In v2, `View.AutoSize` has been removed. Use [Dim.Auto](~/api/Terminal.Gui.Dim.Auto.yml) for width or height instead.
 
 
 ### How to Fix
 ### How to Fix
 
 
@@ -130,17 +143,17 @@ In v1, `View.AutoSize` was used to size a view to its `Text`. In v2, `View.AutoS
 
 
 In v2, the `Border`, `Margin`, and `Padding` properties have been added to all views. This simplifies view development and enables a sophisticated look and feel. If you are using custom borders, margins, or padding in your application, you may need to update them to use the new properties.
 In v2, the `Border`, `Margin`, and `Padding` properties have been added to all views. This simplifies view development and enables a sophisticated look and feel. If you are using custom borders, margins, or padding in your application, you may need to update them to use the new properties.
 
 
-* `View.Border` is now of type `Adornment`. `View.BorderStyle` is provided as a convenience property to set the border style (`myView.BorderStyle = LineStyle.Double`).
+* `View.Border` is now of type [Adornment](~/api/Terminal.Gui.Adornment.yml). [View.BorderStyle](~/api/Terminal.Gui.View.BorderStyle.yml) is provided as a convenience property to set the border style (`myView.BorderStyle = LineStyle.Double`).
 
 
 ### How to Fix
 ### How to Fix
 
 
 ## Built-in Scrolling
 ## Built-in Scrolling
 
 
-In v1, scrolling was enabled by using `ScrollView` or `ScrollBarView`. In v2, the base `View` class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by `View.ContentSize`. See [Layout](layout.md) for details.
+In v1, scrolling was enabled by using `ScrollView` or `ScrollBarView`. In v2, the base [View](~/api/Terminal.Gui.View.yml) class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by [View.ContentSize](~/api/Terminal.Gui.View.ContentSize.yml). See [Layout](layout.md) for details.
 
 
 ### How to Fix
 ### How to Fix
 
 
-* Replace `ScrollView` with `View` and use the `Viewport` and `ContentSize` properties to control scrolling.
+* Replace `ScrollView` with [View](~/api/Terminal.Gui.View.yml) and use the `Viewport` and `ContentSize` properties to control scrolling.
 * Update any code that assumed `Bounds.Location` was always `Point.Empty`.
 * Update any code that assumed `Bounds.Location` was always `Point.Empty`.
 * Update any code that used `Bounds` to refer to the size of the view's content. Use `ContentSize` instead.
 * Update any code that used `Bounds` to refer to the size of the view's content. Use `ContentSize` instead.
 * Update any code that assumed `Bounds.Size` was the same as `Frame.Size`. `Frame.Size` defines the size of the view in the superview's coordinate system, while `Viewport.Size` defines the visible area of the view in its own coordinate system.
 * Update any code that assumed `Bounds.Size` was the same as `Frame.Size`. `Frame.Size` defines the size of the view in the superview's coordinate system, while `Viewport.Size` defines the visible area of the view in its own coordinate system.
@@ -149,31 +162,31 @@ In v1, scrolling was enabled by using `ScrollView` or `ScrollBarView`. In v2, th
 
 
 The API for handling keyboard input is significantly improved. See [Keyboard API](keyboard.md).
 The API for handling keyboard input is significantly improved. See [Keyboard API](keyboard.md).
 
 
-* The `Key` class replaces the `KeyEvent` struct and provides a platform-independent abstraction for common keyboard operations. It is used for processing keyboard input and raising keyboard events. This class provides a high-level abstraction with helper methods and properties for common keyboard operations. Use this class instead of the low-level `KeyCode` enum when possible. See [Key](~/api/Terminal.Gui.Key.yml) for more details.
-* The preferred way to handle single keystrokes is to use **Key Bindings**. Key Bindings map a key press to a [Command](~/api/Terminal.Gui.Command.yml). A view can declare which commands it supports, and provide a lambda that implements the functionality of the command, using `View.AddCommand()`. Use the `View.Keybindings` to configure the key bindings.
+* The [Key](~/api/Terminal.Gui.Key.yml) class replaces the `KeyEvent` struct and provides a platform-independent abstraction for common keyboard operations. It is used for processing keyboard input and raising keyboard events. This class provides a high-level abstraction with helper methods and properties for common keyboard operations. Use this class instead of the low-level [KeyCode](~/api/Terminal.Gui.KeyCode.yml) enum when possible. See [Key](~/api/Terminal.Gui.Key.yml) for more details.
+* The preferred way to handle single keystrokes is to use **Key Bindings**. Key Bindings map a key press to a [Command](~/api/Terminal.Gui.Command.yml). A view can declare which commands it supports, and provide a lambda that implements the functionality of the command, using `View.AddCommand()`. Use the [View.Keybindings](~/api/Terminal.Gui.View.Keybindings.yml) to configure the key bindings.
 
 
 ### How to Fix
 ### How to Fix
 
 
 * Replace `KeyEvent` with `Key`
 * Replace `KeyEvent` with `Key`
-* Use `View.AddCommand` to define commands your view supports.
-* Use `View.Keybindings` to configure key bindings to `Command`s.
+* Use [View.AddCommand](~/api/Terminal.Gui.View.AddCommand.yml) to define commands your view supports.
+* Use [View.Keybindings](~/api/Terminal.Gui.View.Keybindings.yml) to configure key bindings to `Command`s.
 * It should be very uncommon for v2 code to override `OnKeyPressed` etc... 
 * It should be very uncommon for v2 code to override `OnKeyPressed` etc... 
 
 
 ## Updated Mouse API
 ## Updated Mouse API
 
 
-The API for mouse input is now internally consistent and easiser to use.
+The API for mouse input is now internally consistent and easier to use.
 
 
-* The `MouseEvent` class replaces `MouseEventEventArgs`.
+* The [MouseEvent](~/api/Terminal.Gui.MouseEvent.yml) class replaces `MouseEventEventArgs`.
 * More granular APIs are provided to ease handling specific mouse actions. See [Mouse API](mouse.md).
 * More granular APIs are provided to ease handling specific mouse actions. See [Mouse API](mouse.md).
-* Views can use the `View.Highlight` event to have the view be visibly highlighted on various mouse events.
-* Views can set `View.WantContinousButtonPresses = true` to ahve their `Command.Accept` command be invoked repeatedly as the user holds a mouse button down on the view.
+* Views can use the [View.Highlight](~/api/Terminal.Gui.View.Highlight.yml) event to have the view be visibly highlighted on various mouse events.
+* Views can set `View.WantContinousButtonPresses = true` to have their [Command.Accept](~/api/Terminal.Gui.Command.Accept.yml) command be invoked repeatedly as the user holds a mouse button down on the view.
 * Mouse and draw events now provide coordinates relative to the `Viewport` not the `Screen`.
 * Mouse and draw events now provide coordinates relative to the `Viewport` not the `Screen`.
 
 
 ### How to Fix
 ### How to Fix
 
 
 * Replace `MouseEventEventArgs` with `MouseEvent`
 * Replace `MouseEventEventArgs` with `MouseEvent`
-* Use the `View.Highlight` event to have the view be visibly highlighted on various mouse events.
-* Set `View.WantContinousButtonPresses = true` to have the `Command.Accept` command be invoked repeatedly as the user holds a mouse button down on the view.
+* Use the [View.Highlight](~/api/Terminal.Gui.View.Highlight.yml) event to have the view be visibly highlighted on various mouse events.
+* Set `View.WantContinousButtonPresses = true` to have the [Command.Accept](~/api/Terminal.Gui.Command.Accept.yml) command be invoked repeatedly as the user holds a mouse button down on the view.
 * Update any code that assumed mouse events provided coordinates relative to the `Screen`.
 * Update any code that assumed mouse events provided coordinates relative to the `Screen`.
 
 
 ## Cursor and Focus
 ## Cursor and Focus
@@ -182,17 +195,17 @@ The cursor and focus system has been redesigned in v2 to be more consistent and
 
 
 ### How to Fix
 ### How to Fix
 
 
-* Use `Application.MostFocusedView` to get the most focused view in the application.
-* Use `View.CursorPosition` to set the cursor position in a view. Set `View.CursorPosition` to `null` to hide the cursor.
-* Set `View.CursorVisibility` to the cursor style you want to use.
-* Remove any overrides of `OnEnter` and `OnLeave` that explicity change the cursor.
+* Use [Application.MostFocusedView](~/api/Terminal.Gui.Application.MostFocusedView.yml) to get the most focused view in the application.
+* Use [View.CursorPosition](~/api/Terminal.Gui.View.CursorPosition.yml) to set the cursor position in a view. Set [View.CursorPosition](~/api/Terminal.Gui.View.CursorPosition.yml) to `null` to hide the cursor.
+* Set [View.CursorVisibility](~/api/Terminal.Gui.View.CursorVisibility.yml) to the cursor style you want to use.
+* Remove any overrides of `OnEnter` and `OnLeave` that explicitly change the cursor.
 
 
 
 
 ## Events now use `object sender, EventArgs args` signature
 ## Events now use `object sender, EventArgs args` signature
 
 
-Previously events in Terminal.Gui used a mixture of `Action` (no arguments), `Action<string>` (or other raw datatype) and `Action<EventArgs>`.  Now all events use the `EventHandler<EventArgs>` [standard .net design pattern](https://learn.microsoft.com/en-us/dotnet/csharp/event-pattern#event-delegate-signatures).
+Previously events in Terminal.Gui used a mixture of `Action` (no arguments), `Action<string>` (or other raw datatype) and `Action<EventArgs>`. Now all events use the `EventHandler<EventArgs>` [standard .net design pattern](https://learn.microsoft.com/en-us/dotnet/csharp/event-pattern#event-delegate-signatures).
 
 
-For example `event Action<long> TimeoutAdded` has become `event EventHandler<TimeoutEventArgs> TimeoutAdded`
+For example, `event Action`<long> TimeoutAdded` has become `event EventHandler<TimeoutEventArgs> TimeoutAdded`
 
 
 This change was made for the following reasons:
 This change was made for the following reasons:
 
 
@@ -247,4 +260,16 @@ Replace references to to nested types with the new standalone version
 ```diff
 ```diff
 - var myTab = new TabView.Tab();
 - var myTab = new TabView.Tab();
 + var myTab = new Tab();
 + var myTab = new Tab();
-```
+```
+
+## View and Text Alignment Changes
+
+In v1, both `TextAlignment` and `VerticalTextAlignment` enums were used to align text in views. In v2, these enums have been replaced with the [Alignment](~/api/Terminal.Gui.Alignment.yml) enum. The [View.TextAlignment](~/api/Terminal.Gui.View.TextAlignment.yml) property controls horizontal text alignment and the [View.VerticalTextAlignment](~/api/Terminal.Gui.View.VerticalTextAlignment.yml) property controls vertical text alignment.
+
+v2 now supports [Pos.Align](~/api/Terminal.Gui.Pos.Align.yml) which enables views to be easily aligned within their Superview. 
+
+The [Aligner](~/api/Terminal.Gui.Aligner.yml) class makes it easy to align elements (text, Views, etc...) within a container. 
+
+### How to Fix
+
+* Replace `VerticalAlignment.Middle` is now [Alignment.Center](~/api/Terminal.Gui.Alignment.Center.yml). 

+ 9 - 9
docfx/docs/newinv2.md

@@ -11,23 +11,23 @@ Apps built with Terminal.Gui now feel modern thanks to these improvements:
 * *TrueColor support* - 24-bit color support for Windows, Mac, and Linux. Legacy 16-color systems are still supported, automatically. See [TrueColor](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#truecolor) for details.
 * *TrueColor support* - 24-bit color support for Windows, Mac, and Linux. Legacy 16-color systems are still supported, automatically. See [TrueColor](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#truecolor) for details.
 * *Enhanced Borders and Padding* - Terminal.Gui now supports a `Border`, `Margin`, and `Padding` property on all views. This simplifies View development and enables a sophisticated look and feel. See [Adornments](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#adornments) for details.
 * *Enhanced Borders and Padding* - Terminal.Gui now supports a `Border`, `Margin`, and `Padding` property on all views. This simplifies View development and enables a sophisticated look and feel. See [Adornments](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#adornments) for details.
 * *User Configurable Color Themes* - See [Color Themes](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#color-themes) for details.
 * *User Configurable Color Themes* - See [Color Themes](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#color-themes) for details.
-* *Enhanced Unicode/Wide Character support *- Terminal.Gui now supports the full range of Unicode/wide characters. See [Unicode](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#unicode) for details.
+* *Enhanced Unicode/Wide Character support* - Terminal.Gui now supports the full range of Unicode/wide characters. See [Unicode](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#unicode) for details.
 * *Line Canvas* - Terminal.Gui now supports a line canvas enabling high-performance drawing of lines and shapes using box-drawing glyphs. `LineCanvas` provides *auto join*, a smart TUI drawing system that automatically selects the correct line/box drawing glyphs for intersections making drawing complex shapes easy. See [Line Canvas](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#line-canvas) for details.
 * *Line Canvas* - Terminal.Gui now supports a line canvas enabling high-performance drawing of lines and shapes using box-drawing glyphs. `LineCanvas` provides *auto join*, a smart TUI drawing system that automatically selects the correct line/box drawing glyphs for intersections making drawing complex shapes easy. See [Line Canvas](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#line-canvas) for details.
 
 
 ## Simplified API
 ## Simplified API
 
 
 The entire library has been reviewed and simplified. As a result, the API is more consistent and uses modern .NET API standards (e.g. for events). This refactoring resulted in the removal of thousands of lines of code, better unit tests, and higher performance than v1. See [Simplified API](overview.md#simplified-api) for details.
 The entire library has been reviewed and simplified. As a result, the API is more consistent and uses modern .NET API standards (e.g. for events). This refactoring resulted in the removal of thousands of lines of code, better unit tests, and higher performance than v1. See [Simplified API](overview.md#simplified-api) for details.
 
 
-## View Improvements
+## `View` Improvements
 
 
 * *Life Cycle Management* - 
 * *Life Cycle Management* - 
-* In v1, `View` was derived from `Responder` which supported `IDisposable`. In v2, `Responder` has been removed and `View` is the base-class supporting `IDisposable`. 
-* `Application.Init` no longer automatically creates a toplevel or sets `Applicaton.Top`; app developers must explicitly create the toplevel view and pass it to `Appliation.Run` (or use `Application.Run<myTopLevel>`). Developers are responsible for calling `Dispose` on any toplevel they create before exiting. 
-* *Adornments* - 
-* *Built-in Scrolling/Virtual Content Area* - In v1, to have a view a user could scroll required either a bespoke scrolling implementation, inheriting from `ScrollView`, or managing the complexity of `ScrollBarView` directly. In v2, the base-View class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by `View.ContentSize`. See [Layout](layout.md) for details.
-* *Computed Layout Improvements* - 
-* *`Pos.AnchorEnd ()`* - New to v2 is `Pos.AnchorEnd ()` (with no parameters) which allows a view to be anchored to the right or bottom of the Superview. 
-* *`Dim.Auto`* - Automatic size based on the View's content (either Subviews or Text) - `Dim.Auto()` - See the [DimAuto Deep Dive](dimauto.md) for more information.
+  * In v1, `View` was derived from `Responder` which supported `IDisposable`. In v2, `Responder` has been removed and `View` is the base-class supporting `IDisposable`. 
+  * `Application.Init` no longer automatically creates a toplevel or sets `Applicaton.Top`; app developers must explicitly create the toplevel view and pass it to `Appliation.Run` (or use `Application.Run<myTopLevel>`). Developers are responsible for calling `Dispose` on any toplevel they create before exiting. 
+* New! *Adornments* -  Adornments are a special form of View that appear outside the `Viewport`: `Margin`, `Border`, and `Padding`.
+* New! *Built-in Scrolling/Virtual Content Area* - In v1, to have a view a user could scroll required either a bespoke scrolling implementation, inheriting from `ScrollView`, or managing the complexity of `ScrollBarView` directly. In v2, the base-View class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by `View.ContentSize`. See [Layout](layout.md) for details.
+* New! *`Dim.Auto`* - Automatically sizes the view to fitthe view's Text, SubViews, or ContentArea.
+* Improved! *`Pos.AnchorEnd ()`* - New to v2 is `Pos.AnchorEnd ()` (with no parameters) which allows a view to be anchored to the right or bottom of the Superview. 
+* New! *`Pos.Align ()`* - Aligns a set of views horizontally or vertically (left, rigth, center, etc...).
 * ...	
 * ...	
 
 
 ## New and Improved Built-in Views
 ## New and Improved Built-in Views

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů