Tig 1 rok pred
rodič
commit
a59c44d258
76 zmenil súbory, kde vykonal 2765 pridanie a 2399 odobranie
  1. 482 0
      Terminal.Gui/Drawing/Aligner.cs
  2. 0 333
      Terminal.Gui/Drawing/Justification.cs
  3. 2 2
      Terminal.Gui/Drawing/Thickness.cs
  4. 1 1
      Terminal.Gui/Resources/config.json
  5. 0 20
      Terminal.Gui/Text/TextAlignment.cs
  6. 52 49
      Terminal.Gui/Text/TextFormatter.cs
  7. 0 20
      Terminal.Gui/Text/VerticalTextAlignment.cs
  8. 441 232
      Terminal.Gui/View/Layout/PosDim.cs
  9. 8 8
      Terminal.Gui/View/Layout/ViewLayout.cs
  10. 4 4
      Terminal.Gui/View/ViewText.cs
  11. 3 3
      Terminal.Gui/Views/Button.cs
  12. 5 4
      Terminal.Gui/Views/CheckBox.cs
  13. 18 144
      Terminal.Gui/Views/Dialog.cs
  14. 1 1
      Terminal.Gui/Views/ListView.cs
  15. 1 1
      Terminal.Gui/Views/Menu/Menu.cs
  16. 9 5
      Terminal.Gui/Views/MessageBox.cs
  17. 1 1
      Terminal.Gui/Views/ProgressBar.cs
  18. 8 8
      Terminal.Gui/Views/Slider.cs
  19. 2 0
      Terminal.Gui/Views/TabView.cs
  20. 13 13
      Terminal.Gui/Views/TableView/ColumnStyle.cs
  21. 2 2
      Terminal.Gui/Views/TableView/TableStyle.cs
  22. 5 5
      Terminal.Gui/Views/TableView/TableView.cs
  23. 7 7
      Terminal.Gui/Views/TextValidateField.cs
  24. 5 2
      Terminal.Gui/Views/TextView.cs
  25. 4 0
      Terminal.Gui/Views/TileView.cs
  26. 2 20
      Terminal.Gui/Views/Wizard/Wizard.cs
  27. 1 0
      Terminal.sln.DotSettings
  28. 2 2
      UICatalog/Scenarios/AllViewsTester.cs
  29. 2 2
      UICatalog/Scenarios/BasicColors.cs
  30. 27 28
      UICatalog/Scenarios/Buttons.cs
  31. 1 1
      UICatalog/Scenarios/CharacterMap.cs
  32. 2 2
      UICatalog/Scenarios/CollectionNavigatorTester.cs
  33. 2 2
      UICatalog/Scenarios/ColorPicker.cs
  34. 26 23
      UICatalog/Scenarios/ComputedLayout.cs
  35. 11 11
      UICatalog/Scenarios/CsvEditor.cs
  36. 63 31
      UICatalog/Scenarios/Dialogs.cs
  37. 2 2
      UICatalog/Scenarios/DynamicMenuBar.cs
  38. 9 9
      UICatalog/Scenarios/Editor.cs
  39. 1 1
      UICatalog/Scenarios/ListColumns.cs
  40. 9 9
      UICatalog/Scenarios/MessageBoxes.cs
  41. 2 2
      UICatalog/Scenarios/Mouse.cs
  42. 365 0
      UICatalog/Scenarios/PosAlign.cs
  43. 18 10
      UICatalog/Scenarios/ProgressBarStyles.cs
  44. 7 7
      UICatalog/Scenarios/TableEditor.cs
  45. 1 1
      UICatalog/Scenarios/Text.cs
  46. 50 50
      UICatalog/Scenarios/TextAlignmentAndDirection.cs
  47. 0 142
      UICatalog/Scenarios/TextAlignments.cs
  48. 32 20
      UICatalog/Scenarios/TextFormatterDemo.cs
  49. 6 6
      UICatalog/Scenarios/TimeAndDate.cs
  50. 2 2
      UICatalog/Scenarios/Unicode.cs
  51. 5 5
      UICatalog/Scenarios/ViewExperiments.cs
  52. 4 4
      UICatalog/Scenarios/Wizards.cs
  53. 1 2
      UnitTests/Configuration/ConfigurationMangerTests.cs
  54. 3 3
      UnitTests/Configuration/ThemeScopeTests.cs
  55. 3 3
      UnitTests/Configuration/ThemeTests.cs
  56. 253 249
      UnitTests/Dialogs/DialogTests.cs
  57. 6 6
      UnitTests/Dialogs/MessageBoxTests.cs
  58. 462 0
      UnitTests/Drawing/AlignerTests.cs
  59. 0 426
      UnitTests/Drawing/JustifierTests.cs
  60. 120 325
      UnitTests/Text/TextFormatterTests.cs
  61. 2 2
      UnitTests/View/DrawTests.cs
  62. 6 7
      UnitTests/View/Layout/Dim.AutoTests.cs
  63. 0 2
      UnitTests/View/Layout/Dim.PercentTests.cs
  64. 2 2
      UnitTests/View/Layout/Dim.Tests.cs
  65. 59 0
      UnitTests/View/Layout/Pos.AlignTests.cs
  66. 58 62
      UnitTests/View/Layout/Pos.Tests.cs
  67. 1 1
      UnitTests/View/NeedsDisplayTests.cs
  68. 6 6
      UnitTests/View/Text/AutoSizeTrueTests.cs
  69. 4 4
      UnitTests/Views/ButtonTests.cs
  70. 9 9
      UnitTests/Views/CheckBoxTests.cs
  71. 1 1
      UnitTests/Views/LabelTests.cs
  72. 20 20
      UnitTests/Views/TextValidateFieldTests.cs
  73. 2 2
      UnitTests/Views/ToplevelTests.cs
  74. 1 0
      docfx/docs/layout.md
  75. 11 1
      docfx/docs/migratingfromv1.md
  76. 9 9
      docfx/docs/newinv2.md

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

@@ -0,0 +1,482 @@
+using System.ComponentModel;
+using Microsoft.CodeAnalysis;
+using static Terminal.Gui.Pos;
+
+namespace Terminal.Gui;
+
+/// <summary>
+///     Controls how the <see cref="Aligner"/> aligns items within a container.
+/// </summary>
+public enum Alignment
+{
+    /// <summary>
+    ///     The items will be aligned to the left.
+    ///     Set <see cref="Aligner.SpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
+    ///     each item.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the right items will be clipped (their locations
+    ///         will be greater than the container size).
+    ///     </para>
+    ///     <para>
+    ///         <see cref="Left"/> and <see cref="Top"/> have equivalent behavior.
+    ///     </para>
+    /// </remarks>
+    /// <example>
+    ///     <c>
+    ///         111 2222 33333
+    ///     </c>
+    /// </example>
+    Left,
+
+    /// <summary>
+    ///     The items will be aligned to the top.
+    ///     Set <see cref="Aligner.SpaceBetweenItems"/> to <see langword="true"/> to ensure at least one line between
+    ///     each item.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the bottom items will be clipped (their locations
+    ///         will be greater than the container size).
+    ///     </para>
+    ///     <para>
+    ///         <see cref="Left"/> and <see cref="Top"/> have equivalent behavior.
+    ///     </para>
+    /// </remarks>
+    Top,
+
+    /// <summary>
+    ///     The items will be aligned to the right.
+    ///     Set <see cref="Aligner.SpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
+    ///     each item.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the left items will be clipped (their locations
+    ///         will be negative).
+    ///     </para>
+    ///     <para>
+    ///         <see cref="Right"/> and <see cref="Bottom"/> have equivalent behavior.
+    ///     </para>
+    /// </remarks>
+    /// <example>
+    ///     <c>
+    ///         111 2222 33333
+    ///     </c>
+    /// </example>
+    Right,
+
+    /// <summary>
+    ///     The items will be aligned to the bottom.
+    ///     Set <see cref="Aligner.SpaceBetweenItems"/> to <see langword="true"/> to ensure at least one line between
+    ///     each item.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the top items will be clipped (their locations
+    ///         will be negative).
+    ///     </para>
+    ///     <para>
+    ///         <see cref="Right"/> and <see cref="Bottom"/> have equivalent behavior.
+    ///     </para>
+    /// </remarks>
+    Bottom,
+
+    /// <summary>
+    ///     The group will be centered in the container.
+    ///     If centering is not possible, the group will be left-aligned.
+    ///     Set <see cref="Aligner.SpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
+    ///     each item.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         Extra space will be distributed between the items, biased towards the left.
+    ///     </para>
+    /// </remarks>
+    /// <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="Aligner.SpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
+        ///     each item.
+        /// </summary>
+        /// <remarks>
+        ///     <para>
+        ///         Extra space will be distributed between the items, biased towards the left.
+        ///     </para>
+        /// </remarks>
+        /// <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="Aligner.SpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
+    ///     each item.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the right items will be clipped (their locations
+    ///         will be greater than the container size).
+    ///     </para>
+    ///     <para>
+    ///         <see cref="FirstLeftRestRight"/> and <see cref="FirstTopRestBottom"/> have equivalent behavior.
+    ///     </para>
+    /// </remarks>
+    /// <example>
+    ///     <c>
+    ///         111        2222 33333
+    ///     </c>
+    /// </example>
+    FirstLeftRestRight,
+
+    /// <summary>
+    ///     The first item will be aligned to the top and the remaining will aligned to the bottom.
+    ///     Set <see cref="Aligner.SpaceBetweenItems"/> to <see langword="true"/> to ensure at least one line between
+    ///     each item.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the bottom items will be clipped (their locations
+    ///         will be greater than the container size).
+    ///     </para>
+    ///     <para>
+    ///         <see cref="FirstLeftRestRight"/> and <see cref="FirstTopRestBottom"/> have equivalent behavior.
+    ///     </para>
+    /// </remarks>
+    FirstTopRestBottom,
+
+    /// <summary>
+    ///     The last item will be aligned to the right and the remaining will aligned to the left.
+    ///     Set <see cref="Aligner.SpaceBetweenItems"/> to <see langword="true"/> to ensure at least one space between
+    ///     each item.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the left items will be clipped (their locations
+    ///         will be negative).
+    ///     </para>
+    ///     <para>
+    ///         <see cref="LastRightRestLeft"/> and <see cref="LastBottomRestTop"/> have equivalent behavior.
+    ///     </para>
+    /// </remarks>
+    /// <example>
+    ///     <c>
+    ///         111 2222        33333
+    ///     </c>
+    /// </example>
+    LastRightRestLeft,
+
+    /// <summary>
+    ///     The last item will be aligned to the bottom and the remaining will aligned to the left.
+    ///     Set <see cref="Aligner.SpaceBetweenItems"/> to <see langword="true"/> to ensure at least one line between
+    ///     each item.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         If the container is smaller than the total size of the items, the top items will be clipped (their locations
+    ///         will be negative).
+    ///     </para>
+    ///     <para>
+    ///         <see cref="LastRightRestLeft"/> and <see cref="LastBottomRestTop"/> have equivalent behavior.
+    ///     </para>
+    /// </remarks>
+    LastBottomRestTop
+}
+
+/// <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>
+    public Alignment Alignment
+    {
+        get => _alignment;
+        set
+        {
+            _alignment = value;
+            PropertyChanged?.Invoke (this, new (nameof (Alignment)));
+        }
+    }
+
+    private int _containerSize;
+
+    /// <summary>
+    ///     The size of the container.
+    /// </summary>
+    public int ContainerSize
+    {
+        get => _containerSize;
+        set
+        {
+            _containerSize = value;
+            PropertyChanged?.Invoke (this, new (nameof (ContainerSize)));
+        }
+    }
+
+    private bool _spaceBetweenItems;
+
+    /// <summary>
+    ///     Gets or sets whether <see cref="Aligner"/> adds at least one space between items. Default is
+    ///     <see langword="false"/>.
+    /// </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 right or bottom.
+    ///     </para>
+    /// </remarks>
+    public bool SpaceBetweenItems
+    {
+        get => _spaceBetweenItems;
+        set
+        {
+            _spaceBetweenItems = value;
+            PropertyChanged?.Invoke (this, new (nameof (SpaceBetweenItems)));
+        }
+    }
+
+    /// <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="SpaceBetweenItems"/> 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, SpaceBetweenItems, 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="sizes">The sizes of the items to align.</param>
+    /// <param name="alignment">Specifies how the items will be aligned.</param>
+    /// <param name="spaceBetweenItems">
+    ///     <para>
+    ///         Indicates whether at least one space should be added between items.
+    ///     </para>
+    ///     <para>
+    ///         If the total size of the items is greater than the container size, the space between items will be ignored
+    ///         starting from the right or bottom.
+    ///     </para>
+    /// </param>
+    /// <param name="containerSize">The size of the container.</param>
+    /// <returns>The positions of the items, from left/top to right/bottom.</returns>
+    public static int [] Align (Alignment alignment, bool spaceBetweenItems, int containerSize, int [] sizes)
+    {
+        if (sizes.Length == 0)
+        {
+            return new int [] { };
+        }
+
+        int maxSpaceBetweenItems = spaceBetweenItems ? 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 (alignment)
+        {
+            case Alignment.Left:
+            case Alignment.Top:
+                var currentPosition = 0;
+
+                for (var i = 0; i < sizes.Length; i++)
+                {
+                    CheckSizeCannotBeNegative (i, sizes);
+
+                    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 Alignment.Right:
+            case Alignment.Bottom:
+
+                currentPosition = containerSize - totalItemsSize - spaces;
+
+                for (var i = 0; i < sizes.Length; i++)
+                {
+                    CheckSizeCannotBeNegative (i, sizes);
+                    int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
+
+                    positions [i] = currentPosition;
+                    currentPosition += sizes [i] + spaceBefore;
+                }
+
+                break;
+
+            case Alignment.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++)
+                    {
+                        CheckSizeCannotBeNegative (i, sizes);
+
+                        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)
+                {
+                    CheckSizeCannotBeNegative (0, sizes);
+                    positions [0] = (containerSize - sizes [0]) / 2; // single item is centered
+                }
+
+                break;
+
+            case Alignment.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++)
+                {
+                    CheckSizeCannotBeNegative (i, sizes);
+                    positions [i] = currentPosition;
+                    int extraSpace = i < remainder ? 1 : 0;
+                    currentPosition += sizes [i] + spaceBetween + extraSpace;
+                }
+
+                break;
+
+            // 111 2222        33333
+            case Alignment.LastRightRestLeft:
+            case Alignment.LastBottomRestTop:
+                if (sizes.Length > 1)
+                {
+                    if (totalItemsSize > containerSize)
+                    {
+                        currentPosition = containerSize - totalItemsSize - spaces;
+                    }
+                    else
+                    {
+                        currentPosition = 0;
+                    }
+
+                    for (var i = 0; i < sizes.Length; i++)
+                    {
+                        CheckSizeCannotBeNegative (i, sizes);
+
+                        if (i < sizes.Length - 1)
+                        {
+                            int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
+
+                            positions [i] = currentPosition;
+                            currentPosition += sizes [i] + spaceBefore;
+                        }
+                    }
+
+                    positions [sizes.Length - 1] = containerSize - sizes [^1];
+                }
+                else if (sizes.Length == 1)
+                {
+                    CheckSizeCannotBeNegative (0, sizes);
+
+                    positions [0] = containerSize - sizes [0]; // single item is flush right
+                }
+
+                break;
+
+            // 111        2222 33333
+            case Alignment.FirstLeftRestRight:
+            case Alignment.FirstTopRestBottom:
+                if (sizes.Length > 1)
+                {
+                    currentPosition = 0;
+                    positions [0] = currentPosition; // first item is flush left
+
+                    for (int i = sizes.Length - 1; i >= 0; i--)
+                    {
+                        CheckSizeCannotBeNegative (i, 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 = spaces-- > 0 ? maxSpaceBetweenItems : 0;
+
+                            positions [i] = currentPosition - sizes [i] - spaceBefore;
+                            currentPosition = positions [i];
+                        }
+                    }
+                }
+                else if (sizes.Length == 1)
+                {
+                    CheckSizeCannotBeNegative (0, sizes);
+                    positions [0] = 0; // single item is flush left
+                }
+
+                break;
+
+            default:
+                throw new ArgumentOutOfRangeException (nameof (alignment), alignment, null);
+        }
+
+        return positions;
+    }
+
+    private static void CheckSizeCannotBeNegative (int i, int [] sizes)
+    {
+        if (sizes [i] < 0)
+        {
+            throw new ArgumentException ("The size of an item cannot be negative.");
+        }
+    }
+}

+ 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
             {
                 Text = label is null ? string.Empty : $"{label} {this}",
-                Alignment = TextAlignment.Centered,
-                VerticalAlignment = VerticalTextAlignment.Bottom,
+                Alignment = Alignment.Centered,
+                VerticalAlignment = Alignment.Bottom,
                 AutoSize = true
             };
             tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute, rect);

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

@@ -24,7 +24,7 @@
   "Themes": [
     {
       "Default": {
-        "Dialog.DefaultButtonAlignment": "Center",
+        "Dialog.DefaultButtonAlignment": "Right",
         "FrameView.DefaultBorderStyle": "Single",
         "Window.DefaultBorderStyle": "Single",
         "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;
 
 /// <summary>
@@ -15,14 +17,14 @@ public class TextFormatter
     private Size _size;
     private int _tabWidth = 4;
     private string _text;
-    private TextAlignment _textAlignment;
+    private Alignment _textAlignment = Alignment.Left;
     private TextDirection _textDirection;
-    private VerticalTextAlignment _textVerticalAlignment;
+    private Alignment _textVerticalAlignment = Alignment.Top;
     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>
-    public TextAlignment Alignment
+    public Alignment Alignment
     {
         get => _textAlignment;
         set => _textAlignment = EnableNeedsFormat (value);
@@ -32,8 +34,7 @@ public class TextFormatter
     /// <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>
-    ///         AutoSize is ignored if <see cref="TextAlignment.Justified"/> and
-    ///         <see cref="VerticalTextAlignment.Justified"/> are used.
+    ///         AutoSize is ignored if <see cref="Alignment.Justified"/> is used.
     ///     </para>
     /// </remarks>
     public bool AutoSize
@@ -68,9 +69,8 @@ public class TextFormatter
     ///     Only the first HotKey specifier found in <see cref="Text"/> is supported.
     /// </remarks>
     /// <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>
     /// <returns>
     ///     The number of characters required for the <see cref="TextFormatter.HotKeySpecifier"/>. If the text
@@ -97,8 +97,8 @@ public class TextFormatter
     /// </summary>
     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
     {
         get => _textDirection;
@@ -112,8 +112,7 @@ public class TextFormatter
             }
         }
     }
-
-
+    
     /// <summary>
     ///     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
@@ -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>
-    public VerticalTextAlignment VerticalAlignment
+    public Alignment VerticalAlignment
     {
         get => _textVerticalAlignment;
         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. 
 
-            int x, y;
+            int x = 0, y = 0;
 
             // Horizontal Alignment
-            if (Alignment is TextAlignment.Right)
+            if (Alignment is Alignment.Right)
             {
                 if (isVertical)
                 {
@@ -336,7 +335,7 @@ public class TextFormatter
                     CursorPosition = screen.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0);
                 }
             }
-            else if (Alignment is TextAlignment.Left)
+            else if (Alignment is Alignment.Left)
             {
                 if (isVertical)
                 {
@@ -352,7 +351,7 @@ public class TextFormatter
 
                 CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0;
             }
-            else if (Alignment is TextAlignment.Justified)
+            else if (Alignment is Alignment.Justified)
             {
                 if (isVertical)
                 {
@@ -375,7 +374,7 @@ public class TextFormatter
 
                 CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0;
             }
-            else if (Alignment is TextAlignment.Centered)
+            else if (Alignment is Alignment.Centered)
             {
                 if (isVertical)
                 {
@@ -395,11 +394,13 @@ public class TextFormatter
             }
             else
             {
-                throw new ArgumentOutOfRangeException ($"{nameof (Alignment)}");
+                Debug.WriteLine ($"Unsupported Alignment: {nameof (VerticalAlignment)}");
+
+                return;
             }
 
             // Vertical Alignment
-            if (VerticalAlignment is VerticalTextAlignment.Bottom)
+            if (VerticalAlignment is Alignment.Bottom)
             {
                 if (isVertical)
                 {
@@ -410,7 +411,7 @@ public class TextFormatter
                     y = screen.Bottom - linesFormatted.Count + line;
                 }
             }
-            else if (VerticalAlignment is VerticalTextAlignment.Top)
+            else if (VerticalAlignment is Alignment.Top)
             {
                 if (isVertical)
                 {
@@ -421,7 +422,7 @@ public class TextFormatter
                     y = screen.Top + line;
                 }
             }
-            else if (VerticalAlignment is VerticalTextAlignment.Justified)
+            else if (VerticalAlignment is Alignment.Justified)
             {
                 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;
                 }
             }
-            else if (VerticalAlignment is VerticalTextAlignment.Middle)
+            else if (VerticalAlignment is Alignment.Centered)
             {
                 if (isVertical)
                 {
@@ -450,7 +451,9 @@ public class TextFormatter
             }
             else
             {
-                throw new ArgumentOutOfRangeException ($"{nameof (VerticalAlignment)}");
+               Debug.WriteLine ($"Unsupported Alignment: {nameof (VerticalAlignment)}");
+
+               return;
             }
 
             int colOffset = screen.X < 0 ? Math.Abs (screen.X) : 0;
@@ -471,8 +474,8 @@ public class TextFormatter
                 {
                     if (idx < 0
                         || (isVertical
-                                ? VerticalAlignment != VerticalTextAlignment.Bottom && current < 0
-                                : Alignment != TextAlignment.Right && x + current + colOffset < 0))
+                                ? VerticalAlignment != Alignment.Bottom && current < 0
+                                : Alignment != Alignment.Right && x + current + colOffset < 0))
                     {
                         current++;
 
@@ -561,7 +564,7 @@ public class TextFormatter
 
                 if (HotKeyPos > -1 && idx == HotKeyPos)
                 {
-                    if ((isVertical && VerticalAlignment == VerticalTextAlignment.Justified) || (!isVertical && Alignment == TextAlignment.Justified))
+                    if ((isVertical && VerticalAlignment == Alignment.Justified) || (!isVertical && Alignment == Alignment.Justified))
                     {
                         CursorPosition = idx - start;
                     }
@@ -699,7 +702,7 @@ public class TextFormatter
                 _lines = Format (
                                  text,
                                  Size.Height,
-                                 VerticalAlignment == VerticalTextAlignment.Justified,
+                                 VerticalAlignment == Alignment.Justified,
                                  Size.Width > colsWidth && WordWrap,
                                  PreserveTrailingSpaces,
                                  TabWidth,
@@ -723,7 +726,7 @@ public class TextFormatter
                 _lines = Format (
                                  text,
                                  Size.Width,
-                                 Alignment == TextAlignment.Justified,
+                                 Alignment == Alignment.Justified,
                                  Size.Height > 1 && WordWrap,
                                  PreserveTrailingSpaces,
                                  TabWidth,
@@ -977,7 +980,7 @@ public class TextFormatter
         // if value is not wide enough
         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 ());
 
             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>
     /// <returns>A list of word wrapped lines.</returns>
     /// <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>
     ///         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 ();
 
         int start = Math.Max (
-                              !runes.Contains ((Rune)' ') && textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom } && IsVerticalDirection (textDirection)
+                              !runes.Contains ((Rune)' ') && textFormatter is { VerticalAlignment: Alignment.Bottom } && IsVerticalDirection (textDirection)
                                   ? runes.Count - width
                                   : 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
     ///     clipped.
     /// </param>
-    /// <param name="talign">Alignment.</param>
+    /// <param name="textAlignment">Alignment.</param>
     /// <param name="textDirection">The text direction.</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>
@@ -1257,13 +1260,13 @@ public class TextFormatter
     public static string ClipAndJustify (
         string text,
         int width,
-        TextAlignment talign,
+        Alignment textAlignment,
         TextDirection textDirection = TextDirection.LeftRight_TopBottom,
         int tabWidth = 0,
         TextFormatter textFormatter = null
     )
     {
-        return ClipAndJustify (text, width, talign == TextAlignment.Justified, textDirection, tabWidth, textFormatter);
+        return ClipAndJustify (text, width, textAlignment == Alignment.Justified, textDirection, tabWidth, textFormatter);
     }
 
     /// <summary>Justifies text within a specified width.</summary>
@@ -1304,12 +1307,12 @@ public class TextFormatter
         {
             if (IsHorizontalDirection (textDirection))
             {
-                if (textFormatter is { Alignment: TextAlignment.Right })
+                if (textFormatter is { Alignment: Alignment.Right })
                 {
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                 }
 
-                if (textFormatter is { Alignment: TextAlignment.Centered })
+                if (textFormatter is { Alignment: Alignment.Centered })
                 {
                     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 (textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom })
+                if (textFormatter is { VerticalAlignment: Alignment.Bottom })
                 {
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                 }
 
-                if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Middle })
+                if (textFormatter is { VerticalAlignment: Alignment.Centered })
                 {
                     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 (textFormatter is { Alignment: TextAlignment.Right })
+            if (textFormatter is { Alignment: Alignment.Right })
             {
                 if (GetRuneWidth (text, tabWidth, textDirection) > width)
                 {
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                 }
             }
-            else if (textFormatter is { Alignment: TextAlignment.Centered })
+            else if (textFormatter is { Alignment: Alignment.Centered })
             {
                 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 (textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom })
+            if (textFormatter is { VerticalAlignment: Alignment.Bottom })
             {
                 if (runes.Count - zeroLength > width)
                 {
                     return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
                 }
             }
-            else if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Middle })
+            else if (textFormatter is { VerticalAlignment: Alignment.Centered })
             {
                 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>
     /// <param name="text"></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">
     ///     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
@@ -1498,7 +1501,7 @@ public class TextFormatter
     public static List<string> Format (
         string text,
         int width,
-        TextAlignment talign,
+        Alignment textAlignment,
         bool wordWrap,
         bool preserveTrailingSpaces = false,
         int tabWidth = 0,
@@ -1510,7 +1513,7 @@ public class TextFormatter
         return Format (
                        text,
                        width,
-                       talign == TextAlignment.Justified,
+                       textAlignment == Alignment.Justified,
                        wordWrap,
                        preserveTrailingSpaces,
                        tabWidth,
@@ -1884,7 +1887,7 @@ public class TextFormatter
         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>
     ///     This API will return incorrect results if the text includes glyphs who's width is dependent on surrounding
     ///     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
-}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 441 - 232
Terminal.Gui/View/Layout/PosDim.cs


+ 8 - 8
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -889,8 +889,8 @@ public partial class View
 
                 return;
             case Dim.DimCombine dc:
-                CollectDim (dc._left, from, ref nNodes, ref nEdges);
-                CollectDim (dc._right, from, ref nNodes, ref nEdges);
+                CollectDim (dc.Left, from, ref nNodes, ref nEdges);
+                CollectDim (dc.Right, from, ref nNodes, ref nEdges);
 
                 break;
         }
@@ -912,8 +912,8 @@ public partial class View
 
                 return;
             case Pos.PosCombine pc:
-                CollectPos (pc._left, from, ref nNodes, ref nEdges);
-                CollectPos (pc._right, from, ref nNodes, ref nEdges);
+                CollectPos (pc.LeftPos, from, ref nNodes, ref nEdges);
+                CollectPos (pc.RightPos, from, ref nNodes, ref nEdges);
 
                 break;
         }
@@ -1100,8 +1100,8 @@ public partial class View
 
                 case Pos pos and Pos.PosCombine:
                     // Recursively check for not Absolute or not View
-                    ThrowInvalid (view, (pos as Pos.PosCombine)._left, name);
-                    ThrowInvalid (view, (pos as Pos.PosCombine)._right, name);
+                    ThrowInvalid (view, (pos as Pos.PosCombine).LeftPos, name);
+                    ThrowInvalid (view, (pos as Pos.PosCombine).RightPos, name);
 
                     break;
 
@@ -1112,8 +1112,8 @@ public partial class View
 
                 case Dim dim and Dim.DimCombine:
                     // Recursively check for not Absolute or not View
-                    ThrowInvalid (view, (dim as Dim.DimCombine)._left, name);
-                    ThrowInvalid (view, (dim as Dim.DimCombine)._right, name);
+                    ThrowInvalid (view, (dim as Dim.DimCombine).Left, name);
+                    ThrowInvalid (view, (dim as Dim.DimCombine).Right, name);
 
                     break;
             }

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

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

@@ -37,15 +37,15 @@ 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>
     public Button ()
     {
-        TextAlignment = TextAlignment.Centered;
-        VerticalTextAlignment = VerticalTextAlignment.Middle;
+        TextAlignment = Alignment.Centered;
+        VerticalTextAlignment = Alignment.Centered;
 
         _leftBracket = Glyphs.LeftBracket;
         _rightBracket = Glyphs.RightBracket;
         _leftDefault = Glyphs.LeftDefaultIndicator;
         _rightDefault = Glyphs.RightDefaultIndicator;
 
-        Height = 1;
+        Height = Dim.Auto (Dim.DimAutoStyle.Text);
         Width = Dim.Auto (Dim.DimAutoStyle.Text);
 
         CanFocus = true;

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

@@ -155,13 +155,13 @@ public class CheckBox : View
     {
         switch (TextAlignment)
         {
-            case TextAlignment.Left:
-            case TextAlignment.Centered:
-            case TextAlignment.Justified:
+            case Alignment.Left:
+            case Alignment.Centered:
+            case Alignment.Justified:
                 TextFormatter.Text = $"{GetCheckedState ()} {GetFormatterText ()}";
 
                 break;
-            case TextAlignment.Right:
+            case Alignment.Right:
                 TextFormatter.Text = $"{GetFormatterText ()} {GetCheckedState ()}";
 
                 break;
@@ -180,6 +180,7 @@ public class CheckBox : View
 
     private string GetFormatterText ()
     {
+        // BUGBUG: DimAuto is internal - do something else here.
         if (Width is Dim.DimAuto || string.IsNullOrEmpty (Title) || ContentSize?.Width <= 2)
         {
             return Text;

+ 18 - 144
Terminal.Gui/Views/Dialog.cs

@@ -15,21 +15,6 @@ namespace Terminal.Gui;
 /// </remarks>
 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>Justifies the buttons</summary>
-        Justify,
-
-        /// <summary>Left-aligns the buttons</summary>
-        Left,
-
-        /// <summary>Right-aligns the buttons</summary>
-        Right
-    }
 
     // TODO: Reenable once border/borderframe design is settled
     /// <summary>
@@ -61,19 +46,22 @@ public class Dialog : Window
         Y = Pos.Center ();
         ValidatePosDim = true;
 
-        Width = Dim.Percent (85); 
+        Width = Dim.Percent (85);
         Height = Dim.Percent (85);
         ColorScheme = Colors.ColorSchemes ["Dialog"];
 
         Modal = true;
         ButtonAlignment = DefaultButtonAlignment;
 
-        AddCommand (Command.QuitToplevel, () =>
-                                          {
-                                              Canceled = true;
-                                              RequestStop ();
-                                              return true;
-                                          });
+        AddCommand (
+                    Command.QuitToplevel,
+                    () =>
+                    {
+                        Canceled = true;
+                        RequestStop ();
+
+                        return true;
+                    });
         KeyBindings.Add (Key.Esc, Command.QuitToplevel);
     }
 
@@ -103,12 +91,14 @@ public class Dialog : Window
             }
 #endif
             _canceled = value;
+
             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>
-    public ButtonAlignments ButtonAlignment { get; set; }
+    public Alignment ButtonAlignment { get; set; }
 
     /// <summary>Optional buttons to lay out at the bottom of the dialog.</summary>
     public Button [] Buttons
@@ -128,11 +118,11 @@ public class Dialog : Window
         }
     }
 
-    /// <summary>The default <see cref="ButtonAlignments"/> for <see cref="Dialog"/>.</summary>
+    /// <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 ButtonAlignments DefaultButtonAlignment { get; set; } = ButtonAlignments.Center;
+    public static Alignment DefaultButtonAlignment { get; set; } = Alignment.Right;
 
     /// <summary>
     ///     Adds a <see cref="Button"/> to the <see cref="Dialog"/>, its layout will be controlled by the
@@ -146,6 +136,9 @@ public class Dialog : Window
             return;
         }
 
+        button.X = Pos.Align (ButtonAlignment);
+        button.Y = Pos.AnchorEnd () - 1;
+
         _buttons.Add (button);
         Add (button);
 
@@ -157,20 +150,6 @@ public class Dialog : Window
         }
     }
 
-    /// <inheritdoc/>
-    public override void LayoutSubviews ()
-    {
-        if (_inLayout)
-        {
-            return;
-        }
-
-        _inLayout = true;
-        LayoutButtons ();
-        base.LayoutSubviews ();
-        _inLayout = false;
-    }
-
     // Get the width of all buttons, not including any Margin.
     internal int GetButtonsWidth ()
     {
@@ -184,109 +163,4 @@ public class Dialog : Window
 
         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 (1);
-                }
-
-                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 (1);
-                }
-
-                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 (1);
-                }
-
-                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)
     {
         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.Left);
         driver.AddStr (u);
         width -= u.GetColumns ();
 

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

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

+ 9 - 5
Terminal.Gui/Views/MessageBox.cs

@@ -325,7 +325,10 @@ public static class MessageBox
 
             foreach (string s in buttons)
             {
-                var b = new Button { Text = s };
+                var b = new Button
+                {
+                    Text = s,
+                };
 
                 if (count == defaultButton)
                 {
@@ -337,9 +340,9 @@ public static class MessageBox
             }
         }
 
-        Dialog d;
-
-        d = new Dialog
+        Alignment buttonJust = Dialog.DefaultButtonAlignment;
+        Dialog.DefaultButtonAlignment = Alignment.Centered;
+        var d = new Dialog
         {
             Buttons = buttonList.ToArray (),
             Title = title,
@@ -347,6 +350,7 @@ public static class MessageBox
             Width = Dim.Percent (60),
             Height = 5 // Border + one line of text + vspace + buttons
         };
+        Dialog.DefaultButtonAlignment = buttonJust;
 
         if (width != 0)
         {
@@ -370,7 +374,7 @@ public static class MessageBox
         var messageLabel = new Label
         {
             Text = message,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             X = Pos.Center (),
             Y = 0
         };

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

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

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

@@ -930,7 +930,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)
         {
@@ -947,20 +947,20 @@ public class Slider<T> : View
         string s2 = new (' ', w % 2);
 
         // Note: The formatter doesn't handle all of this ???
-        switch (textAlignment)
+        switch (alignment)
         {
-            case TextAlignment.Justified:
+            case Alignment.Justified:
                 return TextFormatter.Justify (text, width);
-            case TextAlignment.Left:
+            case Alignment.Left:
                 return text + s1 + s1 + s2;
-            case TextAlignment.Centered:
+            case Alignment.Centered:
                 if (text.Length % 2 != 0)
                 {
                     return s1 + text + s1 + s2;
                 }
 
                 return s1 + s2 + text + s1;
-            case TextAlignment.Right:
+            case Alignment.Right:
                 return s1 + s1 + s2 + text;
             default:
                 return text;
@@ -1293,7 +1293,7 @@ public class Slider<T> : View
                     switch (_config._legendsOrientation)
                     {
                         case Orientation.Horizontal:
-                            text = AlignText (text, _config._innerSpacing + 1, TextAlignment.Centered);
+                            text = AlignText (text, _config._innerSpacing + 1, Alignment.Centered);
 
                             break;
                         case Orientation.Vertical:
@@ -1311,7 +1311,7 @@ public class Slider<T> : View
 
                             break;
                         case Orientation.Vertical:
-                            text = AlignText (text, _config._innerSpacing + 1, TextAlignment.Centered);
+                            text = AlignText (text, _config._innerSpacing + 1, Alignment.Centered);
 
                             break;
                     }

+ 2 - 0
Terminal.Gui/Views/TabView.cs

@@ -1265,6 +1265,7 @@ public class TabView : View
                         tab.Margin.Thickness = new Thickness (0, 0, 0, 0);
                     }
 
+                    // BUGBUG: Dim.Anchor is internal. This should do something else to get the width.
                     tab.Width = Math.Max (tab.Width.Anchor (0) - 1, 1);
                 }
                 else
@@ -1280,6 +1281,7 @@ public class TabView : View
                         tab.Margin.Thickness = new Thickness (0, 0, 0, 0);
                     }
 
+                    // BUGBUG: Dim.Anchor is internal. This should do something else to get the width.
                     tab.Width = Math.Max (tab.Width.Anchor (0) - 1, 1);
                 }
 

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

@@ -8,10 +8,10 @@
 public class ColumnStyle
 {
     /// <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"/>
     /// </summary>
-    public Func<object, TextAlignment> AlignmentGetter;
+    public Func<object, Alignment> AlignmentGetter;
 
     /// <summary>
     ///     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;
 
     /// <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"/>
     /// </summary>
     public Func<object, string> RepresentationGetter;
 
-    private bool visible = true;
+    private bool _visible = true;
 
     /// <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"/>.
     /// </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>
     public string Format { get; set; }
 
     /// <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>
     public int MaxWidth { get; set; } = TableView.DefaultMaxCellWidth;
 
@@ -47,7 +47,7 @@ public class ColumnStyle
     public int MinAcceptableWidth { get; set; } = TableView.DefaultMinAcceptableWidth;
 
     /// <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.
     ///     <para>
     ///         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>
     public bool Visible
     {
-        get => MaxWidth >= 0 && visible;
-        set => visible = value;
+        get => MaxWidth >= 0 && _visible;
+        set => _visible = value;
     }
 
     /// <summary>
@@ -74,7 +74,7 @@ public class ColumnStyle
     /// </summary>
     /// <param name="cellValue"></param>
     /// <returns></returns>
-    public TextAlignment GetAlignment (object cellValue)
+    public Alignment GetAlignment (object cellValue)
     {
         if (AlignmentGetter is { })
         {

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

@@ -15,11 +15,11 @@ public class TableStyle
     /// </summary>
     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 ();
 
     /// <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
     ///     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.

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

@@ -2116,16 +2116,16 @@ public class TableView : View
                         - (representation.EnumerateRunes ().Sum (c => c.GetColumns ())
                            + 1 /*leave 1 space for cell boundary*/);
 
-            switch (colStyle?.GetAlignment (originalCellValue) ?? TextAlignment.Left)
+            switch (colStyle?.GetAlignment (originalCellValue) ?? Alignment.Left)
             {
-                case TextAlignment.Left:
+                case Alignment.Left:
                     return representation + new string (' ', toPad);
-                case TextAlignment.Right:
+                case Alignment.Right:
                     return new string (' ', toPad) + representation;
 
                 // TODO: With single line cells, centered and justified are the same right?
-                case TextAlignment.Centered:
-                case TextAlignment.Justified:
+                case Alignment.Centered:
+                case Alignment.Justified:
                     return
                         new string (' ', (int)Math.Floor (toPad / 2.0))
                         + // 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);
 
-                if (_provider.Fixed == false && TextAlignment == TextAlignment.Right && Text.Length > 0)
+                if (_provider.Fixed == false && TextAlignment == Alignment.Right && Text.Length > 0)
                 {
                     c++;
                 }
@@ -633,7 +633,7 @@ namespace Terminal.Gui
             // When it's right-aligned and it's a normal input, the cursor behaves differently.
             int curPos;
 
-            if (_provider?.Fixed == false && TextAlignment == TextAlignment.Right)
+            if (_provider?.Fixed == false && TextAlignment == Alignment.Right)
             {
                 curPos = _cursorPosition + left - 1;
             }
@@ -650,7 +650,7 @@ namespace Terminal.Gui
         /// <returns></returns>
         private bool BackspaceKeyHandler ()
         {
-            if (_provider.Fixed == false && TextAlignment == TextAlignment.Right && _cursorPosition <= 1)
+            if (_provider.Fixed == false && TextAlignment == Alignment.Right && _cursorPosition <= 1)
             {
                 return false;
             }
@@ -688,7 +688,7 @@ namespace Terminal.Gui
         /// <returns></returns>
         private bool DeleteKeyHandler ()
         {
-            if (_provider.Fixed == false && TextAlignment == TextAlignment.Right)
+            if (_provider.Fixed == false && TextAlignment == Alignment.Right)
             {
                 _cursorPosition = _provider.CursorLeft (_cursorPosition);
             }
@@ -719,11 +719,11 @@ namespace Terminal.Gui
 
             switch (TextAlignment)
             {
-                case TextAlignment.Left:
+                case Alignment.Left:
                     return (0, total);
-                case TextAlignment.Centered:
+                case Alignment.Centered:
                     return (total / 2, total / 2 + total % 2);
-                case TextAlignment.Right:
+                case Alignment.Right:
                     return (total, 0);
                 default:
                     return (0, total);

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

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

+ 4 - 0
Terminal.Gui/Views/TileView.cs

@@ -417,6 +417,7 @@ public class TileView : View
     /// </summary>
     public bool SetSplitterPos (int idx, Pos value)
     {
+        // BUGBUG: PosAbsolute & PosFactor are internal API. TileView should not be using it and should do something different to get the value.
         if (!(value is Pos.PosAbsolute) && !(value is Pos.PosFactor))
         {
             throw new ArgumentException (
@@ -601,10 +602,12 @@ public class TileView : View
 
         TileViewLineView nextSplitter = visibleSplitterLines [i];
         Pos nextSplitterPos = Orientation == Orientation.Vertical ? nextSplitter.X : nextSplitter.Y;
+        // BUGBUG: Pos.Anchor is an internal API. TileView should not be using it and should do something different to get the value.
         int nextSplitterDistance = nextSplitterPos.Anchor (space);
 
         TileViewLineView lastSplitter = i >= 1 ? visibleSplitterLines [i - 1] : null;
         Pos lastSplitterPos = Orientation == Orientation.Vertical ? lastSplitter?.X : lastSplitter?.Y;
+        // BUGBUG: Pos.Anchor is an internal API. TileView should not be using it and should do something different to get the value.
         int lastSplitterDistance = lastSplitterPos?.Anchor (space) ?? 0;
 
         int distance = nextSplitterDistance - lastSplitterDistance;
@@ -848,6 +851,7 @@ public class TileView : View
         {
             Dim spaceDim = Tile.ContentView.Width;
 
+            // BUGBUG: Dim.Anchor is internal. This should do something else to get the width.
             int spaceAbs = spaceDim.Anchor (Parent.Viewport.Width);
 
             var title = $" {Tile.Title} ";

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

@@ -54,23 +54,6 @@ public class Wizard : Dialog
     private readonly LinkedList<WizardStep> _steps = new ();
     private WizardStep _currentStep;
     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;
 
     /// <summary>
@@ -83,9 +66,8 @@ public class Wizard : Dialog
     /// </remarks>
     public Wizard ()
     {
-        // Using Justify causes the Back and Next buttons to be hard justified against
-        // the left and right edge
-        ButtonAlignment = ButtonAlignments.Justify;
+        // TODO: LastRightRestLeft will enable a "Quit" button to always appear at the far left
+        ButtonAlignment = Alignment.LastRightRestLeft;
         BorderStyle = LineStyle.Double;
 
         //// Add a horiz separator

+ 1 - 0
Terminal.sln.DotSettings

@@ -439,5 +439,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/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:Boolean x:Key="/Default/UserDictionary/Words/=Justifier/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=unsynchronized/@EntryIndexedValue">True</s:Boolean>
 </wpf:ResourceDictionary>

+ 2 - 2
UICatalog/Scenarios/AllViewsTester.cs

@@ -483,12 +483,12 @@ public class AllViewsTester : Scenario
             return;
         }
 
-        if (view.Width is not Dim.DimAuto && (view.Width is null || view.Frame.Width == 0))
+        if (view.Width is null || view.Frame.Width == 0)
         {
             view.Width = Dim.Fill ();
         }
 
-        if (view.Width is not Dim.DimAuto && (view.Height is null || view.Frame.Height == 0))
+        if (view.Height is null || view.Frame.Height == 0)
         {
             view.Height = Dim.Fill ();
         }

+ 2 - 2
UICatalog/Scenarios/BasicColors.cs

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

+ 27 - 28
UICatalog/Scenarios/Buttons.cs

@@ -287,39 +287,39 @@ public class Buttons : Scenario
                                               switch (args.SelectedItem)
                                               {
                                                   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.Left;
+                                                      sizeBtn.TextAlignment = Alignment.Left;
+                                                      moveBtnA.TextAlignment = Alignment.Left;
+                                                      sizeBtnA.TextAlignment = Alignment.Left;
+                                                      moveHotKeyBtn.TextAlignment = Alignment.Left;
+                                                      moveUnicodeHotKeyBtn.TextAlignment = Alignment.Left;
 
                                                       break;
                                                   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.Right;
+                                                      sizeBtn.TextAlignment = Alignment.Right;
+                                                      moveBtnA.TextAlignment = Alignment.Right;
+                                                      sizeBtnA.TextAlignment = Alignment.Right;
+                                                      moveHotKeyBtn.TextAlignment = Alignment.Right;
+                                                      moveUnicodeHotKeyBtn.TextAlignment = Alignment.Right;
 
                                                       break;
                                                   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.Centered;
+                                                      sizeBtn.TextAlignment = Alignment.Centered;
+                                                      moveBtnA.TextAlignment = Alignment.Centered;
+                                                      sizeBtnA.TextAlignment = Alignment.Centered;
+                                                      moveHotKeyBtn.TextAlignment = Alignment.Centered;
+                                                      moveUnicodeHotKeyBtn.TextAlignment = Alignment.Centered;
 
                                                       break;
                                                   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.Justified;
+                                                      sizeBtn.TextAlignment = Alignment.Justified;
+                                                      moveBtnA.TextAlignment = Alignment.Justified;
+                                                      sizeBtnA.TextAlignment = Alignment.Justified;
+                                                      moveHotKeyBtn.TextAlignment = Alignment.Justified;
+                                                      moveUnicodeHotKeyBtn.TextAlignment = Alignment.Justified;
 
                                                       break;
                                               }
@@ -418,9 +418,8 @@ public class Buttons : Scenario
                 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.Function (() => Digits + 2); // button + 3 for number + button
+            Width = Dim.Auto (Dim.DimAutoStyle.Content); //Dim.Function (() => Digits + 2); // button + 3 for number + button
+            Height = Dim.Auto (Dim.DimAutoStyle.Content);
 
             _down = new ()
             {
@@ -440,7 +439,7 @@ public class Buttons : Scenario
                 Y = Pos.Top (_down),
                 Width = Dim.Function (() => Digits),
                 Height = 1,
-                TextAlignment = TextAlignment.Centered,
+                TextAlignment = Alignment.Centered,
                 CanFocus = true
             };
 

+ 1 - 1
UICatalog/Scenarios/CharacterMap.cs

@@ -958,7 +958,7 @@ internal class CharMap : View
             Y = 1,
             Width = Dim.Fill (),
             Height = Dim.Fill (1),
-            TextAlignment = TextAlignment.Centered
+            TextAlignment = Alignment.Centered
         };
         var spinner = new SpinnerView { X = Pos.Center (), Y = Pos.Center (), Style = new Aesthetic () };
         spinner.AutoSpin = true;

+ 2 - 2
UICatalog/Scenarios/CollectionNavigatorTester.cs

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

+ 2 - 2
UICatalog/Scenarios/ColorPicker.cs

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

+ 26 - 23
UICatalog/Scenarios/ComputedLayout.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Linq;
 using Terminal.Gui;
+using static Terminal.Gui.Dialog;
 
 namespace UICatalog.Scenarios;
 
@@ -85,12 +86,12 @@ public class ComputedLayout : Scenario
         var i = 1;
         var txt = "Resize the terminal to see computed layout in action.";
         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 (
                        new Label
                        {
-                           TextAlignment = TextAlignment.Left,
+                           TextAlignment = Alignment.Left,
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -102,7 +103,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
                        new Label
                        {
-                           TextAlignment = TextAlignment.Right,
+                           TextAlignment = Alignment.Right,
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -114,7 +115,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
                        new Label
                        {
-                           TextAlignment = TextAlignment.Centered,
+                           TextAlignment = Alignment.Centered,
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -126,7 +127,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
                        new Label
                        {
-                           TextAlignment = TextAlignment.Justified,
+                           TextAlignment = Alignment.Justified,
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -147,12 +148,12 @@ public class ComputedLayout : Scenario
                                  };
         i = 1;
         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 (
                        new Label
                        {
-                           TextAlignment = TextAlignment.Left,
+                           TextAlignment = Alignment.Left,
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -164,7 +165,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
                        new Label
                        {
-                           TextAlignment = TextAlignment.Right,
+                           TextAlignment = Alignment.Right,
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -176,7 +177,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
                        new Label
                        {
-                           TextAlignment = TextAlignment.Centered,
+                           TextAlignment = Alignment.Centered,
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -188,7 +189,7 @@ public class ComputedLayout : Scenario
         labelList.Add (
                        new Label
                        {
-                           TextAlignment = TextAlignment.Justified,
+                           TextAlignment = Alignment.Justified,
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -322,12 +323,12 @@ public class ComputedLayout : Scenario
         // This is intentionally convoluted to illustrate potential bugs.
         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.Centered,
             ColorScheme = Colors.ColorSchemes ["Menu"],
             Width = Dim.Fill (5),
             X = 5,
-            Y = Pos.AnchorEnd (2)
+            Y = Pos.AnchorEnd (3)
         };
         app.Add (anchorEndLabel1);
 
@@ -336,19 +337,18 @@ public class ComputedLayout : Scenario
         var anchorEndLabel2 = new TextField
         {
             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.Left,
             ColorScheme = Colors.ColorSchemes ["Menu"],
             Width = Dim.Fill (5),
             X = 5,
-            Y = Pos.AnchorEnd (2) - 1 // Pos.Combine
+            Y = Pos.AnchorEnd (3) - 1 // Pos.Combine
         };
         app.Add (anchorEndLabel2);
 
-        // Show positioning vertically using Pos.AnchorEnd via Pos.Combine
         var leftButton = new Button
         {
-            Text = "Left", Y = Pos.AnchorEnd (0) - 1 // Pos.Combine
+            Text = "Left", Y = Pos.AnchorEnd () - 1
         };
 
         leftButton.Accept += (s, e) =>
@@ -364,7 +364,7 @@ public class ComputedLayout : Scenario
         // show positioning vertically using Pos.AnchorEnd
         var centerButton = new Button
         {
-            Text = "Center", X = Pos.Center (), Y = Pos.AnchorEnd (1) // Pos.AnchorEnd(1)
+            Text = "Center", Y = Pos.AnchorEnd (2) // Pos.AnchorEnd(1)
         };
 
         centerButton.Accept += (s, e) =>
@@ -390,14 +390,17 @@ public class ComputedLayout : Scenario
                                    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 (centerButton);
         app.Add (rightButton);
 
+
+        // Center three buttons with 
+        leftButton.X = Pos.Align (Alignment.Centered);
+        centerButton.X = Pos.Align (Alignment.Centered);
+        rightButton.X = Pos.Align (Alignment.Centered);
+
         Application.Run (app);
         app.Dispose ();
     }

+ 11 - 11
UICatalog/Scenarios/CsvEditor.cs

@@ -78,17 +78,17 @@ public class CsvEditor : Scenario
                                      _miLeft = new MenuItem (
                                                              "_Align Left",
                                                              "",
-                                                             () => Align (TextAlignment.Left)
+                                                             () => Align (Alignment.Left)
                                                             ),
                                      _miRight = new MenuItem (
                                                               "_Align Right",
                                                               "",
-                                                              () => Align (TextAlignment.Right)
+                                                              () => Align (Alignment.Right)
                                                              ),
                                      _miCentered = new MenuItem (
                                                                  "_Align Centered",
                                                                  "",
-                                                                 () => Align (TextAlignment.Centered)
+                                                                 () => Align (Alignment.Centered)
                                                                 ),
 
                                      // 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),
             Text = "0,0",
             Width = Dim.Fill (),
-            TextAlignment = TextAlignment.Right
+            TextAlignment = Alignment.Right
         };
         _selectedCellLabel.TextChanged += SelectedCellLabel_TextChanged;
 
@@ -218,7 +218,7 @@ public class CsvEditor : Scenario
         _tableView.Update ();
     }
 
-    private void Align (TextAlignment newAlignment)
+    private void Align (Alignment newAlignment)
     {
         if (NoTableLoaded ())
         {
@@ -228,9 +228,9 @@ public class CsvEditor : Scenario
         ColumnStyle style = _tableView.Style.GetOrCreateColumnStyle (_tableView.SelectedColumn);
         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.Left;
+        _miRight.Checked = style.Alignment == Alignment.Right;
+        _miCentered.Checked = style.Alignment == Alignment.Centered;
 
         _tableView.Update ();
     }
@@ -437,9 +437,9 @@ public class CsvEditor : Scenario
 
         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.Left;
+        _miRight.Checked = style?.Alignment == Alignment.Right;
+        _miCentered.Checked = style?.Alignment == Alignment.Centered;
     }
 
     private void Open ()

+ 63 - 31
UICatalog/Scenarios/Dialogs.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
@@ -10,14 +11,30 @@ public class Dialogs : Scenario
 {
     private static readonly int CODE_POINT = '你'; // We know this is a wide char
 
-    public override void Setup ()
+    public override void Main ()
     {
-        var frame = new FrameView { X = Pos.Center (), Y = 1, Width = Dim.Percent (75), Title = "Dialog Options" };
+        // Init
+        Application.Init ();
+
+        // Setup - Create a top-level application window and configure it.
+        Window appWindow = new ()
+        {
+            Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()} - {GetDescription ()}"
+        };
+
+        var frame = new FrameView
+        {
+            X = Pos.Center (),
+            Y = 1,
+            Width = Dim.Percent (75),
+            //Height = Dim.Auto (),
+            Title = "Dialog Options"
+        };
 
         var numButtonsLabel = new Label
         {
             X = 0,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = "_Number of Buttons:"
         };
 
@@ -27,7 +44,7 @@ public class Dialogs : Scenario
             Y = 0,
             Width = Dim.Width (numButtonsLabel),
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = "_Width:"
         };
         frame.Add (label);
@@ -42,13 +59,13 @@ public class Dialogs : Scenario
         };
         frame.Add (widthEdit);
 
-        label = new()
+        label = new ()
         {
             X = 0,
             Y = Pos.Bottom (label),
             Width = Dim.Width (numButtonsLabel),
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = "_Height:"
         };
         frame.Add (label);
@@ -76,13 +93,13 @@ public class Dialogs : Scenario
                    }
                   );
 
-        label = new()
+        label = new ()
         {
             X = 0,
             Y = Pos.Bottom (label),
             Width = Dim.Width (numButtonsLabel),
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = "_Title:"
         };
         frame.Add (label);
@@ -114,54 +131,57 @@ public class Dialogs : Scenario
         {
             X = Pos.Right (numButtonsLabel) + 1,
             Y = Pos.Bottom (numButtonsLabel),
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = $"_Add {char.ConvertFromUtf32 (CODE_POINT)} to button text to stress wide char support",
             Checked = false
         };
         frame.Add (glyphsNotWords);
 
-        label = new()
+        label = new ()
         {
             X = 0,
             Y = Pos.Bottom (glyphsNotWords),
             Width = Dim.Width (numButtonsLabel),
             Height = 1,
-            TextAlignment = TextAlignment.Right,
-            Text = "Button St_yle:"
+            TextAlignment = Alignment.Right,
+            Text = "Button A_lignment:"
         };
         frame.Add (label);
 
-        var styleRadioGroup = new RadioGroup
+        var labels = new [] { "Left", "Centered", "Right", "Justified", "FirstLeftRestRight", "LastRightRestLeft" };
+        var alignmentGroup = new RadioGroup
         {
             X = Pos.Right (label) + 1,
             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;
 
         void Top_LayoutComplete (object sender, EventArgs args)
         {
+            // TODO: Replace with Dim.Auto when DimAutoStyle.Content is working
             frame.Height =
                 widthEdit.Frame.Height
                 + heightEdit.Frame.Height
                 + titleEdit.Frame.Height
                 + numButtonsEdit.Frame.Height
                 + glyphsNotWords.Frame.Height
-                + styleRadioGroup.Frame.Height
+                + alignmentGroup.Frame.Height
                 + frame.GetAdornmentsThickness ().Vertical;
         }
 
-        Top.LayoutComplete += Top_LayoutComplete;
+        appWindow.LayoutComplete += Top_LayoutComplete;
 
-        Win.Add (frame);
+        appWindow.Add (frame);
 
-        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.Right, Text = "Button Pressed:"
         };
-        Win.Add (label);
+        appWindow.Add (label);
 
         var buttonPressedLabel = new Label
         {
@@ -186,16 +206,24 @@ public class Dialogs : Scenario
                                                                       titleEdit,
                                                                       numButtonsEdit,
                                                                       glyphsNotWords,
-                                                                      styleRadioGroup,
+                                                                      alignmentGroup,
                                                                       buttonPressedLabel
                                                                      );
                                        Application.Run (dlg);
                                        dlg.Dispose ();
                                    };
 
-        Win.Add (showDialogButton);
+        appWindow.Add (showDialogButton);
+
+        appWindow.Add (buttonPressedLabel);
+
+        // Run - Start the application.
+        Application.Run (appWindow);
+        appWindow.Dispose ();
+
+        // Shutdown - Calling Application.Shutdown is required.
+        Application.Shutdown ();
 
-        Win.Add (buttonPressedLabel);
     }
 
     private Dialog CreateDemoDialog (
@@ -204,7 +232,7 @@ public class Dialogs : Scenario
         TextField titleEdit,
         TextField numButtonsEdit,
         CheckBox glyphsNotWords,
-        RadioGroup styleRadioGroup,
+        RadioGroup alignmentRadioGroup,
         Label buttonPressedLabel
     )
     {
@@ -231,7 +259,7 @@ public class Dialogs : Scenario
                 {
                     buttonId = i;
 
-                    button = new()
+                    button = new ()
                     {
                         Text = NumberToWords.Convert (buttonId) + " " + char.ConvertFromUtf32 (buttonId + CODE_POINT),
                         IsDefault = buttonId == 0
@@ -239,7 +267,10 @@ public class Dialogs : Scenario
                 }
                 else
                 {
-                    button = new() { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 };
+                    button = new Button
+                    {
+                        Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0
+                    };
                 }
 
                 button.Accept += (s, e) =>
@@ -260,10 +291,11 @@ public class Dialogs : Scenario
 
             // This tests dynamically adding buttons; ensuring the dialog resizes if needed and 
             // the buttons are laid out correctly
-            dialog = new()
+            dialog = new ()
             {
                 Title = titleEdit.Text,
-                ButtonAlignment = (Dialog.ButtonAlignments)styleRadioGroup.SelectedItem,
+                ButtonAlignment = (Alignment)Enum.Parse (typeof (Alignment), alignmentRadioGroup.RadioLabels [alignmentRadioGroup.SelectedItem]),
+
                 Buttons = buttons.ToArray ()
             };
 
@@ -282,7 +314,7 @@ public class Dialogs : Scenario
 
                               if (glyphsNotWords.Checked == true)
                               {
-                                  button = new()
+                                  button = new ()
                                   {
                                       Text = NumberToWords.Convert (buttonId) + " " + char.ConvertFromUtf32 (buttonId + CODE_POINT),
                                       IsDefault = buttonId == 0
@@ -290,7 +322,7 @@ public class Dialogs : Scenario
                               }
                               else
                               {
-                                  button = new() { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 };
+                                  button = new () { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 };
                               }
 
                               button.Accept += (s, e) =>

+ 2 - 2
UICatalog/Scenarios/DynamicMenuBar.cs

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

+ 9 - 9
UICatalog/Scenarios/Editor.cs

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

+ 1 - 1
UICatalog/Scenarios/ListColumns.cs

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

+ 9 - 9
UICatalog/Scenarios/MessageBoxes.cs

@@ -14,7 +14,7 @@ public class MessageBoxes : Scenario
         var frame = new FrameView { X = Pos.Center (), Y = 1, Width = Dim.Percent (75), Title = "MessageBox Options" };
         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.Right, Text = "Width:" };
         frame.Add (label);
 
         var widthEdit = new TextField
@@ -34,7 +34,7 @@ public class MessageBoxes : Scenario
 
             Width = Dim.Width (label),
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = "Height:"
         };
         frame.Add (label);
@@ -69,7 +69,7 @@ public class MessageBoxes : Scenario
 
             Width = Dim.Width (label),
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = "Title:"
         };
         frame.Add (label);
@@ -91,7 +91,7 @@ public class MessageBoxes : Scenario
 
             Width = Dim.Width (label),
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = "Message:"
         };
         frame.Add (label);
@@ -113,7 +113,7 @@ public class MessageBoxes : Scenario
 
             Width = Dim.Width (label),
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = "Num Buttons:"
         };
         frame.Add (label);
@@ -135,7 +135,7 @@ public class MessageBoxes : Scenario
 
             Width = Dim.Width (label),
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = "Default Button:"
         };
         frame.Add (label);
@@ -157,7 +157,7 @@ public class MessageBoxes : Scenario
 
             Width = Dim.Width (label),
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = "Style:"
         };
         frame.Add (label);
@@ -195,7 +195,7 @@ public class MessageBoxes : Scenario
 
         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.Right, Text = "Button Pressed:"
         };
         Win.Add (label);
 
@@ -204,7 +204,7 @@ public class MessageBoxes : Scenario
             X = Pos.Center (),
             Y = Pos.Bottom (label) + 1,
             ColorScheme = Colors.ColorSchemes ["Error"],
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Text = " "
         };
 

+ 2 - 2
UICatalog/Scenarios/Mouse.cs

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

+ 365 - 0
UICatalog/Scenarios/PosAlign.cs

@@ -0,0 +1,365 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Terminal.Gui;
+
+namespace UICatalog.Scenarios;
+
+[ScenarioMetadata ("Pos.Align", "Shows off Pos.Align")]
+[ScenarioCategory ("Layout")]
+public sealed class PosAlign : Scenario
+{
+    private readonly Aligner _horizAligner = new ();
+    private int _leftMargin;
+    private readonly Aligner _vertAligner = new ();
+    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 ()}"
+        };
+
+        SetupHorizontalControls (appWindow);
+
+        SetupVerticalControls (appWindow);
+
+        Setup3by3Grid (appWindow);
+
+        // Run - Start the application.
+        Application.Run (appWindow);
+        appWindow.Dispose ();
+
+        // Shutdown - Calling Application.Shutdown is required.
+        Application.Shutdown ();
+    }
+
+    private void SetupHorizontalControls (Window appWindow)
+    {
+        ColorScheme colorScheme = Colors.ColorSchemes ["Toplevel"];
+
+        RadioGroup alignRadioGroup = new ()
+        {
+            X = Pos.Align (_horizAligner.Alignment),
+            Y = Pos.Center (),
+            RadioLabels = new [] { "Left", "Right", "Centered", "Justified", "FirstLeftRestRight", "LastRightRestLeft" },
+            ColorScheme = colorScheme
+        };
+
+        alignRadioGroup.SelectedItemChanged += (s, e) =>
+                                             {
+                                                 _horizAligner.Alignment =
+                                                     (Alignment)Enum.Parse (typeof (Alignment), alignRadioGroup.RadioLabels [alignRadioGroup.SelectedItem]);
+
+                                                 foreach (View view in appWindow.Subviews.Where (v => v.X is Pos.PosAlign))
+                                                 {
+                                                     if (view.X is Pos.PosAlign j)
+                                                     {
+                                                         var newJust = new Pos.PosAlign (_horizAligner.Alignment)
+                                                         {
+                                                             Aligner =
+                                                             {
+                                                                 SpaceBetweenItems = _horizAligner.SpaceBetweenItems
+                                                             }
+                                                         };
+                                                         view.X = newJust;
+                                                     }
+                                                 }
+                                             };
+        appWindow.Add (alignRadioGroup);
+
+        CheckBox putSpaces = new ()
+        {
+            X = Pos.Align (_horizAligner.Alignment),
+            Y = Pos.Top (alignRadioGroup),
+            ColorScheme = colorScheme,
+            Text = "Spaces"
+        };
+
+        putSpaces.Toggled += (s, e) =>
+                             {
+                                 _horizAligner.SpaceBetweenItems = e.NewValue is { } && e.NewValue.Value;
+
+                                 foreach (View view in appWindow.Subviews.Where (v => v.X is Pos.PosAlign))
+                                 {
+                                     if (view.X is Pos.PosAlign j)
+                                     {
+                                         j.Aligner.SpaceBetweenItems = _horizAligner.SpaceBetweenItems;
+                                     }
+                                 }
+                             };
+        appWindow.Add (putSpaces);
+
+        CheckBox margin = new ()
+        {
+            X = Pos.Left (putSpaces),
+            Y = Pos.Bottom (putSpaces),
+            ColorScheme = colorScheme,
+            Text = "Margin"
+        };
+
+        margin.Toggled += (s, e) =>
+                          {
+                              _leftMargin = e.NewValue is { } && e.NewValue.Value ? 1 : 0;
+
+                              foreach (View view in appWindow.Subviews.Where (v => v.X is Pos.PosAlign))
+                              {
+                                  // Skip the justification radio group
+                                  if (view != alignRadioGroup)
+                                  {
+                                      view.Margin.Thickness = new (_leftMargin, 0, 0, 0);
+                                  }
+                              }
+
+                              appWindow.LayoutSubviews ();
+                          };
+        appWindow.Add (margin);
+
+        List<Button> addedViews = new List<Button> ();
+
+        addedViews.Add (
+                        new()
+                        {
+                            X = Pos.Align (_horizAligner.Alignment),
+                            Y = Pos.Center (),
+                            Text = NumberToWords.Convert (0)
+                        });
+
+        Buttons.NumericUpDown<int> addedViewsUpDown = new Buttons.NumericUpDown<int>
+        {
+            X = Pos.Align (_horizAligner.Alignment),
+            Y = Pos.Top (alignRadioGroup),
+            Width = 9,
+            Title = "Added",
+            ColorScheme = colorScheme,
+            BorderStyle = LineStyle.None,
+            Value = addedViews.Count
+        };
+        addedViewsUpDown.Border.Thickness = new (0, 1, 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 = Pos.Align (_horizAligner.Alignment),
+                                                          Y = Pos.Center (),
+                                                          Text = NumberToWords.Convert (i + 1)
+                                                      };
+                                                      appWindow.Add (button);
+                                                      addedViews.Add (button);
+                                                  }
+                                              }
+                                          };
+        appWindow.Add (addedViewsUpDown);
+
+        appWindow.Add (addedViews [0]);
+    }
+
+    private void SetupVerticalControls (Window appWindow)
+    {
+        ColorScheme colorScheme = Colors.ColorSchemes ["Error"];
+
+        RadioGroup alignRadioGroup = new ()
+        {
+            X = 0,
+            Y = Pos.Align (_vertAligner.Alignment),
+            RadioLabels = new [] { "Top", "Bottom", "Centered", "Justified", "FirstTopRestBottom", "LastBottomRestTop" },
+            ColorScheme = colorScheme
+        };
+
+        alignRadioGroup.SelectedItemChanged += (s, e) =>
+                                             {
+                                                 _vertAligner.Alignment =
+                                                     (Alignment)Enum.Parse (typeof (Alignment), alignRadioGroup.RadioLabels [alignRadioGroup.SelectedItem]);
+
+                                                 foreach (View view in appWindow.Subviews.Where (v => v.Y is Pos.PosAlign))
+                                                 {
+                                                     if (view.Y is Pos.PosAlign j)
+                                                     {
+                                                         var newJust = new Pos.PosAlign (_vertAligner.Alignment)
+                                                         {
+                                                             Aligner =
+                                                             {
+                                                                 SpaceBetweenItems = _vertAligner.SpaceBetweenItems
+                                                             }
+                                                         };
+                                                         view.Y = newJust;
+                                                     }
+                                                 }
+                                             };
+        appWindow.Add (alignRadioGroup);
+
+        CheckBox putSpaces = new ()
+        {
+            X = 0,
+            Y = Pos.Align (_vertAligner.Alignment),
+            ColorScheme = colorScheme,
+            Text = "Spaces"
+        };
+
+        putSpaces.Toggled += (s, e) =>
+                             {
+                                 _vertAligner.SpaceBetweenItems = e.NewValue is { } && e.NewValue.Value;
+
+                                 foreach (View view in appWindow.Subviews.Where (v => v.Y is Pos.PosAlign))
+                                 {
+                                     if (view.Y is Pos.PosAlign j)
+                                     {
+                                         j.Aligner.SpaceBetweenItems = _vertAligner.SpaceBetweenItems;
+                                     }
+                                 }
+                             };
+        appWindow.Add (putSpaces);
+
+        CheckBox margin = new ()
+        {
+            X = Pos.Right (putSpaces) + 1,
+            Y = Pos.Top (putSpaces),
+            ColorScheme = colorScheme,
+            Text = "Margin"
+        };
+
+        margin.Toggled += (s, e) =>
+                          {
+                              _topMargin = e.NewValue is { } && e.NewValue.Value ? 1 : 0;
+
+                              foreach (View view in appWindow.Subviews.Where (v => v.Y is Pos.PosAlign))
+                              {
+                                  // Skip the justification radio group
+                                  if (view != alignRadioGroup)
+                                  {
+                                      view.Margin.Thickness = new (0, _topMargin, 0, 0);
+                                  }
+                              }
+
+                              appWindow.LayoutSubviews ();
+                          };
+        appWindow.Add (margin);
+
+        List<CheckBox> addedViews = new List<CheckBox> ();
+
+        addedViews.Add (
+                        new()
+                        {
+                            X = 0,
+                            Y = Pos.Align (_vertAligner.Alignment),
+                            Text = NumberToWords.Convert (0)
+                        });
+
+        Buttons.NumericUpDown<int> addedViewsUpDown = new Buttons.NumericUpDown<int>
+        {
+            X = 0,
+            Y = Pos.Align (_vertAligner.Alignment),
+            Width = 9,
+            Title = "Added",
+            ColorScheme = colorScheme,
+            BorderStyle = LineStyle.None,
+            Value = addedViews.Count
+        };
+        addedViewsUpDown.Border.Thickness = new (0, 1, 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--)
+                                                  {
+                                                      CheckBox 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 CheckBox
+                                                      {
+                                                          X = 0,
+                                                          Y = Pos.Align (_vertAligner.Alignment),
+                                                          Text = NumberToWords.Convert (i + 1)
+                                                      };
+                                                      appWindow.Add (button);
+                                                      addedViews.Add (button);
+                                                  }
+                                              }
+                                          };
+        appWindow.Add (addedViewsUpDown);
+
+        appWindow.Add (addedViews [0]);
+    }
+
+    private void Setup3by3Grid (Window appWindow)
+    {
+        var container = new View
+        {
+            Title = "3 by 3",
+            BorderStyle = LineStyle.Single,
+            X = Pos.AnchorEnd (),
+            Y = Pos.AnchorEnd (),
+            Width = Dim.Percent (30),
+            Height = Dim.Percent (30)
+        };
+
+        for (var i = 0; i < 9; i++)
+
+        {
+            var v = new View
+            {
+                Title = $"{i}",
+                BorderStyle = LineStyle.Dashed,
+                Height = 3,
+                Width = 5
+            };
+
+            v.X = Pos.Align (Alignment.Right, i / 3);
+            v.Y = Pos.Align (Alignment.Justified, i % 3 + 10);
+
+            container.Add (v);
+        }
+
+        appWindow.Add (container);
+    }
+}

+ 18 - 10
UICatalog/Scenarios/ProgressBarStyles.cs

@@ -50,13 +50,12 @@ public class ProgressBarStyles : Scenario
         var pbList = new ListView
         {
             Title = "Focused ProgressBar",
-            Y = 0,
+            Y = Pos.Align (Alignment.Top),
             X = Pos.Center (),
             Width = 30,
             Height = 7,
             BorderStyle = LineStyle.Single
         };
-
         container.Add (pbList);
 
         #region ColorPicker
@@ -97,7 +96,9 @@ public class ProgressBarStyles : Scenario
 
         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.Top),
         };
         container.Add (fgColorPickerBtn);
 
@@ -122,7 +123,9 @@ public class ProgressBarStyles : Scenario
 
         var bgColorPickerBtn = new Button
         {
-            X = Pos.Center (), Y = Pos.Bottom (fgColorPickerBtn), Text = "Background HotNormal Color"
+            X = Pos.Center (),
+            Y = Pos.Align (Alignment.Top),
+            Text = "Background HotNormal Color"
         };
         container.Add (bgColorPickerBtn);
 
@@ -155,19 +158,24 @@ public class ProgressBarStyles : Scenario
             BorderStyle = LineStyle.Single,
             Title = "ProgressBarFormat",
             X = Pos.Left (pbList),
-            Y = Pos.Bottom (bgColorPickerBtn) + 1,
+            Y = Pos.Align (Alignment.Top),
             RadioLabels = pbFormatEnum.Select (e => e.ToString ()).ToArray ()
         };
         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.Top),
+            Text = "Start timer"
+        };
         container.Add (button);
 
         var blocksPB = new ProgressBar
         {
             Title = "Blocks",
             X = Pos.Center (),
-            Y = Pos.Bottom (button) + 1,
+            Y = Pos.Align (Alignment.Top),
             Width = Dim.Width (pbList),
             BorderStyle = LineStyle.Single,
             CanFocus = true
@@ -178,7 +186,7 @@ public class ProgressBarStyles : Scenario
         {
             Title = "Continuous",
             X = Pos.Center (),
-            Y = Pos.Bottom (blocksPB) + 1,
+            Y = Pos.Align (Alignment.Top),
             Width = Dim.Width (pbList),
             ProgressBarStyle = ProgressBarStyle.Continuous,
             BorderStyle = LineStyle.Single,
@@ -228,7 +236,7 @@ public class ProgressBarStyles : Scenario
         {
             Title = "Marquee Blocks",
             X = Pos.Center (),
-            Y = Pos.Bottom (ckbBidirectional) + 1,
+            Y = Pos.Align (Alignment.Top),
             Width = Dim.Width (pbList),
             ProgressBarStyle = ProgressBarStyle.MarqueeBlocks,
             BorderStyle = LineStyle.Single,
@@ -240,7 +248,7 @@ public class ProgressBarStyles : Scenario
         {
             Title = "Marquee Continuous",
             X = Pos.Center (),
-            Y = Pos.Bottom (marqueesBlocksPB) + 1,
+            Y = Pos.Align (Alignment.Top),
             Width = Dim.Width (pbList),
             ProgressBarStyle = ProgressBarStyle.MarqueeContinuous,
             BorderStyle = LineStyle.Single,

+ 7 - 7
UICatalog/Scenarios/TableEditor.cs

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

+ 50 - 50
UICatalog/Scenarios/TextAlignmentsAndDirection.cs → UICatalog/Scenarios/TextAlignmentAndDirection.cs

@@ -6,9 +6,9 @@ using Terminal.Gui;
 
 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")]
-public class TextAlignmentsAndDirections : Scenario
+public class TextAlignmentAndDirection : Scenario
 {
     public override void Main ()
     {
@@ -35,7 +35,7 @@ public class TextAlignmentsAndDirections : Scenario
             Y = 1,
             Width = 9,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             ColorScheme = Colors.ColorSchemes ["Dialog"],
             Text = "Left"
         };
@@ -46,7 +46,7 @@ public class TextAlignmentsAndDirections : Scenario
             Y = 2,
             Width = 9,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             ColorScheme = Colors.ColorSchemes ["Dialog"],
             Text = "Centered"
         };
@@ -57,7 +57,7 @@ public class TextAlignmentsAndDirections : Scenario
             Y = 3,
             Width = 9,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             ColorScheme = Colors.ColorSchemes ["Dialog"],
             Text = "Right"
         };
@@ -68,7 +68,7 @@ public class TextAlignmentsAndDirections : Scenario
             Y = 4,
             Width = 9,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             ColorScheme = Colors.ColorSchemes ["Dialog"],
             Text = "Justified"
         };
@@ -80,7 +80,7 @@ public class TextAlignmentsAndDirections : Scenario
             Width = Dim.Fill (1) - 9,
             Height = 1,
             ColorScheme = color1,
-            TextAlignment = TextAlignment.Left,
+            TextAlignment = Alignment.Left,
             Text = txt
         };
 
@@ -91,7 +91,7 @@ public class TextAlignmentsAndDirections : Scenario
             Width = Dim.Fill (1) - 9,
             Height = 1,
             ColorScheme = color2,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Text = txt
         };
 
@@ -102,7 +102,7 @@ public class TextAlignmentsAndDirections : Scenario
             Width = Dim.Fill (1) - 9,
             Height = 1,
             ColorScheme = color1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Text = txt
         };
 
@@ -113,7 +113,7 @@ public class TextAlignmentsAndDirections : Scenario
             Width = Dim.Fill (1) - 9,
             Height = 1,
             ColorScheme = color2,
-            TextAlignment = TextAlignment.Justified,
+            TextAlignment = Alignment.Justified,
             Text = txt
         };
 
@@ -141,7 +141,7 @@ public class TextAlignmentsAndDirections : Scenario
             Height = 9,
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            VerticalTextAlignment = Alignment.Bottom,
             Text = "Top"
         };
         labelVT.TextFormatter.WordWrap = false;
@@ -154,8 +154,8 @@ public class TextAlignmentsAndDirections : Scenario
             Height = 9,
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
-            Text = "Middle"
+            VerticalTextAlignment = Alignment.Bottom,
+            Text = "Centered"
         };
         labelVM.TextFormatter.WordWrap = false;
 
@@ -167,7 +167,7 @@ public class TextAlignmentsAndDirections : Scenario
             Height = 9,
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            VerticalTextAlignment = Alignment.Bottom,
             Text = "Bottom"
         };
         labelVB.TextFormatter.WordWrap = false;
@@ -180,7 +180,7 @@ public class TextAlignmentsAndDirections : Scenario
             Height = 9,
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            VerticalTextAlignment = Alignment.Bottom,
             Text = "Justified"
         };
         labelVJ.TextFormatter.WordWrap = false;
@@ -193,7 +193,7 @@ public class TextAlignmentsAndDirections : Scenario
             Height = Dim.Fill (1),
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Top,
+            VerticalTextAlignment = Alignment.Top,
             Text = txt
         };
         txtLabelVT.TextFormatter.WordWrap = false;
@@ -206,7 +206,7 @@ public class TextAlignmentsAndDirections : Scenario
             Height = Dim.Fill (1),
             ColorScheme = color2,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Middle,
+            VerticalTextAlignment = Alignment.Centered,
             Text = txt
         };
         txtLabelVM.TextFormatter.WordWrap = false;
@@ -219,7 +219,7 @@ public class TextAlignmentsAndDirections : Scenario
             Height = Dim.Fill (1),
             ColorScheme = color1,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            VerticalTextAlignment = Alignment.Bottom,
             Text = txt
         };
         txtLabelVB.TextFormatter.WordWrap = false;
@@ -232,7 +232,7 @@ public class TextAlignmentsAndDirections : Scenario
             Height = Dim.Fill (1),
             ColorScheme = color2,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Justified,
+            VerticalTextAlignment = Alignment.Justified,
             Text = txt
         };
         txtLabelVJ.TextFormatter.WordWrap = false;
@@ -268,8 +268,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = 1,
             Width = Dim.Percent (100f / 3f),
             Height = Dim.Percent (100f / 3f),
-            TextAlignment = TextAlignment.Left,
-            VerticalTextAlignment = VerticalTextAlignment.Top,
+            TextAlignment = Alignment.Left,
+            VerticalTextAlignment = Alignment.Top,
             ColorScheme = color1,
             Text = txt
         };
@@ -281,8 +281,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = 1,
             Width = Dim.Percent (100f / 3f),
             Height = Dim.Percent (100f / 3f),
-            TextAlignment = TextAlignment.Centered,
-            VerticalTextAlignment = VerticalTextAlignment.Top,
+            TextAlignment = Alignment.Centered,
+            VerticalTextAlignment = Alignment.Top,
             ColorScheme = color1,
             Text = txt
         };
@@ -294,8 +294,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = 1,
             Width = Dim.Percent (100f, true),
             Height = Dim.Percent (100f / 3f),
-            TextAlignment = TextAlignment.Right,
-            VerticalTextAlignment = VerticalTextAlignment.Top,
+            TextAlignment = Alignment.Right,
+            VerticalTextAlignment = Alignment.Top,
             ColorScheme = color1,
             Text = txt
         };
@@ -307,8 +307,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelTL) + 1,
             Width = Dim.Width (txtLabelTL),
             Height = Dim.Percent (100f / 3f),
-            TextAlignment = TextAlignment.Left,
-            VerticalTextAlignment = VerticalTextAlignment.Middle,
+            TextAlignment = Alignment.Left,
+            VerticalTextAlignment = Alignment.Centered,
             ColorScheme = color1,
             Text = txt
         };
@@ -320,8 +320,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelTC) + 1,
             Width = Dim.Width (txtLabelTC),
             Height = Dim.Percent (100f / 3f),
-            TextAlignment = TextAlignment.Centered,
-            VerticalTextAlignment = VerticalTextAlignment.Middle,
+            TextAlignment = Alignment.Centered,
+            VerticalTextAlignment = Alignment.Centered,
             ColorScheme = color1,
             Text = txt
         };
@@ -333,8 +333,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelTR) + 1,
             Width = Dim.Percent (100f, true),
             Height = Dim.Percent (100f / 3f),
-            TextAlignment = TextAlignment.Right,
-            VerticalTextAlignment = VerticalTextAlignment.Middle,
+            TextAlignment = Alignment.Right,
+            VerticalTextAlignment = Alignment.Centered,
             ColorScheme = color1,
             Text = txt
         };
@@ -346,8 +346,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelML) + 1,
             Width = Dim.Width (txtLabelML),
             Height = Dim.Percent (100f, true),
-            TextAlignment = TextAlignment.Left,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            TextAlignment = Alignment.Left,
+            VerticalTextAlignment = Alignment.Bottom,
             ColorScheme = color1,
             Text = txt
         };
@@ -359,8 +359,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelMC) + 1,
             Width = Dim.Width (txtLabelMC),
             Height = Dim.Percent (100f, true),
-            TextAlignment = TextAlignment.Centered,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            TextAlignment = Alignment.Centered,
+            VerticalTextAlignment = Alignment.Bottom,
             ColorScheme = color1,
             Text = txt
         };
@@ -372,8 +372,8 @@ public class TextAlignmentsAndDirections : Scenario
             Y = Pos.Bottom (txtLabelMR) + 1,
             Width = Dim.Percent (100f, true),
             Height = Dim.Percent (100f, true),
-            TextAlignment = TextAlignment.Right,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom,
+            TextAlignment = Alignment.Right,
+            VerticalTextAlignment = Alignment.Bottom,
             ColorScheme = color1,
             Text = txt
         };
@@ -389,7 +389,7 @@ public class TextAlignmentsAndDirections : Scenario
         mtxts.Add (txtLabelBC);
         mtxts.Add (txtLabelBR);
 
-        // Save Alignments in Data
+        // Save Alignment in Data
         foreach (Label t in mtxts)
         {
             t.Data = new { h = t.TextAlignment, v = t.VerticalTextAlignment };
@@ -593,8 +593,8 @@ public class TextAlignmentsAndDirections : Scenario
 
                 foreach (Label t in mtxts)
                 {
-                    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
@@ -611,16 +611,16 @@ public class TextAlignmentsAndDirections : Scenario
                         switch (justifyOptions.SelectedItem)
                         {
                             case 0:
-                                t.VerticalTextAlignment = VerticalTextAlignment.Justified;
+                                t.VerticalTextAlignment = Alignment.Justified;
                                 t.TextAlignment = ((dynamic)t.Data).h;
                                 break;
                             case 1:
-                                t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v;
-                                t.TextAlignment = TextAlignment.Justified;
+                                t.VerticalTextAlignment = (Alignment)((dynamic)t.Data).v;
+                                t.TextAlignment = Alignment.Justified;
                                 break;
                             case 2:
-                                t.VerticalTextAlignment = VerticalTextAlignment.Justified;
-                                t.TextAlignment = TextAlignment.Justified;
+                                t.VerticalTextAlignment = Alignment.Justified;
+                                t.TextAlignment = Alignment.Justified;
                                 break;
                         }
                     }
@@ -629,16 +629,16 @@ public class TextAlignmentsAndDirections : Scenario
                         switch (justifyOptions.SelectedItem)
                         {
                             case 0:
-                                t.TextAlignment = TextAlignment.Justified;
+                                t.TextAlignment = Alignment.Justified;
                                 t.VerticalTextAlignment = ((dynamic)t.Data).v;
                                 break;
                             case 1:
-                                t.TextAlignment = (TextAlignment)((dynamic)t.Data).h;
-                                t.VerticalTextAlignment = VerticalTextAlignment.Justified;
+                                t.TextAlignment = (Alignment)((dynamic)t.Data).h;
+                                t.VerticalTextAlignment = Alignment.Justified;
                                 break;
                             case 2:
-                                t.TextAlignment = TextAlignment.Justified;
-                                t.VerticalTextAlignment = VerticalTextAlignment.Justified;
+                                t.TextAlignment = Alignment.Justified;
+                                t.VerticalTextAlignment = Alignment.Justified;
                                 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);
 
-        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.Left, Alignment.Right, Alignment.Centered, Alignment.Justified };
         Label [] singleLines = new Label [alignments.Count];
         Label [] multipleLines = new Label [alignments.Count];
 
         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,
 
                 Width = Dim.Fill (),
@@ -82,9 +94,9 @@ public class TextFormatterDemo : Scenario
                 Text = text
             };
 
-            multipleLines [(int)alignment] = new()
+            multipleLines [i] = new ()
             {
-                TextAlignment = alignment,
+                TextAlignment = alignments [i],
                 X = 0,
 
                 Width = Dim.Fill (),
@@ -100,33 +112,33 @@ public class TextFormatterDemo : Scenario
         };
         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);
-            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);
 
-        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);
-            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) =>
                                    {
-                                       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 (),
             Y = Pos.Bottom (longDate) + 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
 
             Width = Dim.Fill (),
             Text = "Old Time: "
@@ -68,7 +68,7 @@ public class TimeAndDate : Scenario
         {
             X = Pos.Center (),
             Y = Pos.Bottom (_lblOldTime) + 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
 
             Width = Dim.Fill (),
             Text = "New Time: "
@@ -79,7 +79,7 @@ public class TimeAndDate : Scenario
         {
             X = Pos.Center (),
             Y = Pos.Bottom (_lblNewTime) + 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
 
             Width = Dim.Fill (),
             Text = "Time Format: "
@@ -90,7 +90,7 @@ public class TimeAndDate : Scenario
         {
             X = Pos.Center (),
             Y = Pos.Bottom (_lblTimeFmt) + 2,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
 
             Width = Dim.Fill (),
             Text = "Old Date: "
@@ -101,7 +101,7 @@ public class TimeAndDate : Scenario
         {
             X = Pos.Center (),
             Y = Pos.Bottom (_lblOldDate) + 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
 
             Width = Dim.Fill (),
             Text = "New Date: "
@@ -112,7 +112,7 @@ public class TimeAndDate : Scenario
         {
             X = Pos.Center (),
             Y = Pos.Bottom (_lblNewDate) + 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
 
             Width = Dim.Fill (),
             Text = "Date Format: "

+ 2 - 2
UICatalog/Scenarios/Unicode.cs

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

+ 5 - 5
UICatalog/Scenarios/ViewExperiments.cs

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

+ 4 - 4
UICatalog/Scenarios/Wizards.cs

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

+ 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 ();
         Assert.NotEmpty (Themes);
-        Assert.Equal (Dialog.ButtonAlignments.Center, Dialog.DefaultButtonAlignment);
+        Assert.Equal (Alignment.Right, Dialog.DefaultButtonAlignment);
 
-        Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = Dialog.ButtonAlignments.Right;
+        Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = Alignment.Centered;
 
         ThemeManager.Themes! [ThemeManager.SelectedTheme]!.Apply ();
-        Assert.Equal (Dialog.ButtonAlignments.Right, Dialog.DefaultButtonAlignment);
+        Assert.Equal (Alignment.Centered, Dialog.DefaultButtonAlignment);
         Reset ();
     }
 

+ 3 - 3
UnitTests/Configuration/ThemeTests.cs

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

+ 253 - 249
UnitTests/Dialogs/DialogTests.cs

@@ -32,14 +32,14 @@ public class DialogTests
             Title = title,
             Width = width,
             Height = 1,
-            ButtonAlignment = Dialog.ButtonAlignments.Center,
-            Buttons = [new () { Text = btn1Text }]
+            ButtonAlignment = Alignment.Centered,
+            Buttons = [new Button { Text = btn1Text }]
         };
 
         // 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);
         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);
 
         // Now add a second button
@@ -57,14 +57,14 @@ public class DialogTests
             Title = title,
             Width = width,
             Height = 1,
-            ButtonAlignment = Dialog.ButtonAlignments.Justify,
-            Buttons = [new () { Text = btn1Text }]
+            ButtonAlignment = Alignment.Justified,
+            Buttons = [new Button { Text = btn1Text }]
         };
 
         // 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);
         runstate = Begin (dlg);
-        buttonRow = $"{CM.Glyphs.VLine}         {btn1}{CM.Glyphs.VLine}";
+        buttonRow = $"{CM.Glyphs.VLine}{btn1}         {CM.Glyphs.VLine}";
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
 
         // Now add a second button
@@ -82,8 +82,8 @@ public class DialogTests
             Title = title,
             Width = width,
             Height = 1,
-            ButtonAlignment = Dialog.ButtonAlignments.Right,
-            Buttons = [new () { Text = btn1Text }]
+            ButtonAlignment = Alignment.Right,
+            Buttons = [new Button { Text = btn1Text }]
         };
 
         // 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,
             Width = width,
             Height = 1,
-            ButtonAlignment = Dialog.ButtonAlignments.Left,
-            Buttons = [new () { Text = btn1Text }]
+            ButtonAlignment = Alignment.Left,
+            Buttons = [new Button { Text = btn1Text }]
         };
 
         // 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
         (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.Centered,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
 
         // 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);
 
         (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.Justified,
+                                                      new Button { Text = btn1Text },
+                                                      new Button { Text = btn2Text },
+                                                      new Button { Text = btn3Text },
+                                                      new Button { Text = btn4Text }
+                                                     );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -187,14 +187,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (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.Right,
+                                                      new Button { Text = btn1Text },
+                                                      new Button { Text = btn2Text },
+                                                      new Button { Text = btn3Text },
+                                                      new Button { Text = btn4Text }
+                                                     );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -204,14 +204,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (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.Left,
+                                                      new Button { Text = btn1Text },
+                                                      new Button { Text = btn2Text },
+                                                      new Button { Text = btn3Text },
+                                                      new Button { Text = btn4Text }
+                                                     );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -243,12 +243,12 @@ public class DialogTests
 
         // Default - Center
         buttonRow =
-            $"{CM.Glyphs.VLine}es {CM.Glyphs.RightBracket} {btn2} {btn3} {CM.Glyphs.LeftBracket} neve{CM.Glyphs.VLine}";
+            $"{CM.Glyphs.VLine}{CM.Glyphs.LeftBracket} yes {CM.Glyphs.RightBracket}{btn2}{btn3}{CM.Glyphs.LeftBracket} neve{CM.Glyphs.VLine}";
 
         (runstate, Dialog dlg) = RunButtonTestDialog (
                                                       title,
                                                       width,
-                                                      Dialog.ButtonAlignments.Center,
+                                                      Alignment.Centered,
                                                       new Button { Text = btn1Text },
                                                       new Button { Text = btn2Text },
                                                       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}";
 
         (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.Justified,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
 
         // 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 (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Right,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
 
         // 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 (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Left,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -337,14 +338,14 @@ public class DialogTests
 
         // Default - Center
         (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.Centered,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -354,14 +355,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (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.Justified,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -371,14 +372,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (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.Right,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -388,14 +389,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (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.Left,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -431,14 +432,14 @@ public class DialogTests
 
         // Default - Center
         (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.Centered,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -448,14 +449,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.GetColumns ());
 
         (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.Justified,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -465,14 +466,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.GetColumns ());
 
         (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.Right,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -482,14 +483,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.GetColumns ());
 
         (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.Left,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text },
+                                                    new Button { Text = btn4Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -514,11 +515,11 @@ public class DialogTests
         d.SetBufferSize (width, 1);
 
         (runstate, Dialog dlg) = RunButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Dialog.ButtonAlignments.Center,
-                                                      new Button { Text = btnText }
-                                                     );
+                                                    title,
+                                                    width,
+                                                    Alignment.Centered,
+                                                    new Button { Text = btnText }
+                                                   );
 
         // Center
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -527,15 +528,15 @@ public class DialogTests
 
         // Justify 
         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);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Justified,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -546,11 +547,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Right,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -561,11 +562,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Left,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -578,26 +579,26 @@ public class DialogTests
         d.SetBufferSize (width, 1);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Center,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Centered,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
 
         // Justify
         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);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Justified,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -608,11 +609,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Right,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -623,11 +624,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btnText }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Left,
+                                                    new Button { Text = btnText }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -657,13 +658,13 @@ public class DialogTests
         d.SetBufferSize (buttonRow.Length, 3);
 
         (runstate, Dialog dlg) = RunButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Dialog.ButtonAlignments.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text },
-                                                      new Button { Text = btn3Text }
-                                                     );
+                                                    title,
+                                                    width,
+                                                    Alignment.Centered,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -673,13 +674,13 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Justified,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -689,13 +690,13 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Right,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -705,13 +706,13 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Left,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text },
+                                                    new Button { Text = btn3Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -739,12 +740,12 @@ public class DialogTests
         d.SetBufferSize (buttonRow.Length, 3);
 
         (runstate, Dialog dlg) = RunButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Dialog.ButtonAlignments.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text }
-                                                     );
+                                                    title,
+                                                    width,
+                                                    Alignment.Centered,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -754,12 +755,12 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Justify,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Justified,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -769,12 +770,12 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Right,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Right,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -784,12 +785,12 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = RunButtonTestDialog (
-                                               title,
-                                               width,
-                                               Dialog.ButtonAlignments.Left,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text }
-                                              );
+                                                    title,
+                                                    width,
+                                                    Alignment.Left,
+                                                    new Button { Text = btn1Text },
+                                                    new Button { Text = btn2Text }
+                                                   );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -821,9 +822,9 @@ public class DialogTests
         Button button1, button2;
 
         // 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.Centered, button1, button2);
         button1.Visible = false;
         RunIteration (ref runstate, ref firstIteration);
         buttonRow = $@"{CM.Glyphs.VLine}         {btn2} {CM.Glyphs.VLine}";
@@ -833,9 +834,9 @@ public class DialogTests
 
         // Justify
         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.Justified, button1, button2);
         button1.Visible = false;
         RunIteration (ref runstate, ref firstIteration);
         buttonRow = $@"{CM.Glyphs.VLine}          {btn2}{CM.Glyphs.VLine}";
@@ -845,9 +846,9 @@ public class DialogTests
 
         // Right
         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.Right, button1, button2);
         button1.Visible = false;
         RunIteration (ref runstate, ref firstIteration);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -856,9 +857,9 @@ public class DialogTests
 
         // Left
         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.Left, button1, button2);
         button1.Visible = false;
         RunIteration (ref runstate, ref firstIteration);
         buttonRow = $@"{CM.Glyphs.VLine}        {btn2}  {CM.Glyphs.VLine}";
@@ -888,6 +889,7 @@ public class DialogTests
 
         win.Loaded += (s, a) =>
                       {
+                          Dialog.DefaultButtonAlignment = Alignment.Centered;
                           var dlg = new Dialog { Width = 18, Height = 3, Buttons = [new () { Text = "Ok" }] };
 
                           dlg.Loaded += (s, a) =>
@@ -915,7 +917,7 @@ public class DialogTests
                     @"
 ┌┌───────────────┐─┐
 ││               │ │
-││     ⟦ 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 ();
 
         int iterations = -1;
+        Dialog.DefaultButtonAlignment = Alignment.Centered;
 
         Iteration += (s, a) =>
                      {
@@ -1005,6 +1008,7 @@ public class DialogTests
     public void Dialog_Opened_From_Another_Dialog ()
     {
         ((FakeDriver)Driver).SetBufferSize (30, 10);
+        Dialog.DefaultButtonAlignment = Alignment.Centered;
 
         var btn1 = new Button { Text = "press me 1" };
         Button btn2 = null;
@@ -1281,7 +1285,7 @@ public class DialogTests
         (runstate, Dialog _) = RunButtonTestDialog (
                                                     title,
                                                     width,
-                                                    Dialog.ButtonAlignments.Center,
+                                                    Alignment.Centered,
                                                     new Button { Text = btnText }
                                                    );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -1334,7 +1338,7 @@ public class DialogTests
         int width = buttonRow.Length;
         d.SetBufferSize (buttonRow.Length, 3);
 
-        (runstate, Dialog dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, null);
+        (runstate, Dialog dlg) = RunButtonTestDialog (title, width, Alignment.Centered, null);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
 
         End (runstate);
@@ -1344,7 +1348,7 @@ public class DialogTests
     private (RunState, Dialog) RunButtonTestDialog (
         string title,
         int width,
-        Dialog.ButtonAlignments align,
+        Alignment align,
         params Button [] btns
     )
     {

+ 6 - 6
UnitTests/Dialogs/MessageBoxTests.cs

@@ -278,7 +278,7 @@ public class MessageBoxTests
 │ffffffffffffffffff│
 │  ffffffffffffff  │
 │                  │
-│     {btn}    │
+│    {btn} 
 └──────────────────┘",
                                                                                        _output
                                                                                       );
@@ -302,7 +302,7 @@ public class MessageBoxTests
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │ffffffffffffffffff│
-│     {btn}    │",
+│    {btn}     │",
                                                                                        _output
                                                                                       );
                                          Application.RequestStop ();
@@ -377,7 +377,7 @@ ff ff ff ff ff ff ff
 ────────────────────
 ffffffffffffffffffff
                     
-      ⟦► btn ◄⟧     
+     ⟦► btn ◄⟧      
 ────────────────────
 ",
                                                                                        _output
@@ -459,7 +459,7 @@ ffffffffffffffffffff
 │ffffffffffffffffff│
 │ffffffffffffffffff│
 │ffffffffffffffffff│
-│     {btn}    │",
+│    {btn}     │",
                                                                                        _output
                                                                                       );
                                          Application.RequestStop ();
@@ -509,7 +509,7 @@ ffffffffffffffffffff
 ────────────────────
 ffffffffffffffffffff
                     
-      ⟦► btn ◄⟧     
+     ⟦► btn ◄⟧      
 ────────────────────
 ",
                                                                                        _output
@@ -529,7 +529,7 @@ ffffffffffffffffffff
 ────────────────────
 ffffffffffffffffffff
                     
-      ⟦► btn ◄⟧     
+     ⟦► btn ◄⟧      
 ────────────────────
 ",
                                                                                        _output

+ 462 - 0
UnitTests/Drawing/AlignerTests.cs

@@ -0,0 +1,462 @@
+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);
+    }
+
+    [Theory]
+    [MemberData (nameof (AlignmentEnumValues))]
+    public void NoItems_Works (Alignment alignment)
+    {
+        int [] sizes = [];
+        int [] positions = Aligner.Align (alignment, false, 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 }));
+    }
+
+    [Theory]
+    [InlineData (Alignment.Left, new [] { 0 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Left, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.Left, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+    [InlineData (Alignment.Left, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Left, new [] { 1 }, 2, new [] { 0 })]
+    [InlineData (Alignment.Left, new [] { 1 }, 3, new [] { 0 })]
+    [InlineData (Alignment.Left, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.Left, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.Left, new [] { 1, 1 }, 4, new [] { 0, 2 })]
+    [InlineData (Alignment.Left, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 10, new [] { 0, 2, 5 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 11, new [] { 0, 2, 5 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 12, new [] { 0, 2, 5 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 13, new [] { 0, 2, 5 })]
+    [InlineData (
+                    Alignment.Left,
+                    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.Left, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+    [InlineData (Alignment.Left, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.Left, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.Left, new [] { 10, 20 }, 101, new [] { 0, 11 })]
+    [InlineData (Alignment.Left, new [] { 10, 20, 30 }, 100, new [] { 0, 11, 32 })]
+    [InlineData (Alignment.Left, new [] { 10, 20, 30 }, 101, new [] { 0, 11, 32 })]
+    [InlineData (Alignment.Left, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.Left, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Right, new [] { 0 }, 1, new [] { 1 })]
+    [InlineData (Alignment.Right, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.Right, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 10, new [] { 2, 4, 7 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 11, new [] { 3, 5, 8 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 12, new [] { 4, 6, 9 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 13, new [] { 5, 7, 10 })]
+    [InlineData (Alignment.Right, 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.Right, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+    [InlineData (Alignment.Right, new [] { 10, 20, 30 }, 100, new [] { 38, 49, 70 })]
+    [InlineData (Alignment.Right, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.Right, new [] { 10 }, 101, new [] { 91 })]
+    [InlineData (Alignment.Right, new [] { 10, 20 }, 101, new [] { 70, 81 })]
+    [InlineData (Alignment.Right, new [] { 10, 20, 30 }, 101, new [] { 39, 50, 71 })]
+    [InlineData (Alignment.Right, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.Right, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Centered, new [] { 0 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Centered, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.Centered, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+    [InlineData (Alignment.Centered, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Centered, new [] { 1 }, 2, new [] { 0 })]
+    [InlineData (Alignment.Centered, new [] { 1 }, 3, new [] { 1 })]
+    [InlineData (Alignment.Centered, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.Centered, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.Centered, new [] { 1, 1 }, 4, new [] { 0, 2 })]
+    [InlineData (Alignment.Centered, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3 }, 10, new [] { 1, 3, 6 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3 }, 11, new [] { 1, 3, 6 })]
+    [InlineData (
+                    Alignment.Centered,
+                    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.Centered, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+    [InlineData (Alignment.Centered, new [] { 3, 3, 3 }, 9, new [] { 0, 3, 6 })]
+    [InlineData (Alignment.Centered, new [] { 3, 3, 3 }, 10, new [] { 0, 4, 7 })]
+    [InlineData (Alignment.Centered, new [] { 3, 3, 3 }, 11, new [] { 0, 4, 8 })]
+    [InlineData (Alignment.Centered, new [] { 3, 3, 3 }, 12, new [] { 0, 4, 8 })]
+    [InlineData (Alignment.Centered, new [] { 3, 3, 3 }, 13, new [] { 1, 5, 9 })]
+    [InlineData (Alignment.Centered, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.Centered, new [] { 33, 33, 33 }, 101, new [] { 0, 34, 68 })]
+    [InlineData (Alignment.Centered, new [] { 33, 33, 33 }, 102, new [] { 0, 34, 68 })]
+    [InlineData (Alignment.Centered, new [] { 33, 33, 33 }, 103, new [] { 1, 35, 69 })]
+    [InlineData (Alignment.Centered, new [] { 33, 33, 33 }, 104, new [] { 1, 35, 69 })]
+    [InlineData (Alignment.Centered, new [] { 10 }, 101, new [] { 45 })]
+    [InlineData (Alignment.Centered, new [] { 10, 20 }, 101, new [] { 35, 46 })]
+    [InlineData (Alignment.Centered, new [] { 10, 20, 30 }, 100, new [] { 19, 30, 51 })]
+    [InlineData (Alignment.Centered, new [] { 10, 20, 30 }, 101, new [] { 19, 30, 51 })]
+    [InlineData (Alignment.Centered, new [] { 10, 20, 30, 40 }, 100, new [] { 0, 10, 30, 60 })]
+    [InlineData (Alignment.Centered, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.Centered, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Centered, new [] { 3, 4, 5, 6 }, 25, new [] { 2, 6, 11, 17 })]
+    [InlineData (Alignment.Justified, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Justified, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.Justified, new [] { 10, 20, 30 }, 100, new [] { 0, 30, 70 })]
+    [InlineData (Alignment.Justified, new [] { 10, 20, 30 }, 101, new [] { 0, 31, 71 })]
+    [InlineData (Alignment.Justified, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.Justified, new [] { 11, 17, 23 }, 100, new [] { 0, 36, 77 })]
+    [InlineData (Alignment.Justified, new [] { 1, 2, 3 }, 11, new [] { 0, 4, 8 })]
+    [InlineData (Alignment.Justified, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.Justified, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.Justified, new [] { 3, 3, 3 }, 21, new [] { 0, 9, 18 })]
+    [InlineData (Alignment.Justified, new [] { 3, 4, 5 }, 21, new [] { 0, 8, 16 })]
+    [InlineData (Alignment.Justified, new [] { 3, 4, 5, 6 }, 18, new [] { 0, 3, 7, 12 })]
+    [InlineData (Alignment.Justified, new [] { 3, 4, 5, 6 }, 19, new [] { 0, 4, 8, 13 })]
+    [InlineData (Alignment.Justified, new [] { 3, 4, 5, 6 }, 20, new [] { 0, 4, 9, 14 })]
+    [InlineData (Alignment.Justified, new [] { 3, 4, 5, 6 }, 21, new [] { 0, 4, 9, 15 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 22, new [] { 0, 8, 14, 19 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 23, new [] { 0, 8, 15, 20 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 24, new [] { 0, 8, 15, 21 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 25, new [] { 0, 9, 16, 22 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 26, new [] { 0, 9, 17, 23 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 31, new [] { 0, 11, 20, 28 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 0 }, 1, new [] { 1 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1 }, 2, new [] { 1 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1 }, 3, new [] { 2 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 8, new [] { 0, 2, 5 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 9, new [] { 0, 2, 6 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 10, new [] { 0, 2, 7 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 11, new [] { 0, 2, 8 })]
+    [InlineData (Alignment.LastRightRestLeft, 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.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 3, 3, 3 }, 21, new [] { 0, 4, 18 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 3, 4, 5 }, 21, new [] { 0, 4, 16 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10 }, 101, new [] { 91 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10, 20, 30 }, 100, new [] { 0, 11, 70 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10, 20, 30 }, 101, new [] { 0, 11, 71 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 0 }, 1, new [] { 0 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 1 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1 }, 2, new [] { 0 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1 }, 3, new [] { 0 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 4 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 8, new [] { 0, 2, 5 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 9, new [] { 0, 3, 6 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 10, new [] { 0, 4, 7 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 11, new [] { 0, 5, 8 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 5, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 7 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 1, 4, 8 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 3, 3, 3 }, 21, new [] { 0, 14, 18 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 67 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30 }, 100, new [] { 0, 49, 70 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30 }, 101, new [] { 0, 50, 71 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })]
+    public void Alignment_SpaceBetweenItems (Alignment alignment, int [] sizes, int containerSize, int [] expected)
+    {
+        int [] positions = new Aligner
+        {
+            SpaceBetweenItems = true,
+            Alignment = alignment,
+            ContainerSize = containerSize
+        }.Align (sizes);
+        AssertAlignment (alignment, sizes, containerSize, positions, expected);
+    }
+
+    [Theory]
+    [InlineData (Alignment.Left, new [] { 0 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Left, new [] { 0, 0 }, 1, new [] { 0, 0 })]
+    [InlineData (Alignment.Left, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 0 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 10, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 11, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 12, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3 }, 13, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Left, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 6 })]
+    [InlineData (
+                    Alignment.Left,
+                    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.Left, new [] { 10, 20, 30 }, 100, new [] { 0, 10, 30 })]
+    [InlineData (Alignment.Left, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 66 })]
+    [InlineData (Alignment.Left, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.Left, new [] { 10, 20 }, 101, new [] { 0, 10 })]
+    [InlineData (Alignment.Left, new [] { 10, 20, 30 }, 101, new [] { 0, 10, 30 })]
+    [InlineData (Alignment.Left, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 60 })]
+    [InlineData (Alignment.Left, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 100 })]
+    [InlineData (Alignment.Right, new [] { 0 }, 1, new [] { 1 })]
+    [InlineData (Alignment.Right, new [] { 0, 0 }, 1, new [] { 1, 1 })]
+    [InlineData (Alignment.Right, new [] { 0, 0, 0 }, 1, new [] { 1, 1, 1 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 7, new [] { 1, 2, 4 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 10, new [] { 4, 5, 7 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 11, new [] { 5, 6, 8 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 12, new [] { 6, 7, 9 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3 }, 13, new [] { 7, 8, 10 })]
+    [InlineData (Alignment.Right, 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.Right, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Right, new [] { 1, 2, 3, 4 }, 11, new [] { 1, 2, 4, 7 })]
+    [InlineData (Alignment.Right, new [] { 10, 20, 30 }, 100, new [] { 40, 50, 70 })]
+    [InlineData (Alignment.Right, new [] { 33, 33, 33 }, 100, new [] { 1, 34, 67 })]
+    [InlineData (Alignment.Right, new [] { 10 }, 101, new [] { 91 })]
+    [InlineData (Alignment.Right, new [] { 10, 20 }, 101, new [] { 71, 81 })]
+    [InlineData (Alignment.Right, new [] { 10, 20, 30 }, 101, new [] { 41, 51, 71 })]
+    [InlineData (Alignment.Right, new [] { 10, 20, 30, 40 }, 101, new [] { 1, 11, 31, 61 })]
+    [InlineData (Alignment.Right, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 1, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Centered, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.Centered, new [] { 1 }, 2, new [] { 0 })]
+    [InlineData (Alignment.Centered, new [] { 1 }, 3, new [] { 1 })]
+    [InlineData (Alignment.Centered, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.Centered, new [] { 1, 1 }, 3, new [] { 0, 1 })]
+    [InlineData (Alignment.Centered, new [] { 1, 1 }, 4, new [] { 1, 2 })]
+    [InlineData (Alignment.Centered, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3 }, 10, new [] { 2, 3, 5 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3 }, 11, new [] { 2, 3, 5 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Centered, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.Centered, new [] { 3, 3, 3 }, 9, new [] { 0, 3, 6 })]
+    [InlineData (Alignment.Centered, new [] { 3, 3, 3 }, 10, new [] { 0, 3, 6 })]
+    [InlineData (Alignment.Centered, new [] { 3, 3, 3 }, 11, new [] { 1, 4, 7 })]
+    [InlineData (Alignment.Centered, new [] { 3, 3, 3 }, 12, new [] { 1, 4, 7 })]
+    [InlineData (Alignment.Centered, new [] { 3, 3, 3 }, 13, new [] { 2, 5, 8 })]
+    [InlineData (
+                    Alignment.Centered,
+                    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.Centered, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 66 })]
+    [InlineData (Alignment.Centered, new [] { 33, 33, 33 }, 101, new [] { 1, 34, 67 })]
+    [InlineData (Alignment.Centered, new [] { 33, 33, 33 }, 102, new [] { 1, 34, 67 })]
+    [InlineData (Alignment.Centered, new [] { 33, 33, 33 }, 103, new [] { 2, 35, 68 })]
+    [InlineData (Alignment.Centered, new [] { 33, 33, 33 }, 104, new [] { 2, 35, 68 })]
+    [InlineData (Alignment.Centered, new [] { 3, 4, 5, 6 }, 25, new [] { 3, 6, 10, 15 })]
+    [InlineData (Alignment.Justified, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    [InlineData (Alignment.Justified, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.Justified, new [] { 10, 20, 30 }, 100, new [] { 0, 30, 70 })]
+    [InlineData (Alignment.Justified, new [] { 10, 20, 30 }, 101, new [] { 0, 31, 71 })]
+    [InlineData (Alignment.Justified, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.Justified, new [] { 11, 17, 23 }, 100, new [] { 0, 36, 77 })]
+    [InlineData (Alignment.Justified, new [] { 1, 2, 3 }, 11, new [] { 0, 4, 8 })]
+    [InlineData (Alignment.Justified, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.Justified, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.Justified, new [] { 3, 3, 3 }, 21, new [] { 0, 9, 18 })]
+    [InlineData (Alignment.Justified, new [] { 3, 4, 5 }, 21, new [] { 0, 8, 16 })]
+    [InlineData (Alignment.Justified, new [] { 3, 4, 5, 6 }, 18, new [] { 0, 3, 7, 12 })]
+    [InlineData (Alignment.Justified, new [] { 3, 4, 5, 6 }, 19, new [] { 0, 4, 8, 13 })]
+    [InlineData (Alignment.Justified, new [] { 3, 4, 5, 6 }, 20, new [] { 0, 4, 9, 14 })]
+    [InlineData (Alignment.Justified, new [] { 3, 4, 5, 6 }, 21, new [] { 0, 4, 9, 15 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 22, new [] { 0, 8, 14, 19 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 23, new [] { 0, 8, 15, 20 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 24, new [] { 0, 8, 15, 21 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 25, new [] { 0, 9, 16, 22 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 26, new [] { 0, 9, 17, 23 })]
+    [InlineData (Alignment.Justified, new [] { 6, 5, 4, 3 }, 31, new [] { 0, 11, 20, 28 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 0 }, 1, new [] { 1 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 1 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1 }, 2, new [] { 1 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1 }, 3, new [] { 2 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 4 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 8, new [] { 0, 1, 5 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 9, new [] { 0, 1, 6 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 10, new [] { 0, 1, 7 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3 }, 11, new [] { 0, 1, 8 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 7 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 1, 3, 8 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 3, 3, 3 }, 21, new [] { 0, 3, 18 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 3, 4, 5 }, 21, new [] { 0, 3, 16 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 67 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10 }, 101, new [] { 91 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10, 20, 30 }, 100, new [] { 0, 10, 70 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10, 20, 30 }, 101, new [] { 0, 10, 71 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
+    [InlineData (Alignment.LastRightRestLeft, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 0 }, 1, new [] { 0 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1 }, 1, new [] { 0 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1 }, 2, new [] { 0 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1 }, 3, new [] { 0 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 8, new [] { 0, 3, 5 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 9, new [] { 0, 4, 6 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 10, new [] { 0, 5, 7 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3 }, 11, new [] { 0, 6, 8 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 3, 5, 8 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 3, 3, 3 }, 21, new [] { 0, 15, 18 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 12, 16 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10 }, 101, new [] { 0 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30 }, 100, new [] { 0, 50, 70 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30 }, 101, new [] { 0, 51, 71 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+    [InlineData (Alignment.FirstLeftRestRight, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+    public void Alignment_NoSpaceBetweenItems (Alignment alignment, int [] sizes, int containerSize, int [] expected)
+    {
+        int [] positions = new Aligner
+        {
+            SpaceBetweenItems = false,
+            Alignment = alignment,
+            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 ();
-    }
-}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 120 - 325
UnitTests/Text/TextFormatterTests.cs


+ 2 - 2
UnitTests/View/DrawTests.cs

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

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

@@ -681,11 +681,11 @@ public class DimAutoTests (ITestOutputHelper output)
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
-        view.TextFormatter.Alignment = TextAlignment.Justified;
+        view.TextFormatter.Alignment = Alignment.Justified;
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
-        view.TextFormatter.VerticalAlignment = VerticalTextAlignment.Middle;
+        view.TextFormatter.VerticalAlignment = Alignment.Centered;
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
@@ -709,11 +709,11 @@ public class DimAutoTests (ITestOutputHelper output)
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
-        view.TextAlignment = TextAlignment.Justified;
+        view.TextAlignment = Alignment.Justified;
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
-        view.VerticalTextAlignment = VerticalTextAlignment.Middle;
+        view.VerticalTextAlignment = Alignment.Centered;
         Assert.False (view.TextFormatter.AutoSize);
         Assert.Equal (Size.Empty, view.Frame.Size);
 
@@ -738,7 +738,7 @@ public class DimAutoTests (ITestOutputHelper output)
         Assert.True (view.TextFormatter.AutoSize);
         Assert.NotEqual (Size.Empty, view.Frame.Size);
 
-        view.TextAlignment = TextAlignment.Justified;
+        view.TextAlignment = Alignment.Justified;
         Assert.True (view.TextFormatter.AutoSize);
         Assert.NotEqual (Size.Empty, view.Frame.Size);
 
@@ -747,7 +747,7 @@ public class DimAutoTests (ITestOutputHelper output)
             Text = "_1234",
             Width = Dim.Auto ()
         };
-        view.VerticalTextAlignment = VerticalTextAlignment.Middle;
+        view.VerticalTextAlignment = Alignment.Centered;
         Assert.True (view.TextFormatter.AutoSize);
         Assert.NotEqual (Size.Empty, view.Frame.Size);
 
@@ -893,7 +893,6 @@ public class DimAutoTests (ITestOutputHelper output)
     [Theory]
     [InlineData (0, 15, 15)]
     [InlineData (1, 15, 16)]
-    [InlineData (0, 15, 15)]
     [InlineData (-1, 15, 14)]
     public void DimAuto_With_Subview_Using_DimAbsolute (int subViewOffset, int dimAbsoluteSize, int expectedSize)
     {

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

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

+ 2 - 2
UnitTests/View/Layout/Dim.Tests.cs

@@ -355,8 +355,8 @@ public class DimTests
         Assert.Equal (99, dimFill.Anchor (100));
 
         var dimCombine = new Dim.DimCombine (true, dimFactor, dimAbsolute);
-        Assert.Equal (dimCombine._left, dimFactor);
-        Assert.Equal (dimCombine._right, dimAbsolute);
+        Assert.Equal (dimCombine.Left, dimFactor);
+        Assert.Equal (dimCombine.Right, dimAbsolute);
         Assert.Equal (20, dimCombine.Anchor (100));
 
         var view = new View { Frame = new Rectangle (20, 10, 20, 1) };

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

@@ -0,0 +1,59 @@
+using Xunit.Abstractions;
+using static Terminal.Gui.Dim;
+using static Terminal.Gui.Pos;
+
+namespace Terminal.Gui.PosDimTests;
+
+public class PosAlignTests ()
+{
+    [Fact]
+    public void PosAlign_Constructor ()
+    {
+        var posAlign = new PosAlign (Alignment.Justified);
+        Assert.NotNull (posAlign);
+    }
+
+    [Theory]
+    [InlineData (Alignment.Left, Alignment.Left, true)]
+    [InlineData (Alignment.Centered, Alignment.Centered, true)]
+    [InlineData (Alignment.Left, Alignment.Centered, false)]
+    [InlineData (Alignment.Centered, Alignment.Left, false)]
+    public void PosAlign_Equals (Alignment align1, Alignment align2, bool expectedEquals)
+    {
+        var posAlign1 = new PosAlign (align1);
+        var posAlign2 = new PosAlign (align2);
+
+        Assert.Equal (expectedEquals, posAlign1.Equals (posAlign2));
+        Assert.Equal (expectedEquals, posAlign2.Equals (posAlign1));
+    }
+
+    [Fact]
+    public void PosAlign_ToString ()
+    {
+        var posAlign = new PosAlign (Alignment.Justified);
+        var expectedString = "Align(groupId=0, alignment=Justified)";
+
+        Assert.Equal (expectedString, posAlign.ToString ());
+    }
+
+    [Fact]
+    public void PosAlign_Anchor ()
+    {
+        var posAlign = new PosAlign (Alignment.Left);
+        var width = 50;
+        var expectedAnchor = -width;
+
+        Assert.Equal (expectedAnchor, posAlign.Anchor (width));
+    }
+
+    [Fact]
+    public void PosAlign_CreatesCorrectInstance ()
+    {
+        var pos = Pos.Align (Alignment.Left);
+        Assert.IsType<PosAlign> (pos);
+    }
+
+    // Tests that test Left alignment
+
+    // 
+}

+ 58 - 62
UnitTests/View/Layout/Pos.Tests.cs

@@ -4,7 +4,7 @@ using static Terminal.Gui.Pos;
 
 namespace Terminal.Gui.PosDimTests;
 
-public class PosTests (ITestOutputHelper output)
+public class PosTests ()
 {
     // Was named AutoSize_Pos_Validation_Do_Not_Throws_If_NewValue_Is_PosAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute ()
     // but doesn't actually have anything to do with AutoSize.
@@ -110,7 +110,7 @@ public class PosTests (ITestOutputHelper output)
     {
         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 f = new FrameView ();
@@ -225,13 +225,13 @@ public class PosTests (ITestOutputHelper output)
         Assert.Equal (10, posAbsolute.Anchor (0));
 
         var posCombine = new Pos.PosCombine (true, posFactor, posAbsolute);
-        Assert.Equal (posCombine._left, posFactor);
-        Assert.Equal (posCombine._right, posAbsolute);
+        Assert.Equal (posCombine.LeftPos, posFactor);
+        Assert.Equal (posCombine.RightPos, posAbsolute);
         Assert.Equal (20, posCombine.Anchor (100));
 
         posCombine = new (true, posAbsolute, posFactor);
-        Assert.Equal (posCombine._left, posAbsolute);
-        Assert.Equal (posCombine._right, posFactor);
+        Assert.Equal (posCombine.LeftPos, posAbsolute);
+        Assert.Equal (posCombine.RightPos, posFactor);
         Assert.Equal (20, posCombine.Anchor (100));
 
         var view = new View { Frame = new (20, 10, 20, 1) };
@@ -254,6 +254,32 @@ public class PosTests (ITestOutputHelper output)
     [TestRespondersDisposed]
     public void LeftTopBottomRight_Win_ShouldNotThrow ()
     {
+        // Setup Fake driver
+        (Toplevel top, Window win, Button button) Setup ()
+        {
+            Application.Init (new FakeDriver ());
+            Application.Iteration += (s, a) => { Application.RequestStop (); };
+            var win = new Window { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill () };
+            var top = new Toplevel ();
+            top.Add (win);
+
+            var button = new Button { X = Pos.Center (), Text = "button" };
+            win.Add (button);
+
+            return (top, win, button);
+        }
+
+        void Cleanup (RunState rs)
+        {
+            // Cleanup
+            Application.End (rs);
+
+            Application.Top.Dispose ();
+
+            // Shutdown must be called to safely clean up Application if Init has been called
+            Application.Shutdown ();
+        }
+
         // Test cases:
         (Toplevel top, Window win, Button button) app = Setup ();
         app.button.Y = Pos.Left (app.win);
@@ -302,34 +328,6 @@ public class PosTests (ITestOutputHelper output)
         // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
         Application.RunLoop (rs);
         Cleanup (rs);
-
-        return;
-
-        void Cleanup (RunState rs)
-        {
-            // Cleanup
-            Application.End (rs);
-
-            Application.Top.Dispose ();
-
-            // Shutdown must be called to safely clean up Application if Init has been called
-            Application.Shutdown ();
-        }
-
-        // Setup Fake driver
-        (Toplevel top, Window win, Button button) Setup ()
-        {
-            Application.Init (new FakeDriver ());
-            Application.Iteration += (s, a) => { Application.RequestStop (); };
-            var win = new Window { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill () };
-            var top = new Toplevel ();
-            top.Add (win);
-
-            var button = new Button { X = Pos.Center (), Text = "button" };
-            win.Add (button);
-
-            return (top, win, button);
-        }
     }
 
     [Fact]
@@ -548,15 +546,15 @@ public class PosTests (ITestOutputHelper output)
         pos = Pos.Left (new ());
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
-        pos = Pos.Left (new() { Frame = testRect });
+        pos = Pos.Left (new () { Frame = testRect });
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
         testRect = new (1, 2, 3, 4);
-        pos = Pos.Left (new() { Frame = testRect });
+        pos = Pos.Left (new () { Frame = testRect });
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
         // Pos.Left(win) + 0
-        pos = Pos.Left (new() { Frame = testRect }) + testInt;
+        pos = Pos.Left (new () { Frame = testRect }) + testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -566,7 +564,7 @@ public class PosTests (ITestOutputHelper output)
         testInt = 1;
 
         // Pos.Left(win) +1
-        pos = Pos.Left (new() { Frame = testRect }) + testInt;
+        pos = Pos.Left (new () { Frame = testRect }) + testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -576,7 +574,7 @@ public class PosTests (ITestOutputHelper output)
         testInt = -1;
 
         // Pos.Left(win) -1
-        pos = Pos.Left (new() { Frame = testRect }) - testInt;
+        pos = Pos.Left (new () { Frame = testRect }) - testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -590,15 +588,15 @@ public class PosTests (ITestOutputHelper output)
         pos = Pos.X (new ());
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
-        pos = Pos.X (new() { Frame = testRect });
+        pos = Pos.X (new () { Frame = testRect });
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
         testRect = new (1, 2, 3, 4);
-        pos = Pos.X (new() { Frame = testRect });
+        pos = Pos.X (new () { Frame = testRect });
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
         // Pos.X(win) + 0
-        pos = Pos.X (new() { Frame = testRect }) + testInt;
+        pos = Pos.X (new () { Frame = testRect }) + testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -608,7 +606,7 @@ public class PosTests (ITestOutputHelper output)
         testInt = 1;
 
         // Pos.X(win) +1
-        pos = Pos.X (new() { Frame = testRect }) + testInt;
+        pos = Pos.X (new () { Frame = testRect }) + testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -618,7 +616,7 @@ public class PosTests (ITestOutputHelper output)
         testInt = -1;
 
         // Pos.X(win) -1
-        pos = Pos.X (new() { Frame = testRect }) - testInt;
+        pos = Pos.X (new () { Frame = testRect }) - testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -632,15 +630,15 @@ public class PosTests (ITestOutputHelper output)
         pos = Pos.Top (new ());
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
-        pos = Pos.Top (new() { Frame = testRect });
+        pos = Pos.Top (new () { Frame = testRect });
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
         testRect = new (1, 2, 3, 4);
-        pos = Pos.Top (new() { Frame = testRect });
+        pos = Pos.Top (new () { Frame = testRect });
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
         // Pos.Top(win) + 0
-        pos = Pos.Top (new() { Frame = testRect }) + testInt;
+        pos = Pos.Top (new () { Frame = testRect }) + testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -650,7 +648,7 @@ public class PosTests (ITestOutputHelper output)
         testInt = 1;
 
         // Pos.Top(win) +1
-        pos = Pos.Top (new() { Frame = testRect }) + testInt;
+        pos = Pos.Top (new () { Frame = testRect }) + testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -660,7 +658,7 @@ public class PosTests (ITestOutputHelper output)
         testInt = -1;
 
         // Pos.Top(win) -1
-        pos = Pos.Top (new() { Frame = testRect }) - testInt;
+        pos = Pos.Top (new () { Frame = testRect }) - testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -674,15 +672,15 @@ public class PosTests (ITestOutputHelper output)
         pos = Pos.Y (new ());
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
-        pos = Pos.Y (new() { Frame = testRect });
+        pos = Pos.Y (new () { Frame = testRect });
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
         testRect = new (1, 2, 3, 4);
-        pos = Pos.Y (new() { Frame = testRect });
+        pos = Pos.Y (new () { Frame = testRect });
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
         // Pos.Y(win) + 0
-        pos = Pos.Y (new() { Frame = testRect }) + testInt;
+        pos = Pos.Y (new () { Frame = testRect }) + testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -692,7 +690,7 @@ public class PosTests (ITestOutputHelper output)
         testInt = 1;
 
         // Pos.Y(win) +1
-        pos = Pos.Y (new() { Frame = testRect }) + testInt;
+        pos = Pos.Y (new () { Frame = testRect }) + testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -702,7 +700,7 @@ public class PosTests (ITestOutputHelper output)
         testInt = -1;
 
         // Pos.Y(win) -1
-        pos = Pos.Y (new() { Frame = testRect }) - testInt;
+        pos = Pos.Y (new () { Frame = testRect }) - testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -716,15 +714,15 @@ public class PosTests (ITestOutputHelper output)
         pos = Pos.Bottom (new ());
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
-        pos = Pos.Bottom (new() { Frame = testRect });
+        pos = Pos.Bottom (new () { Frame = testRect });
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
         testRect = new (1, 2, 3, 4);
-        pos = Pos.Bottom (new() { Frame = testRect });
+        pos = Pos.Bottom (new () { Frame = testRect });
         Assert.Equal ($"View(side={side},target=View(){testRect})", pos.ToString ());
 
         // Pos.Bottom(win) + 0
-        pos = Pos.Bottom (new() { Frame = testRect }) + testInt;
+        pos = Pos.Bottom (new () { Frame = testRect }) + testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -734,7 +732,7 @@ public class PosTests (ITestOutputHelper output)
         testInt = 1;
 
         // Pos.Bottom(win) +1
-        pos = Pos.Bottom (new() { Frame = testRect }) + testInt;
+        pos = Pos.Bottom (new () { Frame = testRect }) + testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -744,7 +742,7 @@ public class PosTests (ITestOutputHelper output)
         testInt = -1;
 
         // Pos.Bottom(win) -1
-        pos = Pos.Bottom (new() { Frame = testRect }) - testInt;
+        pos = Pos.Bottom (new () { Frame = testRect }) - testInt;
 
         Assert.Equal (
                       $"Combine(View(side={side},target=View(){testRect}){(testInt < 0 ? '-' : '+')}Absolute({testInt}))",
@@ -878,7 +876,6 @@ public class PosTests (ITestOutputHelper output)
     [SetupFakeDriver]
     public void PosCombine_DimCombine_View_With_SubViews ()
     {
-        var clicked = false;
         Toplevel top = new Toplevel () { Width = 80, Height = 25 };
         var win1 = new Window { Id = "win1", Width = 20, Height = 10 };
         var view1 = new View
@@ -887,10 +884,9 @@ public class PosTests (ITestOutputHelper output)
             Width = Auto (DimAutoStyle.Text),
             Height = Auto (DimAutoStyle.Text)
 
-        }; 
+        };
         var win2 = new Window { Id = "win2", Y = Pos.Bottom (view1) + 1, Width = 10, Height = 3 };
         var view2 = new View { Id = "view2", Width = Dim.Fill (), Height = 1, CanFocus = true };
-        view2.MouseClick += (sender, e) => clicked = true;
         var view3 = new View { Id = "view3", Width = Dim.Fill (1), Height = 1, CanFocus = true };
 
         view2.Add (view3);

+ 1 - 1
UnitTests/View/NeedsDisplayTests.cs

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

+ 6 - 6
UnitTests/View/Text/AutoSizeTrueTests.cs

@@ -1811,7 +1811,7 @@ Y
             Y = 1,
             Width = width,
             Height = 1,
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
         };
 
         if (autoSize)
@@ -1826,7 +1826,7 @@ Y
             Y = 2,
             Width = width,
             Height = 1,
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
         };
         if (autoSize)
         {
@@ -1840,7 +1840,7 @@ Y
             Y = 3,
             Width = width,
             Height = 1,
-            TextAlignment = TextAlignment.Justified,
+            TextAlignment = Alignment.Justified,
         };
         if (autoSize)
         {
@@ -1937,7 +1937,7 @@ Y
             Width = 1,
             Height = height,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Middle
+            VerticalTextAlignment = Alignment.Centered
         };
         if (autoSize)
         {
@@ -1952,7 +1952,7 @@ Y
             Width = 1,
             Height = height,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Bottom
+            VerticalTextAlignment = Alignment.Bottom
         };
         if (autoSize)
         {
@@ -1967,7 +1967,7 @@ Y
             Width = 1,
             Height = height,
             TextDirection = TextDirection.TopBottom_LeftRight,
-            VerticalTextAlignment = VerticalTextAlignment.Justified
+            VerticalTextAlignment = Alignment.Justified
         };
         if (autoSize)
         {

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

+ 9 - 9
UnitTests/Views/CheckBoxTests.cs

@@ -251,7 +251,7 @@ public class CheckBoxTests
             X = 1,
             Y = Pos.Center (),
             Text = "Check this out 你",
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 25
         };
         var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
@@ -262,7 +262,7 @@ public class CheckBoxTests
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 
-        Assert.Equal (TextAlignment.Centered, checkBox.TextAlignment);
+        Assert.Equal (Alignment.Centered, checkBox.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
         Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
 
@@ -301,7 +301,7 @@ public class CheckBoxTests
             X = 1,
             Y = Pos.Center (),
             Text = "Check first out 你",
-            TextAlignment = TextAlignment.Justified,
+            TextAlignment = Alignment.Justified,
             Width = 25
         };
 
@@ -310,7 +310,7 @@ public class CheckBoxTests
             X = 1,
             Y = Pos.Bottom (checkBox1),
             Text = "Check second out 你",
-            TextAlignment = TextAlignment.Justified,
+            TextAlignment = Alignment.Justified,
             Width = 25
         };
         var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
@@ -321,9 +321,9 @@ public class CheckBoxTests
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 6);
 
-        Assert.Equal (TextAlignment.Justified, checkBox1.TextAlignment);
+        Assert.Equal (Alignment.Justified, checkBox1.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
-        Assert.Equal (TextAlignment.Justified, checkBox2.TextAlignment);
+        Assert.Equal (Alignment.Justified, checkBox2.TextAlignment);
         Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
  
         var expected = @$"
@@ -378,7 +378,7 @@ public class CheckBoxTests
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 
-        Assert.Equal (TextAlignment.Left, checkBox.TextAlignment);
+        Assert.Equal (Alignment.Left, checkBox.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
         Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
 
@@ -417,7 +417,7 @@ public class CheckBoxTests
             X = 1,
             Y = Pos.Center (),
             Text = "Check this out 你",
-            TextAlignment = TextAlignment.Right,
+            TextAlignment = Alignment.Right,
             Width = 25
         };
         var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
@@ -428,7 +428,7 @@ public class CheckBoxTests
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 
-        Assert.Equal (TextAlignment.Right, checkBox.TextAlignment);
+        Assert.Equal (Alignment.Right, checkBox.TextAlignment);
         Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
         Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
 

+ 1 - 1
UnitTests/Views/LabelTests.cs

@@ -206,7 +206,7 @@ public class LabelTests
     {
         var label = new Label ();
         Assert.Equal (string.Empty, label.Text);
-        Assert.Equal (TextAlignment.Left, label.TextAlignment);
+        Assert.Equal (Alignment.Left, label.TextAlignment);
         Assert.False (label.CanFocus);
         Assert.Equal (new Rectangle (0, 0, 0, 0), label.Frame);
         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
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             ****
@@ -44,7 +44,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Left,
+            TextAlignment = Alignment.Left,
             Width = 30,
 
             //                                             ****
@@ -81,7 +81,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             ****
@@ -115,7 +115,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             *
@@ -137,7 +137,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             *
@@ -161,7 +161,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             ****
@@ -179,7 +179,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             ****
@@ -196,7 +196,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             ****
@@ -214,7 +214,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             *
@@ -233,7 +233,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             *
@@ -253,7 +253,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             ** **
@@ -283,7 +283,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             *
@@ -308,7 +308,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Left,
+            TextAlignment = Alignment.Left,
             Width = 30,
 
             //                                             ****
@@ -338,7 +338,7 @@ public class TextValidateField_NET_Provider_Tests
 
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Left, Width = 30, Provider = new NetMaskedTextProvider ("--(0000)--")
+            TextAlignment = Alignment.Left, Width = 30, Provider = new NetMaskedTextProvider ("--(0000)--")
         };
 
         field.Provider.TextChanged += (sender, e) => wasTextChanged = true;
@@ -356,7 +356,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             *
@@ -381,7 +381,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Left,
+            TextAlignment = Alignment.Left,
             Width = 30,
 
             //                                             ****
@@ -400,7 +400,7 @@ public class TextValidateField_NET_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
 
             //                                             ****
@@ -540,7 +540,7 @@ public class TextValidateField_Regex_Provider_Tests
     {
         var field = new TextValidateField
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
             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
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
             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
         {
-            TextAlignment = TextAlignment.Centered,
+            TextAlignment = Alignment.Centered,
             Width = 20,
             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 (),
                         Width = Dim.Fill (),
                         Height = Dim.Fill (),
-                        TextAlignment = TextAlignment.Centered,
-                        VerticalTextAlignment = VerticalTextAlignment.Middle,
+                        TextAlignment = Alignment.Centered,
+                        VerticalTextAlignment = Alignment.Centered,
                         Text = "Test"
                     }
                    );

+ 1 - 0
docfx/docs/layout.md

@@ -66,6 +66,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()`.
 * Centered, using `Pos.Center()`.
 * 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.
 

+ 11 - 1
docfx/docs/migratingfromv1.md

@@ -231,4 +231,14 @@ Replace references to to nested types with the new standalone version
 ```diff
 - var myTab = new TabView.Tab();
 + var myTab = new Tab();
-```
+```
+
+## View and Text Alignment is now Justification
+
+In v1, both `TextAlignment` and `VerticalTextAlignment` enums were used to align text in views. In v2, these enums have been replaced with the `Alignment` enum. The `View.TextAlignment` property controls horizontal text alignment, and the `View.VerticalTextAlignment` property controls vertical text alignment.
+
+v2 now supports `Pos.Align` which enables views to be justified within their superview. 
+
+### How to Fix
+
+* Replace `VerticalAlignment.Middle` is now `Alignment.Center`. 

+ 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.
 * *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.
-* *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.
 
 ## 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.
 
-## View Improvements
+## `View` Improvements
 
 * *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`* - 
+  * 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

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov