From 4ed5ed8bb68f54876c0bf4b6840c28709145c416 Mon Sep 17 00:00:00 2001 From: Tig Date: Wed, 17 Apr 2024 12:51:19 -0600 Subject: [PATCH 001/173] Initial commit. Just a prototype --- Terminal.Gui/View/Layout/PosDim.cs | 206 ++++++++++++++++----- Terminal.Gui/View/Layout/ViewLayout.cs | 1 + Terminal.Gui/Views/Dialog.cs | 29 +-- Terminal.Gui/Views/TextView.cs | 5 +- Terminal.Gui/Views/Wizard/Wizard.cs | 2 +- UICatalog/Scenarios/ComputedLayout.cs | 25 +-- UICatalog/Scenarios/Dialogs.cs | 2 +- UnitTests/Configuration/ThemeScopeTests.cs | 6 +- UnitTests/Configuration/ThemeTests.cs | 6 +- UnitTests/Dialogs/DialogTests.cs | 86 ++++----- 10 files changed, 235 insertions(+), 133 deletions(-) diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs index 4438fb844d..f94209390e 100644 --- a/Terminal.Gui/View/Layout/PosDim.cs +++ b/Terminal.Gui/View/Layout/PosDim.cs @@ -1,4 +1,22 @@ -namespace Terminal.Gui; +using static Terminal.Gui.Dialog; + +namespace Terminal.Gui; + +/// Determines the horizontal alignment of Views. +public enum ViewAlignments +{ + /// Center-aligns the buttons (the default). + Center = 0, + + /// Justifies the buttons + Justify, + + /// Left-aligns the buttons + Left, + + /// Right-aligns the buttons + Right +} /// /// Describes the position of a which can be an absolute value, a percentage, centered, or @@ -169,14 +187,6 @@ public static Pos AnchorEnd (int offset) /// The value to convert to the . public static Pos At (int n) { return new PosAbsolute (n); } - /// - /// Creates a object that tracks the Bottom (Y+Height) coordinate of the specified - /// - /// - /// The that depends on the other view. - /// The that will be tracked. - public static Pos Bottom (View view) { return new PosView (view, Side.Bottom); } - /// Creates a object that can be used to center the . /// The center Pos. /// @@ -193,6 +203,12 @@ public static Pos AnchorEnd (int offset) /// public static Pos Center () { return new PosCenter (); } + public static Pos Justify (View[] views, ViewAlignments alignment) + { + return new PosJustify (views, alignment); + } + + /// Determines whether the specified object is equal to the current object. /// The object to compare with the current object. /// @@ -213,11 +229,6 @@ public static Pos AnchorEnd (int offset) /// A hash code for the current object. public override int GetHashCode () { return Anchor (0).GetHashCode (); } - /// Creates a object that tracks the Left (X) position of the specified . - /// The that depends on the other view. - /// The that will be tracked. - public static Pos Left (View view) { return new PosView (view, Side.X); } - /// Adds a to a , yielding a new . /// The first to add. /// The second to add. @@ -293,28 +304,41 @@ public static Pos Percent (float percent) return new PosFactor (percent / 100); } - /// - /// Creates a object that tracks the Right (X+Width) coordinate of the specified - /// . - /// + /// Creates a object that tracks the Top (Y) position of the specified . /// The that depends on the other view. /// The that will be tracked. - public static Pos Right (View view) { return new PosView (view, Side.Right); } + public static Pos Top (View view) { return new PosView (view, Side.Y); } /// Creates a object that tracks the Top (Y) position of the specified . /// The that depends on the other view. /// The that will be tracked. - public static Pos Top (View view) { return new PosView (view, Side.Y); } + public static Pos Y (View view) { return new PosView (view, Side.Y); } + + /// Creates a object that tracks the Left (X) position of the specified . + /// The that depends on the other view. + /// The that will be tracked. + public static Pos Left (View view) { return new PosView (view, Side.X); } /// Creates a object that tracks the Left (X) position of the specified . /// The that depends on the other view. /// The that will be tracked. public static Pos X (View view) { return new PosView (view, Side.X); } - /// Creates a object that tracks the Top (Y) position of the specified . + /// + /// Creates a object that tracks the Bottom (Y+Height) coordinate of the specified + /// + /// /// The that depends on the other view. /// The that will be tracked. - public static Pos Y (View view) { return new PosView (view, Side.Y); } + public static Pos Bottom (View view) { return new PosView (view, Side.Bottom); } + + /// + /// Creates a object that tracks the Right (X+Width) coordinate of the specified + /// . + /// + /// The that depends on the other view. + /// The that will be tracked. + public static Pos Right (View view) { return new PosView (view, Side.Right); } /// /// Gets a position that is anchored to a certain point in the layout. This method is typically used @@ -460,7 +484,7 @@ internal class PosFunc (Func n) : Pos internal override int Anchor (int width) { return _function (); } } - internal enum Side + public enum Side { X = 0, Y = 1, @@ -478,13 +502,13 @@ internal class PosView (View view, Side side) : Pos public override string ToString () { string sideString = side switch - { - Side.X => "x", - Side.Y => "y", - Side.Right => "right", - Side.Bottom => "bottom", - _ => "unknown" - }; + { + Side.X => "x", + Side.Y => "y", + Side.Right => "right", + Side.Bottom => "bottom", + _ => "unknown" + }; if (Target == null) { @@ -497,14 +521,100 @@ public override string ToString () internal override int Anchor (int width) { return side switch - { - Side.X => Target.Frame.X, - Side.Y => Target.Frame.Y, - Side.Right => Target.Frame.Right, - Side.Bottom => Target.Frame.Bottom, - _ => 0 - }; + { + Side.X => Target.Frame.X, + Side.Y => Target.Frame.Y, + Side.Right => Target.Frame.Right, + Side.Bottom => Target.Frame.Bottom, + _ => 0 + }; + } + } + + + /// + /// Enables justification of a set of views. + /// + public class PosJustify : Pos + { + private readonly View [] _views; + private readonly ViewAlignments _alignment; + + /// + /// Enables justification of a set of views. + /// + /// The set of views to justify according to . + /// + public PosJustify (View [] views, ViewAlignments alignment) + { + _alignment = alignment; + _views = views; } + + public override bool Equals (object other) + { + return other is PosJustify justify && justify._views == _views && justify._alignment == _alignment; + } + + public override int GetHashCode () { return _views.GetHashCode (); } + + + public override string ToString () + { + return $"Justify(views={_views},alignment={_alignment})"; + } + + internal override int Anchor (int width) + { + if (_views.Length == 0 || !_views [0].IsInitialized) + { + return 0; + } + int spacing = 0; + switch (_alignment) + { + case ViewAlignments.Center: + // Center spacing is sum of the widths of the views - width / number of views + spacing = (width - _views.Select (v => v.Frame.Width).Sum ()) / _views.Length; + + // How do I know which view we are? + View us = _views.Where (v => v.X.Equals (this)).First(); + + if (_views [0] == us) + { + return spacing; + } + // Calculate the position of the previous (left or above us) view + int previous = _views.Where (v => v.X.Equals (us)).First().Frame.Left; + + return previous + spacing; + //case ViewAlignments.Left: + // return Left (width); + //case ViewAlignments.Right: + // return Right (width); + //case ViewAlignments.Justify: + // return Justify (width); + default: + return 0; + + } + } + + //internal override int Calculate (int superviewDimension, Dim dim, int autosize, bool autoSize) + //{ + // // Assuming autosize is the size that the View would have if it were to automatically adjust its size based on its content + // // and autoSize is a boolean value that indicates whether the View should automatically adjust its size based on its content + // if (autoSize) + // { + // return autosize; + // } + // else + // { + // // Assuming dim.Calculate returns the calculated size of the View + // return dim.Calculate (_views.Frame.Left, _views.Frame.Width, autosize, autoSize); + // } + //} + } } @@ -822,7 +932,7 @@ internal class DimFunc (Func n) : Dim internal override int Anchor (int width) { return _function (); } } - internal enum Side + public enum Side { Height = 0, Width = 1 @@ -850,11 +960,11 @@ public override string ToString () } string sideString = _side switch - { - Side.Height => "Height", - Side.Width => "Width", - _ => "unknown" - }; + { + Side.Height => "Height", + Side.Width => "Width", + _ => "unknown" + }; return $"View({sideString},{Target})"; } @@ -862,11 +972,11 @@ public override string ToString () internal override int Anchor (int width) { return _side switch - { - Side.Height => Target.Frame.Height, - Side.Width => Target.Frame.Width, - _ => 0 - }; + { + Side.Height => Target.Frame.Height, + Side.Width => Target.Frame.Width, + _ => 0 + }; } } } diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 1afa0994bf..5c6f0cc648 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -33,6 +33,7 @@ public enum LayoutStyle Computed } + public partial class View { #region Frame diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index 46787265e2..cd859ac0bc 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -15,21 +15,6 @@ namespace Terminal.Gui; /// public class Dialog : Window { - /// Determines the horizontal alignment of the Dialog buttons. - public enum ButtonAlignments - { - /// Center-aligns the buttons (the default). - Center = 0, - - /// Justifies the buttons - Justify, - - /// Left-aligns the buttons - Left, - - /// Right-aligns the buttons - Right - } // TODO: Reenable once border/borderframe design is settled /// @@ -109,7 +94,7 @@ public bool Canceled } /// Determines how the s are aligned along the bottom of the dialog. - public ButtonAlignments ButtonAlignment { get; set; } + public ViewAlignments ButtonAlignment { get; set; } /// Optional buttons to lay out at the bottom of the dialog. public Button [] Buttons @@ -129,11 +114,11 @@ public Button [] Buttons } } - /// The default for . + /// The default for . /// This property can be set in a Theme. [SerializableConfigurationProperty (Scope = typeof (ThemeScope))] [JsonConverter (typeof (JsonStringEnumConverter))] - public static ButtonAlignments DefaultButtonAlignment { get; set; } = ButtonAlignments.Center; + public static ViewAlignments DefaultButtonAlignment { get; set; } = ViewAlignments.Center; /// /// Adds a to the , its layout will be controlled by the @@ -200,7 +185,7 @@ private void LayoutButtons () switch (ButtonAlignment) { - case ButtonAlignments.Center: + case ViewAlignments.Center: // Center Buttons shiftLeft = (Viewport.Width - buttonsWidth - _buttons.Count - 1) / 2 + 1; @@ -223,7 +208,7 @@ private void LayoutButtons () break; - case ButtonAlignments.Justify: + case ViewAlignments.Justify: // Justify Buttons // leftmost and rightmost buttons are hard against edges. The rest are evenly spaced. @@ -258,7 +243,7 @@ private void LayoutButtons () break; - case ButtonAlignments.Left: + case ViewAlignments.Left: // Left Align Buttons Button prevButton = _buttons [0]; prevButton.X = 0; @@ -274,7 +259,7 @@ private void LayoutButtons () break; - case ButtonAlignments.Right: + case ViewAlignments.Right: // Right align buttons shiftLeft = _buttons [_buttons.Count - 1].Frame.Width; _buttons [_buttons.Count - 1].X = Pos.AnchorEnd (shiftLeft); diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index a20b4cbbc4..12cdc5961f 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -4180,7 +4180,10 @@ private void Adjust () } else { - PositionCursor (); + if (IsInitialized) + { + PositionCursor (); + } } OnUnwrappedCursorPosition (); diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index c3691b3e12..eddef7f4c5 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -85,7 +85,7 @@ public Wizard () { // Using Justify causes the Back and Next buttons to be hard justified against // the left and right edge - ButtonAlignment = ButtonAlignments.Justify; + ButtonAlignment = ViewAlignments.Justify; BorderStyle = LineStyle.Double; //// Add a horiz separator diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index c8013c46ac..fea26eab98 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/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; @@ -332,13 +333,13 @@ public override void Main () // This is intentionally convoluted to illustrate potential bugs. var anchorEndLabel1 = new Label { - Text = "This Label should be the 2nd to last line (AnchorEnd (2)).", + Text = "This Label should be the 3rd to last line (AnchorEnd (3)).", TextAlignment = TextAlignment.Centered, ColorScheme = Colors.ColorSchemes ["Menu"], AutoSize = false, Width = Dim.Fill (5), X = 5, - Y = Pos.AnchorEnd (2) + Y = Pos.AnchorEnd (3) }; app.Add (anchorEndLabel1); @@ -347,20 +348,19 @@ public override void Main () var anchorEndLabel2 = new TextField { Text = - "This TextField should be the 3rd to last line (AnchorEnd (2) - 1).", + "This TextField should be the 4th to last line (AnchorEnd (3) - 1).", TextAlignment = TextAlignment.Left, ColorScheme = Colors.ColorSchemes ["Menu"], AutoSize = false, 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) => @@ -376,7 +376,7 @@ public override void Main () // 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) => @@ -402,14 +402,17 @@ public override void Main () 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 5 spaces between them + leftButton.X = Pos.Justify (buttons, ViewAlignments.Center); + centerButton.X = Pos.Justify (buttons, ViewAlignments.Center); + rightButton.X = Pos.Justify (buttons, ViewAlignments.Center); + Application.Run (app); app.Dispose (); } diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs index fa8cacd216..cc23993177 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -265,7 +265,7 @@ Label buttonPressedLabel dialog = new Dialog { Title = titleEdit.Text, - ButtonAlignment = (Dialog.ButtonAlignments)styleRadioGroup.SelectedItem, + ButtonAlignment = (ViewAlignments)styleRadioGroup.SelectedItem, Buttons = buttons.ToArray () }; diff --git a/UnitTests/Configuration/ThemeScopeTests.cs b/UnitTests/Configuration/ThemeScopeTests.cs index 3da7f881a8..b22ae60eee 100644 --- a/UnitTests/Configuration/ThemeScopeTests.cs +++ b/UnitTests/Configuration/ThemeScopeTests.cs @@ -29,12 +29,12 @@ public void Apply_ShouldApplyUpdatedProperties () { Reset (); Assert.NotEmpty (Themes); - Assert.Equal (Dialog.ButtonAlignments.Center, Dialog.DefaultButtonAlignment); + Assert.Equal (ViewAlignments.Center, Dialog.DefaultButtonAlignment); - Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = Dialog.ButtonAlignments.Right; + Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = ViewAlignments.Right; ThemeManager.Themes! [ThemeManager.SelectedTheme]!.Apply (); - Assert.Equal (Dialog.ButtonAlignments.Right, Dialog.DefaultButtonAlignment); + Assert.Equal (ViewAlignments.Right, Dialog.DefaultButtonAlignment); Reset (); } diff --git a/UnitTests/Configuration/ThemeTests.cs b/UnitTests/Configuration/ThemeTests.cs index f7d8c732fd..c9c2ba2bb6 100644 --- a/UnitTests/Configuration/ThemeTests.cs +++ b/UnitTests/Configuration/ThemeTests.cs @@ -77,15 +77,15 @@ public void TestApply_UpdatesColors () public void TestSerialize_RoundTrip () { var theme = new ThemeScope (); - theme ["Dialog.DefaultButtonAlignment"].PropertyValue = Dialog.ButtonAlignments.Right; + theme ["Dialog.DefaultButtonAlignment"].PropertyValue = ViewAlignments.Right; string json = JsonSerializer.Serialize (theme, _jsonOptions); var deserialized = JsonSerializer.Deserialize (json, _jsonOptions); Assert.Equal ( - Dialog.ButtonAlignments.Right, - (Dialog.ButtonAlignments)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue + ViewAlignments.Right, + (ViewAlignments)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue ); Reset (); } diff --git a/UnitTests/Dialogs/DialogTests.cs b/UnitTests/Dialogs/DialogTests.cs index 6c7eb754a1..f74ea5b122 100644 --- a/UnitTests/Dialogs/DialogTests.cs +++ b/UnitTests/Dialogs/DialogTests.cs @@ -32,7 +32,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonAlignment = Dialog.ButtonAlignments.Center, + ButtonAlignment = ViewAlignments.Center, Buttons = [new Button { Text = btn1Text }] }; @@ -57,7 +57,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonAlignment = Dialog.ButtonAlignments.Justify, + ButtonAlignment = ViewAlignments.Justify, Buttons = [new Button { Text = btn1Text }] }; @@ -82,7 +82,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonAlignment = Dialog.ButtonAlignments.Right, + ButtonAlignment = ViewAlignments.Right, Buttons = [new Button { Text = btn1Text }] }; @@ -107,7 +107,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonAlignment = Dialog.ButtonAlignments.Left, + ButtonAlignment = ViewAlignments.Left, Buttons = [new Button { Text = btn1Text }] }; @@ -155,7 +155,7 @@ public void ButtonAlignment_Four () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -172,7 +172,7 @@ public void ButtonAlignment_Four () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -189,7 +189,7 @@ public void ButtonAlignment_Four () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -206,7 +206,7 @@ public void ButtonAlignment_Four () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -248,7 +248,7 @@ public void ButtonAlignment_Four_On_Too_Small_Width () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -280,7 +280,7 @@ public void ButtonAlignment_Four_On_Too_Small_Width () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -296,7 +296,7 @@ public void ButtonAlignment_Four_On_Too_Small_Width () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -312,7 +312,7 @@ public void ButtonAlignment_Four_On_Too_Small_Width () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -353,7 +353,7 @@ public void ButtonAlignment_Four_WideOdd () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -370,7 +370,7 @@ public void ButtonAlignment_Four_WideOdd () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -387,7 +387,7 @@ public void ButtonAlignment_Four_WideOdd () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -404,7 +404,7 @@ public void ButtonAlignment_Four_WideOdd () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -447,7 +447,7 @@ public void ButtonAlignment_Four_Wider () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -464,7 +464,7 @@ public void ButtonAlignment_Four_Wider () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -481,7 +481,7 @@ public void ButtonAlignment_Four_Wider () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -498,7 +498,7 @@ public void ButtonAlignment_Four_Wider () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -530,7 +530,7 @@ public void ButtonAlignment_One () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btnText } ); @@ -547,7 +547,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -562,7 +562,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -577,7 +577,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -594,7 +594,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -609,7 +609,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -624,7 +624,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -639,7 +639,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -673,7 +673,7 @@ public void ButtonAlignment_Three () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -689,7 +689,7 @@ public void ButtonAlignment_Three () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -705,7 +705,7 @@ public void ButtonAlignment_Three () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -721,7 +721,7 @@ public void ButtonAlignment_Three () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -755,7 +755,7 @@ public void ButtonAlignment_Two () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -770,7 +770,7 @@ public void ButtonAlignment_Two () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -785,7 +785,7 @@ public void ButtonAlignment_Two () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -800,7 +800,7 @@ public void ButtonAlignment_Two () (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -837,7 +837,7 @@ public void ButtonAlignment_Two_Hidden () // Default (Center) button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, button1, button2); + (runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Center, button1, button2); button1.Visible = false; RunIteration (ref runstate, ref firstIteration); buttonRow = $@"{CM.Glyphs.VLine} {btn2} {CM.Glyphs.VLine}"; @@ -849,7 +849,7 @@ public void ButtonAlignment_Two_Hidden () Assert.Equal (width, buttonRow.Length); button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, button1, button2); + (runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Justify, button1, button2); button1.Visible = false; RunIteration (ref runstate, ref firstIteration); buttonRow = $@"{CM.Glyphs.VLine} {btn2}{CM.Glyphs.VLine}"; @@ -861,7 +861,7 @@ public void ButtonAlignment_Two_Hidden () Assert.Equal (width, buttonRow.Length); button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, button1, button2); + (runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Right, button1, button2); button1.Visible = false; RunIteration (ref runstate, ref firstIteration); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -872,7 +872,7 @@ public void ButtonAlignment_Two_Hidden () Assert.Equal (width, buttonRow.Length); button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, button1, button2); + (runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Left, button1, button2); button1.Visible = false; RunIteration (ref runstate, ref firstIteration); buttonRow = $@"{CM.Glyphs.VLine} {btn2} {CM.Glyphs.VLine}"; @@ -1301,7 +1301,7 @@ public void One_Button_Works () (runstate, Dialog _) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -1347,7 +1347,7 @@ public void Zero_Buttons_Works () int width = buttonRow.Length; d.SetBufferSize (buttonRow.Length, 3); - (runstate, Dialog _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, null); + (runstate, Dialog _) = RunButtonTestDialog (title, width, ViewAlignments.Center, null); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); End (runstate); @@ -1356,7 +1356,7 @@ public void Zero_Buttons_Works () private (RunState, Dialog) RunButtonTestDialog ( string title, int width, - Dialog.ButtonAlignments align, + ViewAlignments align, params Button [] btns ) { From f2a16dc1a3f68e33914da8eef073ee239c720d9e Mon Sep 17 00:00:00 2001 From: Tig Date: Fri, 19 Apr 2024 11:39:16 -0600 Subject: [PATCH 002/173] Added Justifier class with robust unit tests --- Terminal.Gui/Drawing/Justification.cs | 170 ++++++++++++++++++++ Terminal.sln.DotSettings | 1 + UnitTests/Drawing/JustifierTests.cs | 220 ++++++++++++++++++++++++++ 3 files changed, 391 insertions(+) create mode 100644 Terminal.Gui/Drawing/Justification.cs create mode 100644 UnitTests/Drawing/JustifierTests.cs diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs new file mode 100644 index 0000000000..88d63fb292 --- /dev/null +++ b/Terminal.Gui/Drawing/Justification.cs @@ -0,0 +1,170 @@ +namespace Terminal.Gui; + +/// +/// Controls how items are justified within a container. Used by . +/// +public enum Justification +{ + /// + /// The items will be left-justified. + /// + Left, + + /// + /// The items will be right-justified. + /// + Right, + + /// + /// The items will be centered. + /// + Centered, + + /// + /// 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. + /// + Justified, + + RightJustified, + LeftJustified +} + +/// +/// Justifies items within a container based on the specified . +/// +public class Justifier +{ + /// + /// Justifies the within a container wide based on the specified + /// . + /// + /// + /// + /// + /// + public static int [] Justify (int [] sizes, Justification justification, int totalSize) + { + var positions = new int [sizes.Length]; + int totalItemsSize = sizes.Sum (); + + if (totalItemsSize > totalSize) + { + throw new ArgumentException ("The sum of the sizes is greater than the total size."); + } + + 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."); + } + + positions [i] = currentPosition; + currentPosition += sizes [i]; + } + + break; + case Justification.Right: + currentPosition = totalSize - totalItemsSize; + + 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; + currentPosition += sizes [i]; + } + + break; + case Justification.Centered: + currentPosition = (totalSize - totalItemsSize) / 2; + + 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; + currentPosition += sizes [i]; + } + + break; + + case Justification.Justified: + int spaceBetween = sizes.Length > 1 ? (totalSize - totalItemsSize) / (sizes.Length - 1) : 0; + int remainder = sizes.Length > 1 ? (totalSize - 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; + + case Justification.LeftJustified: + if (sizes.Length > 1) + { + int spaceBetweenLeft = totalSize - sizes.Sum () + 1; // +1 for the extra space + currentPosition = 0; + for (var i = 0; i < sizes.Length - 1; i++) + { + if (sizes [i] < 0) + { + throw new ArgumentException ("The size of an item cannot be negative."); + } + positions [i] = currentPosition; + currentPosition += sizes [i] + 1; // +1 for the extra space + } + positions [sizes.Length - 1] = totalSize - sizes [sizes.Length - 1]; + } + else if (sizes.Length == 1) + { + positions [0] = 0; + } + break; + + case Justification.RightJustified: + if (sizes.Length > 1) + { + totalItemsSize = sizes.Sum (); + int totalSpaces = totalSize - totalItemsSize; + int bigSpace = totalSpaces - (sizes.Length - 2); + + positions [0] = 0; // first item is flush left + positions [1] = sizes [0] + bigSpace; // second item has the big space before it + + // remaining items have one space between them + for (var i = 2; i < sizes.Length; i++) + { + positions [i] = positions [i - 1] + sizes [i - 1] + 1; + } + } + else if (sizes.Length == 1) + { + positions [0] = 0; // single item is flush left + } + break; + + + + } + + return positions; + } +} diff --git a/Terminal.sln.DotSettings b/Terminal.sln.DotSettings index 3bc1fab5d4..cdfa4823d1 100644 --- a/Terminal.sln.DotSettings +++ b/Terminal.sln.DotSettings @@ -438,5 +438,6 @@ Concurrency Issue (?<=\W|^)(?<TAG>CONCURRENCY:)(\W|$)(.*) Warning + True True diff --git a/UnitTests/Drawing/JustifierTests.cs b/UnitTests/Drawing/JustifierTests.cs new file mode 100644 index 0000000000..62f036aa0d --- /dev/null +++ b/UnitTests/Drawing/JustifierTests.cs @@ -0,0 +1,220 @@ + +using System.Text; +using Xunit.Abstractions; +using Xunit.Sdk; + +namespace Terminal.Gui.DrawingTests; + +public class JustifierTests (ITestOutputHelper output) +{ + + private readonly ITestOutputHelper _output = output; + + [Fact] + public void TestLeftJustification () + { + int [] sizes = { 10, 20, 30 }; + var positions = Justifier.Justify (sizes, Justification.Left, 100); + Assert.Equal (new List { 0, 10, 30 }, positions); + } + + [Fact] + public void TestRightJustification () + { + int [] sizes = { 10, 20, 30 }; + var positions = Justifier.Justify (sizes, Justification.Right, 100); + Assert.Equal (new List { 40, 50, 70 }, positions); + } + + [Fact] + public void TestCenterJustification () + { + int [] sizes = { 10, 20, 30 }; + var positions = Justifier.Justify (sizes, Justification.Centered, 100); + Assert.Equal (new List { 20, 30, 50 }, positions); + } + + [Fact] + public void TestJustifiedJustification () + { + int [] sizes = { 10, 20, 30 }; + var positions = Justifier.Justify (sizes, Justification.Justified, 100); + Assert.Equal (new List { 0, 30, 70 }, positions); + } + + [Fact] + public void TestNoItems () + { + int [] sizes = { }; + var positions = Justifier.Justify (sizes, Justification.Left, 100); + Assert.Equal (new int [] { }, positions); + } + + [Fact] + public void TestTenItems () + { + int [] sizes = { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }; + var positions = Justifier.Justify (sizes, Justification.Left, 100); + Assert.Equal (new int [] { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 }, positions); + } + + [Fact] + public void TestZeroLengthItems () + { + int [] sizes = { 0, 0, 0 }; + var positions = Justifier.Justify (sizes, Justification.Left, 100); + Assert.Equal (new int [] { 0, 0, 0 }, positions); + } + + [Fact] + public void TestLongItems () + { + int [] sizes = { 1000, 2000, 3000 }; + Assert.Throws (() => Justifier.Justify (sizes, Justification.Left, 100)); + } + + [Fact] + public void TestNegativeLengths () + { + int [] sizes = { -10, -20, -30 }; + Assert.Throws (() => Justifier.Justify (sizes, Justification.Left, 100)); + } + + [Theory] + [InlineData (Justification.Left, new int [] { 10, 20, 30 }, 100, new int [] { 0, 10, 30 })] + [InlineData (Justification.Left, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 66 })] + [InlineData (Justification.Left, new int [] { 10 }, 101, new int [] { 0 })] + [InlineData (Justification.Left, new int [] { 10, 20 }, 101, new int [] { 0, 10 })] + [InlineData (Justification.Left, new int [] { 10, 20, 30 }, 101, new int [] { 0, 10, 30 })] + [InlineData (Justification.Left, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 60 })] + [InlineData (Justification.Left, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 100 })] + + [InlineData (Justification.Right, new int [] { 10, 20, 30 }, 100, new int [] { 40, 50, 70 })] + [InlineData (Justification.Right, new int [] { 33, 33, 33 }, 100, new int [] { 1, 34, 67 })] + [InlineData (Justification.Right, new int [] { 10 }, 101, new int [] { 91 })] + [InlineData (Justification.Right, new int [] { 10, 20 }, 101, new int [] { 71, 81 })] + [InlineData (Justification.Right, new int [] { 10, 20, 30 }, 101, new int [] { 41, 51, 71 })] + [InlineData (Justification.Right, new int [] { 10, 20, 30, 40 }, 101, new int [] { 1, 11, 31, 61 })] + [InlineData (Justification.Right, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 1, 11, 31, 61, 101 })] + + [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 100, new int [] { 20, 30, 50 })] + [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 99, new int [] { 0, 33, 66 })] + [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 66 })] + [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 101, new int [] { 1, 34, 67 })] + [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 102, new int [] { 1, 34, 67 })] + [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 104, new int [] { 2, 35, 68 })] + [InlineData (Justification.Centered, new int [] { 10 }, 101, new int [] { 45 })] + [InlineData (Justification.Centered, new int [] { 10, 20 }, 101, new int [] { 35, 45 })] + [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 101, new int [] { 20, 30, 50 })] + [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 60 })] + [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 100 })] + + [InlineData (Justification.Justified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] + [InlineData (Justification.Justified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] + [InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 30, 70 })] + [InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 31, 71 })] + [InlineData (Justification.Justified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] + [InlineData (Justification.Justified, new int [] { 11, 17, 23 }, 100, new int [] { 0, 36, 77 })] + [InlineData (Justification.Justified, new int [] { 1, 2, 3 }, 11, new int [] { 0, 4, 8 })] + [InlineData (Justification.Justified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + [InlineData (Justification.Justified, new int [] { 10 }, 101, new int [] { 0 })] + [InlineData (Justification.Justified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 9, 18 })] + [InlineData (Justification.Justified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 8, 16 })] + [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 18, new int [] { 0, 3, 7, 12 })] + [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 19, new int [] { 0, 4, 8, 13 })] + [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 20, new int [] { 0, 4, 9, 14 })] + [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 21, new int [] { 0, 4, 9, 15 })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 22, new int [] { 0, 8, 14, 19 })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 23, new int [] { 0, 8, 15, 20, })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 24, new int [] { 0, 8, 15, 21 })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 25, new int [] { 0, 9, 16, 22 })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 26, new int [] { 0, 9, 17, 23 })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 31, new int [] { 0, 11, 20, 28 })] + + [InlineData (Justification.LeftJustified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 11, 70 })] + [InlineData (Justification.LeftJustified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] + [InlineData (Justification.LeftJustified, new int [] { 10 }, 101, new int [] { 0 })] + [InlineData (Justification.LeftJustified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + [InlineData (Justification.LeftJustified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 11, 71 })] + [InlineData (Justification.LeftJustified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 32, 61 })] + [InlineData (Justification.LeftJustified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 32, 63, 101 })] + [InlineData (Justification.LeftJustified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 4, 18 })] + [InlineData (Justification.LeftJustified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 4, 16 })] + + [InlineData (Justification.RightJustified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 49, 70 })] + [InlineData (Justification.RightJustified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 67 })] + [InlineData (Justification.RightJustified, new int [] { 10 }, 101, new int [] { 0 })] + [InlineData (Justification.RightJustified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + [InlineData (Justification.RightJustified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 50, 71 })] + [InlineData (Justification.RightJustified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 9, 30, 61 })] + [InlineData (Justification.RightJustified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 8, 29, 60, 101 })] + [InlineData (Justification.RightJustified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 14, 18 })] + [InlineData (Justification.RightJustified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 11, 16 })] + + public void TestJustifications (Justification justification, int [] sizes, int totalSize, int [] expected) + { + var positions = Justifier.Justify (sizes, justification, totalSize); + AssertJustification (justification, sizes, totalSize, 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 (int i = 0; i <= totalSize / 10; i++) + { + output.Append (i.ToString ().PadRight (9) + " "); + } + output.AppendLine (); + + for (int i = 0; i < totalSize; i++) + { + output.Append (i % 10); + } + output.AppendLine (); + + var items = new char [totalSize]; + for (int position = 0; position < positions.Length; position++) + { + try + { + for (int j = 0; j < sizes [position]; 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 (); + } + +} From 48cf0db2917112bb3a39209f776f7d10adff8e29 Mon Sep 17 00:00:00 2001 From: Tig Date: Fri, 19 Apr 2024 12:57:07 -0600 Subject: [PATCH 003/173] Working on Centered --- Terminal.Gui/Drawing/Justification.cs | 73 +++++++++++++-- Terminal.Gui/View/Layout/PosDim.cs | 38 ++++---- UnitTests/Drawing/JustifierTests.cs | 124 +++++++++++++------------- 3 files changed, 147 insertions(+), 88 deletions(-) diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs index 88d63fb292..557d35855d 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Justification.cs @@ -16,7 +16,7 @@ public enum Justification Right, /// - /// The items will be centered. + /// The items will be arranged such that there is no more than 1 space between them. The group will be centered in the container. /// Centered, @@ -24,9 +24,33 @@ public enum Justification /// 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. /// + /// + /// + /// 111 2222 33333 + /// + /// Justified, + /// + /// The items will be left-justified. The first item will be at the start and the last item will be at the end. + /// Those in between will be tight against the right item. + /// + /// + /// + /// 111 2222 33333 + /// + /// RightJustified, + + /// + /// The items will be left-justified. The first item will be at the start and the last item will be at the end. + /// Those in between will be tight against the right item. + /// + /// + /// + /// 111 2222 33333 + /// + /// LeftJustified } @@ -85,22 +109,53 @@ public static int [] Justify (int [] sizes, Justification justification, int tot } break; - case Justification.Centered: - currentPosition = (totalSize - totalItemsSize) / 2; - for (var i = 0; i < sizes.Length; i++) + case Justification.Centered: + if (sizes.Length > 1) { - if (sizes [i] < 0) + totalItemsSize = sizes.Sum (); // total size of items + int totalGaps = sizes.Length - 1; // total gaps (0 or 1 space) + int totalItemsAndSpaces = totalItemsSize + totalGaps; // total size of items and spaces + + int spaces = totalGaps; + + if (totalItemsSize >= totalSize) { - throw new ArgumentException ("The size of an item cannot be negative."); + spaces = 0; + } + else if (totalItemsAndSpaces > totalSize) + { + spaces = totalItemsAndSpaces - totalSize; } - positions [i] = currentPosition; - currentPosition += sizes [i]; - } + int remainingSpace = Math.Max(0, totalSize - totalItemsSize - spaces); // remaining space to be distributed before and after the items + int spaceBefore = remainingSpace / 2; // space before the items + positions [0] = spaceBefore; // first item position + for (var i = 1; i < sizes.Length; i++) + { + int aSpace = 0; + if (spaces > 0) + { + spaces--; + aSpace = 1; + } + // subsequent items are placed one space after the previous item + positions [i] = positions [i - 1] + sizes [i - 1] + aSpace; + } + // Adjust the last position if there is an extra space + if (positions [sizes.Length - 1] + sizes [sizes.Length - 1] > totalSize) + { + positions [sizes.Length - 1]--; + } + } + else if (sizes.Length == 1) + { + positions [0] = (totalSize - sizes [0]) / 2; // single item is centered + } break; + case Justification.Justified: int spaceBetween = sizes.Length > 1 ? (totalSize - totalItemsSize) / (sizes.Length - 1) : 0; int remainder = sizes.Length > 1 ? (totalSize - totalItemsSize) % (sizes.Length - 1) : 0; diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs index 812b29b3ef..37f2a5bf0e 100644 --- a/Terminal.Gui/View/Layout/PosDim.cs +++ b/Terminal.Gui/View/Layout/PosDim.cs @@ -307,22 +307,22 @@ public static Pos Percent (float percent) /// Creates a object that tracks the Top (Y) position of the specified . /// The that depends on the other view. /// The that will be tracked. - public static Pos Top (View view) { return new PosView (view, Side.Y); } + public static Pos Top (View view) { return new PosView (view, Side.Top); } /// Creates a object that tracks the Top (Y) position of the specified . /// The that depends on the other view. /// The that will be tracked. - public static Pos Y (View view) { return new PosView (view, Side.Y); } + public static Pos Y (View view) { return new PosView (view, Side.Top); } /// Creates a object that tracks the Left (X) position of the specified . /// The that depends on the other view. /// The that will be tracked. - public static Pos Left (View view) { return new PosView (view, Side.X); } + public static Pos Left (View view) { return new PosView (view, Side.Left); } /// Creates a object that tracks the Left (X) position of the specified . /// The that depends on the other view. /// The that will be tracked. - public static Pos X (View view) { return new PosView (view, Side.X); } + public static Pos X (View view) { return new PosView (view, Side.Left); } /// /// Creates a object that tracks the Bottom (Y+Height) coordinate of the specified @@ -486,8 +486,8 @@ internal class PosFunc (Func n) : Pos public enum Side { - X = 0, - Y = 1, + Left = 0, + Top = 1, Right = 2, Bottom = 3 } @@ -503,8 +503,8 @@ public override string ToString () { string sideString = side switch { - Side.X => "x", - Side.Y => "y", + Side.Left => "x", + Side.Top => "y", Side.Right => "right", Side.Bottom => "bottom", _ => "unknown" @@ -522,8 +522,8 @@ internal override int Anchor (int width) { return side switch { - Side.X => Target.Frame.X, - Side.Y => Target.Frame.Y, + Side.Left => Target.Frame.X, + Side.Top => Target.Frame.Y, Side.Right => Target.Frame.Right, Side.Bottom => Target.Frame.Bottom, _ => 0 @@ -718,7 +718,7 @@ public class Dim /// Creates a object that tracks the Height of the specified . /// The height of the other . /// The view that will be tracked. - public static Dim Height (View view) { return new DimView (view, Side.Height); } + public static Dim Height (View view) { return new DimView (view, Dimension.Height); } /// Adds a to a , yielding a new . /// The first to add. @@ -801,7 +801,7 @@ public static Dim Percent (float percent, bool usePosition = false) /// Creates a object that tracks the Width of the specified . /// The width of the other . /// The view that will be tracked. - public static Dim Width (View view) { return new DimView (view, Side.Width); } + public static Dim Width (View view) { return new DimView (view, Dimension.Width); } /// /// Gets a dimension that is anchored to a certain point in the layout. @@ -932,7 +932,7 @@ internal class DimFunc (Func n) : Dim internal override int Anchor (int width) { return _function (); } } - public enum Side + public enum Dimension { Height = 0, Width = 1 @@ -940,9 +940,9 @@ public enum Side internal class DimView : Dim { - private readonly Side _side; + private readonly Dimension _side; - internal DimView (View view, Side side) + internal DimView (View view, Dimension side) { Target = view; _side = side; @@ -961,8 +961,8 @@ public override string ToString () string sideString = _side switch { - Side.Height => "Height", - Side.Width => "Width", + Dimension.Height => "Height", + Dimension.Width => "Width", _ => "unknown" }; @@ -973,8 +973,8 @@ internal override int Anchor (int width) { return _side switch { - Side.Height => Target.Frame.Height, - Side.Width => Target.Frame.Width, + Dimension.Height => Target.Frame.Height, + Dimension.Width => Target.Frame.Width, _ => 0 }; } diff --git a/UnitTests/Drawing/JustifierTests.cs b/UnitTests/Drawing/JustifierTests.cs index 62f036aa0d..37c50c506c 100644 --- a/UnitTests/Drawing/JustifierTests.cs +++ b/UnitTests/Drawing/JustifierTests.cs @@ -81,24 +81,27 @@ public void TestNegativeLengths () } [Theory] - [InlineData (Justification.Left, new int [] { 10, 20, 30 }, 100, new int [] { 0, 10, 30 })] - [InlineData (Justification.Left, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 66 })] - [InlineData (Justification.Left, new int [] { 10 }, 101, new int [] { 0 })] - [InlineData (Justification.Left, new int [] { 10, 20 }, 101, new int [] { 0, 10 })] - [InlineData (Justification.Left, new int [] { 10, 20, 30 }, 101, new int [] { 0, 10, 30 })] - [InlineData (Justification.Left, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 60 })] - [InlineData (Justification.Left, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 100 })] - - [InlineData (Justification.Right, new int [] { 10, 20, 30 }, 100, new int [] { 40, 50, 70 })] - [InlineData (Justification.Right, new int [] { 33, 33, 33 }, 100, new int [] { 1, 34, 67 })] - [InlineData (Justification.Right, new int [] { 10 }, 101, new int [] { 91 })] - [InlineData (Justification.Right, new int [] { 10, 20 }, 101, new int [] { 71, 81 })] - [InlineData (Justification.Right, new int [] { 10, 20, 30 }, 101, new int [] { 41, 51, 71 })] - [InlineData (Justification.Right, new int [] { 10, 20, 30, 40 }, 101, new int [] { 1, 11, 31, 61 })] - [InlineData (Justification.Right, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 1, 11, 31, 61, 101 })] - - [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 100, new int [] { 20, 30, 50 })] - [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 99, new int [] { 0, 33, 66 })] + //[InlineData (Justification.Left, new int [] { 10, 20, 30 }, 100, new int [] { 0, 10, 30 })] + //[InlineData (Justification.Left, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 66 })] + //[InlineData (Justification.Left, new int [] { 10 }, 101, new int [] { 0 })] + //[InlineData (Justification.Left, new int [] { 10, 20 }, 101, new int [] { 0, 10 })] + //[InlineData (Justification.Left, new int [] { 10, 20, 30 }, 101, new int [] { 0, 10, 30 })] + //[InlineData (Justification.Left, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 60 })] + //[InlineData (Justification.Left, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 100 })] + + //[InlineData (Justification.Right, new int [] { 10, 20, 30 }, 100, new int [] { 40, 50, 70 })] + //[InlineData (Justification.Right, new int [] { 33, 33, 33 }, 100, new int [] { 1, 34, 67 })] + //[InlineData (Justification.Right, new int [] { 10 }, 101, new int [] { 91 })] + //[InlineData (Justification.Right, new int [] { 10, 20 }, 101, new int [] { 71, 81 })] + //[InlineData (Justification.Right, new int [] { 10, 20, 30 }, 101, new int [] { 41, 51, 71 })] + //[InlineData (Justification.Right, new int [] { 10, 20, 30, 40 }, 101, new int [] { 1, 11, 31, 61 })] + //[InlineData (Justification.Right, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 1, 11, 31, 61, 101 })] + + [InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 10, new int [] { 1, 3, 6 })] + [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 100, new int [] { 19, 30, 51 })] + [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 9, new int [] { 0, 3, 6 })] + [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 10, new int [] { 0, 4, 7 })] + [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 11, new int [] { 0, 4, 8 })] [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 66 })] [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 101, new int [] { 1, 34, 67 })] [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 102, new int [] { 1, 34, 67 })] @@ -108,48 +111,49 @@ public void TestNegativeLengths () [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 101, new int [] { 20, 30, 50 })] [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 60 })] [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 100 })] - - [InlineData (Justification.Justified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] - [InlineData (Justification.Justified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] - [InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 30, 70 })] - [InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 31, 71 })] - [InlineData (Justification.Justified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] - [InlineData (Justification.Justified, new int [] { 11, 17, 23 }, 100, new int [] { 0, 36, 77 })] - [InlineData (Justification.Justified, new int [] { 1, 2, 3 }, 11, new int [] { 0, 4, 8 })] - [InlineData (Justification.Justified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - [InlineData (Justification.Justified, new int [] { 10 }, 101, new int [] { 0 })] - [InlineData (Justification.Justified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 9, 18 })] - [InlineData (Justification.Justified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 8, 16 })] - [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 18, new int [] { 0, 3, 7, 12 })] - [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 19, new int [] { 0, 4, 8, 13 })] - [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 20, new int [] { 0, 4, 9, 14 })] - [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 21, new int [] { 0, 4, 9, 15 })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 22, new int [] { 0, 8, 14, 19 })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 23, new int [] { 0, 8, 15, 20, })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 24, new int [] { 0, 8, 15, 21 })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 25, new int [] { 0, 9, 16, 22 })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 26, new int [] { 0, 9, 17, 23 })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 31, new int [] { 0, 11, 20, 28 })] - - [InlineData (Justification.LeftJustified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 11, 70 })] - [InlineData (Justification.LeftJustified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] - [InlineData (Justification.LeftJustified, new int [] { 10 }, 101, new int [] { 0 })] - [InlineData (Justification.LeftJustified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - [InlineData (Justification.LeftJustified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 11, 71 })] - [InlineData (Justification.LeftJustified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 32, 61 })] - [InlineData (Justification.LeftJustified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 32, 63, 101 })] - [InlineData (Justification.LeftJustified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 4, 18 })] - [InlineData (Justification.LeftJustified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 4, 16 })] - - [InlineData (Justification.RightJustified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 49, 70 })] - [InlineData (Justification.RightJustified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 67 })] - [InlineData (Justification.RightJustified, new int [] { 10 }, 101, new int [] { 0 })] - [InlineData (Justification.RightJustified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - [InlineData (Justification.RightJustified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 50, 71 })] - [InlineData (Justification.RightJustified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 9, 30, 61 })] - [InlineData (Justification.RightJustified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 8, 29, 60, 101 })] - [InlineData (Justification.RightJustified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 14, 18 })] - [InlineData (Justification.RightJustified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 11, 16 })] + [InlineData (Justification.Centered, new int [] { 3, 4, 5, 6 }, 25, new int [] { 2, 6, 11, 17 })] + + //[InlineData (Justification.Justified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] + //[InlineData (Justification.Justified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] + //[InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 30, 70 })] + //[InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 31, 71 })] + //[InlineData (Justification.Justified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] + //[InlineData (Justification.Justified, new int [] { 11, 17, 23 }, 100, new int [] { 0, 36, 77 })] + //[InlineData (Justification.Justified, new int [] { 1, 2, 3 }, 11, new int [] { 0, 4, 8 })] + //[InlineData (Justification.Justified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + //[InlineData (Justification.Justified, new int [] { 10 }, 101, new int [] { 0 })] + //[InlineData (Justification.Justified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 9, 18 })] + //[InlineData (Justification.Justified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 8, 16 })] + //[InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 18, new int [] { 0, 3, 7, 12 })] + //[InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 19, new int [] { 0, 4, 8, 13 })] + //[InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 20, new int [] { 0, 4, 9, 14 })] + //[InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 21, new int [] { 0, 4, 9, 15 })] + //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 22, new int [] { 0, 8, 14, 19 })] + //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 23, new int [] { 0, 8, 15, 20, })] + //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 24, new int [] { 0, 8, 15, 21 })] + //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 25, new int [] { 0, 9, 16, 22 })] + //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 26, new int [] { 0, 9, 17, 23 })] + //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 31, new int [] { 0, 11, 20, 28 })] + + //[InlineData (Justification.LeftJustified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 11, 70 })] + //[InlineData (Justification.LeftJustified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] + //[InlineData (Justification.LeftJustified, new int [] { 10 }, 101, new int [] { 0 })] + //[InlineData (Justification.LeftJustified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + //[InlineData (Justification.LeftJustified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 11, 71 })] + //[InlineData (Justification.LeftJustified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 32, 61 })] + //[InlineData (Justification.LeftJustified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 32, 63, 101 })] + //[InlineData (Justification.LeftJustified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 4, 18 })] + //[InlineData (Justification.LeftJustified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 4, 16 })] + + //[InlineData (Justification.RightJustified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 49, 70 })] + //[InlineData (Justification.RightJustified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 67 })] + //[InlineData (Justification.RightJustified, new int [] { 10 }, 101, new int [] { 0 })] + //[InlineData (Justification.RightJustified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + //[InlineData (Justification.RightJustified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 50, 71 })] + //[InlineData (Justification.RightJustified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 9, 30, 61 })] + //[InlineData (Justification.RightJustified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 8, 29, 60, 101 })] + //[InlineData (Justification.RightJustified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 14, 18 })] + //[InlineData (Justification.RightJustified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 11, 16 })] public void TestJustifications (Justification justification, int [] sizes, int totalSize, int [] expected) { From 292ebfb6380586c31c936534d90de9f66818fc93 Mon Sep 17 00:00:00 2001 From: Tig Date: Sat, 20 Apr 2024 18:30:01 -0600 Subject: [PATCH 004/173] WIP --- Terminal.Gui/Drawing/Justification.cs | 194 ++++++++----- UnitTests/Drawing/JustifierTests.cs | 380 +++++++++++++++++++------- 2 files changed, 414 insertions(+), 160 deletions(-) diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs index 557d35855d..5038c31d22 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Justification.cs @@ -6,52 +6,70 @@ namespace Terminal.Gui; public enum Justification { /// - /// The items will be left-justified. + /// The items will be aligned to the left. + /// The items will be arranged such that there is no more than space between each. /// + /// + /// + /// 111 2222 33333 + /// + /// Left, /// - /// The items will be right-justified. + /// The items will be aligned to the right. + /// The items will be arranged such that there is no more than space between each. /// + /// + /// + /// 111 2222 33333 + /// + /// Right, /// - /// The items will be arranged such that there is no more than 1 space between them. The group will be centered in the container. + /// The group will be centered in the container. + /// If centering is not possible, the group will be left-justified. + /// The items will be arranged such that there is no more than space between each. /// + /// + /// + /// 111 2222 33333 + /// + /// Centered, /// /// 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. + /// The items will be arranged such that there is no more than space between each. /// /// /// - /// 111 2222 33333 + /// 111 2222 33333 /// /// Justified, /// - /// The items will be left-justified. The first item will be at the start and the last item will be at the end. - /// Those in between will be tight against the right item. + /// The first item will be aligned to the left and the remaining will aligned to the right with no more than between each. /// /// /// - /// 111 2222 33333 + /// 111 2222 33333 /// /// - RightJustified, + OneLeftRestRight, /// - /// The items will be left-justified. The first item will be at the start and the last item will be at the end. - /// Those in between will be tight against the right item. + /// The last item will be aligned to right and the remaining will aligned to the left with no more than between each. /// /// /// - /// 111 2222 33333 + /// 111 2222 33333 /// /// - LeftJustified + OneRightRestLeft } /// @@ -59,6 +77,11 @@ public enum Justification /// public class Justifier { + /// + /// Gets or sets the maximum space between items. The default is 0. For text, this is usually 1. + /// + public int MaxSpaceBetweenItems { get; set; } = 0; + /// /// Justifies the within a container wide based on the specified /// . @@ -67,9 +90,12 @@ public class Justifier /// /// /// - public static int [] Justify (int [] sizes, Justification justification, int totalSize) + public int [] Justify (int [] sizes, Justification justification, int totalSize) { - var positions = new int [sizes.Length]; + if (sizes.Length == 0) + { + return new int []{}; + } int totalItemsSize = sizes.Sum (); if (totalItemsSize > totalSize) @@ -77,6 +103,21 @@ public static int [] Justify (int [] sizes, Justification justification, int tot throw new ArgumentException ("The sum of the sizes is greater than the total size."); } + var positions = new int [sizes.Length]; + totalItemsSize = sizes.Sum (); // total size of items + int totalGaps = sizes.Length - 1; // total gaps (MinimumSpaceBetweenItems) + 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 >= totalSize) + { + spaces = 0; + } + else if (totalItemsAndSpaces > totalSize) + { + spaces = totalSize - totalItemsSize; + } + + switch (justification) { case Justification.Left: @@ -89,13 +130,21 @@ public static int [] Justify (int [] sizes, Justification justification, int tot throw new ArgumentException ("The size of an item cannot be negative."); } - positions [i] = currentPosition; - currentPosition += sizes [i]; + if (i == 0) + { + positions [0] = 0; // first item position + continue; + } + + var 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 = totalSize - totalItemsSize; + currentPosition = Math.Max (0, totalSize - totalItemsSize - spaces); for (var i = 0; i < sizes.Length; i++) { @@ -104,8 +153,10 @@ public static int [] Justify (int [] sizes, Justification justification, int tot throw new ArgumentException ("The size of an item cannot be negative."); } + var spaceBefore = spaces-- > 0 ? MaxSpaceBetweenItems : 0; + positions [i] = currentPosition; - currentPosition += sizes [i]; + currentPosition += sizes [i] + spaceBefore; } break; @@ -113,44 +164,35 @@ public static int [] Justify (int [] sizes, Justification justification, int tot case Justification.Centered: if (sizes.Length > 1) { - totalItemsSize = sizes.Sum (); // total size of items - int totalGaps = sizes.Length - 1; // total gaps (0 or 1 space) - int totalItemsAndSpaces = totalItemsSize + totalGaps; // total size of items and spaces + // remaining space to be distributed before first and after the items + int remainingSpace = Math.Max(0, totalSize - totalItemsSize - spaces); - int spaces = totalGaps; - - if (totalItemsSize >= totalSize) - { - spaces = 0; - } - else if (totalItemsAndSpaces > totalSize) + for (var i = 0; i < sizes.Length; i++) { - spaces = totalItemsAndSpaces - totalSize; - } - - int remainingSpace = Math.Max(0, totalSize - totalItemsSize - spaces); // remaining space to be distributed before and after the items - int spaceBefore = remainingSpace / 2; // space before the items + if (sizes [i] < 0) + { + throw new ArgumentException ("The size of an item cannot be negative."); + } - positions [0] = spaceBefore; // first item position - for (var i = 1; i < sizes.Length; i++) - { - int aSpace = 0; - if (spaces > 0) + if (i == 0) { - spaces--; - aSpace = 1; + positions [i] = remainingSpace / 2; // first item position + + continue; } + + var spaceBefore = spaces-- > 0 ? MaxSpaceBetweenItems : 0; + // subsequent items are placed one space after the previous item - positions [i] = positions [i - 1] + sizes [i - 1] + aSpace; - } - // Adjust the last position if there is an extra space - if (positions [sizes.Length - 1] + sizes [sizes.Length - 1] > totalSize) - { - positions [sizes.Length - 1]--; + 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] = (totalSize - sizes [0]) / 2; // single item is centered } break; @@ -172,46 +214,74 @@ public static int [] Justify (int [] sizes, Justification justification, int tot } break; - case Justification.LeftJustified: + /// 111 2222 33333 + case Justification.OneRightRestLeft: if (sizes.Length > 1) { - int spaceBetweenLeft = totalSize - sizes.Sum () + 1; // +1 for the extra space currentPosition = 0; - for (var i = 0; i < sizes.Length - 1; i++) + 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; - currentPosition += sizes [i] + 1; // +1 for the extra space + + if (i < sizes.Length - 1) + { + var spaceBefore = spaces-- > 0 ? MaxSpaceBetweenItems : 0; + + positions [i] = currentPosition; + currentPosition += sizes [i] + spaceBefore; + } } positions [sizes.Length - 1] = totalSize - sizes [sizes.Length - 1]; } else if (sizes.Length == 1) { - positions [0] = 0; + if (sizes [0] < 0) + { + throw new ArgumentException ("The size of an item cannot be negative."); + } + positions [0] = totalSize - sizes [0]; // single item is flush right } break; - case Justification.RightJustified: + /// 111 2222 33333 + case Justification.OneLeftRestRight: if (sizes.Length > 1) { - totalItemsSize = sizes.Sum (); - int totalSpaces = totalSize - totalItemsSize; - int bigSpace = totalSpaces - (sizes.Length - 2); - - positions [0] = 0; // first item is flush left - positions [1] = sizes [0] + bigSpace; // second item has the big space before it + currentPosition = 0; + positions [0] = currentPosition; // first item is flush left - // remaining items have one space between them - for (var i = 2; i < sizes.Length; i++) + for (var i = sizes.Length - 1 ; i >= 0; i--) { - positions [i] = positions [i - 1] + sizes [i - 1] + 1; + if (sizes [i] < 0) + { + throw new ArgumentException ("The size of an item cannot be negative."); + } + + if (i == sizes.Length - 1) + { + // start at right + currentPosition = totalSize - sizes [i]; + positions [i] = currentPosition; + } + + if (i < sizes.Length - 1 && i > 0) + { + var spaceBefore = spaces-- > 0 ? MaxSpaceBetweenItems : 0; + + positions [i] = currentPosition - sizes [i] - spaceBefore; + currentPosition -= sizes [i + 1]; + } } } 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; diff --git a/UnitTests/Drawing/JustifierTests.cs b/UnitTests/Drawing/JustifierTests.cs index 37c50c506c..de7ae2e2bd 100644 --- a/UnitTests/Drawing/JustifierTests.cs +++ b/UnitTests/Drawing/JustifierTests.cs @@ -10,77 +10,199 @@ public class JustifierTests (ITestOutputHelper output) private readonly ITestOutputHelper _output = output; - [Fact] - public void TestLeftJustification () + public static IEnumerable JustificationEnumValues () { - int [] sizes = { 10, 20, 30 }; - var positions = Justifier.Justify (sizes, Justification.Left, 100); - Assert.Equal (new List { 0, 10, 30 }, positions); + foreach (var number in Enum.GetValues (typeof (Justification))) + { + yield return new object [] { number }; + } } - [Fact] - public void TestRightJustification () + [Theory] + [MemberData (nameof (JustificationEnumValues))] + public void NoItems_Works (Justification justification) { - int [] sizes = { 10, 20, 30 }; - var positions = Justifier.Justify (sizes, Justification.Right, 100); - Assert.Equal (new List { 40, 50, 70 }, positions); + int [] sizes = { }; + var positions = new Justifier ().Justify (sizes, justification, 100); + Assert.Equal (new int [] { }, positions); } - [Fact] - public void TestCenterJustification () + [Theory] + [MemberData (nameof (JustificationEnumValues))] + public void Items_Width_Cannot_Exceed_TotalSize (Justification justification) { - int [] sizes = { 10, 20, 30 }; - var positions = Justifier.Justify (sizes, Justification.Centered, 100); - Assert.Equal (new List { 20, 30, 50 }, positions); + int [] sizes = { 1000, 2000, 3000 }; + Assert.Throws (() => new Justifier ().Justify (sizes, justification, 100)); } - [Fact] - public void TestJustifiedJustification () + [Theory] + [MemberData (nameof (JustificationEnumValues))] + public void Negative_Widths_Not_Allowed (Justification justification) { - int [] sizes = { 10, 20, 30 }; - var positions = Justifier.Justify (sizes, Justification.Justified, 100); - Assert.Equal (new List { 0, 30, 70 }, positions); + Assert.Throws (() => new Justifier ().Justify (new int [] { -10, 20, 30 }, justification, 100)); + Assert.Throws (() => new Justifier ().Justify (new int [] { 10, -20, 30 }, justification, 100)); + Assert.Throws (() => new Justifier ().Justify (new int [] { 10, 20, -30 }, justification, 100)); } - [Fact] - public void TestNoItems () - { - int [] sizes = { }; - var positions = Justifier.Justify (sizes, Justification.Left, 100); - Assert.Equal (new int [] { }, positions); - } + [Theory] + [InlineData (Justification.Left, new int [] { 0 }, 1, new int [] { 0 })] + [InlineData (Justification.Left, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] + [InlineData (Justification.Left, new int [] { 0, 0, 0 }, 1, new int [] { 0, 1, 1 })] + [InlineData (Justification.Left, new int [] { 1 }, 1, new int [] { 0 })] + [InlineData (Justification.Left, new int [] { 1 }, 2, new int [] { 0 })] + [InlineData (Justification.Left, new int [] { 1 }, 3, new int [] { 0 })] + [InlineData (Justification.Left, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] + [InlineData (Justification.Left, new int [] { 1, 1 }, 3, new int [] { 0, 2 })] + [InlineData (Justification.Left, new int [] { 1, 1 }, 4, new int [] { 0, 2 })] + [InlineData (Justification.Left, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] + [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] + [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 7, new int [] { 0, 2, 4 })] + [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 10, new int [] { 0, 2, 5 })] + [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 11, new int [] { 0, 2, 5 })] + [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 12, new int [] { 0, 2, 5 })] + [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 13, new int [] { 0, 2, 5 })] + [InlineData (Justification.Left, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] + [InlineData (Justification.Left, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 2, 4, 7 })] + [InlineData (Justification.Left, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] + [InlineData (Justification.Left, new int [] { 10 }, 101, new int [] { 0 })] + [InlineData (Justification.Left, new int [] { 10, 20 }, 101, new int [] { 0, 11 })] + [InlineData (Justification.Left, new int [] { 10, 20, 30 }, 100, new int [] { 0, 11, 32 })] + [InlineData (Justification.Left, new int [] { 10, 20, 30 }, 101, new int [] { 0, 11, 32 })] + [InlineData (Justification.Left, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] + [InlineData (Justification.Left, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] - [Fact] - public void TestTenItems () - { - int [] sizes = { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }; - var positions = Justifier.Justify (sizes, Justification.Left, 100); - Assert.Equal (new int [] { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 }, positions); - } + [InlineData (Justification.Right, new int [] { 0 }, 1, new int [] { 1 })] + [InlineData (Justification.Right, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] + [InlineData (Justification.Right, new int [] { 0, 0, 0 }, 1, new int [] { 0, 1, 1 })] + [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] + [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 7, new int [] { 0, 2, 4 })] + [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 10, new int [] { 2, 4, 7 })] + [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 11, new int [] { 3, 5, 8 })] + [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 12, new int [] { 4, 6, 9 })] + [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 13, new int [] { 5, 7, 10 })] + [InlineData (Justification.Right, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] + [InlineData (Justification.Right, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 2, 4, 7 })] + [InlineData (Justification.Right, new int [] { 10, 20, 30 }, 100, new int [] { 38, 49, 70 })] + [InlineData (Justification.Right, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] + [InlineData (Justification.Right, new int [] { 10 }, 101, new int [] { 91 })] + [InlineData (Justification.Right, new int [] { 10, 20 }, 101, new int [] { 70, 81 })] + [InlineData (Justification.Right, new int [] { 10, 20, 30 }, 101, new int [] { 39, 50, 71 })] + [InlineData (Justification.Right, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] + [InlineData (Justification.Right, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] - [Fact] - public void TestZeroLengthItems () - { - int [] sizes = { 0, 0, 0 }; - var positions = Justifier.Justify (sizes, Justification.Left, 100); - Assert.Equal (new int [] { 0, 0, 0 }, positions); - } + [InlineData (Justification.Centered, new int [] { 0 }, 1, new int [] { 0 })] + [InlineData (Justification.Centered, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] + [InlineData (Justification.Centered, new int [] { 0, 0, 0 }, 1, new int [] { 0, 1, 1 })] + [InlineData (Justification.Centered, new int [] { 1 }, 1, new int [] { 0 })] + [InlineData (Justification.Centered, new int [] { 1 }, 2, new int [] { 0 })] + [InlineData (Justification.Centered, new int [] { 1 }, 3, new int [] { 1 })] + [InlineData (Justification.Centered, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] + [InlineData (Justification.Centered, new int [] { 1, 1 }, 3, new int [] { 0, 2 })] + [InlineData (Justification.Centered, new int [] { 1, 1 }, 4, new int [] { 0, 2 })] + [InlineData (Justification.Centered, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] + [InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] + [InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 7, new int [] { 0, 2, 4 })] + [InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 10, new int [] { 1, 3, 6 })] + [InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 11, new int [] { 1, 3, 6 })] + [InlineData (Justification.Centered, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] + [InlineData (Justification.Centered, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 2, 4, 7 })] + [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 9, new int [] { 0, 3, 6 })] + [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 10, new int [] { 0, 4, 7 })] + [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 11, new int [] { 0, 4, 8 })] + [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 12, new int [] { 0, 4, 8 })] + [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 13, new int [] { 1, 5, 9 })] + [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] + [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 101, new int [] { 0, 34, 68 })] + [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 102, new int [] { 0, 34, 68 })] + [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 103, new int [] { 1, 35, 69 })] + [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 104, new int [] { 1, 35, 69 })] + [InlineData (Justification.Centered, new int [] { 10 }, 101, new int [] { 45 })] + [InlineData (Justification.Centered, new int [] { 10, 20 }, 101, new int [] { 35, 46 })] + [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 100, new int [] { 19, 30, 51 })] + [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 101, new int [] { 19, 30, 51 })] + [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40 }, 100, new int [] { 0, 10, 30, 60 })] + [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] + [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] + [InlineData (Justification.Centered, new int [] { 3, 4, 5, 6 }, 25, new int [] { 2, 6, 11, 17 })] - [Fact] - public void TestLongItems () - { - int [] sizes = { 1000, 2000, 3000 }; - Assert.Throws (() => Justifier.Justify (sizes, Justification.Left, 100)); - } + [InlineData (Justification.Justified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] + [InlineData (Justification.Justified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] + [InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 30, 70 })] + [InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 31, 71 })] + [InlineData (Justification.Justified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] + [InlineData (Justification.Justified, new int [] { 11, 17, 23 }, 100, new int [] { 0, 36, 77 })] + [InlineData (Justification.Justified, new int [] { 1, 2, 3 }, 11, new int [] { 0, 4, 8 })] + [InlineData (Justification.Justified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + [InlineData (Justification.Justified, new int [] { 10 }, 101, new int [] { 0 })] + [InlineData (Justification.Justified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 9, 18 })] + [InlineData (Justification.Justified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 8, 16 })] + [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 18, new int [] { 0, 3, 7, 12 })] + [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 19, new int [] { 0, 4, 8, 13 })] + [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 20, new int [] { 0, 4, 9, 14 })] + [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 21, new int [] { 0, 4, 9, 15 })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 22, new int [] { 0, 8, 14, 19 })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 23, new int [] { 0, 8, 15, 20, })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 24, new int [] { 0, 8, 15, 21 })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 25, new int [] { 0, 9, 16, 22 })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 26, new int [] { 0, 9, 17, 23 })] + [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 31, new int [] { 0, 11, 20, 28 })] + + [InlineData (Justification.OneRightRestLeft, new int [] { 0 }, 1, new int [] { 0 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 0, 0, 0 }, 1, new int [] { 0, 1, 1 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 1, new int [] { 0 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 2, new int [] { 0 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 3, new int [] { 0 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 3, new int [] { 0, 2 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 4, new int [] { 0, 3 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 7, new int [] { 0, 2, 4 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 8, new int [] { 0, 2, 5 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 9, new int [] { 0, 2, 6 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 10, new int [] { 0, 2, 7 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 11, new int [] { 0, 2, 8 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 2, 4, 7 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 3, 3, 3 }, 21, new int [] { 0, 4, 18 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 3, 4, 5 }, 21, new int [] { 0, 4, 16 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 10 }, 101, new int [] { 0 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30 }, 100, new int [] { 0, 11, 70 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30 }, 101, new int [] { 0, 11, 71 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] + [InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] + + //[InlineData (Justification.SplitLeft, new int [] { 10, 20, 30 }, 100, new int [] { 0, 49, 70 })] + //[InlineData (Justification.SplitLeft, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 67 })] + //[InlineData (Justification.SplitLeft, new int [] { 10 }, 101, new int [] { 0 })] + //[InlineData (Justification.SplitLeft, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + //[InlineData (Justification.SplitLeft, new int [] { 10, 20, 30 }, 101, new int [] { 0, 50, 71 })] + //[InlineData (Justification.SplitLeft, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 9, 30, 61 })] + //[InlineData (Justification.SplitLeft, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 8, 29, 60, 101 })] + //[InlineData (Justification.SplitLeft, new int [] { 3, 3, 3 }, 21, new int [] { 0, 14, 18 })] + //[InlineData (Justification.SplitLeft, new int [] { 3, 4, 5 }, 21, new int [] { 0, 11, 16 })] - [Fact] - public void TestNegativeLengths () + public void TestJustifications_1Space (Justification justification, int [] sizes, int totalSize, int [] expected) { - int [] sizes = { -10, -20, -30 }; - Assert.Throws (() => Justifier.Justify (sizes, Justification.Left, 100)); + var positions = new Justifier () { MaxSpaceBetweenItems = 1 }.Justify (sizes, justification, totalSize); + AssertJustification (justification, sizes, totalSize, positions, expected); } [Theory] + //[InlineData (Justification.Left, new int [] { 0 }, 1, new int [] { 0 })] + //[InlineData (Justification.Left, new int [] { 0, 0 }, 1, new int [] { 0, 0 })] + //[InlineData (Justification.Left, new int [] { 0, 0, 0 }, 1, new int [] { 0, 0, 0 })] + //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] + //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 7, new int [] { 0, 1, 3 })] + //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 10, new int [] { 0, 1, 3 })] + //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 11, new int [] { 0, 1, 3 })] + //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 12, new int [] { 0, 1, 3 })] + //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 13, new int [] { 0, 1, 3 })] + //[InlineData (Justification.Left, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] + //[InlineData (Justification.Left, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 1, 3, 6 })] //[InlineData (Justification.Left, new int [] { 10, 20, 30 }, 100, new int [] { 0, 10, 30 })] //[InlineData (Justification.Left, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 66 })] //[InlineData (Justification.Left, new int [] { 10 }, 101, new int [] { 0 })] @@ -89,6 +211,17 @@ public void TestNegativeLengths () //[InlineData (Justification.Left, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 60 })] //[InlineData (Justification.Left, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 100 })] + //[InlineData (Justification.Right, new int [] { 0 }, 1, new int [] { 1 })] + //[InlineData (Justification.Right, new int [] { 0, 0 }, 1, new int [] { 1, 1 })] + //[InlineData (Justification.Right, new int [] { 0, 0, 0 }, 1, new int [] { 1, 1, 1 })] + //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] + //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 7, new int [] { 1, 2, 4 })] + //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 10, new int [] { 4, 5, 7 })] + //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 11, new int [] { 5, 6, 8 })] + //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 12, new int [] { 6, 7, 9 })] + //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 13, new int [] { 7, 8, 10 })] + //[InlineData (Justification.Right, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] + //[InlineData (Justification.Right, new int [] { 1, 2, 3, 4 }, 11, new int [] { 1, 2, 4, 7 })] //[InlineData (Justification.Right, new int [] { 10, 20, 30 }, 100, new int [] { 40, 50, 70 })] //[InlineData (Justification.Right, new int [] { 33, 33, 33 }, 100, new int [] { 1, 34, 67 })] //[InlineData (Justification.Right, new int [] { 10 }, 101, new int [] { 91 })] @@ -97,21 +230,30 @@ public void TestNegativeLengths () //[InlineData (Justification.Right, new int [] { 10, 20, 30, 40 }, 101, new int [] { 1, 11, 31, 61 })] //[InlineData (Justification.Right, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 1, 11, 31, 61, 101 })] - [InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 10, new int [] { 1, 3, 6 })] - [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 100, new int [] { 19, 30, 51 })] - [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 9, new int [] { 0, 3, 6 })] - [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 10, new int [] { 0, 4, 7 })] - [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 11, new int [] { 0, 4, 8 })] - [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 66 })] - [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 101, new int [] { 1, 34, 67 })] - [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 102, new int [] { 1, 34, 67 })] - [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 104, new int [] { 2, 35, 68 })] - [InlineData (Justification.Centered, new int [] { 10 }, 101, new int [] { 45 })] - [InlineData (Justification.Centered, new int [] { 10, 20 }, 101, new int [] { 35, 45 })] - [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 101, new int [] { 20, 30, 50 })] - [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 60 })] - [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 100 })] - [InlineData (Justification.Centered, new int [] { 3, 4, 5, 6 }, 25, new int [] { 2, 6, 11, 17 })] + //[InlineData (Justification.Centered, new int [] { 1 }, 1, new int [] { 0 })] + //[InlineData (Justification.Centered, new int [] { 1 }, 2, new int [] { 0 })] + //[InlineData (Justification.Centered, new int [] { 1 }, 3, new int [] { 1 })] + //[InlineData (Justification.Centered, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] + //[InlineData (Justification.Centered, new int [] { 1, 1 }, 3, new int [] { 0, 1 })] + //[InlineData (Justification.Centered, new int [] { 1, 1 }, 4, new int [] { 1, 2 })] + //[InlineData (Justification.Centered, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] + //[InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] + //[InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 7, new int [] { 0, 1, 3 })] + //[InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 10, new int [] { 2, 3, 5 })] + //[InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 11, new int [] { 2, 3, 5 })] + //[InlineData (Justification.Centered, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] + //[InlineData (Justification.Centered, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 1, 3, 6 })] + //[InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 9, new int [] { 0, 3, 6 })] + //[InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 10, new int [] { 0, 3, 6 })] + //[InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 11, new int [] { 1, 4, 7 })] + //[InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 12, new int [] { 1, 4, 7 })] + //[InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 13, new int [] { 2, 5, 8 })] + //[InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 66 })] + //[InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 101, new int [] { 1, 34, 67 })] + //[InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 102, new int [] { 1, 34, 67 })] + //[InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 103, new int [] { 2, 35, 68 })] + //[InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 104, new int [] { 2, 35, 68 })] + //[InlineData (Justification.Centered, new int [] { 3, 4, 5, 6 }, 25, new int [] { 3, 6, 10, 15 })] //[InlineData (Justification.Justified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] //[InlineData (Justification.Justified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] @@ -135,29 +277,70 @@ public void TestNegativeLengths () //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 26, new int [] { 0, 9, 17, 23 })] //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 31, new int [] { 0, 11, 20, 28 })] - //[InlineData (Justification.LeftJustified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 11, 70 })] - //[InlineData (Justification.LeftJustified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] - //[InlineData (Justification.LeftJustified, new int [] { 10 }, 101, new int [] { 0 })] - //[InlineData (Justification.LeftJustified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - //[InlineData (Justification.LeftJustified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 11, 71 })] - //[InlineData (Justification.LeftJustified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 32, 61 })] - //[InlineData (Justification.LeftJustified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 32, 63, 101 })] - //[InlineData (Justification.LeftJustified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 4, 18 })] - //[InlineData (Justification.LeftJustified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 4, 16 })] - - //[InlineData (Justification.RightJustified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 49, 70 })] - //[InlineData (Justification.RightJustified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 67 })] - //[InlineData (Justification.RightJustified, new int [] { 10 }, 101, new int [] { 0 })] - //[InlineData (Justification.RightJustified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - //[InlineData (Justification.RightJustified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 50, 71 })] - //[InlineData (Justification.RightJustified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 9, 30, 61 })] - //[InlineData (Justification.RightJustified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 8, 29, 60, 101 })] - //[InlineData (Justification.RightJustified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 14, 18 })] - //[InlineData (Justification.RightJustified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 11, 16 })] - - public void TestJustifications (Justification justification, int [] sizes, int totalSize, int [] expected) + //[InlineData (Justification.OneRightRestLeft, new int [] { 0 }, 1, new int [] { 0 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 0, 0, 0 }, 1, new int [] { 0, 0, 1 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 1, new int [] { 0 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 2, new int [] { 0 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 3, new int [] { 0 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 3, new int [] { 0, 2 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 4, new int [] { 0, 3 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 7, new int [] { 0, 1, 4 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 8, new int [] { 0, 1, 5 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 9, new int [] { 0, 1, 6 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 10, new int [] { 0, 1, 7 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 11, new int [] { 0, 1, 8 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 1, 3, 7 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3, 4 }, 12, new int [] { 0, 1, 3, 8 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 3, 3, 3 }, 21, new int [] { 0, 3, 18 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 3, 4, 5 }, 21, new int [] { 0, 3, 16 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 67 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 10 }, 101, new int [] { 0 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30 }, 100, new int [] { 0, 10, 70 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30 }, 101, new int [] { 0, 10, 71 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 61 })] + //[InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 101, })] + + + [InlineData (Justification.OneLeftRestRight, new int [] { 0 }, 1, new int [] { 0 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 0, 0, 0 }, 1, new int [] { 0, 1, 1 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1 }, 1, new int [] { 0 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1 }, 2, new int [] { 1 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1 }, 3, new int [] { 2 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1, 1 }, 3, new int [] { 0, 2 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1, 1 }, 4, new int [] { 0, 3 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 7, new int [] { 0, 2, 4 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 8, new int [] { 0, 3, 5 })] + [InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 9, new int [] { 0, 4, 6 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 10, new int [] { 0, 1, 7 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 11, new int [] { 0, 1, 8 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 1, 3, 7 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3, 4 }, 12, new int [] { 0, 1, 3, 8 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 3, 3, 3 }, 21, new int [] { 0, 3, 18 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 3, 4, 5 }, 21, new int [] { 0, 3, 16 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 67 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 10 }, 101, new int [] { 0 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 10, 20, 30 }, 100, new int [] { 0, 10, 70 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 10, 20, 30 }, 101, new int [] { 0, 10, 71 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 61 })] + //[InlineData (Justification.OneLeftRestRight, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 101, })] + + + + public void TestJustifications_0Space (Justification justification, int [] sizes, int totalSize, int [] expected) { - var positions = Justifier.Justify (sizes, justification, totalSize); + var positions = new Justifier () { MaxSpaceBetweenItems = 0 }.Justify (sizes, justification, totalSize); AssertJustification (justification, sizes, totalSize, positions, expected); } @@ -173,11 +356,11 @@ public void AssertJustification (Justification justification, int [] sizes, int _output.WriteLine ($"Actual: {RenderJustification (justification, sizes, totalSize, positions)}"); } - if (!expected.SequenceEqual(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"); + Assert.Fail (" Expected and actual do not match"); } } @@ -201,19 +384,20 @@ public string RenderJustification (Justification justification, int [] sizes, in var items = new char [totalSize]; for (int position = 0; position < positions.Length; position++) { - try + // try { - for (int j = 0; j < sizes [position]; j++) + for (int 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 ()); } + //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', ' ')); From 3f7159256c3288010fb2f2386e63ee1018476f8c Mon Sep 17 00:00:00 2001 From: Tig Date: Sat, 20 Apr 2024 23:24:18 -0600 Subject: [PATCH 005/173] Finished Justifier --- Terminal.Gui/Drawing/Justification.cs | 136 +++--- UnitTests/Drawing/JustifierTests.cs | 616 +++++++++++++------------- 2 files changed, 393 insertions(+), 359 deletions(-) diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs index 5038c31d22..9109c64713 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Justification.cs @@ -1,75 +1,83 @@ namespace Terminal.Gui; /// -/// Controls how items are justified within a container. Used by . +/// Controls how the justifies items within a container. /// public enum Justification { /// /// The items will be aligned to the left. - /// The items will be arranged such that there is no more than space between each. + /// Set to to ensure at least one space between + /// each item. /// /// - /// - /// 111 2222 33333 - /// + /// + /// 111 2222 33333 + /// /// Left, /// /// The items will be aligned to the right. - /// The items will be arranged such that there is no more than space between each. + /// Set to to ensure at least one space between + /// each item. /// /// - /// - /// 111 2222 33333 - /// + /// + /// 111 2222 33333 + /// /// Right, /// /// The group will be centered in the container. /// If centering is not possible, the group will be left-justified. - /// The items will be arranged such that there is no more than space between each. + /// Set to to ensure at least one space between + /// each item. /// /// - /// - /// 111 2222 33333 - /// + /// + /// 111 2222 33333 + /// /// Centered, /// /// 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. - /// The items will be arranged such that there is no more than space between each. + /// Set to to ensure at least one space between + /// each item. /// /// - /// - /// 111 2222 33333 - /// + /// + /// 111 2222 33333 + /// /// Justified, /// - /// The first item will be aligned to the left and the remaining will aligned to the right with no more than between each. + /// The first item will be aligned to the left and the remaining will aligned to the right. + /// Set to to ensure at least one space between + /// each item. /// /// - /// - /// 111 2222 33333 - /// + /// + /// 111 2222 33333 + /// /// - OneLeftRestRight, + FirstLeftRestRight, /// - /// The last item will be aligned to right and the remaining will aligned to the left with no more than between each. + /// The last item will be aligned to the right and the remaining will aligned to the left. + /// Set to to ensure at least one space between + /// each item. /// /// - /// - /// 111 2222 33333 - /// + /// + /// 111 2222 33333 + /// /// - OneRightRestLeft + LastRightRestLeft } /// @@ -77,25 +85,34 @@ public enum Justification /// public class Justifier { + private int _maxSpaceBetweenItems; + /// - /// Gets or sets the maximum space between items. The default is 0. For text, this is usually 1. + /// Gets or sets whether puts a space is placed between items. Default is . If , a space will be + /// placed between each item, which is useful for + /// justifying text. /// - public int MaxSpaceBetweenItems { get; set; } = 0; + public bool PutSpaceBetweenItems + { + get => _maxSpaceBetweenItems == 1; + set => _maxSpaceBetweenItems = value ? 1 : 0; + } /// - /// Justifies the within a container wide based on the specified + /// Takes a list of items and returns their positions when justified within a container wide based on the specified /// . /// - /// - /// - /// - /// + /// The sizes of the items to justify. + /// The justification style. + /// The width of the container. + /// The locations of the items, from left to right. public int [] Justify (int [] sizes, Justification justification, int totalSize) { if (sizes.Length == 0) { - return new int []{}; + return new int [] { }; } + int totalItemsSize = sizes.Sum (); if (totalItemsSize > totalSize) @@ -106,8 +123,9 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) var positions = new int [sizes.Length]; totalItemsSize = sizes.Sum (); // total size of items int totalGaps = sizes.Length - 1; // total gaps (MinimumSpaceBetweenItems) - 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 + 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 >= totalSize) { spaces = 0; @@ -117,7 +135,6 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) spaces = totalSize - totalItemsSize; } - switch (justification) { case Justification.Left: @@ -133,10 +150,11 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) if (i == 0) { positions [0] = 0; // first item position + continue; } - var spaceBefore = spaces-- > 0 ? MaxSpaceBetweenItems : 0; + 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; @@ -153,7 +171,7 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) throw new ArgumentException ("The size of an item cannot be negative."); } - var spaceBefore = spaces-- > 0 ? MaxSpaceBetweenItems : 0; + int spaceBefore = spaces-- > 0 ? _maxSpaceBetweenItems : 0; positions [i] = currentPosition; currentPosition += sizes [i] + spaceBefore; @@ -165,7 +183,7 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) if (sizes.Length > 1) { // remaining space to be distributed before first and after the items - int remainingSpace = Math.Max(0, totalSize - totalItemsSize - spaces); + int remainingSpace = Math.Max (0, totalSize - totalItemsSize - spaces); for (var i = 0; i < sizes.Length; i++) { @@ -181,7 +199,7 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) continue; } - var spaceBefore = spaces-- > 0 ? MaxSpaceBetweenItems : 0; + 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; @@ -193,32 +211,37 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) { throw new ArgumentException ("The size of an item cannot be negative."); } + positions [0] = (totalSize - sizes [0]) / 2; // single item is centered } - break; + break; case Justification.Justified: int spaceBetween = sizes.Length > 1 ? (totalSize - totalItemsSize) / (sizes.Length - 1) : 0; int remainder = sizes.Length > 1 ? (totalSize - 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.OneRightRestLeft: + // 111 2222 33333 + case Justification.LastRightRestLeft: if (sizes.Length > 1) { currentPosition = 0; + for (var i = 0; i < sizes.Length; i++) { if (sizes [i] < 0) @@ -228,12 +251,13 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) if (i < sizes.Length - 1) { - var spaceBefore = spaces-- > 0 ? MaxSpaceBetweenItems : 0; + int spaceBefore = spaces-- > 0 ? _maxSpaceBetweenItems : 0; positions [i] = currentPosition; - currentPosition += sizes [i] + spaceBefore; + currentPosition += sizes [i] + spaceBefore; } } + positions [sizes.Length - 1] = totalSize - sizes [sizes.Length - 1]; } else if (sizes.Length == 1) @@ -242,18 +266,20 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) { throw new ArgumentException ("The size of an item cannot be negative."); } + positions [0] = totalSize - sizes [0]; // single item is flush right } + break; - /// 111 2222 33333 - case Justification.OneLeftRestRight: + // 111 2222 33333 + case Justification.FirstLeftRestRight: if (sizes.Length > 1) { currentPosition = 0; positions [0] = currentPosition; // first item is flush left - for (var i = sizes.Length - 1 ; i >= 0; i--) + for (int i = sizes.Length - 1; i >= 0; i--) { if (sizes [i] < 0) { @@ -269,10 +295,10 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) if (i < sizes.Length - 1 && i > 0) { - var spaceBefore = spaces-- > 0 ? MaxSpaceBetweenItems : 0; + int spaceBefore = spaces-- > 0 ? _maxSpaceBetweenItems : 0; positions [i] = currentPosition - sizes [i] - spaceBefore; - currentPosition -= sizes [i + 1]; + currentPosition = positions [i]; } } } @@ -282,12 +308,14 @@ public int [] Justify (int [] sizes, Justification justification, int totalSize) { throw new ArgumentException ("The size of an item cannot be negative."); } + positions [0] = 0; // single item is flush left } - break; - + break; + default: + throw new ArgumentOutOfRangeException (nameof (justification), justification, null); } return positions; diff --git a/UnitTests/Drawing/JustifierTests.cs b/UnitTests/Drawing/JustifierTests.cs index de7ae2e2bd..f9f477a87b 100644 --- a/UnitTests/Drawing/JustifierTests.cs +++ b/UnitTests/Drawing/JustifierTests.cs @@ -1,20 +1,17 @@ - using System.Text; using Xunit.Abstractions; -using Xunit.Sdk; namespace Terminal.Gui.DrawingTests; public class JustifierTests (ITestOutputHelper output) { - private readonly ITestOutputHelper _output = output; public static IEnumerable JustificationEnumValues () { - foreach (var number in Enum.GetValues (typeof (Justification))) + foreach (object number in Enum.GetValues (typeof (Justification))) { - yield return new object [] { number }; + yield return new [] { number }; } } @@ -23,7 +20,7 @@ public static IEnumerable JustificationEnumValues () public void NoItems_Works (Justification justification) { int [] sizes = { }; - var positions = new Justifier ().Justify (sizes, justification, 100); + int [] positions = new Justifier ().Justify (sizes, justification, 100); Assert.Equal (new int [] { }, positions); } @@ -39,308 +36,314 @@ public void Items_Width_Cannot_Exceed_TotalSize (Justification justification) [MemberData (nameof (JustificationEnumValues))] public void Negative_Widths_Not_Allowed (Justification justification) { - Assert.Throws (() => new Justifier ().Justify (new int [] { -10, 20, 30 }, justification, 100)); - Assert.Throws (() => new Justifier ().Justify (new int [] { 10, -20, 30 }, justification, 100)); - Assert.Throws (() => new Justifier ().Justify (new int [] { 10, 20, -30 }, justification, 100)); + Assert.Throws (() => new Justifier ().Justify (new [] { -10, 20, 30 }, justification, 100)); + Assert.Throws (() => new Justifier ().Justify (new [] { 10, -20, 30 }, justification, 100)); + Assert.Throws (() => new Justifier ().Justify (new [] { 10, 20, -30 }, justification, 100)); } [Theory] - [InlineData (Justification.Left, new int [] { 0 }, 1, new int [] { 0 })] - [InlineData (Justification.Left, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] - [InlineData (Justification.Left, new int [] { 0, 0, 0 }, 1, new int [] { 0, 1, 1 })] - [InlineData (Justification.Left, new int [] { 1 }, 1, new int [] { 0 })] - [InlineData (Justification.Left, new int [] { 1 }, 2, new int [] { 0 })] - [InlineData (Justification.Left, new int [] { 1 }, 3, new int [] { 0 })] - [InlineData (Justification.Left, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] - [InlineData (Justification.Left, new int [] { 1, 1 }, 3, new int [] { 0, 2 })] - [InlineData (Justification.Left, new int [] { 1, 1 }, 4, new int [] { 0, 2 })] - [InlineData (Justification.Left, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] - [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] - [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 7, new int [] { 0, 2, 4 })] - [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 10, new int [] { 0, 2, 5 })] - [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 11, new int [] { 0, 2, 5 })] - [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 12, new int [] { 0, 2, 5 })] - [InlineData (Justification.Left, new int [] { 1, 2, 3 }, 13, new int [] { 0, 2, 5 })] - [InlineData (Justification.Left, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] - [InlineData (Justification.Left, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 2, 4, 7 })] - [InlineData (Justification.Left, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] - [InlineData (Justification.Left, new int [] { 10 }, 101, new int [] { 0 })] - [InlineData (Justification.Left, new int [] { 10, 20 }, 101, new int [] { 0, 11 })] - [InlineData (Justification.Left, new int [] { 10, 20, 30 }, 100, new int [] { 0, 11, 32 })] - [InlineData (Justification.Left, new int [] { 10, 20, 30 }, 101, new int [] { 0, 11, 32 })] - [InlineData (Justification.Left, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] - [InlineData (Justification.Left, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] - - [InlineData (Justification.Right, new int [] { 0 }, 1, new int [] { 1 })] - [InlineData (Justification.Right, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] - [InlineData (Justification.Right, new int [] { 0, 0, 0 }, 1, new int [] { 0, 1, 1 })] - [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] - [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 7, new int [] { 0, 2, 4 })] - [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 10, new int [] { 2, 4, 7 })] - [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 11, new int [] { 3, 5, 8 })] - [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 12, new int [] { 4, 6, 9 })] - [InlineData (Justification.Right, new int [] { 1, 2, 3 }, 13, new int [] { 5, 7, 10 })] - [InlineData (Justification.Right, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] - [InlineData (Justification.Right, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 2, 4, 7 })] - [InlineData (Justification.Right, new int [] { 10, 20, 30 }, 100, new int [] { 38, 49, 70 })] - [InlineData (Justification.Right, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] - [InlineData (Justification.Right, new int [] { 10 }, 101, new int [] { 91 })] - [InlineData (Justification.Right, new int [] { 10, 20 }, 101, new int [] { 70, 81 })] - [InlineData (Justification.Right, new int [] { 10, 20, 30 }, 101, new int [] { 39, 50, 71 })] - [InlineData (Justification.Right, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] - [InlineData (Justification.Right, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] - - [InlineData (Justification.Centered, new int [] { 0 }, 1, new int [] { 0 })] - [InlineData (Justification.Centered, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] - [InlineData (Justification.Centered, new int [] { 0, 0, 0 }, 1, new int [] { 0, 1, 1 })] - [InlineData (Justification.Centered, new int [] { 1 }, 1, new int [] { 0 })] - [InlineData (Justification.Centered, new int [] { 1 }, 2, new int [] { 0 })] - [InlineData (Justification.Centered, new int [] { 1 }, 3, new int [] { 1 })] - [InlineData (Justification.Centered, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] - [InlineData (Justification.Centered, new int [] { 1, 1 }, 3, new int [] { 0, 2 })] - [InlineData (Justification.Centered, new int [] { 1, 1 }, 4, new int [] { 0, 2 })] - [InlineData (Justification.Centered, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] - [InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] - [InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 7, new int [] { 0, 2, 4 })] - [InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 10, new int [] { 1, 3, 6 })] - [InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 11, new int [] { 1, 3, 6 })] - [InlineData (Justification.Centered, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] - [InlineData (Justification.Centered, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 2, 4, 7 })] - [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 9, new int [] { 0, 3, 6 })] - [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 10, new int [] { 0, 4, 7 })] - [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 11, new int [] { 0, 4, 8 })] - [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 12, new int [] { 0, 4, 8 })] - [InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 13, new int [] { 1, 5, 9 })] - [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] - [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 101, new int [] { 0, 34, 68 })] - [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 102, new int [] { 0, 34, 68 })] - [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 103, new int [] { 1, 35, 69 })] - [InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 104, new int [] { 1, 35, 69 })] - [InlineData (Justification.Centered, new int [] { 10 }, 101, new int [] { 45 })] - [InlineData (Justification.Centered, new int [] { 10, 20 }, 101, new int [] { 35, 46 })] - [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 100, new int [] { 19, 30, 51 })] - [InlineData (Justification.Centered, new int [] { 10, 20, 30 }, 101, new int [] { 19, 30, 51 })] - [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40 }, 100, new int [] { 0, 10, 30, 60 })] - [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] - [InlineData (Justification.Centered, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] - [InlineData (Justification.Centered, new int [] { 3, 4, 5, 6 }, 25, new int [] { 2, 6, 11, 17 })] - - [InlineData (Justification.Justified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] - [InlineData (Justification.Justified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] - [InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 30, 70 })] - [InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 31, 71 })] - [InlineData (Justification.Justified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] - [InlineData (Justification.Justified, new int [] { 11, 17, 23 }, 100, new int [] { 0, 36, 77 })] - [InlineData (Justification.Justified, new int [] { 1, 2, 3 }, 11, new int [] { 0, 4, 8 })] - [InlineData (Justification.Justified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - [InlineData (Justification.Justified, new int [] { 10 }, 101, new int [] { 0 })] - [InlineData (Justification.Justified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 9, 18 })] - [InlineData (Justification.Justified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 8, 16 })] - [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 18, new int [] { 0, 3, 7, 12 })] - [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 19, new int [] { 0, 4, 8, 13 })] - [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 20, new int [] { 0, 4, 9, 14 })] - [InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 21, new int [] { 0, 4, 9, 15 })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 22, new int [] { 0, 8, 14, 19 })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 23, new int [] { 0, 8, 15, 20, })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 24, new int [] { 0, 8, 15, 21 })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 25, new int [] { 0, 9, 16, 22 })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 26, new int [] { 0, 9, 17, 23 })] - [InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 31, new int [] { 0, 11, 20, 28 })] - - [InlineData (Justification.OneRightRestLeft, new int [] { 0 }, 1, new int [] { 0 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 0, 0, 0 }, 1, new int [] { 0, 1, 1 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 1, new int [] { 0 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 2, new int [] { 0 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 3, new int [] { 0 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 3, new int [] { 0, 2 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 4, new int [] { 0, 3 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 7, new int [] { 0, 2, 4 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 8, new int [] { 0, 2, 5 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 9, new int [] { 0, 2, 6 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 10, new int [] { 0, 2, 7 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 11, new int [] { 0, 2, 8 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 2, 4, 7 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 3, 3, 3 }, 21, new int [] { 0, 4, 18 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 3, 4, 5 }, 21, new int [] { 0, 4, 16 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 10 }, 101, new int [] { 0 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30 }, 100, new int [] { 0, 11, 70 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30 }, 101, new int [] { 0, 11, 71 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] - [InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] - - //[InlineData (Justification.SplitLeft, new int [] { 10, 20, 30 }, 100, new int [] { 0, 49, 70 })] - //[InlineData (Justification.SplitLeft, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 67 })] - //[InlineData (Justification.SplitLeft, new int [] { 10 }, 101, new int [] { 0 })] - //[InlineData (Justification.SplitLeft, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - //[InlineData (Justification.SplitLeft, new int [] { 10, 20, 30 }, 101, new int [] { 0, 50, 71 })] - //[InlineData (Justification.SplitLeft, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 9, 30, 61 })] - //[InlineData (Justification.SplitLeft, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 8, 29, 60, 101 })] - //[InlineData (Justification.SplitLeft, new int [] { 3, 3, 3 }, 21, new int [] { 0, 14, 18 })] - //[InlineData (Justification.SplitLeft, new int [] { 3, 4, 5 }, 21, new int [] { 0, 11, 16 })] - - public void TestJustifications_1Space (Justification justification, int [] sizes, int totalSize, int [] expected) + [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 })] + [InlineData (Justification.FirstLeftRestRight, new [] { 3, 3, 3 }, 21, new [] { 0, 14, 18 })] + [InlineData (Justification.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })] + public void TestJustifications_PutSpaceBetweenItems (Justification justification, int [] sizes, int totalSize, int [] expected) { - var positions = new Justifier () { MaxSpaceBetweenItems = 1 }.Justify (sizes, justification, totalSize); + int [] positions = new Justifier { PutSpaceBetweenItems = true }.Justify (sizes, justification, totalSize); AssertJustification (justification, sizes, totalSize, positions, expected); } [Theory] - //[InlineData (Justification.Left, new int [] { 0 }, 1, new int [] { 0 })] - //[InlineData (Justification.Left, new int [] { 0, 0 }, 1, new int [] { 0, 0 })] - //[InlineData (Justification.Left, new int [] { 0, 0, 0 }, 1, new int [] { 0, 0, 0 })] - //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] - //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 7, new int [] { 0, 1, 3 })] - //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 10, new int [] { 0, 1, 3 })] - //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 11, new int [] { 0, 1, 3 })] - //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 12, new int [] { 0, 1, 3 })] - //[InlineData (Justification.Left, new int [] { 1, 2, 3 }, 13, new int [] { 0, 1, 3 })] - //[InlineData (Justification.Left, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] - //[InlineData (Justification.Left, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 1, 3, 6 })] - //[InlineData (Justification.Left, new int [] { 10, 20, 30 }, 100, new int [] { 0, 10, 30 })] - //[InlineData (Justification.Left, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 66 })] - //[InlineData (Justification.Left, new int [] { 10 }, 101, new int [] { 0 })] - //[InlineData (Justification.Left, new int [] { 10, 20 }, 101, new int [] { 0, 10 })] - //[InlineData (Justification.Left, new int [] { 10, 20, 30 }, 101, new int [] { 0, 10, 30 })] - //[InlineData (Justification.Left, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 60 })] - //[InlineData (Justification.Left, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 100 })] - - //[InlineData (Justification.Right, new int [] { 0 }, 1, new int [] { 1 })] - //[InlineData (Justification.Right, new int [] { 0, 0 }, 1, new int [] { 1, 1 })] - //[InlineData (Justification.Right, new int [] { 0, 0, 0 }, 1, new int [] { 1, 1, 1 })] - //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] - //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 7, new int [] { 1, 2, 4 })] - //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 10, new int [] { 4, 5, 7 })] - //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 11, new int [] { 5, 6, 8 })] - //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 12, new int [] { 6, 7, 9 })] - //[InlineData (Justification.Right, new int [] { 1, 2, 3 }, 13, new int [] { 7, 8, 10 })] - //[InlineData (Justification.Right, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] - //[InlineData (Justification.Right, new int [] { 1, 2, 3, 4 }, 11, new int [] { 1, 2, 4, 7 })] - //[InlineData (Justification.Right, new int [] { 10, 20, 30 }, 100, new int [] { 40, 50, 70 })] - //[InlineData (Justification.Right, new int [] { 33, 33, 33 }, 100, new int [] { 1, 34, 67 })] - //[InlineData (Justification.Right, new int [] { 10 }, 101, new int [] { 91 })] - //[InlineData (Justification.Right, new int [] { 10, 20 }, 101, new int [] { 71, 81 })] - //[InlineData (Justification.Right, new int [] { 10, 20, 30 }, 101, new int [] { 41, 51, 71 })] - //[InlineData (Justification.Right, new int [] { 10, 20, 30, 40 }, 101, new int [] { 1, 11, 31, 61 })] - //[InlineData (Justification.Right, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 1, 11, 31, 61, 101 })] - - //[InlineData (Justification.Centered, new int [] { 1 }, 1, new int [] { 0 })] - //[InlineData (Justification.Centered, new int [] { 1 }, 2, new int [] { 0 })] - //[InlineData (Justification.Centered, new int [] { 1 }, 3, new int [] { 1 })] - //[InlineData (Justification.Centered, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] - //[InlineData (Justification.Centered, new int [] { 1, 1 }, 3, new int [] { 0, 1 })] - //[InlineData (Justification.Centered, new int [] { 1, 1 }, 4, new int [] { 1, 2 })] - //[InlineData (Justification.Centered, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] - //[InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] - //[InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 7, new int [] { 0, 1, 3 })] - //[InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 10, new int [] { 2, 3, 5 })] - //[InlineData (Justification.Centered, new int [] { 1, 2, 3 }, 11, new int [] { 2, 3, 5 })] - //[InlineData (Justification.Centered, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] - //[InlineData (Justification.Centered, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 1, 3, 6 })] - //[InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 9, new int [] { 0, 3, 6 })] - //[InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 10, new int [] { 0, 3, 6 })] - //[InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 11, new int [] { 1, 4, 7 })] - //[InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 12, new int [] { 1, 4, 7 })] - //[InlineData (Justification.Centered, new int [] { 3, 3, 3 }, 13, new int [] { 2, 5, 8 })] - //[InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 66 })] - //[InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 101, new int [] { 1, 34, 67 })] - //[InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 102, new int [] { 1, 34, 67 })] - //[InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 103, new int [] { 2, 35, 68 })] - //[InlineData (Justification.Centered, new int [] { 33, 33, 33 }, 104, new int [] { 2, 35, 68 })] - //[InlineData (Justification.Centered, new int [] { 3, 4, 5, 6 }, 25, new int [] { 3, 6, 10, 15 })] - - //[InlineData (Justification.Justified, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 11, 31, 61, 101 })] - //[InlineData (Justification.Justified, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 11, 31, 61 })] - //[InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 100, new int [] { 0, 30, 70 })] - //[InlineData (Justification.Justified, new int [] { 10, 20, 30 }, 101, new int [] { 0, 31, 71 })] - //[InlineData (Justification.Justified, new int [] { 33, 33, 33 }, 100, new int [] { 0, 34, 67 })] - //[InlineData (Justification.Justified, new int [] { 11, 17, 23 }, 100, new int [] { 0, 36, 77 })] - //[InlineData (Justification.Justified, new int [] { 1, 2, 3 }, 11, new int [] { 0, 4, 8 })] - //[InlineData (Justification.Justified, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - //[InlineData (Justification.Justified, new int [] { 10 }, 101, new int [] { 0 })] - //[InlineData (Justification.Justified, new int [] { 3, 3, 3 }, 21, new int [] { 0, 9, 18 })] - //[InlineData (Justification.Justified, new int [] { 3, 4, 5 }, 21, new int [] { 0, 8, 16 })] - //[InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 18, new int [] { 0, 3, 7, 12 })] - //[InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 19, new int [] { 0, 4, 8, 13 })] - //[InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 20, new int [] { 0, 4, 9, 14 })] - //[InlineData (Justification.Justified, new int [] { 3, 4, 5, 6 }, 21, new int [] { 0, 4, 9, 15 })] - //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 22, new int [] { 0, 8, 14, 19 })] - //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 23, new int [] { 0, 8, 15, 20, })] - //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 24, new int [] { 0, 8, 15, 21 })] - //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 25, new int [] { 0, 9, 16, 22 })] - //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 26, new int [] { 0, 9, 17, 23 })] - //[InlineData (Justification.Justified, new int [] { 6, 5, 4, 3 }, 31, new int [] { 0, 11, 20, 28 })] - - //[InlineData (Justification.OneRightRestLeft, new int [] { 0 }, 1, new int [] { 0 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 0, 0, 0 }, 1, new int [] { 0, 0, 1 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 1, new int [] { 0 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 2, new int [] { 0 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1 }, 3, new int [] { 0 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 3, new int [] { 0, 2 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 1 }, 4, new int [] { 0, 3 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 7, new int [] { 0, 1, 4 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 8, new int [] { 0, 1, 5 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 9, new int [] { 0, 1, 6 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 10, new int [] { 0, 1, 7 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3 }, 11, new int [] { 0, 1, 8 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 1, 3, 7 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 1, 2, 3, 4 }, 12, new int [] { 0, 1, 3, 8 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 3, 3, 3 }, 21, new int [] { 0, 3, 18 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 3, 4, 5 }, 21, new int [] { 0, 3, 16 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 67 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 10 }, 101, new int [] { 0 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30 }, 100, new int [] { 0, 10, 70 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30 }, 101, new int [] { 0, 10, 71 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 61 })] - //[InlineData (Justification.OneRightRestLeft, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 101, })] - - - [InlineData (Justification.OneLeftRestRight, new int [] { 0 }, 1, new int [] { 0 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 0, 0 }, 1, new int [] { 0, 1 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 0, 0, 0 }, 1, new int [] { 0, 1, 1 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1 }, 1, new int [] { 0 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1 }, 2, new int [] { 1 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1 }, 3, new int [] { 2 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1, 1 }, 2, new int [] { 0, 1 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1, 1 }, 3, new int [] { 0, 2 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1, 1 }, 4, new int [] { 0, 3 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1, 1, 1 }, 3, new int [] { 0, 1, 2 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 6, new int [] { 0, 1, 3 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 7, new int [] { 0, 2, 4 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 8, new int [] { 0, 3, 5 })] - [InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 9, new int [] { 0, 4, 6 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 10, new int [] { 0, 1, 7 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3 }, 11, new int [] { 0, 1, 8 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3, 4 }, 10, new int [] { 0, 1, 3, 6 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3, 4 }, 11, new int [] { 0, 1, 3, 7 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 1, 2, 3, 4 }, 12, new int [] { 0, 1, 3, 8 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 3, 3, 3 }, 21, new int [] { 0, 3, 18 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 3, 4, 5 }, 21, new int [] { 0, 3, 16 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 33, 33, 33 }, 100, new int [] { 0, 33, 67 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 10 }, 101, new int [] { 0 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 10, 20 }, 101, new int [] { 0, 81 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 10, 20, 30 }, 100, new int [] { 0, 10, 70 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 10, 20, 30 }, 101, new int [] { 0, 10, 71 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 10, 20, 30, 40 }, 101, new int [] { 0, 10, 30, 61 })] - //[InlineData (Justification.OneLeftRestRight, new int [] { 10, 20, 30, 40, 50 }, 151, new int [] { 0, 10, 30, 60, 101, })] - - - - public void TestJustifications_0Space (Justification justification, int [] sizes, int totalSize, int [] expected) + [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 totalSize, int [] expected) { - var positions = new Justifier () { MaxSpaceBetweenItems = 0 }.Justify (sizes, justification, totalSize); + int [] positions = new Justifier { PutSpaceBetweenItems = false }.Justify (sizes, justification, totalSize); AssertJustification (justification, sizes, totalSize, positions, expected); } @@ -364,33 +367,37 @@ public void AssertJustification (Justification justification, int [] sizes, int } } - 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 (int i = 0; i <= totalSize / 10; i++) + + for (var i = 0; i <= totalSize / 10; i++) { output.Append (i.ToString ().PadRight (9) + " "); } + output.AppendLine (); - for (int i = 0; i < totalSize; i++) + for (var i = 0; i < totalSize; i++) { output.Append (i % 10); } + output.AppendLine (); var items = new char [totalSize]; - for (int position = 0; position < positions.Length; position++) + + for (var position = 0; position < positions.Length; position++) { // try { - for (int j = 0; j < sizes [position] && positions [position] + j < totalSize; j++) + 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}"); @@ -404,5 +411,4 @@ public string RenderJustification (Justification justification, int [] sizes, in return output.ToString (); } - } From 13134df595d448095851c4152213271aed069fba Mon Sep 17 00:00:00 2001 From: Tig Date: Sun, 21 Apr 2024 00:02:26 -0600 Subject: [PATCH 006/173] Prototype Pos.Justify --- Terminal.Gui/Resources/config.json | 2 +- Terminal.Gui/View/Layout/PosDim.cs | 430 +++++++++++------ Terminal.Gui/View/Layout/ViewLayout.cs | 8 +- Terminal.Gui/Views/Dialog.cs | 14 +- Terminal.Gui/Views/Wizard/Wizard.cs | 2 +- UICatalog/Scenarios/ComputedLayout.cs | 8 +- UICatalog/Scenarios/Dialogs.cs | 4 +- UnitTests/Configuration/ThemeScopeTests.cs | 6 +- UnitTests/Configuration/ThemeTests.cs | 6 +- UnitTests/Dialogs/DialogTests.cs | 86 ++-- UnitTests/View/Layout/DimTests.cs | 537 ++++++++++++++++----- UnitTests/View/Layout/PosTests.cs | 230 +++++++-- 12 files changed, 955 insertions(+), 378 deletions(-) diff --git a/Terminal.Gui/Resources/config.json b/Terminal.Gui/Resources/config.json index 368ccd8bf5..4f82e43d6d 100644 --- a/Terminal.Gui/Resources/config.json +++ b/Terminal.Gui/Resources/config.json @@ -24,7 +24,7 @@ "Themes": [ { "Default": { - "Dialog.DefaultButtonAlignment": "Center", + "Dialog.DefaultButtonAlignment": "Centered", "FrameView.DefaultBorderStyle": "Single", "Window.DefaultBorderStyle": "Single", "ColorSchemes": [ diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs index 37f2a5bf0e..1147e96dc4 100644 --- a/Terminal.Gui/View/Layout/PosDim.cs +++ b/Terminal.Gui/View/Layout/PosDim.cs @@ -1,23 +1,10 @@ +using System.Diagnostics; +using static System.Net.Mime.MediaTypeNames; using static Terminal.Gui.Dialog; +using static Terminal.Gui.Dim; namespace Terminal.Gui; -/// Determines the horizontal alignment of Views. -public enum ViewAlignments -{ - /// Center-aligns the buttons (the default). - Center = 0, - - /// Justifies the buttons - Justify, - - /// Left-aligns the buttons - Left, - - /// Right-aligns the buttons - Right -} - /// /// Describes the position of a which can be an absolute value, a percentage, centered, or /// relative to the ending dimension. Integer values are implicitly convertible to an absolute . These @@ -203,12 +190,6 @@ public static Pos AnchorEnd (int offset) /// public static Pos Center () { return new PosCenter (); } - public static Pos Justify (View[] views, ViewAlignments alignment) - { - return new PosJustify (views, alignment); - } - - /// Determines whether the specified object is equal to the current object. /// The object to compare with the current object. /// @@ -225,6 +206,14 @@ public static Pos Justify (View[] views, ViewAlignments alignment) /// The returned from the function. public static Pos Function (Func function) { return new PosFunc (function); } + /// + /// Creates a object that justifies a set of views according to the specified justification. + /// + /// + /// + /// + public static Pos Justify ( Justification justification) { return new PosJustify (justification); } + /// Serves as the default hash function. /// A hash code for the current object. public override int GetHashCode () { return Anchor (0).GetHashCode (); } @@ -361,14 +350,17 @@ public static Pos Percent (float percent) /// height for y-coordinate calculation. /// /// The dimension of the View. It could be the current width or height. - /// Obsolete; to be deprecated. - /// Obsolete; to be deprecated. + /// The View that holds this Pos object. + /// Width or Height /// /// The calculated position of the View. The way this position is calculated depends on the specific subclass of Pos /// that /// is used. /// - internal virtual int Calculate (int superviewDimension, Dim dim, int autosize, bool autoSize) { return Anchor (superviewDimension); } + internal virtual int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension) + { + return Anchor (superviewDimension); + } internal class PosAbsolute (int n) : Pos { @@ -404,7 +396,7 @@ internal override int Anchor (int width) return width - _offset; } - internal override int Calculate (int superviewDimension, Dim dim, int autosize, bool autoSize) + internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension) { int newLocation = Anchor (superviewDimension); @@ -422,9 +414,9 @@ internal class PosCenter : Pos public override string ToString () { return "Center"; } internal override int Anchor (int width) { return width / 2; } - internal override int Calculate (int superviewDimension, Dim dim, int autosize, bool autoSize) + internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension) { - int newDimension = Math.Max (dim.Calculate (0, superviewDimension, autosize, autoSize), 0); + int newDimension = Math.Max (dim.Calculate (0, superviewDimension, us, dimension), 0); return Anchor (superviewDimension - newDimension); } @@ -450,11 +442,11 @@ internal override int Anchor (int width) return la - ra; } - internal override int Calculate (int superviewDimension, Dim dim, int autosize, bool autoSize) + internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension) { - int newDimension = dim.Calculate (0, superviewDimension, autosize, autoSize); - int left = _left.Calculate (superviewDimension, dim, autosize, autoSize); - int right = _right.Calculate (superviewDimension, dim, autosize, autoSize); + int newDimension = dim.Calculate (0, superviewDimension, us, dimension); + int left = _left.Calculate (superviewDimension, dim, us, dimension); + int right = _right.Calculate (superviewDimension, dim, us, dimension); if (_add) { @@ -474,6 +466,79 @@ internal class PosFactor (float factor) : Pos internal override int Anchor (int width) { return (int)(width * _factor); } } + + /// + /// Enables justification of a set of views. + /// + public class PosJustify : Pos + { + private readonly Justification _justification; + + /// + /// Enables justification of a set of views. + /// + /// The set of views to justify according to . + /// + public PosJustify (Justification justification) + { + _justification = justification; + } + + public override bool Equals (object other) + { + return other is PosJustify justify && justify._justification == _justification; + } + + public override int GetHashCode () { return _justification.GetHashCode (); } + + + public override string ToString () + { + return $"Justify(alignment={_justification})"; + } + + internal override int Anchor (int width) + { + return width; + } + + internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension) + { + // Find all the views that are being justified - they have the same justification and opposite position as us + // Use linq to filter us.Superview.Subviews that match `dimension` and are at our same location in the opposite dimension (e.g. if dimension is Width, filter by Y) + // Then, pass the array of views to the Justify method + int [] dimensions; + int [] positions; + + int ourIndex = 0; + if (dimension == Dimension.Width) + { + List dimensionsList = new List (); + for (int i = 0; i < us.SuperView.Subviews.Count; i++) + { + if (us.SuperView.Subviews [i].Frame.Y == us.Frame.Y) + { + dimensionsList.Add (us.SuperView.Subviews [i].Frame.Width); + + if (us.SuperView.Subviews [i] == us) + { + ourIndex = dimensionsList.Count - 1; + } + } + } + dimensions = dimensionsList.ToArray (); + positions = new Justifier ().Justify (dimensions, _justification, superviewDimension); + } + else + { + dimensions = us.SuperView.Subviews.Where (v => v.Frame.X == us.Frame.X).Select(v => v.Frame.Height ).ToArray (); + positions = new Justifier ().Justify (dimensions, _justification, superviewDimension); + } + + return positions [ourIndex]; + } + + } // Helper class to provide dynamic value by the execution of a function that returns an integer. internal class PosFunc (Func n) : Pos { @@ -484,11 +549,29 @@ internal class PosFunc (Func n) : Pos internal override int Anchor (int width) { return _function (); } } + /// + /// Describes which side of the view to use for the position. + /// public enum Side { + /// + /// The left (X) side of the view. + /// Left = 0, + + /// + /// The top (Y) side of the view. + /// Top = 1, + + /// + /// The right (X + Width) side of the view. + /// Right = 2, + + /// + /// The bottom (Y + Height) side of the view. + /// Bottom = 3 } @@ -503,8 +586,8 @@ public override string ToString () { string sideString = side switch { - Side.Left => "x", - Side.Top => "y", + Side.Left => "left", + Side.Top => "top", Side.Right => "right", Side.Bottom => "bottom", _ => "unknown" @@ -530,92 +613,6 @@ internal override int Anchor (int width) }; } } - - - /// - /// Enables justification of a set of views. - /// - public class PosJustify : Pos - { - private readonly View [] _views; - private readonly ViewAlignments _alignment; - - /// - /// Enables justification of a set of views. - /// - /// The set of views to justify according to . - /// - public PosJustify (View [] views, ViewAlignments alignment) - { - _alignment = alignment; - _views = views; - } - - public override bool Equals (object other) - { - return other is PosJustify justify && justify._views == _views && justify._alignment == _alignment; - } - - public override int GetHashCode () { return _views.GetHashCode (); } - - - public override string ToString () - { - return $"Justify(views={_views},alignment={_alignment})"; - } - - internal override int Anchor (int width) - { - if (_views.Length == 0 || !_views [0].IsInitialized) - { - return 0; - } - int spacing = 0; - switch (_alignment) - { - case ViewAlignments.Center: - // Center spacing is sum of the widths of the views - width / number of views - spacing = (width - _views.Select (v => v.Frame.Width).Sum ()) / _views.Length; - - // How do I know which view we are? - View us = _views.Where (v => v.X.Equals (this)).First(); - - if (_views [0] == us) - { - return spacing; - } - // Calculate the position of the previous (left or above us) view - int previous = _views.Where (v => v.X.Equals (us)).First().Frame.Left; - - return previous + spacing; - //case ViewAlignments.Left: - // return Left (width); - //case ViewAlignments.Right: - // return Right (width); - //case ViewAlignments.Justify: - // return Justify (width); - default: - return 0; - - } - } - - //internal override int Calculate (int superviewDimension, Dim dim, int autosize, bool autoSize) - //{ - // // Assuming autosize is the size that the View would have if it were to automatically adjust its size based on its content - // // and autoSize is a boolean value that indicates whether the View should automatically adjust its size based on its content - // if (autoSize) - // { - // return autosize; - // } - // else - // { - // // Assuming dim.Calculate returns the calculated size of the View - // return dim.Calculate (_views.Frame.Left, _views.Frame.Width, autosize, autoSize); - // } - //} - - } } /// @@ -638,6 +635,15 @@ internal override int Anchor (int width) /// /// /// +/// +/// +/// +/// Creates a object that automatically sizes the view to fit +/// the view's SubViews. +/// +/// +/// +/// /// /// /// @@ -687,6 +693,85 @@ internal override int Anchor (int width) /// public class Dim { + /// + /// Specifies how will compute the dimension. + /// + public enum DimAutoStyle + { + /// + /// The dimension will be computed using both the view's and + /// (whichever is larger). + /// + Auto, + + /// + /// The Subview in with the largest corresponding position plus dimension + /// will determine the dimension. + /// The corresponding dimension of the view's will be ignored. + /// + Subviews, + + /// + /// The corresponding dimension of the view's , formatted using the + /// settings, + /// will be used to determine the dimension. + /// The corresponding dimensions of the will be ignored. + /// + Text + } + + + /// + /// + /// + public enum Dimension + { + /// + /// No dimension specified. + /// + None = 0, + + /// + /// The height dimension. + /// + Height = 1, + + /// + /// The width dimension. + /// + Width = 2 + } + + + /// + /// Creates a object that automatically sizes the view to fit all of the view's SubViews and/or Text. + /// + /// + /// This initializes a with two SubViews. The view will be automatically sized to fit the two + /// SubViews. + /// + /// var button = new Button () { Text = "Click Me!", X = 1, Y = 1, Width = 10, Height = 1 }; + /// var textField = new TextField { Text = "Type here", X = 1, Y = 2, Width = 20, Height = 1 }; + /// var view = new Window () { Title = "MyWindow", X = 0, Y = 0, Width = Dim.Auto (), Height = Dim.Auto () }; + /// view.Add (button, textField); + /// + /// + /// The object. + /// + /// Specifies how will compute the dimension. The default is . + /// + /// Specifies the minimum dimension that view will be automatically sized to. + /// Specifies the maximum dimension that view will be automatically sized to. NOT CURRENTLY SUPPORTED. + public static Dim Auto (DimAutoStyle style = DimAutoStyle.Auto, Dim min = null, Dim max = null) + { + if (max != null) + { + throw new NotImplementedException (@"max is not implemented"); + } + + return new DimAuto (style, min, max); + } + /// Determines whether the specified object is equal to the current object. /// The object to compare with the current object. /// @@ -817,24 +902,22 @@ public static Dim Percent (float percent, bool usePosition = false) /// /// Calculates and returns the dimension of a object. It takes into account the location of the - /// , its current size, and whether it should automatically adjust its size based on its content. + /// , it's SuperView's ContentSize, and whether it should automatically adjust its size based on its content. /// /// /// The starting point from where the size calculation begins. It could be the left edge for width calculation or the /// top edge for height calculation. /// - /// The current size of the View. It could be the current width or height. - /// Obsolete; To be deprecated. - /// Obsolete; To be deprecated. + /// The size of the SuperView's content. It could be width or height. + /// The View that holds this Pos object. + /// Width or Height /// /// The calculated size of the View. The way this size is calculated depends on the specific subclass of Dim that /// is used. /// - internal virtual int Calculate (int location, int dimension, int autosize, bool autoSize) + internal virtual int Calculate (int location, int superviewContentSize, View us, Dimension dimension) { - int newDimension = Math.Max (Anchor (dimension - location), 0); - - return autoSize && autosize > newDimension ? autosize : newDimension; + return Math.Max (Anchor (superviewContentSize - location), 0); } internal class DimAbsolute (int n) : Dim @@ -845,15 +928,75 @@ internal class DimAbsolute (int n) : Dim public override string ToString () { return $"Absolute({_n})"; } internal override int Anchor (int width) { return _n; } - internal override int Calculate (int location, int dimension, int autosize, bool autoSize) + internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension) { // DimAbsolute.Anchor (int width) ignores width and returns n - int newDimension = Math.Max (Anchor (0), 0); - - return autoSize && autosize > newDimension ? autosize : newDimension; + return Math.Max (Anchor (0), 0); } } + internal class DimAuto (DimAutoStyle style, Dim min, Dim max) : Dim + { + internal readonly Dim _max = max; + internal readonly Dim _min = min; + internal readonly DimAutoStyle _style = style; + internal int Size; + + public override bool Equals (object other) { return other is DimAuto auto && auto._min == _min && auto._max == _max && auto._style == _style; } + public override int GetHashCode () { return HashCode.Combine (base.GetHashCode (), _min, _max, _style); } + public override string ToString () { return $"Auto({_style},{_min},{_max})"; } + + internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension) + { + if (us == null) + { + return _max?.Anchor (0) ?? 0; + } + + var textSize = 0; + var subviewsSize = 0; + + int autoMin = _min?.Anchor (superviewContentSize) ?? 0; + + if (superviewContentSize < autoMin) + { + Debug.WriteLine ($"WARNING: DimAuto specifies a min size ({autoMin}), but the SuperView's bounds are smaller ({superviewContentSize})."); + + return superviewContentSize; + } + + if (_style is Dim.DimAutoStyle.Text or Dim.DimAutoStyle.Auto) + { + textSize = int.Max (autoMin, dimension == Dimension.Width ? us.TextFormatter.Size.Width : us.TextFormatter.Size.Height); + } + + if (_style is Dim.DimAutoStyle.Subviews or Dim.DimAutoStyle.Auto) + { + subviewsSize = us.Subviews.Count == 0 + ? 0 + : us.Subviews + .Where (v => dimension == Dimension.Width ? v.X is not Pos.PosAnchorEnd : v.Y is not Pos.PosAnchorEnd) + .Max (v => dimension == Dimension.Width ? v.Frame.X + v.Frame.Width : v.Frame.Y + v.Frame.Height); + } + + int max = int.Max (textSize, subviewsSize); + + Thickness thickness = us.GetAdornmentsThickness (); + + if (dimension == Dimension.Width) + { + max += thickness.Horizontal; + } + else + { + max += thickness.Vertical; + } + + max = int.Max (max, autoMin); + return int.Min (max, _max?.Anchor (superviewContentSize) ?? superviewContentSize); + } + + } internal class DimCombine (bool add, Dim left, Dim right) : Dim { internal bool _add = add; @@ -874,10 +1017,10 @@ internal override int Anchor (int width) return la - ra; } - internal override int Calculate (int location, int dimension, int autosize, bool autoSize) + internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension) { - int leftNewDim = _left.Calculate (location, dimension, autosize, autoSize); - int rightNewDim = _right.Calculate (location, dimension, autosize, autoSize); + int leftNewDim = _left.Calculate (location, superviewContentSize, us, dimension); + int rightNewDim = _right.Calculate (location, superviewContentSize, us, dimension); int newDimension; @@ -890,8 +1033,9 @@ internal override int Calculate (int location, int dimension, int autosize, bool newDimension = Math.Max (0, leftNewDim - rightNewDim); } - return autoSize && autosize > newDimension ? autosize : newDimension; + return newDimension; } + } internal class DimFactor (float factor, bool remaining = false) : Dim @@ -905,11 +1049,9 @@ internal class DimFactor (float factor, bool remaining = false) : Dim public override string ToString () { return $"Factor({_factor},{_remaining})"; } internal override int Anchor (int width) { return (int)(width * _factor); } - internal override int Calculate (int location, int dimension, int autosize, bool autoSize) + internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension) { - int newDimension = _remaining ? Math.Max (Anchor (dimension - location), 0) : Anchor (dimension); - - return autoSize && autosize > newDimension ? autosize : newDimension; + return _remaining ? Math.Max (Anchor (superviewContentSize - location), 0) : Anchor (superviewContentSize); } } @@ -932,12 +1074,6 @@ internal class DimFunc (Func n) : Dim internal override int Anchor (int width) { return _function (); } } - public enum Dimension - { - Height = 0, - Width = 1 - } - internal class DimView : Dim { private readonly Dimension _side; @@ -979,4 +1115,4 @@ internal override int Anchor (int width) }; } } -} +} \ No newline at end of file diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 5c6f0cc648..c20e012dd4 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -1025,10 +1025,10 @@ internal void SetRelativeLayout (Size superviewContentSize) autoSize = GetAutoSize (); } - int newX = _x.Calculate (superviewContentSize.Width, _width, autoSize.Width, AutoSize); - int newW = _width.Calculate (newX, superviewContentSize.Width, autoSize.Width, AutoSize); - int newY = _y.Calculate (superviewContentSize.Height, _height, autoSize.Height, AutoSize); - int newH = _height.Calculate (newY, superviewContentSize.Height, autoSize.Height, AutoSize); + int newX = _x.Calculate (superviewContentSize.Width, _width, this, Dim.Dimension.Width); + int newW = _width.Calculate (newX, superviewContentSize.Width, this, Dim.Dimension.Width); + int newY = _y.Calculate (superviewContentSize.Height, _height, this, Dim.Dimension.Height); + int newH = _height.Calculate (newY, superviewContentSize.Height, this, Dim.Dimension.Height); Rectangle newFrame = new (newX, newY, newW, newH); diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index cd859ac0bc..564af72454 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -94,7 +94,7 @@ public bool Canceled } /// Determines how the s are aligned along the bottom of the dialog. - public ViewAlignments ButtonAlignment { get; set; } + public Justification ButtonAlignment { get; set; } /// Optional buttons to lay out at the bottom of the dialog. public Button [] Buttons @@ -114,11 +114,11 @@ public Button [] Buttons } } - /// The default for . + /// The default for . /// This property can be set in a Theme. [SerializableConfigurationProperty (Scope = typeof (ThemeScope))] [JsonConverter (typeof (JsonStringEnumConverter))] - public static ViewAlignments DefaultButtonAlignment { get; set; } = ViewAlignments.Center; + public static Justification DefaultButtonAlignment { get; set; } = Justification.Centered; /// /// Adds a to the , its layout will be controlled by the @@ -185,7 +185,7 @@ private void LayoutButtons () switch (ButtonAlignment) { - case ViewAlignments.Center: + case Justification.Centered: // Center Buttons shiftLeft = (Viewport.Width - buttonsWidth - _buttons.Count - 1) / 2 + 1; @@ -208,7 +208,7 @@ private void LayoutButtons () break; - case ViewAlignments.Justify: + case Justification.Justified: // Justify Buttons // leftmost and rightmost buttons are hard against edges. The rest are evenly spaced. @@ -243,7 +243,7 @@ private void LayoutButtons () break; - case ViewAlignments.Left: + case Justification.Left: // Left Align Buttons Button prevButton = _buttons [0]; prevButton.X = 0; @@ -259,7 +259,7 @@ private void LayoutButtons () break; - case ViewAlignments.Right: + case Justification.Right: // Right align buttons shiftLeft = _buttons [_buttons.Count - 1].Frame.Width; _buttons [_buttons.Count - 1].X = Pos.AnchorEnd (shiftLeft); diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index eddef7f4c5..e77d4cfe56 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -85,7 +85,7 @@ public Wizard () { // Using Justify causes the Back and Next buttons to be hard justified against // the left and right edge - ButtonAlignment = ViewAlignments.Justify; + ButtonAlignment = Justification.Justified; BorderStyle = LineStyle.Double; //// Add a horiz separator diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index fea26eab98..cd8f36ee49 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -408,10 +408,10 @@ public override void Main () app.Add (rightButton); - // Center three buttons with 5 spaces between them - leftButton.X = Pos.Justify (buttons, ViewAlignments.Center); - centerButton.X = Pos.Justify (buttons, ViewAlignments.Center); - rightButton.X = Pos.Justify (buttons, ViewAlignments.Center); + // Center three buttons with + leftButton.X = Pos.Justify (Justification.Centered); + centerButton.X = Pos.Justify (Justification.Centered); + rightButton.X = Pos.Justify (Justification.Centered); Application.Run (app); app.Dispose (); diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs index cc23993177..802591aad5 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -137,7 +137,7 @@ public override void Setup () { X = Pos.Right (label) + 1, Y = Pos.Top (label), - RadioLabels = new [] { "_Center", "_Justify", "_Left", "_Right" } + RadioLabels = new [] { "_Centered", "_Justified", "_Left", "_Right" } }; frame.Add (styleRadioGroup); @@ -265,7 +265,7 @@ Label buttonPressedLabel dialog = new Dialog { Title = titleEdit.Text, - ButtonAlignment = (ViewAlignments)styleRadioGroup.SelectedItem, + ButtonAlignment = (Justification)styleRadioGroup.SelectedItem, Buttons = buttons.ToArray () }; diff --git a/UnitTests/Configuration/ThemeScopeTests.cs b/UnitTests/Configuration/ThemeScopeTests.cs index b22ae60eee..0eecd05b7f 100644 --- a/UnitTests/Configuration/ThemeScopeTests.cs +++ b/UnitTests/Configuration/ThemeScopeTests.cs @@ -29,12 +29,12 @@ public void Apply_ShouldApplyUpdatedProperties () { Reset (); Assert.NotEmpty (Themes); - Assert.Equal (ViewAlignments.Center, Dialog.DefaultButtonAlignment); + Assert.Equal (Justification.Centered, Dialog.DefaultButtonAlignment); - Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = ViewAlignments.Right; + Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = Justification.Right; ThemeManager.Themes! [ThemeManager.SelectedTheme]!.Apply (); - Assert.Equal (ViewAlignments.Right, Dialog.DefaultButtonAlignment); + Assert.Equal (Justification.Right, Dialog.DefaultButtonAlignment); Reset (); } diff --git a/UnitTests/Configuration/ThemeTests.cs b/UnitTests/Configuration/ThemeTests.cs index c9c2ba2bb6..5ecee6bbe3 100644 --- a/UnitTests/Configuration/ThemeTests.cs +++ b/UnitTests/Configuration/ThemeTests.cs @@ -77,15 +77,15 @@ public void TestApply_UpdatesColors () public void TestSerialize_RoundTrip () { var theme = new ThemeScope (); - theme ["Dialog.DefaultButtonAlignment"].PropertyValue = ViewAlignments.Right; + theme ["Dialog.DefaultButtonAlignment"].PropertyValue = Justification.Right; string json = JsonSerializer.Serialize (theme, _jsonOptions); var deserialized = JsonSerializer.Deserialize (json, _jsonOptions); Assert.Equal ( - ViewAlignments.Right, - (ViewAlignments)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue + Justification.Right, + (Justification)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue ); Reset (); } diff --git a/UnitTests/Dialogs/DialogTests.cs b/UnitTests/Dialogs/DialogTests.cs index f74ea5b122..04f859ed0c 100644 --- a/UnitTests/Dialogs/DialogTests.cs +++ b/UnitTests/Dialogs/DialogTests.cs @@ -32,7 +32,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonAlignment = ViewAlignments.Center, + ButtonAlignment = Justification.Centered, Buttons = [new Button { Text = btn1Text }] }; @@ -57,7 +57,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonAlignment = ViewAlignments.Justify, + ButtonAlignment = Justification.Justified, Buttons = [new Button { Text = btn1Text }] }; @@ -82,7 +82,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonAlignment = ViewAlignments.Right, + ButtonAlignment = Justification.Right, Buttons = [new Button { Text = btn1Text }] }; @@ -107,7 +107,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonAlignment = ViewAlignments.Left, + ButtonAlignment = Justification.Left, Buttons = [new Button { Text = btn1Text }] }; @@ -155,7 +155,7 @@ public void ButtonAlignment_Four () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Center, + Justification.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -172,7 +172,7 @@ public void ButtonAlignment_Four () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Justify, + Justification.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -189,7 +189,7 @@ public void ButtonAlignment_Four () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Right, + Justification.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -206,7 +206,7 @@ public void ButtonAlignment_Four () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Left, + Justification.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -248,7 +248,7 @@ public void ButtonAlignment_Four_On_Too_Small_Width () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Center, + Justification.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -280,7 +280,7 @@ public void ButtonAlignment_Four_On_Too_Small_Width () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Justify, + Justification.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -296,7 +296,7 @@ public void ButtonAlignment_Four_On_Too_Small_Width () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Right, + Justification.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -312,7 +312,7 @@ public void ButtonAlignment_Four_On_Too_Small_Width () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Left, + Justification.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -353,7 +353,7 @@ public void ButtonAlignment_Four_WideOdd () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Center, + Justification.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -370,7 +370,7 @@ public void ButtonAlignment_Four_WideOdd () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Justify, + Justification.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -387,7 +387,7 @@ public void ButtonAlignment_Four_WideOdd () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Right, + Justification.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -404,7 +404,7 @@ public void ButtonAlignment_Four_WideOdd () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Left, + Justification.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -447,7 +447,7 @@ public void ButtonAlignment_Four_Wider () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Center, + Justification.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -464,7 +464,7 @@ public void ButtonAlignment_Four_Wider () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Justify, + Justification.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -481,7 +481,7 @@ public void ButtonAlignment_Four_Wider () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Right, + Justification.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -498,7 +498,7 @@ public void ButtonAlignment_Four_Wider () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Left, + Justification.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -530,7 +530,7 @@ public void ButtonAlignment_One () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Center, + Justification.Centered, new Button { Text = btnText } ); @@ -547,7 +547,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Justify, + Justification.Justified, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -562,7 +562,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Right, + Justification.Right, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -577,7 +577,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Left, + Justification.Left, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -594,7 +594,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Center, + Justification.Centered, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -609,7 +609,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Justify, + Justification.Justified, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -624,7 +624,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Right, + Justification.Right, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -639,7 +639,7 @@ public void ButtonAlignment_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Left, + Justification.Left, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -673,7 +673,7 @@ public void ButtonAlignment_Three () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Center, + Justification.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -689,7 +689,7 @@ public void ButtonAlignment_Three () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Justify, + Justification.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -705,7 +705,7 @@ public void ButtonAlignment_Three () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Right, + Justification.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -721,7 +721,7 @@ public void ButtonAlignment_Three () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Left, + Justification.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -755,7 +755,7 @@ public void ButtonAlignment_Two () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Center, + Justification.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -770,7 +770,7 @@ public void ButtonAlignment_Two () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Justify, + Justification.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -785,7 +785,7 @@ public void ButtonAlignment_Two () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Right, + Justification.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -800,7 +800,7 @@ public void ButtonAlignment_Two () (runstate, dlg) = RunButtonTestDialog ( title, width, - ViewAlignments.Left, + Justification.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -837,7 +837,7 @@ public void ButtonAlignment_Two_Hidden () // Default (Center) button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Center, button1, button2); + (runstate, dlg) = RunButtonTestDialog (title, width, Justification.Centered, button1, button2); button1.Visible = false; RunIteration (ref runstate, ref firstIteration); buttonRow = $@"{CM.Glyphs.VLine} {btn2} {CM.Glyphs.VLine}"; @@ -849,7 +849,7 @@ public void ButtonAlignment_Two_Hidden () Assert.Equal (width, buttonRow.Length); button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Justify, button1, button2); + (runstate, dlg) = RunButtonTestDialog (title, width, Justification.Justified, button1, button2); button1.Visible = false; RunIteration (ref runstate, ref firstIteration); buttonRow = $@"{CM.Glyphs.VLine} {btn2}{CM.Glyphs.VLine}"; @@ -861,7 +861,7 @@ public void ButtonAlignment_Two_Hidden () Assert.Equal (width, buttonRow.Length); button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Right, button1, button2); + (runstate, dlg) = RunButtonTestDialog (title, width, Justification.Right, button1, button2); button1.Visible = false; RunIteration (ref runstate, ref firstIteration); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -872,7 +872,7 @@ public void ButtonAlignment_Two_Hidden () Assert.Equal (width, buttonRow.Length); button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Left, button1, button2); + (runstate, dlg) = RunButtonTestDialog (title, width, Justification.Left, button1, button2); button1.Visible = false; RunIteration (ref runstate, ref firstIteration); buttonRow = $@"{CM.Glyphs.VLine} {btn2} {CM.Glyphs.VLine}"; @@ -1301,7 +1301,7 @@ public void One_Button_Works () (runstate, Dialog _) = RunButtonTestDialog ( title, width, - ViewAlignments.Center, + Justification.Centered, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -1347,7 +1347,7 @@ public void Zero_Buttons_Works () int width = buttonRow.Length; d.SetBufferSize (buttonRow.Length, 3); - (runstate, Dialog _) = RunButtonTestDialog (title, width, ViewAlignments.Center, null); + (runstate, Dialog _) = RunButtonTestDialog (title, width, Justification.Centered, null); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); End (runstate); @@ -1356,7 +1356,7 @@ public void Zero_Buttons_Works () private (RunState, Dialog) RunButtonTestDialog ( string title, int width, - ViewAlignments align, + Justification align, params Button [] btns ) { diff --git a/UnitTests/View/Layout/DimTests.cs b/UnitTests/View/Layout/DimTests.cs index c1a529a728..04f636c802 100644 --- a/UnitTests/View/Layout/DimTests.cs +++ b/UnitTests/View/Layout/DimTests.cs @@ -25,61 +25,62 @@ public DimTests (ITestOutputHelper output) } [Fact] - public void DimAbsolute_GetDimension_ReturnsCorrectValue () + public void DimAbsolute_Calculate_ReturnsCorrectValue () { var dim = new DimAbsolute (10); - var result = dim.Calculate (0, 100, 50, false); + var result = dim.Calculate (0, 100, null, Dim.Dimension.None); Assert.Equal (10, result); } [Fact] - public void DimCombine_GetDimension_ReturnsCorrectValue () + public void DimCombine_Calculate_ReturnsCorrectValue () { var dim1 = new DimAbsolute (10); var dim2 = new DimAbsolute (20); var dim = dim1 + dim2; - var result = dim.Calculate (0, 100, 50, false); + var result = dim.Calculate (0, 100, null, Dim.Dimension.None); Assert.Equal (30, result); } [Fact] - public void DimFactor_GetDimension_ReturnsCorrectValue () + public void DimFactor_Calculate_ReturnsCorrectValue () { var dim = new DimFactor (0.5f); - var result = dim.Calculate (0, 100, 50, false); + var result = dim.Calculate (0, 100, null, Dim.Dimension.None); Assert.Equal (50, result); } [Fact] - public void DimFill_GetDimension_ReturnsCorrectValue () + public void DimFill_Calculate_ReturnsCorrectValue () { var dim = Dim.Fill (); - var result = dim.Calculate (0, 100, 50, false); + var result = dim.Calculate (0, 100, null, Dim.Dimension.None); Assert.Equal (100, result); } [Fact] - public void DimFunc_GetDimension_ReturnsCorrectValue () + public void DimFunc_Calculate_ReturnsCorrectValue () { var dim = new DimFunc (() => 10); - var result = dim.Calculate (0, 100, 50, false); + var result = dim.Calculate (0, 100, null, Dim.Dimension.None); Assert.Equal (10, result); } [Fact] - public void DimView_GetDimension_ReturnsCorrectValue () + public void DimView_Calculate_ReturnsCorrectValue () { var view = new View { Width = 10 }; var dim = new DimView (view, Dimension.Width); - var result = dim.Calculate (0, 100, 50, false); + var result = dim.Calculate (0, 100, null, Dim.Dimension.None); Assert.Equal (10, result); } + // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved // A new test that does not depend on Application is needed. [Fact] [AutoInitShutdown] - public void Dim_Add_Operator () + public void Add_Operator () { Toplevel top = new (); @@ -372,7 +373,7 @@ public void DimCombine_ObtuseScenario_Does_Not_Throw_If_Two_SubViews_Refs_The_Sa /// This is an intentionally obtuse test. See https://github.com/gui-cs/Terminal.Gui/issues/2461 [Fact] [TestRespondersDisposed] - public void DimCombine_ObtuseScenario_Throw_If_SuperView_Refs_SubView () + public void Combine_ObtuseScenario_Throw_If_SuperView_Refs_SubView () { var t = new View { Width = 80, Height = 25 }; @@ -420,55 +421,159 @@ public void DimCombine_ObtuseScenario_Throw_If_SuperView_Refs_SubView () // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved // TODO: A new test that calls SetRelativeLayout directly is needed. + [Fact] + [TestRespondersDisposed] + public void Combine_View_Not_Added_Throws () + { + var t = new View { Width = 80, Height = 50 }; + + var super = new View { Width = Dim.Width (t) - 2, Height = Dim.Height (t) - 2 }; + t.Add (super); + + var sub = new View (); + super.Add (sub); + + var v1 = new View { Width = Dim.Width (super) - 2, Height = Dim.Height (super) - 2 }; + var v2 = new View { Width = Dim.Width (v1) - 2, Height = Dim.Height (v1) - 2 }; + sub.Add (v1); + + // v2 not added to sub; should cause exception on Layout since it's referenced by sub. + sub.Width = Dim.Fill () - Dim.Width (v2); + sub.Height = Dim.Fill () - Dim.Height (v2); + + t.BeginInit (); + t.EndInit (); + + Assert.Throws (() => t.LayoutSubviews ()); + t.Dispose (); + v2.Dispose (); + } + + // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved + // TODO: A new test that calls SetRelativeLayout directly is needed. + [Fact] + [TestRespondersDisposed] + public void + Dim_Validation_Does_Not_Throw_If_NewValue_Is_DimAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute () + { + var t = new View { Width = 80, Height = 25, Text = "top" }; + + var w = new Window { Width = Dim.Fill (), Height = Dim.Sized (10) }; + var v = new View { Width = Dim.Width (w) - 2, Height = Dim.Percent (10), Text = "v" }; + + w.Add (v); + t.Add (w); + + Assert.Equal (LayoutStyle.Absolute, t.LayoutStyle); + Assert.Equal (LayoutStyle.Computed, w.LayoutStyle); + Assert.Equal (LayoutStyle.Computed, v.LayoutStyle); + + t.LayoutSubviews (); + Assert.Equal (2, v.Width = 2); + Assert.Equal (2, v.Height = 2); + + // Force v to be LayoutStyle.Absolute; + v.Frame = new Rectangle (0, 1, 3, 4); + Assert.Equal (LayoutStyle.Absolute, v.LayoutStyle); + t.LayoutSubviews (); + + Assert.Equal (2, v.Width = 2); + Assert.Equal (2, v.Height = 2); + t.Dispose (); + } + + [Fact] + public void Fill_Equal () + { + var margin1 = 0; + var margin2 = 0; + Dim dim1 = Dim.Fill (margin1); + Dim dim2 = Dim.Fill (margin2); + Assert.Equal (dim1, dim2); + } + + // Tests that Dim.Fill honors the margin parameter correctly [Theory] - [AutoInitShutdown] - [InlineData (0, true)] - [InlineData (0, false)] - [InlineData (50, true)] - [InlineData (50, false)] - public void DimPercentPlusOne (int startingDistance, bool testHorizontal) + [InlineData (0, true, 25)] + [InlineData (0, false, 25)] + [InlineData (1, true, 24)] + [InlineData (1, false, 24)] + [InlineData (2, true, 23)] + [InlineData (2, false, 23)] + [InlineData (-2, true, 27)] + [InlineData (-2, false, 27)] + public void Fill_Margin (int margin, bool width, int expected) { - var container = new View { Width = 100, Height = 100 }; + var super = new View { Width = 25, Height = 25 }; - var label = new Label + var view = new View { - AutoSize = false, - X = testHorizontal ? startingDistance : 0, - Y = testHorizontal ? 0 : startingDistance, - Width = testHorizontal ? Dim.Percent (50) + 1 : 1, - Height = testHorizontal ? 1 : Dim.Percent (50) + 1 + X = 0, + Y = 0, + Width = width ? Dim.Fill (margin) : 1, + Height = width ? 1 : Dim.Fill (margin) }; - container.Add (label); - var top = new Toplevel (); - top.Add (container); - top.BeginInit (); - top.EndInit (); - top.LayoutSubviews (); + super.Add (view); + super.BeginInit (); + super.EndInit (); + super.LayoutSubviews (); - Assert.Equal (100, container.Frame.Width); - Assert.Equal (100, container.Frame.Height); + Assert.Equal (25, super.Frame.Width); + Assert.Equal (25, super.Frame.Height); - if (testHorizontal) + if (width) { - Assert.Equal (51, label.Frame.Width); - Assert.Equal (1, label.Frame.Height); + Assert.Equal (expected, view.Frame.Width); + Assert.Equal (1, view.Frame.Height); } else { - Assert.Equal (1, label.Frame.Width); - Assert.Equal (51, label.Frame.Height); + Assert.Equal (1, view.Frame.Width); + Assert.Equal (expected, view.Frame.Height); } } - [Fact] - public void Fill_Equal () + // Tests that Dim.Fill fills the dimension REMAINING from the View's X position to the end of the super view's width + [Theory] + [InlineData (0, true, 25)] + [InlineData (0, false, 25)] + [InlineData (1, true, 24)] + [InlineData (1, false, 24)] + [InlineData (2, true, 23)] + [InlineData (2, false, 23)] + [InlineData (-2, true, 27)] + [InlineData (-2, false, 27)] + public void Fill_Offset (int offset, bool width, int expected) { - var margin1 = 0; - var margin2 = 0; - Dim dim1 = Dim.Fill (margin1); - Dim dim2 = Dim.Fill (margin2); - Assert.Equal (dim1, dim2); + var super = new View { Width = 25, Height = 25 }; + + var view = new View + { + X = width ? offset : 0, + Y = width ? 0 : offset, + Width = width ? Dim.Fill () : 1, + Height = width ? 1 : Dim.Fill () + }; + + super.Add (view); + super.BeginInit (); + super.EndInit (); + super.LayoutSubviews (); + + Assert.Equal (25, super.Frame.Width); + Assert.Equal (25, super.Frame.Height); + + if (width) + { + Assert.Equal (expected, view.Frame.Width); + Assert.Equal (1, view.Frame.Height); + } + else + { + Assert.Equal (1, view.Frame.Width); + Assert.Equal (expected, view.Frame.Height); + } } // TODO: Other Dim.Height tests (e.g. Equal?) @@ -670,45 +775,45 @@ public void Only_DimAbsolute_And_DimFactor_As_A_Different_Procedure_For_Assignin t.Ready += (s, e) => { - Assert.Equal ("Absolute(100)", w.Width.ToString ()); - Assert.Equal ("Absolute(100)", w.Height.ToString ()); - Assert.Equal (100, w.Frame.Width); - Assert.Equal (100, w.Frame.Height); - - Assert.Equal ("Factor(0.5,False)", f1.Width.ToString ()); - Assert.Equal ("Absolute(5)", f1.Height.ToString ()); - Assert.Equal (49, f1.Frame.Width); // 50-1=49 - Assert.Equal (5, f1.Frame.Height); - - Assert.Equal ("Fill(0)", f2.Width.ToString ()); - Assert.Equal ("Absolute(5)", f2.Height.ToString ()); - Assert.Equal (49, f2.Frame.Width); // 50-1=49 - Assert.Equal (5, f2.Frame.Height); - - #if DEBUG + Assert.Equal ("Absolute(100)", w.Width.ToString ()); + Assert.Equal ("Absolute(100)", w.Height.ToString ()); + Assert.Equal (100, w.Frame.Width); + Assert.Equal (100, w.Frame.Height); + + Assert.Equal ("Factor(0.5,False)", f1.Width.ToString ()); + Assert.Equal ("Absolute(5)", f1.Height.ToString ()); + Assert.Equal (49, f1.Frame.Width); // 50-1=49 + Assert.Equal (5, f1.Frame.Height); + + Assert.Equal ("Fill(0)", f2.Width.ToString ()); + Assert.Equal ("Absolute(5)", f2.Height.ToString ()); + Assert.Equal (49, f2.Frame.Width); // 50-1=49 + Assert.Equal (5, f2.Frame.Height); + +#if DEBUG Assert.Equal ($"Combine(View(Width,FrameView(f1){f1.Border.Frame})-Absolute(2))", v1.Width.ToString ()); - #else +#else Assert.Equal ($"Combine(View(Width,FrameView(){f1.Border.Frame})-Absolute(2))", v1.Width.ToString ()); - #endif +#endif Assert.Equal ("Combine(Fill(0)-Absolute(2))", v1.Height.ToString ()); Assert.Equal (47, v1.Frame.Width); // 49-2=47 Assert.Equal (89, v1.Frame.Height); // 98-5-2-2=89 - #if DEBUG +#if DEBUG Assert.Equal ( $"Combine(View(Width,FrameView(f2){f2.Frame})-Absolute(2))", v2.Width.ToString () - #else +#else Assert.Equal ( $"Combine(View(Width,FrameView(){f2.Frame})-Absolute(2))", v2.Width.ToString () - #endif +#endif ); - #if DEBUG +#if DEBUG Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ()); - #else +#else Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ()); - #endif +#endif Assert.Equal (47, v2.Frame.Width); // 49-2=47 Assert.Equal (89, v2.Frame.Height); // 98-5-2-2=89 @@ -757,22 +862,22 @@ public void Only_DimAbsolute_And_DimFactor_As_A_Different_Procedure_For_Assignin Assert.Equal (5, f2.Frame.Height); v1.Text = "Button1"; - #if DEBUG +#if DEBUG Assert.Equal ($"Combine(View(Width,FrameView(f1){f1.Frame})-Absolute(2))", v1.Width.ToString ()); - #else +#else Assert.Equal ($"Combine(View(Width,FrameView(){f1.Frame})-Absolute(2))", v1.Width.ToString ()); - #endif +#endif Assert.Equal ("Combine(Fill(0)-Absolute(2))", v1.Height.ToString ()); Assert.Equal (97, v1.Frame.Width); // 99-2=97 Assert.Equal (189, v1.Frame.Height); // 198-2-7=189 v2.Text = "Button2"; - #if DEBUG - Assert.Equal ( $"Combine(View(Width,FrameView(f2){f2.Frame})-Absolute(2))", v2.Width.ToString ()); - #else +#if DEBUG + Assert.Equal ($"Combine(View(Width,FrameView(f2){f2.Frame})-Absolute(2))", v2.Width.ToString ()); +#else Assert.Equal ($"Combine(View(Width,FrameView(){f2.Frame})-Absolute(2))", v2.Width.ToString ()); - #endif +#endif Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ()); Assert.Equal (97, v2.Frame.Width); // 99-2=97 Assert.Equal (189, v2.Frame.Height); // 198-2-7=189 @@ -782,7 +887,7 @@ public void Only_DimAbsolute_And_DimFactor_As_A_Different_Procedure_For_Assignin Assert.Equal ("Factor(0.1,False)", v3.Height.ToString ()); // 198*10%=19 * Percent is related to the super-view if it isn't null otherwise the view width - Assert.Equal (19, v3.Frame.Width ); + Assert.Equal (19, v3.Frame.Width); // 199*10%=19 Assert.Equal (19, v3.Frame.Height); @@ -793,20 +898,20 @@ public void Only_DimAbsolute_And_DimFactor_As_A_Different_Procedure_For_Assignin Assert.Equal (50, v4.Frame.Width); Assert.Equal (50, v4.Frame.Height); v4.AutoSize = true; - Assert.Equal ("Absolute(11)", v4.Width.ToString ()); - Assert.Equal ("Absolute(1)", v4.Height.ToString ()); + Assert.Equal (Dim.Auto (DimAutoStyle.Text), v4.Width); + Assert.Equal (Dim.Auto (DimAutoStyle.Text), v4.Height); Assert.Equal (11, v4.Frame.Width); // 11 is the text length and because is Dim.DimAbsolute Assert.Equal (1, v4.Frame.Height); // 1 because is Dim.DimAbsolute v5.Text = "Button5"; - #if DEBUG +#if DEBUG Assert.Equal ($"Combine(View(Width,Button(v1){v1.Frame})-View(Width,Button(v3){v3.Frame}))", v5.Width.ToString ()); Assert.Equal ($"Combine(View(Height,Button(v1){v1.Frame})-View(Height,Button(v3){v3.Frame}))", v5.Height.ToString ()); - #else +#else Assert.Equal ($"Combine(View(Width,Button(){v1.Frame})-View(Width,Button(){v3.Frame}))", v5.Width.ToString ()); Assert.Equal ($"Combine(View(Height,Button(){v1.Frame})-View(Height,Button(){v3.Frame}))", v5.Height.ToString ()); - #endif +#endif Assert.Equal (78, v5.Frame.Width); // 97-9=78 Assert.Equal (170, v5.Frame.Height); // 189-19=170 @@ -880,6 +985,89 @@ public void Percent_Invalid_Throws () Assert.Throws (() => dim = Dim.Percent (1000001)); } + [Theory] + [InlineData (0, false, true, 12)] + [InlineData (0, false, false, 12)] + [InlineData (1, false, true, 12)] + [InlineData (1, false, false, 12)] + [InlineData (2, false, true, 12)] + [InlineData (2, false, false, 12)] + + [InlineData (0, true, true, 12)] + [InlineData (0, true, false, 12)] + [InlineData (1, true, true, 12)] + [InlineData (1, true, false, 12)] + [InlineData (2, true, true, 11)] + [InlineData (2, true, false, 11)] + public void Percent_Position (int position, bool usePosition, bool width, int expected) + { + var super = new View { Width = 25, Height = 25 }; + + var view = new View + { + X = width ? position : 0, + Y = width ? 0 : position, + Width = width ? Dim.Percent (50, usePosition) : 1, + Height = width ? 1 : Dim.Percent (50, usePosition) + }; + + super.Add (view); + super.BeginInit (); + super.EndInit (); + super.LayoutSubviews (); + + Assert.Equal (25, super.Frame.Width); + Assert.Equal (25, super.Frame.Height); + + if (width) + { + Assert.Equal (expected, view.Frame.Width); + Assert.Equal (1, view.Frame.Height); + } + else + { + Assert.Equal (1, view.Frame.Width); + Assert.Equal (expected, view.Frame.Height); + } + } + + [Theory] + [InlineData (0, true)] + [InlineData (0, false)] + [InlineData (50, true)] + [InlineData (50, false)] + public void Percent_PlusOne (int startingDistance, bool testHorizontal) + { + var super = new View { Width = 100, Height = 100 }; + + var view = new View + { + X = testHorizontal ? startingDistance : 0, + Y = testHorizontal ? 0 : startingDistance, + Width = testHorizontal ? Dim.Percent (50) + 1 : 1, + Height = testHorizontal ? 1 : Dim.Percent (50) + 1 + }; + + super.Add (view); + super.BeginInit (); + super.EndInit (); + super.LayoutSubviews (); + + Assert.Equal (100, super.Frame.Width); + Assert.Equal (100, super.Frame.Height); + + if (testHorizontal) + { + Assert.Equal (51, view.Frame.Width); + Assert.Equal (1, view.Frame.Height); + } + else + { + Assert.Equal (1, view.Frame.Width); + Assert.Equal (51, view.Frame.Height); + } + } + [Fact] public void Percent_SetsValue () { @@ -898,47 +1086,24 @@ public void Percent_SetsValue () // TODO: A new test that calls SetRelativeLayout directly is needed. [Fact] [TestRespondersDisposed] - public void PosCombine_View_Not_Added_Throws () + public void Referencing_SuperView_Does_Not_Throw () { - var t = new View { Width = 80, Height = 50 }; - - var super = new View { Width = Dim.Width (t) - 2, Height = Dim.Height (t) - 2 }; - t.Add (super); - - var sub = new View (); - super.Add (sub); - - var v1 = new View { Width = Dim.Width (super) - 2, Height = Dim.Height (super) - 2 }; - var v2 = new View { Width = Dim.Width (v1) - 2, Height = Dim.Height (v1) - 2 }; - sub.Add (v1); - - // v2 not added to sub; should cause exception on Layout since it's referenced by sub. - sub.Width = Dim.Fill () - Dim.Width (v2); - sub.Height = Dim.Fill () - Dim.Height (v2); - - t.BeginInit (); - t.EndInit (); + var super = new View { Width = 10, Height = 10, Text = "super" }; - Assert.Throws (() => t.LayoutSubviews ()); - t.Dispose (); - v2.Dispose (); - } + var view = new View + { + Width = Dim.Width (super), // this is allowed + Height = Dim.Height (super), // this is allowed + Text = "view" + }; - [Fact] - [TestRespondersDisposed] - public void SetsValue () - { - var testVal = Rectangle.Empty; - var testValView = new View { Frame = testVal }; - Dim dim = Dim.Width (testValView); - Assert.Equal ($"View(Width,View(){testVal})", dim.ToString ()); - testValView.Dispose (); + super.Add (view); + super.BeginInit (); + super.EndInit (); - testVal = new Rectangle (1, 2, 3, 4); - testValView = new View { Frame = testVal }; - dim = Dim.Width (testValView); - Assert.Equal ($"View(Width,View(){testVal})", dim.ToString ()); - testValView.Dispose (); + Exception exception = Record.Exception (super.LayoutSubviews); + Assert.Null (exception); + super.Dispose (); } [Fact] @@ -982,6 +1147,119 @@ public void Sized_SetsValue () Assert.Equal ($"Absolute({testVal})", dim.ToString ()); } + // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved + // TODO: A new test that calls SetRelativeLayout directly is needed. + [Fact] + [AutoInitShutdown] + public void Subtract_Operator () + { + Toplevel top = new Toplevel (); + + var view = new View { X = 0, Y = 0, Width = 20, Height = 0 }; + var field = new TextField { X = 0, Y = Pos.Bottom (view), Width = 20 }; + var count = 20; + List public class Justifier { - private int _maxSpaceBetweenItems; + /// + /// Gets or sets how the justifies items within a container. + /// + public Justification Justification { get; set; } + + /// + /// The size of the container. + /// + public int ContainerSize { get; set; } /// /// Gets or sets whether puts a space is placed between items. Default is . If , a space will be - /// placed between each item, which is useful for - /// justifying text. + /// placed between each item, which is useful for justifying text. + /// + public bool PutSpaceBetweenItems { get; set; } + + /// + /// Takes a list of items and returns their positions when justified within a container wide based on the specified + /// . /// - public bool PutSpaceBetweenItems + /// The sizes of the items to justify. + /// The locations of the items, from left to right. + public int [] Justify (int [] sizes) { - get => _maxSpaceBetweenItems == 1; - set => _maxSpaceBetweenItems = value ? 1 : 0; + return Justify (Justification, PutSpaceBetweenItems, ContainerSize, sizes); } /// @@ -104,28 +118,23 @@ public bool PutSpaceBetweenItems /// /// The sizes of the items to justify. /// The justification style. - /// The width of the container. + /// The size of the container. /// The locations of the items, from left to right. - public int [] Justify (int [] sizes, Justification justification, int containerSize) + public static int [] Justify (Justification justification, bool putSpaceBetweenItems, int containerSize, int [] sizes) { if (sizes.Length == 0) { return new int [] { }; } - int totalItemsSize = sizes.Sum (); - - if (totalItemsSize > containerSize) - { - // throw new ArgumentException ("The sum of the sizes is greater than the total size."); - } + int maxSpaceBetweenItems = putSpaceBetweenItems ? 1 : 0; - var positions = new int [sizes.Length]; - totalItemsSize = sizes.Sum (); // total size of items - int totalGaps = sizes.Length - 1; // total gaps (MinimumSpaceBetweenItems) - 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 + 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; @@ -154,7 +163,7 @@ public int [] Justify (int [] sizes, Justification justification, int containerS continue; } - int spaceBefore = spaces-- > 0 ? _maxSpaceBetweenItems : 0; + 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; @@ -171,7 +180,7 @@ public int [] Justify (int [] sizes, Justification justification, int containerS throw new ArgumentException ("The size of an item cannot be negative."); } - int spaceBefore = spaces-- > 0 ? _maxSpaceBetweenItems : 0; + int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0; positions [i] = currentPosition; currentPosition += sizes [i] + spaceBefore; @@ -199,7 +208,7 @@ public int [] Justify (int [] sizes, Justification justification, int containerS continue; } - int spaceBefore = spaces-- > 0 ? _maxSpaceBetweenItems : 0; + 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; @@ -251,7 +260,7 @@ public int [] Justify (int [] sizes, Justification justification, int containerS if (i < sizes.Length - 1) { - int spaceBefore = spaces-- > 0 ? _maxSpaceBetweenItems : 0; + int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0; positions [i] = currentPosition; currentPosition += sizes [i] + spaceBefore; @@ -295,7 +304,7 @@ public int [] Justify (int [] sizes, Justification justification, int containerS if (i < sizes.Length - 1 && i > 0) { - int spaceBefore = spaces-- > 0 ? _maxSpaceBetweenItems : 0; + int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0; positions [i] = currentPosition - sizes [i] - spaceBefore; currentPosition = positions [i]; diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs index 5e1b2a58b7..37e8580dfb 100644 --- a/Terminal.Gui/View/Layout/PosDim.cs +++ b/Terminal.Gui/View/Layout/PosDim.cs @@ -469,7 +469,8 @@ internal class PosFactor (float factor) : Pos /// public class PosJustify : Pos { - private readonly Justification _justification; + internal readonly Justifier _justifier; + internal int? _location; /// /// Enables justification of a set of views. @@ -478,81 +479,39 @@ public class PosJustify : Pos /// public PosJustify (Justification justification) { - _justification = justification; + _justifier = new () + { + PutSpaceBetweenItems = false, + Justification = justification, + }; } public override bool Equals (object other) { - return other is PosJustify justify && justify._justification == _justification; + return other is PosJustify justify && justify._justifier == _justifier; } - public override int GetHashCode () { return _justification.GetHashCode (); } + public override int GetHashCode () { return _justifier.GetHashCode (); } public override string ToString () { - return $"Justify(alignment={_justification})"; + return $"Justify(justification={_justifier.Justification})"; } internal override int Anchor (int width) { - return width; + return _location ?? 0 - width; } internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension) { - if (us.SuperView is null) - { - return 0; - } - // Find all the views that are being justified - they have the same justification and opposite position as us - // Then, pass the array of views to the Justify method - int [] dimensions; - int [] positions; - - int ourIndex = 0; - if (dimension == Dim.Dimension.Width) - { - List dimensionsList = new List (); - for (int i = 0; i < us.SuperView.Subviews.Count; i++) - { - var v = us.SuperView.Subviews [i]; - var j = v.X as PosJustify; - if (j?._justification == _justification && v.Frame.Y == us.Frame.Y) - { - dimensionsList.Add (v.Frame.Width); - - if (v == us) - { - ourIndex = dimensionsList.Count - 1; - } - } - } - dimensions = dimensionsList.ToArray (); - positions = new Justifier () { PutSpaceBetweenItems = true }.Justify (dimensions, _justification, superviewDimension); - } - else + if (_location.HasValue) { - List dimensionsList = new List (); - for (int i = 0; i < us.SuperView.Subviews.Count; i++) - { - var v = us.SuperView.Subviews [i]; - var j = v.Y as PosJustify; - if (j?._justification == _justification && v.Frame.X == us.Frame.X) - { - dimensionsList.Add (v.Frame.Height); - - if (v == us) - { - ourIndex = dimensionsList.Count - 1; - } - } - } - dimensions = dimensionsList.ToArray (); - positions = new Justifier () { PutSpaceBetweenItems = false }.Justify (dimensions, _justification, superviewDimension); + return _location.Value; } - return positions [ourIndex]; + return 0; } } diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index e112100bc3..877d07bfb5 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using static Terminal.Gui.Pos; namespace Terminal.Gui; @@ -850,13 +851,62 @@ public virtual void LayoutSubviews () foreach (View v in ordered) { - // TODO: Move this logic into the Pos/Dim classes + var justifyX = v.X as PosJustify; + var justifyY = v.Y as PosJustify; + + if (justifyX is { } || justifyY is { }) + { + int xIndex = 0; + int yIndex = 0; + List XdimensionsList = new (); + List YdimensionsList = new (); + for (int i = 0; i < v.SuperView.Subviews.Count; i++) + { + var viewI = v.SuperView.Subviews [i]; + + var jX = viewI.X as PosJustify; + var jY = viewI.Y as PosJustify; + + if (jX?._justifier.Justification == justifyX?._justifier.Justification && viewI.Frame.Y == v.Frame.Y) + { + XdimensionsList.Add (viewI.Frame.Width); + + if (viewI == v) + { + xIndex = XdimensionsList.Count - 1; + } + } + + if (jY?._justifier.Justification == justifyY?._justifier.Justification && viewI.Frame.X == v.Frame.X) + { + YdimensionsList.Add (viewI.Frame.Height); + + if (viewI == v) + { + yIndex = YdimensionsList.Count - 1; + } + } + } + if (justifyX is { }) + { + justifyX._justifier.ContainerSize = Viewport.Size.Width; + justifyX._location = justifyX._justifier.Justify (XdimensionsList.ToArray ()) [xIndex]; + } + + if (justifyY is { }) + { + justifyY._justifier.ContainerSize = Viewport.Size.Height; + justifyY._location = justifyY._justifier.Justify (YdimensionsList.ToArray ()) [yIndex]; + } + } + + // TODO: Move this logic into the Pos/Dim classes if (v.Width is Dim.DimAuto || v.Height is Dim.DimAuto) { // If the view is auto-sized... Rectangle f = v.Frame; - v._frame = new (v.Frame.X, v.Frame.Y, 0, 0); + v._frame = v.Frame with { Width = 0, Height = 0 }; LayoutSubview (v, Viewport.Size); if (v.Frame != f) @@ -1005,8 +1055,8 @@ internal void OnResizeNeeded () { //if (AutoSize) { - // SetFrameToFitText (); - SetTextFormatterSize (); + // SetFrameToFitText (); + SetTextFormatterSize (); } LayoutAdornments (); @@ -1064,15 +1114,6 @@ internal void SetRelativeLayout (Size superviewContentSize) CheckDimAuto (); - SetTextFormatterSize (); - - var autoSize = Size.Empty; - - //if (AutoSize) - //{ - // // TODO: Nuke this from orbit once Dim.Auto is fully implemented - // autoSize = GetTextAutoSize (); - //} SetTextFormatterSize (); if (TextFormatter.NeedsFormat) { diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs index 15a30def0d..dc10b4397a 100644 --- a/Terminal.Gui/Views/Button.cs +++ b/Terminal.Gui/Views/Button.cs @@ -45,7 +45,7 @@ public Button () _leftDefault = Glyphs.LeftDefaultIndicator; _rightDefault = Glyphs.RightDefaultIndicator; - Height = 1; + Height = Dim.Auto (Dim.DimAutoStyle.Text); Width = Dim.Auto (Dim.DimAutoStyle.Text); CanFocus = true; diff --git a/UICatalog/Scenarios/Generic.cs b/UICatalog/Scenarios/Generic.cs index ca5ee4d35c..b4da210318 100644 --- a/UICatalog/Scenarios/Generic.cs +++ b/UICatalog/Scenarios/Generic.cs @@ -18,9 +18,10 @@ public override void Main () }; int leftMargin = 0; - var just = Justification.Justified; + var just = Justification.Centered; var button = new Button { X = Pos.Justify(just), Y = Pos.Center (), Text = "Press me!" }; + //button.Margin.Thickness = new Thickness (leftMargin, 0, 0, 0); button.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed the button!", "Ok"); appWindow.Add (button); diff --git a/UnitTests/Drawing/JustifierTests.cs b/UnitTests/Drawing/JustifierTests.cs index 3f0a081883..2f98ec4304 100644 --- a/UnitTests/Drawing/JustifierTests.cs +++ b/UnitTests/Drawing/JustifierTests.cs @@ -19,26 +19,30 @@ public static IEnumerable JustificationEnumValues () [MemberData (nameof (JustificationEnumValues))] public void NoItems_Works (Justification justification) { - int [] sizes = { }; - int [] positions = new Justifier ().Justify (sizes, justification, 100); + int [] sizes = []; + int [] positions = Justifier.Justify (justification, false, 100, sizes); Assert.Equal (new int [] { }, positions); } - //[Theory] - //[MemberData (nameof (JustificationEnumValues))] - //public void Items_Width_Cannot_Exceed_TotalSize (Justification justification) - //{ - // int [] sizes = { 1000, 2000, 3000 }; - // Assert.Throws (() => new Justifier ().Justify (sizes, justification, 100)); - //} - [Theory] [MemberData (nameof (JustificationEnumValues))] public void Negative_Widths_Not_Allowed (Justification justification) { - Assert.Throws (() => new Justifier ().Justify (new [] { -10, 20, 30 }, justification, 100)); - Assert.Throws (() => new Justifier ().Justify (new [] { 10, -20, 30 }, justification, 100)); - Assert.Throws (() => new Justifier ().Justify (new [] { 10, 20, -30 }, justification, 100)); + Assert.Throws (() => new Justifier () + { + Justification = justification, + ContainerSize = 100 + }.Justify (new [] { -10, 20, 30 })); + Assert.Throws (() => new Justifier () + { + Justification = justification, + ContainerSize = 100 + }.Justify (new [] { 10, -20, 30 })); + Assert.Throws (() => new Justifier () + { + Justification = justification, + ContainerSize = 100 + }.Justify (new [] { 10, 20, -30 })); } [Theory] @@ -197,10 +201,15 @@ public void Negative_Widths_Not_Allowed (Justification justification) [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })] [InlineData (Justification.FirstLeftRestRight, new [] { 3, 3, 3 }, 21, new [] { 0, 14, 18 })] [InlineData (Justification.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })] - public void TestJustifications_PutSpaceBetweenItems (Justification justification, int [] sizes, int totalSize, int [] expected) + public void TestJustifications_PutSpaceBetweenItems (Justification justification, int [] sizes, int containerSize, int [] expected) { - int [] positions = new Justifier { PutSpaceBetweenItems = true }.Justify (sizes, justification, totalSize); - AssertJustification (justification, sizes, totalSize, positions, expected); + int [] positions = new Justifier + { + PutSpaceBetweenItems = true, + Justification = justification, + ContainerSize = containerSize + }.Justify (sizes); + AssertJustification (justification, sizes, containerSize, positions, expected); } [Theory] @@ -341,10 +350,15 @@ public void TestJustifications_PutSpaceBetweenItems (Justification justification [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 totalSize, int [] expected) + public void TestJustifications_NoSpaceBetweenItems (Justification justification, int [] sizes, int containerSize, int [] expected) { - int [] positions = new Justifier { PutSpaceBetweenItems = false }.Justify (sizes, justification, totalSize); - AssertJustification (justification, sizes, totalSize, positions, 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) From 3585e92da6e9f1ab8350d9b249ce7d3941b30dda Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 22 Apr 2024 06:28:42 -0600 Subject: [PATCH 013/173] Put error handling code in sep method. --- Terminal.Gui/Drawing/Justification.cs | 63 ++++++++------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs index 16c76c372c..7836ec6582 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Justification.cs @@ -151,11 +151,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI for (var i = 0; i < sizes.Length; i++) { - if (sizes [i] < 0) - { - throw new ArgumentException ("The size of an item cannot be negative."); - } - + CheckSizeCannotBeNegative (i, sizes); if (i == 0) { positions [0] = 0; // first item position @@ -175,11 +171,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI for (var i = 0; i < sizes.Length; i++) { - if (sizes [i] < 0) - { - throw new ArgumentException ("The size of an item cannot be negative."); - } - + CheckSizeCannotBeNegative (i, sizes); int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0; positions [i] = currentPosition; @@ -196,11 +188,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI for (var i = 0; i < sizes.Length; i++) { - if (sizes [i] < 0) - { - throw new ArgumentException ("The size of an item cannot be negative."); - } - + CheckSizeCannotBeNegative (i, sizes); if (i == 0) { positions [i] = remainingSpace / 2; // first item position @@ -216,11 +204,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI } else if (sizes.Length == 1) { - if (sizes [0] < 0) - { - throw new ArgumentException ("The size of an item cannot be negative."); - } - + CheckSizeCannotBeNegative (0, sizes); positions [0] = (containerSize - sizes [0]) / 2; // single item is centered } @@ -233,11 +217,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI for (var i = 0; i < sizes.Length; i++) { - if (sizes [i] < 0) - { - throw new ArgumentException ("The size of an item cannot be negative."); - } - + CheckSizeCannotBeNegative (i, sizes); positions [i] = currentPosition; int extraSpace = i < remainder ? 1 : 0; currentPosition += sizes [i] + spaceBetween + extraSpace; @@ -253,11 +233,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI for (var i = 0; i < sizes.Length; i++) { - if (sizes [i] < 0) - { - throw new ArgumentException ("The size of an item cannot be negative."); - } - + CheckSizeCannotBeNegative (i,sizes); if (i < sizes.Length - 1) { int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0; @@ -267,14 +243,11 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI } } - positions [sizes.Length - 1] = containerSize - sizes [sizes.Length - 1]; + positions [sizes.Length - 1] = containerSize - sizes [^1]; } else if (sizes.Length == 1) { - if (sizes [0] < 0) - { - throw new ArgumentException ("The size of an item cannot be negative."); - } + CheckSizeCannotBeNegative (0, sizes); positions [0] = containerSize - sizes [0]; // single item is flush right } @@ -290,11 +263,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI for (int i = sizes.Length - 1; i >= 0; i--) { - if (sizes [i] < 0) - { - throw new ArgumentException ("The size of an item cannot be negative."); - } - + CheckSizeCannotBeNegative (i, sizes); if (i == sizes.Length - 1) { // start at right @@ -313,11 +282,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI } else if (sizes.Length == 1) { - if (sizes [0] < 0) - { - throw new ArgumentException ("The size of an item cannot be negative."); - } - + CheckSizeCannotBeNegative (0, sizes); positions [0] = 0; // single item is flush left } @@ -329,4 +294,12 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI 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."); + } + } } From 4b4c3ae6aae7945314141b4ab4ca3179d698ea18 Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 22 Apr 2024 06:31:12 -0600 Subject: [PATCH 014/173] Code cleanup --- Terminal.Gui/Drawing/Justification.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs index 7836ec6582..28ede7577b 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Justification.cs @@ -1,7 +1,7 @@ namespace Terminal.Gui; /// -/// Controls how the justifies items within a container. +/// Controls how the justifies items within a container. /// public enum Justification { @@ -96,7 +96,7 @@ public class Justifier public int ContainerSize { get; set; } /// - /// Gets or sets whether puts a space is placed between items. Default is . If , a space will be + /// Gets or sets whether puts a space is placed between items. Default is . If , a space will be /// placed between each item, which is useful for justifying text. /// public bool PutSpaceBetweenItems { get; set; } @@ -118,6 +118,7 @@ public int [] Justify (int [] sizes) /// /// The sizes of the items to justify. /// The justification style. + /// Puts a space is placed between items. /// The size of the container. /// The locations of the items, from left to right. public static int [] Justify (Justification justification, bool putSpaceBetweenItems, int containerSize, int [] sizes) From c9830de3c014eb793b7599ac7f4d5a92fa3020ba Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 22 Apr 2024 06:53:30 -0600 Subject: [PATCH 015/173] Got Dialog working. AnchorEnd has a bug --- Terminal.Gui/Drawing/Justification.cs | 25 ++-- Terminal.Gui/View/ViewText.cs | 10 +- Terminal.Gui/Views/Dialog.cs | 207 +++++++++++++------------- Terminal.Gui/Views/MessageBox.cs | 7 +- UICatalog/Scenarios/Dialogs.cs | 7 +- 5 files changed, 136 insertions(+), 120 deletions(-) diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs index 28ede7577b..de459de60f 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Justification.cs @@ -86,34 +86,34 @@ public enum Justification public class Justifier { /// - /// Gets or sets how the justifies items within a container. + /// Gets or sets how the justifies items within a container. /// public Justification Justification { get; set; } /// - /// The size of the container. + /// The size of the container. /// public int ContainerSize { get; set; } /// - /// Gets or sets whether puts a space is placed between items. Default is . If , a space will be + /// Gets or sets whether puts a space is placed between items. Default is + /// . If , a space will be /// placed between each item, which is useful for justifying text. /// public bool PutSpaceBetweenItems { get; set; } /// - /// Takes a list of items and returns their positions when justified within a container wide based on the specified + /// Takes a list of items and returns their positions when justified within a container + /// wide based on the specified /// . /// /// The sizes of the items to justify. /// The locations of the items, from left to right. - public int [] Justify (int [] sizes) - { - return Justify (Justification, PutSpaceBetweenItems, ContainerSize, sizes); - } + public int [] Justify (int [] sizes) { return Justify (Justification, PutSpaceBetweenItems, ContainerSize, sizes); } /// - /// Takes a list of items and returns their positions when justified within a container wide based on the specified + /// Takes a list of items and returns their positions when justified within a container + /// wide based on the specified /// . /// /// The sizes of the items to justify. @@ -136,6 +136,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI 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; @@ -153,6 +154,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI for (var i = 0; i < sizes.Length; i++) { CheckSizeCannotBeNegative (i, sizes); + if (i == 0) { positions [0] = 0; // first item position @@ -190,6 +192,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI for (var i = 0; i < sizes.Length; i++) { CheckSizeCannotBeNegative (i, sizes); + if (i == 0) { positions [i] = remainingSpace / 2; // first item position @@ -234,7 +237,8 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI for (var i = 0; i < sizes.Length; i++) { - CheckSizeCannotBeNegative (i,sizes); + CheckSizeCannotBeNegative (i, sizes); + if (i < sizes.Length - 1) { int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0; @@ -265,6 +269,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI for (int i = sizes.Length - 1; i >= 0; i--) { CheckSizeCannotBeNegative (i, sizes); + if (i == sizes.Length - 1) { // start at right diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs index 9dab46773b..6c2eb66ffb 100644 --- a/Terminal.Gui/View/ViewText.cs +++ b/Terminal.Gui/View/ViewText.cs @@ -248,12 +248,12 @@ internal Size GetSizeNeededForTextWithoutHotKey () /// internal void SetTextFormatterSize () { - //if (!IsInitialized) - //{ - // TextFormatter.Size = Size.Empty; + if (!IsInitialized) + { + TextFormatter.Size = Size.Empty; - // return; - //} + return; + } if (string.IsNullOrEmpty (TextFormatter.Text)) { diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index 8c64478df9..a987361a85 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -92,6 +92,7 @@ public bool Canceled } } + // TODO: Update button.X = Pos.Justify when alignment changes /// Determines how the s are aligned along the bottom of the dialog. public Justification ButtonAlignment { get; set; } @@ -131,7 +132,9 @@ public void AddButton (Button button) return; } - //button.AutoSize = false; // BUGBUG: v2 - Hack to get around autosize not accounting for Margin? + button.X = Pos.Justify (ButtonAlignment); + button.Y = Pos.AnchorEnd () - 1; + _buttons.Add (button); Add (button); @@ -171,108 +174,108 @@ internal int GetButtonsWidth () return widths.Sum (); } - private void LayoutButtons () - { - if (_buttons.Count == 0 || !IsInitialized) - { - return; - } + //private void LayoutButtons () + //{ + // if (_buttons.Count == 0 || !IsInitialized) + // { + // return; + // } - var shiftLeft = 0; + // var shiftLeft = 0; - int buttonsWidth = GetButtonsWidth (); + // int buttonsWidth = GetButtonsWidth (); - switch (ButtonAlignment) - { - case Justification.Centered: - // 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 Justification.Justified: - // 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 Justification.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 Justification.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; - } - } + // switch (ButtonAlignment) + // { + // case Justification.Centered: + // // 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 Justification.Justified: + // // 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 Justification.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 Justification.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; + // } + //} } diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index d758d62f67..871d1b51c1 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -325,7 +325,12 @@ params string [] buttons foreach (string s in buttons) { - var b = new Button { Text = s, Y = Pos.AnchorEnd (), X = Pos.Justify (Justification.Centered) }; + var b = new Button + { + Text = s, + Y = Pos.AnchorEnd (), + X = Pos.Justify (Justification.Centered) + }; if (count == defaultButton) { diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs index 802591aad5..38fced9ca3 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -137,7 +137,7 @@ public override void Setup () { X = Pos.Right (label) + 1, Y = Pos.Top (label), - RadioLabels = new [] { "_Centered", "_Justified", "_Left", "_Right" } + RadioLabels = Enum.GetNames (typeof (Justification)), }; frame.Add (styleRadioGroup); @@ -241,7 +241,10 @@ Label buttonPressedLabel } else { - button = new Button { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 }; + button = new Button + { + Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 + }; } button.Accept += (s, e) => From bf15da3e8b794581595707761bce9e9666545593 Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 22 Apr 2024 07:03:10 -0600 Subject: [PATCH 016/173] Code cleanup --- Terminal.Gui/Drawing/Justification.cs | 30 ++++++++++++++++++++++++++- UICatalog/Scenarios/Dialogs.cs | 17 ++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs index de459de60f..afa701b5da 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Justification.cs @@ -17,6 +17,13 @@ public enum Justification /// Left, + /// + /// The items will be aligned to the top. + /// Set to to ensure at least one line between + /// each item. + /// + Top = Left, + /// /// The items will be aligned to the right. /// Set to to ensure at least one space between @@ -29,6 +36,13 @@ public enum Justification /// Right, + /// + /// The items will be aligned to the bottom. + /// Set to to ensure at least one line between + /// each item. + /// + Bottom = Right, + /// /// The group will be centered in the container. /// If centering is not possible, the group will be left-justified. @@ -67,6 +81,13 @@ public enum Justification /// FirstLeftRestRight, + /// + /// The first item will be aligned to the top and the remaining will aligned to the bottom. + /// Set to to ensure at least one line between + /// each item. + /// + FirstTopRestBottom = FirstLeftRestRight, + /// /// The last item will be aligned to the right and the remaining will aligned to the left. /// Set to to ensure at least one space between @@ -77,7 +98,14 @@ public enum Justification /// 111 2222 33333 /// /// - LastRightRestLeft + LastRightRestLeft, + + /// + /// The last item will be aligned to the bottom and the remaining will aligned to the left. + /// Set to to ensure at least one line between + /// each item. + /// + LastBottomRestTop, } /// diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs index 38fced9ca3..48bbb6c5c6 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Terminal.Gui; namespace UICatalog.Scenarios; @@ -133,11 +134,25 @@ public override void Setup () Text = "Button St_yle:" }; frame.Add (label); + + static IEnumerable GetUniqueEnumNames () where T : Enum + { + var values = new HashSet (); + foreach (var name in Enum.GetNames (typeof (T))) + { + var value = (int)Enum.Parse (typeof (T), name); + if (values.Add (value)) + { + yield return name; + } + } + } + var styleRadioGroup = new RadioGroup { X = Pos.Right (label) + 1, Y = Pos.Top (label), - RadioLabels = Enum.GetNames (typeof (Justification)), + RadioLabels = GetUniqueEnumNames ().ToArray (), }; frame.Add (styleRadioGroup); From 7fc4f5a55e02aa0e736b7d6b589e30d69745b299 Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 22 Apr 2024 11:26:37 -0600 Subject: [PATCH 017/173] Aded PosJusityf scenario . fixed issues. WIP --- Terminal.Gui/Drawing/Justification.cs | 15 +- Terminal.Gui/View/Layout/PosDim.cs | 85 +++++++-- Terminal.Gui/View/Layout/ViewLayout.cs | 57 +----- Terminal.Gui/Views/RadioGroup.cs | 37 ++-- UICatalog/Scenarios/Generic.cs | 74 +------- UICatalog/Scenarios/PosJustification.cs | 221 ++++++++++++++++++++++++ 6 files changed, 340 insertions(+), 149 deletions(-) create mode 100644 UICatalog/Scenarios/PosJustification.cs diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs index afa701b5da..b5bb2c9fac 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Justification.cs @@ -1,3 +1,5 @@ +using static Terminal.Gui.Pos; + namespace Terminal.Gui; /// @@ -105,7 +107,7 @@ public enum Justification /// Set to to ensure at least one line between /// each item. /// - LastBottomRestTop, + LastBottomRestTop = LastRightRestLeft, } /// @@ -336,4 +338,15 @@ private static void CheckSizeCannotBeNegative (int i, int [] sizes) throw new ArgumentException ("The size of an item cannot be negative."); } } + public override bool Equals (object other) + { + if (other is Justifier justifier) + { + return Justification == justifier.Justification && + ContainerSize == justifier.ContainerSize && + PutSpaceBetweenItems == justifier.PutSpaceBetweenItems; + } + + return false; + } } diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs index 37e8580dfb..d223c7a2e5 100644 --- a/Terminal.Gui/View/Layout/PosDim.cs +++ b/Terminal.Gui/View/Layout/PosDim.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using static Terminal.Gui.Dim; namespace Terminal.Gui; @@ -209,7 +210,7 @@ public static Pos AnchorEnd (int offset) /// /// /// - public static Pos Justify ( Justification justification) { return new PosJustify (justification); } + public static Pos Justify (Justification justification) { return new PosJustify (justification); } /// Serves as the default hash function. /// A hash code for the current object. @@ -469,8 +470,74 @@ internal class PosFactor (float factor) : Pos /// public class PosJustify : Pos { - internal readonly Justifier _justifier; - internal int? _location; + public Justifier Justifier { get; } = new (); + public int? _location; + + public int GroupId { get; set; } + + public static void JustifyGroup (int groupId, IList views, Dim.Dimension dimension, int size) + { + if (views is null) + { + return; + } + Justifier firstInGroup = null; + List dimensionsList = new (); + List viewsInGroup = views.Where ( + v => + { + if (dimension == Dimension.Width && v.X is PosJustify justifyX) + { + return justifyX.GroupId == groupId; + } + + if (dimension == Dimension.Height && v.Y is PosJustify justifyY) + { + return justifyY.GroupId == groupId; + } + + return false; + }).ToList (); + if (viewsInGroup.Count == 0) + { + return; + } + + foreach (var view in viewsInGroup) + { + var posJustify = dimension == Dimension.Width ? view.X as PosJustify : view.Y as PosJustify; + + if (posJustify is { }) + { + if (firstInGroup is null) + { + firstInGroup = posJustify.Justifier; + } + + dimensionsList.Add (dimension == Dimension.Width ? view.Frame.Width : view.Frame.Height); + } + } + + if (firstInGroup is null) + { + return; + } + + firstInGroup.ContainerSize = size; + + var locations = firstInGroup.Justify (dimensionsList.ToArray ()); + + for (var index = 0; index < viewsInGroup.Count; index++) + { + View view = viewsInGroup [index]; + PosJustify justify = dimension == Dimension.Width ? view.X as PosJustify : view.Y as PosJustify; + + if (justify is { }) + { + justify._location = locations [index]; + } + } + } /// /// Enables justification of a set of views. @@ -479,24 +546,20 @@ public class PosJustify : Pos /// public PosJustify (Justification justification) { - _justifier = new () - { - PutSpaceBetweenItems = false, - Justification = justification, - }; + Justifier.Justification = justification; } public override bool Equals (object other) { - return other is PosJustify justify && justify._justifier == _justifier; + return other is PosJustify justify && justify.Justifier.Equals (Justifier); } - public override int GetHashCode () { return _justifier.GetHashCode (); } + public override int GetHashCode () { return Justifier.GetHashCode (); } public override string ToString () { - return $"Justify(justification={_justifier.Justification})"; + return $"Justify(justification={Justifier.Justification})"; } internal override int Anchor (int width) diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 877d07bfb5..c43ca1c135 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -193,7 +193,7 @@ public Pos X get => VerifyIsInitialized (_x, nameof (X)); set { - if (Equals (_x, value)) + if (_x.Equals (value)) { return; } @@ -232,7 +232,7 @@ public Pos Y get => VerifyIsInitialized (_y, nameof (Y)); set { - if (Equals (_y, value)) + if (_y.Equals (value)) { return; } @@ -843,6 +843,9 @@ public virtual void LayoutSubviews () SetTextFormatterSize (); + PosJustify.JustifyGroup (0, SuperView?.Subviews, Dim.Dimension.Width, Viewport.Width); + PosJustify.JustifyGroup (0, SuperView?.Subviews, Dim.Dimension.Height, Viewport.Height); + // Sort out the dependencies of the X, Y, Width, Height properties HashSet nodes = new (); HashSet<(View, View)> edges = new (); @@ -851,56 +854,6 @@ public virtual void LayoutSubviews () foreach (View v in ordered) { - var justifyX = v.X as PosJustify; - var justifyY = v.Y as PosJustify; - - if (justifyX is { } || justifyY is { }) - { - int xIndex = 0; - int yIndex = 0; - List XdimensionsList = new (); - List YdimensionsList = new (); - for (int i = 0; i < v.SuperView.Subviews.Count; i++) - { - var viewI = v.SuperView.Subviews [i]; - - var jX = viewI.X as PosJustify; - var jY = viewI.Y as PosJustify; - - if (jX?._justifier.Justification == justifyX?._justifier.Justification && viewI.Frame.Y == v.Frame.Y) - { - XdimensionsList.Add (viewI.Frame.Width); - - if (viewI == v) - { - xIndex = XdimensionsList.Count - 1; - } - } - - if (jY?._justifier.Justification == justifyY?._justifier.Justification && viewI.Frame.X == v.Frame.X) - { - YdimensionsList.Add (viewI.Frame.Height); - - if (viewI == v) - { - yIndex = YdimensionsList.Count - 1; - } - } - } - - if (justifyX is { }) - { - justifyX._justifier.ContainerSize = Viewport.Size.Width; - justifyX._location = justifyX._justifier.Justify (XdimensionsList.ToArray ()) [xIndex]; - } - - if (justifyY is { }) - { - justifyY._justifier.ContainerSize = Viewport.Size.Height; - justifyY._location = justifyY._justifier.Justify (YdimensionsList.ToArray ()) [yIndex]; - } - } - // TODO: Move this logic into the Pos/Dim classes if (v.Width is Dim.DimAuto || v.Height is Dim.DimAuto) { diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs index 5c9d6b477c..59af39bd55 100644 --- a/Terminal.Gui/Views/RadioGroup.cs +++ b/Terminal.Gui/Views/RadioGroup.cs @@ -80,6 +80,11 @@ public RadioGroup () HighlightStyle = Gui.HighlightStyle.PressedOutside | Gui.HighlightStyle.Pressed; MouseClick += RadioGroup_MouseClick; + + // TOOD: Hack - using Text when we should use SubViews + Add (_dummyView); + Width = Dim.Auto (Dim.DimAutoStyle.Subviews); + Height = Dim.Auto (Dim.DimAutoStyle.Subviews); } // TODO: Fix InvertColorsOnPress - only highlight the selected item @@ -172,7 +177,7 @@ public string [] RadioLabels } } - if (IsInitialized && prevCount != _radioLabels.Count) + if (prevCount != _radioLabels.Count) { SetWidthHeight (_radioLabels); } @@ -439,21 +444,25 @@ private void MoveUp () } } - private void RadioGroup_LayoutStarted (object sender, EventArgs e) { SetWidthHeight (_radioLabels); } + private void RadioGroup_LayoutStarted (object sender, EventArgs e) { /*SetWidthHeight (_radioLabels);*/ } private void SelectItem () { SelectedItem = _cursor; } + private View _dummyView = new View () {}; private void SetWidthHeight (List radioLabels) { switch (_orientation) { case Orientation.Vertical: Rectangle r = MakeRect (0, 0, radioLabels); + // TODO: Hack + _dummyView.X = r.Width + +GetAdornmentsThickness ().Horizontal; + _dummyView.Y = radioLabels.Count + GetAdornmentsThickness ().Vertical; - if (IsInitialized) - { - Width = r.Width + GetAdornmentsThickness ().Horizontal; - Height = radioLabels.Count + GetAdornmentsThickness ().Vertical; - } + //if (IsInitialized) + //{ + // Width = r.Width + GetAdornmentsThickness ().Horizontal; + // Height = radioLabels.Count + GetAdornmentsThickness ().Vertical; + //} break; @@ -466,11 +475,15 @@ private void SetWidthHeight (List radioLabels) length += item.length; } - if (IsInitialized) - { - Width = length + GetAdornmentsThickness ().Vertical; - Height = 1 + GetAdornmentsThickness ().Horizontal; - } + // TODO: Hack + _dummyView.X = length + GetAdornmentsThickness ().Horizontal; + _dummyView.Y = 1 + GetAdornmentsThickness ().Vertical; + + //if (IsInitialized) + //{ + // Width = length + GetAdornmentsThickness ().Vertical; + // Height = 1 + GetAdornmentsThickness ().Horizontal; + //} break; } diff --git a/UICatalog/Scenarios/Generic.cs b/UICatalog/Scenarios/Generic.cs index b4da210318..38e1086d7e 100644 --- a/UICatalog/Scenarios/Generic.cs +++ b/UICatalog/Scenarios/Generic.cs @@ -17,82 +17,10 @@ public override void Main () Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" }; - int leftMargin = 0; - var just = Justification.Centered; - - var button = new Button { X = Pos.Justify(just), Y = Pos.Center (), Text = "Press me!" }; - //button.Margin.Thickness = new Thickness (leftMargin, 0, 0, 0); + var button = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "Press me!" }; button.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed the button!", "Ok"); appWindow.Add (button); - button = new Button { X = Pos.Justify (just), Y = Pos.Center (), Text = "Two" }; - button.Margin.Thickness = new Thickness (leftMargin, 0, 0, 0); - button.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Two!", "Ok"); - appWindow.Add (button); - - button = new Button { X = Pos.Justify (just), Y = Pos.Center (), Text = "Three" }; - button.Margin.Thickness = new Thickness (leftMargin, 0, 0, 0); - button.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (button); - - button = new Button { X = Pos.Justify (just), Y = Pos.Center (), Text = "Four" }; - button.Margin.Thickness = new Thickness (leftMargin, 0, 0, 0); - button.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (button); - - button = new Button { X = Pos.Justify (just), Y = Pos.Center (), Text = "Five" }; - button.Margin.Thickness = new Thickness (leftMargin, 0, 0, 0); - button.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (button); - - button = new Button { X = Pos.Justify (just), Y = Pos.Center (), Text = "Six" }; - button.Margin.Thickness = new Thickness (leftMargin, 0, 0, 0); - button.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (button); - - button = new Button { X = Pos.Justify (just), Y = Pos.Center (), Text = "Seven" }; - button.Margin.Thickness = new Thickness (leftMargin, 0, 0, 0); - button.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (button); - - button = new Button { X = Pos.Justify (just), Y = Pos.Center (), Text = "Eight" }; - button.Margin.Thickness = new Thickness (leftMargin, 0, 0, 0); - button.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (button); - - just = Justification.FirstLeftRestRight; - var checkbox = new CheckBox { X = 5, Y = Pos.Justify (just), Text = "Check boxes!" }; - checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed the checkbox!", "Ok"); - appWindow.Add (checkbox); - - checkbox = new CheckBox { X = 5, Y = Pos.Justify (just), Text = "CheckTwo" }; - checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Two!", "Ok"); - appWindow.Add (checkbox); - - checkbox = new CheckBox { X = 5, Y = Pos.Justify (just), Text = "CheckThree" }; - checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (checkbox); - - checkbox = new CheckBox { X = 5, Y = Pos.Justify (just), Text = "CheckFour" }; - checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (checkbox); - - checkbox = new CheckBox { X = 5, Y = Pos.Justify (just), Text = "CheckFive" }; - checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (checkbox); - - checkbox = new CheckBox { X = 5, Y = Pos.Justify (just), Text = "CheckSix" }; - checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (checkbox); - - checkbox = new CheckBox { X = 5, Y = Pos.Justify (just), Text = "CheckSeven" }; - checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (checkbox); - - checkbox = new CheckBox { X = 5, Y = Pos.Justify (just), Text = "CheckEight" }; - checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); - appWindow.Add (checkbox); - // Run - Start the application. Application.Run (appWindow); appWindow.Dispose (); diff --git a/UICatalog/Scenarios/PosJustification.cs b/UICatalog/Scenarios/PosJustification.cs new file mode 100644 index 0000000000..a38fbc7bb2 --- /dev/null +++ b/UICatalog/Scenarios/PosJustification.cs @@ -0,0 +1,221 @@ +using System.Collections.Generic; +using System; +using Terminal.Gui; +using System.Linq; +using System.Reflection.Emit; + +namespace UICatalog.Scenarios; + +[ScenarioMetadata ("PosJustification", "Shows off Pos.Justify")] +[ScenarioCategory ("Layout")] +public sealed class PosJustification : Scenario +{ + + private Justifier _horizJustifier = new Justifier (); + private int _leftMargin = 0; + + 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); + + var checkbox = new CheckBox { X = 5, Y = Pos.Justify (_horizJustifier.Justification), Text = "Check boxes!" }; + checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed the checkbox!", "Ok"); + appWindow.Add (checkbox); + + checkbox = new CheckBox { X = 5, Y = Pos.Justify (_horizJustifier.Justification), Text = "CheckTwo" }; + checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Two!", "Ok"); + appWindow.Add (checkbox); + + checkbox = new CheckBox { X = 5, Y = Pos.Justify (_horizJustifier.Justification), Text = "CheckThree" }; + checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); + appWindow.Add (checkbox); + + checkbox = new CheckBox { X = 5, Y = Pos.Justify (_horizJustifier.Justification), Text = "CheckFour" }; + checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); + appWindow.Add (checkbox); + + checkbox = new CheckBox { X = 5, Y = Pos.Justify (_horizJustifier.Justification), Text = "CheckFive" }; + checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); + appWindow.Add (checkbox); + + checkbox = new CheckBox { X = 5, Y = Pos.Justify (_horizJustifier.Justification), Text = "CheckSix" }; + checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); + appWindow.Add (checkbox); + + checkbox = new CheckBox { X = 5, Y = Pos.Justify (_horizJustifier.Justification), Text = "CheckSeven" }; + checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); + appWindow.Add (checkbox); + + checkbox = new CheckBox { X = 5, Y = Pos.Justify (_horizJustifier.Justification), Text = "CheckEight" }; + checkbox.Accept += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed Three!", "Ok"); + appWindow.Add (checkbox); + + // 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 justification = new () + { + X = Pos.Justify (_horizJustifier.Justification), + Y = Pos.Center (), + RadioLabels = GetUniqueEnumNames ().ToArray (), + ColorScheme = colorScheme + }; + + justification.SelectedItemChanged += (s, e) => + { + _horizJustifier.Justification = (Justification)Enum.Parse (typeof (Justification), justification.SelectedItem.ToString ()); + foreach (var view in appWindow.Subviews.Where (v => v.X is Pos.PosJustify)) + { + if (view.X is Pos.PosJustify j) + { + var newJust = new Pos.PosJustify (_horizJustifier.Justification) + { + Justifier = + { + PutSpaceBetweenItems = _horizJustifier.PutSpaceBetweenItems + } + }; + view.X = newJust; + } + } + }; + appWindow.Add (justification); + + CheckBox putSpaces = new () + { + X = Pos.Justify (_horizJustifier.Justification), + Y = Pos.Top (justification), + ColorScheme = colorScheme, + Text = "Spaces", + }; + putSpaces.Toggled += (s, e) => + { + _horizJustifier.PutSpaceBetweenItems = e.NewValue is { } && e.NewValue.Value; + foreach (var view in appWindow.Subviews.Where (v => v.X is Pos.PosJustify)) + { + if (view != justification) + { + if (view.X is Pos.PosJustify j) + { + j.Justifier.PutSpaceBetweenItems = _horizJustifier.PutSpaceBetweenItems; + } + + } + } + }; + 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 (var view in appWindow.Subviews.Where (v => v.X is Pos.PosJustify)) + { + if (view != justification) + { + view.Margin.Thickness = new Thickness (_leftMargin, 0, 0, 0); + } + } + }; + appWindow.Add (margin); + + var addedViews = new List public bool PutSpaceBetweenItems { get; set; } + // TODO: Add property change events + /// /// Takes a list of items and returns their positions when justified within a container /// wide based on the specified diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs index cd197d1875..bfa28141fb 100644 --- a/Terminal.Gui/View/Layout/PosDim.cs +++ b/Terminal.Gui/View/Layout/PosDim.cs @@ -207,10 +207,10 @@ public static Pos AnchorEnd (int offset) /// /// Creates a object that justifies a set of views according to the specified justification. /// - /// /// + /// The optional, unique identifier for the set of views to justify according to . /// - public static Pos Justify (Justification justification) { return new PosJustify (justification); } + public static Pos Justify (Justification justification, int groupId = 0) { return new PosJustify (justification, groupId); } /// Serves as the default hash function. /// A hash code for the current object. @@ -493,18 +493,48 @@ internal class PosFactor (float factor) : Pos internal override int Anchor (int width) { return (int)(width * _factor); } } - /// - /// Enables justification of a set of views. + /// Enables justification of a set of views. /// + /// + /// + /// The Group ID is used to identify a set of views that should be justified together. When only a single + /// set of views is justified, setting the Group ID is not needed because it defaults to 0. + /// + /// + /// The first view added to the Superview with a given Group ID is used to determine the justification of the group. + /// The justification is applied to all views with the same Group ID. + /// + /// public class PosJustify : Pos { + // TODO: Figure out how to invalidate _location if Justifier changes. + + /// + /// The cached location. Used to store the calculated location to avoid recalculating it. + /// + private int? _location; + + /// + /// Gets the identifier of a set of views that should be justified together. When only a single + /// set of views is justified, setting the is not needed because it defaults to 0. + /// + private readonly int _groupId; + + /// + /// Gets the justification settings. + /// public Justifier Justifier { get; } = new (); - public int? _location; - public int GroupId { get; set; } - public static void JustifyGroup (int groupId, IList views, Dim.Dimension dimension, int size) + /// + /// Justifies the views in that have the same group ID as . + /// + /// + /// + /// + /// + private static void JustifyGroup (int groupId, IList views, Dim.Dimension dimension, int size) { if (views is null) { @@ -517,12 +547,12 @@ public static void JustifyGroup (int groupId, IList views, Dim.Dimension d { if (dimension == Dimension.Width && v.X is PosJustify justifyX) { - return justifyX.GroupId == groupId; + return justifyX._groupId == groupId; } if (dimension == Dimension.Height && v.Y is PosJustify justifyY) { - return justifyY.GroupId == groupId; + return justifyY._groupId == groupId; } return false; @@ -570,24 +600,30 @@ public static void JustifyGroup (int groupId, IList views, Dim.Dimension d /// /// Enables justification of a set of views. /// - /// The set of views to justify according to . /// - public PosJustify (Justification justification) + /// The unique identifier for the set of views to justify according to . + public PosJustify (Justification justification, int groupId = 0) { Justifier.Justification = justification; + _groupId = groupId; } + /// public override bool Equals (object other) { - return other is PosJustify justify && justify.Justifier.Equals (Justifier); + return other is PosJustify justify && _groupId == justify._groupId && _location == justify._location && justify.Justifier.Equals (Justifier); } - public override int GetHashCode () { return Justifier.GetHashCode (); } - + /// + public override int GetHashCode () + { + return Justifier.GetHashCode () ^ _groupId.GetHashCode (); + } + /// public override string ToString () { - return $"Justify(justification={Justifier.Justification})"; + return $"Justify(groupId={_groupId}, justification={Justifier.Justification})"; } internal override int Anchor (int width) @@ -602,6 +638,18 @@ internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.D return _location.Value; } + if (us.SuperView is null) + { + return 0; + } + + JustifyGroup (_groupId, us.SuperView.Subviews, dimension, superviewDimension); + + if (_location.HasValue) + { + return _location.Value; + } + return 0; } diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index e7b3c6078f..bfba04495d 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -679,9 +679,6 @@ public virtual void LayoutSubviews () SetTextFormatterSize (); - PosJustify.JustifyGroup (0, Subviews, Dim.Dimension.Width, Viewport.Width); - PosJustify.JustifyGroup (0, Subviews, Dim.Dimension.Height, Viewport.Height); - // Sort out the dependencies of the X, Y, Width, Height properties HashSet nodes = new (); HashSet<(View, View)> edges = new (); diff --git a/UICatalog/Scenarios/PosJustification.cs b/UICatalog/Scenarios/PosJustification.cs index 9e7ccaff16..266b78a243 100644 --- a/UICatalog/Scenarios/PosJustification.cs +++ b/UICatalog/Scenarios/PosJustification.cs @@ -85,6 +85,7 @@ private void SetupHorizontalControls (Window appWindow) if (view.X is Pos.PosJustify j) { j.Justifier.PutSpaceBetweenItems = _horizJustifier.PutSpaceBetweenItems; + view.X = j; } } }; From ee4d52644a0c6d99a954c5207ea8f2cbe7c8dff8 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 9 May 2024 13:41:41 -0600 Subject: [PATCH 019/173] Tweaks --- Terminal.Gui/Drawing/Justification.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs index b8200fbb04..d0e7311ac8 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Justification.cs @@ -132,7 +132,7 @@ public class Justifier /// public bool PutSpaceBetweenItems { get; set; } - // TODO: Add property change events + // TODO: Add property change events so PosJustify can know when to update the locations. /// /// Takes a list of items and returns their positions when justified within a container From a8ebb5bfe66a3c0055e720f2beb08f4b5af68583 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 9 May 2024 14:01:13 -0600 Subject: [PATCH 020/173] Added property change notification to Justifyer --- Terminal.Gui/Drawing/Justification.cs | 53 +++++++++++++++++-------- Terminal.Gui/View/Layout/PosDim.cs | 8 +++- UICatalog/Scenarios/PosJustification.cs | 1 - 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs index d0e7311ac8..f4fd4e3395 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Justification.cs @@ -1,3 +1,4 @@ +using System.ComponentModel; using static Terminal.Gui.Pos; namespace Terminal.Gui; @@ -113,26 +114,57 @@ public enum Justification /// /// Justifies items within a container based on the specified . /// -public class Justifier +public class Justifier : INotifyPropertyChanged { + private Justification _justification; + /// /// Gets or sets how the justifies items within a container. /// - public Justification Justification { get; set; } + public Justification Justification + { + get => _justification; + set + { + _justification = value; + PropertyChanged?.Invoke (this, new PropertyChangedEventArgs (nameof (Justification))); + } + } + + private int _containerSize; /// /// The size of the container. /// - public int ContainerSize { get; set; } + public int ContainerSize + { + get => _containerSize; + set + { + _containerSize = value; + PropertyChanged?.Invoke (this, new PropertyChangedEventArgs (nameof (ContainerSize))); + } + } + + private bool _putSpaceBetweenItems; /// /// Gets or sets whether puts a space is placed between items. Default is /// . If , a space will be /// placed between each item, which is useful for justifying text. /// - public bool PutSpaceBetweenItems { get; set; } + public bool PutSpaceBetweenItems + { + get => _putSpaceBetweenItems; + set + { + _putSpaceBetweenItems = value; + PropertyChanged?.Invoke (this, new PropertyChangedEventArgs (nameof (PutSpaceBetweenItems))); + } + } - // TODO: Add property change events so PosJustify can know when to update the locations. + /// + public event PropertyChangedEventHandler PropertyChanged; /// /// Takes a list of items and returns their positions when justified within a container @@ -340,15 +372,4 @@ private static void CheckSizeCannotBeNegative (int i, int [] sizes) throw new ArgumentException ("The size of an item cannot be negative."); } } - public override bool Equals (object other) - { - if (other is Justifier justifier) - { - return Justification == justifier.Justification && - ContainerSize == justifier.ContainerSize && - PutSpaceBetweenItems == justifier.PutSpaceBetweenItems; - } - - return false; - } } diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs index bfa28141fb..d7c2ba986f 100644 --- a/Terminal.Gui/View/Layout/PosDim.cs +++ b/Terminal.Gui/View/Layout/PosDim.cs @@ -606,6 +606,12 @@ public PosJustify (Justification justification, int groupId = 0) { Justifier.Justification = justification; _groupId = groupId; + Justifier.PropertyChanged += Justifier_PropertyChanged; + } + + private void Justifier_PropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + _location = null; } /// @@ -633,7 +639,7 @@ internal override int Anchor (int width) internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension) { - if (_location.HasValue) + if (_location.HasValue && Justifier.ContainerSize == superviewDimension) { return _location.Value; } diff --git a/UICatalog/Scenarios/PosJustification.cs b/UICatalog/Scenarios/PosJustification.cs index 266b78a243..9e7ccaff16 100644 --- a/UICatalog/Scenarios/PosJustification.cs +++ b/UICatalog/Scenarios/PosJustification.cs @@ -85,7 +85,6 @@ private void SetupHorizontalControls (Window appWindow) if (view.X is Pos.PosJustify j) { j.Justifier.PutSpaceBetweenItems = _horizJustifier.PutSpaceBetweenItems; - view.X = j; } } }; From 64b355457024b6b105123d266f3becea3bad1aef Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 9 May 2024 17:49:28 -0600 Subject: [PATCH 021/173] Added 3x3 demo --- UICatalog/Scenarios/PosJustification.cs | 412 +++++++++++++----------- 1 file changed, 232 insertions(+), 180 deletions(-) diff --git a/UICatalog/Scenarios/PosJustification.cs b/UICatalog/Scenarios/PosJustification.cs index 9e7ccaff16..14a687100f 100644 --- a/UICatalog/Scenarios/PosJustification.cs +++ b/UICatalog/Scenarios/PosJustification.cs @@ -1,8 +1,7 @@ -using System.Collections.Generic; using System; -using Terminal.Gui; +using System.Collections.Generic; using System.Linq; -using System.Reflection.Emit; +using Terminal.Gui; namespace UICatalog.Scenarios; @@ -10,11 +9,10 @@ namespace UICatalog.Scenarios; [ScenarioCategory ("Layout")] public sealed class PosJustification : Scenario { - - private Justifier _horizJustifier = new Justifier (); - private int _leftMargin = 0; - private Justifier _vertJustifier = new Justifier (); - private int _topMargin = 0; + private readonly Justifier _horizJustifier = new (); + private int _leftMargin; + private readonly Justifier _vertJustifier = new (); + private int _topMargin; public override void Main () { @@ -31,6 +29,8 @@ public override void Main () SetupVerticalControls (appWindow); + Setup3by3Grid (appWindow); + // Run - Start the application. Application.Run (appWindow); appWindow.Dispose (); @@ -42,6 +42,7 @@ public override void Main () private void SetupHorizontalControls (Window appWindow) { ColorScheme colorScheme = Colors.ColorSchemes ["Toplevel"]; + RadioGroup justification = new () { X = Pos.Justify (_horizJustifier.Justification), @@ -51,23 +52,25 @@ private void SetupHorizontalControls (Window appWindow) }; justification.SelectedItemChanged += (s, e) => - { - _horizJustifier.Justification = (Justification)Enum.Parse (typeof (Justification), justification.SelectedItem.ToString ()); - foreach (var view in appWindow.Subviews.Where (v => v.X is Pos.PosJustify)) - { - if (view.X is Pos.PosJustify j) - { - var newJust = new Pos.PosJustify (_horizJustifier.Justification) - { - Justifier = - { - PutSpaceBetweenItems = _horizJustifier.PutSpaceBetweenItems - } - }; - view.X = newJust; - } - } - }; + { + _horizJustifier.Justification = + (Justification)Enum.Parse (typeof (Justification), justification.SelectedItem.ToString ()); + + foreach (View view in appWindow.Subviews.Where (v => v.X is Pos.PosJustify)) + { + if (view.X is Pos.PosJustify j) + { + var newJust = new Pos.PosJustify (_horizJustifier.Justification) + { + Justifier = + { + PutSpaceBetweenItems = _horizJustifier.PutSpaceBetweenItems + } + }; + view.X = newJust; + } + } + }; appWindow.Add (justification); CheckBox putSpaces = new () @@ -75,12 +78,14 @@ private void SetupHorizontalControls (Window appWindow) X = Pos.Justify (_horizJustifier.Justification), Y = Pos.Top (justification), ColorScheme = colorScheme, - Text = "Spaces", + Text = "Spaces" }; + putSpaces.Toggled += (s, e) => { _horizJustifier.PutSpaceBetweenItems = e.NewValue is { } && e.NewValue.Value; - foreach (var view in appWindow.Subviews.Where (v => v.X is Pos.PosJustify)) + + foreach (View view in appWindow.Subviews.Where (v => v.X is Pos.PosJustify)) { if (view.X is Pos.PosJustify j) { @@ -95,33 +100,37 @@ private void SetupHorizontalControls (Window appWindow) X = Pos.Left (putSpaces), Y = Pos.Bottom (putSpaces), ColorScheme = colorScheme, - Text = "Margin", + Text = "Margin" }; - margin.Toggled += (s, e) => - { - _leftMargin = e.NewValue is { } && e.NewValue.Value ? 1 : 0; - foreach (var view in appWindow.Subviews.Where (v => v.X is Pos.PosJustify)) - { - // Skip the justification radio group - if (view != justification) - { - view.Margin.Thickness = new Thickness (_leftMargin, 0, 0, 0); - } - } - appWindow.LayoutSubviews (); - }; + 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.PosJustify)) + { + // Skip the justification radio group + if (view != justification) + { + view.Margin.Thickness = new (_leftMargin, 0, 0, 0); + } + } + + appWindow.LayoutSubviews (); + }; appWindow.Add (margin); - var addedViews = new List + /// + /// + /// 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). + /// + /// /// /// /// 111 2222 33333 @@ -32,6 +37,11 @@ public enum Justification /// Set to to ensure at least one space between /// each item. /// + /// + /// + /// If the container is smaller than the total size of the items, the left items will be clipped (their locations will be negative). + /// + /// /// /// /// 111 2222 33333 @@ -52,6 +62,11 @@ public enum Justification /// Set to to ensure at least one space between /// each item. /// + /// + /// + /// Extra space will be distributed between the items, biased towards the left. + /// + /// /// /// /// 111 2222 33333 @@ -65,6 +80,11 @@ public enum Justification /// Set to to ensure at least one space between /// each item. /// + /// + /// + /// Extra space will be distributed between the items, biased towards the left. + /// + /// /// /// /// 111 2222 33333 @@ -77,6 +97,11 @@ public enum Justification /// Set to to ensure at least one space between /// each item. /// + /// + /// + /// 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). + /// + /// /// /// /// 111 2222 33333 @@ -96,6 +121,11 @@ public enum Justification /// Set to to ensure at least one space between /// each item. /// + /// + /// + /// If the container is smaller than the total size of the items, the left items will be clipped (their locations will be negative). + /// + /// /// /// /// 111 2222 33333 @@ -153,6 +183,12 @@ public int ContainerSize /// . If , a space will be /// placed between each item, which is useful for justifying text. /// + /// + /// + /// If the total size of the items is greater than the container size, the space between items will be ignored starting + /// from the right. + /// + /// public bool PutSpaceBetweenItems { get => _putSpaceBetweenItems; @@ -234,7 +270,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI break; case Justification.Right: - currentPosition = Math.Max (0, containerSize - totalItemsSize - spaces); + currentPosition = containerSize - totalItemsSize - spaces; for (var i = 0; i < sizes.Length; i++) { @@ -297,7 +333,14 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI case Justification.LastRightRestLeft: if (sizes.Length > 1) { - currentPosition = 0; + if (totalItemsSize > containerSize) + { + currentPosition = containerSize - totalItemsSize - spaces; + } + else + { + currentPosition = 0; + } for (var i = 0; i < sizes.Length; i++) { @@ -337,7 +380,7 @@ public static int [] Justify (Justification justification, bool putSpaceBetweenI if (i == sizes.Length - 1) { // start at right - currentPosition = containerSize - sizes [i]; + currentPosition = Math.Max (totalItemsSize, containerSize) - sizes [i]; positions [i] = currentPosition; } diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs index d7c2ba986f..ce2f3d1fc2 100644 --- a/Terminal.Gui/View/Layout/PosDim.cs +++ b/Terminal.Gui/View/Layout/PosDim.cs @@ -204,6 +204,7 @@ public static Pos AnchorEnd (int offset) /// The returned from the function. public static Pos Function (Func function) { return new PosFunc (function); } + /// /// Creates a object that justifies a set of views according to the specified justification. /// @@ -493,6 +494,7 @@ internal class PosFactor (float factor) : Pos internal override int Anchor (int width) { return (int)(width * _factor); } } + /// /// Enables justification of a set of views. /// @@ -604,6 +606,7 @@ private static void JustifyGroup (int groupId, IList views, Dim.Dimension /// The unique identifier for the set of views to justify according to . public PosJustify (Justification justification, int groupId = 0) { + Justifier.PutSpaceBetweenItems = true; Justifier.Justification = justification; _groupId = groupId; Justifier.PropertyChanged += Justifier_PropertyChanged; diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index bfba04495d..5a03664520 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using static Terminal.Gui.Pos; namespace Terminal.Gui; @@ -37,7 +36,6 @@ public enum LayoutStyle Computed } - public partial class View { #region Frame @@ -200,7 +198,7 @@ public Pos X get => VerifyIsInitialized (_x, nameof (X)); set { - if (_x.Equals (value)) + if (Equals (_x, value)) { return; } @@ -239,7 +237,7 @@ public Pos Y get => VerifyIsInitialized (_y, nameof (Y)); set { - if (_y.Equals (value)) + if (Equals (_y, value)) { return; } diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs index 62375ccd51..0535f5f438 100644 --- a/Terminal.Gui/Views/CheckBox.cs +++ b/Terminal.Gui/Views/CheckBox.cs @@ -20,7 +20,7 @@ public CheckBox () _charChecked = Glyphs.Checked; _charUnChecked = Glyphs.UnChecked; - Height = Dim.Auto (Dim.DimAutoStyle.Text); + Height = 1; Width = Dim.Auto (Dim.DimAutoStyle.Text); CanFocus = true; diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs index 8e8d5fc18a..83cc14c3c0 100644 --- a/Terminal.Gui/Views/RadioGroup.cs +++ b/Terminal.Gui/Views/RadioGroup.cs @@ -80,11 +80,6 @@ public RadioGroup () HighlightStyle = Gui.HighlightStyle.PressedOutside | Gui.HighlightStyle.Pressed; MouseClick += RadioGroup_MouseClick; - - // TOOD: Hack - using Text when we should use SubViews - Add (_dummyView); - Width = Dim.Auto (Dim.DimAutoStyle.Content); - Height = Dim.Auto (Dim.DimAutoStyle.Content); } // TODO: Fix InvertColorsOnPress - only highlight the selected item @@ -177,7 +172,7 @@ public string [] RadioLabels } } - if (prevCount != _radioLabels.Count) + if (IsInitialized && prevCount != _radioLabels.Count) { SetWidthHeight (_radioLabels); } @@ -444,25 +439,21 @@ private void MoveUp () } } - private void RadioGroup_LayoutStarted (object sender, EventArgs e) { /*SetWidthHeight (_radioLabels);*/ } + private void RadioGroup_LayoutStarted (object sender, EventArgs e) { SetWidthHeight (_radioLabels); } private void SelectItem () { SelectedItem = _cursor; } - private View _dummyView = new View () {}; private void SetWidthHeight (List radioLabels) { switch (_orientation) { case Orientation.Vertical: Rectangle r = MakeRect (0, 0, radioLabels); - // TODO: Hack - _dummyView.X = r.Width + +GetAdornmentsThickness ().Horizontal; - _dummyView.Y = radioLabels.Count + GetAdornmentsThickness ().Vertical; - //if (IsInitialized) - //{ - // Width = r.Width + GetAdornmentsThickness ().Horizontal; - // Height = radioLabels.Count + GetAdornmentsThickness ().Vertical; - //} + if (IsInitialized) + { + Width = r.Width + GetAdornmentsThickness ().Horizontal; + Height = radioLabels.Count + GetAdornmentsThickness ().Vertical; + } break; @@ -475,15 +466,11 @@ private void SetWidthHeight (List radioLabels) length += item.length; } - // TODO: Hack - _dummyView.X = length + GetAdornmentsThickness ().Horizontal; - _dummyView.Y = 1 + GetAdornmentsThickness ().Vertical; - - //if (IsInitialized) - //{ - // Width = length + GetAdornmentsThickness ().Vertical; - // Height = 1 + GetAdornmentsThickness ().Horizontal; - //} + if (IsInitialized) + { + Width = length + GetAdornmentsThickness ().Vertical; + Height = 1 + GetAdornmentsThickness ().Horizontal; + } break; } diff --git a/UnitTests/Dialogs/DialogTests.cs b/UnitTests/Dialogs/DialogTests.cs index 3ee034ee80..2a11406e20 100644 --- a/UnitTests/Dialogs/DialogTests.cs +++ b/UnitTests/Dialogs/DialogTests.cs @@ -39,7 +39,7 @@ public void Add_Button_Works () // 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 @@ -64,7 +64,7 @@ public void Add_Button_Works () // 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 @@ -166,7 +166,7 @@ public void ButtonAlignment_Four () 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 ( @@ -243,7 +243,7 @@ public void ButtonAlignment_Four_On_Too_Small_Width () // 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, @@ -277,7 +277,8 @@ public void ButtonAlignment_Four_On_Too_Small_Width () 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, @@ -293,7 +294,7 @@ public void ButtonAlignment_Four_On_Too_Small_Width () 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, @@ -527,7 +528,7 @@ public void ButtonAlignment_One () // 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 ( @@ -589,7 +590,7 @@ public void ButtonAlignment_One () // 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 ( @@ -915,7 +916,7 @@ public void Dialog_In_Window_With_Size_One_Button_Aligns () @" ┌┌───────────────┐─┐ ││ │ │ -││ ⟦ Ok ⟧ │ │ +││ ⟦ Ok ⟧ │ │ │└───────────────┘ │ └──────────────────┘" )] @@ -925,7 +926,7 @@ public void Dialog_In_Window_With_Size_One_Button_Aligns () ┌┌───────────────┐─┐ ││ │ │ ││ │ │ -││ ⟦ Ok ⟧ │ │ +││ ⟦ Ok ⟧ │ │ │└───────────────┘ │ └──────────────────┘" )] @@ -936,7 +937,7 @@ public void Dialog_In_Window_With_Size_One_Button_Aligns () │┌───────────────┐ │ ││ │ │ ││ │ │ -││ ⟦ Ok ⟧ │ │ +││ ⟦ Ok ⟧ │ │ │└───────────────┘ │ └──────────────────┘" )] @@ -948,7 +949,7 @@ public void Dialog_In_Window_With_Size_One_Button_Aligns () ││ │ │ ││ │ │ ││ │ │ -││ ⟦ Ok ⟧ │ │ +││ ⟦ Ok ⟧ │ │ │└───────────────┘ │ └──────────────────┘" )] @@ -961,7 +962,7 @@ public void Dialog_In_Window_With_Size_One_Button_Aligns () ││ │ │ ││ │ │ ││ │ │ -││ ⟦ Ok ⟧ │ │ +││ ⟦ Ok ⟧ │ │ │└───────────────┘ │ └──────────────────┘" )] diff --git a/UnitTests/Dialogs/MessageBoxTests.cs b/UnitTests/Dialogs/MessageBoxTests.cs index e513a90fb0..2afdfb36ac 100644 --- a/UnitTests/Dialogs/MessageBoxTests.cs +++ b/UnitTests/Dialogs/MessageBoxTests.cs @@ -278,7 +278,7 @@ public void Message_Long_Without_Spaces_WrapMessage_True () │ffffffffffffffffff│ │ ffffffffffffff │ │ │ -│ {btn} │ +│ {btn} │ └──────────────────┘", _output ); @@ -302,7 +302,7 @@ public void Message_Long_Without_Spaces_WrapMessage_True () │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 @@ public void Message_With_Spaces_WrapMessage_True () │ffffffffffffffffff│ │ffffffffffffffffff│ │ffffffffffffffffff│ -│ {btn} │", +│ {btn} │", _output ); Application.RequestStop (); @@ -509,7 +509,7 @@ public void Message_Without_Spaces_WrapMessage_False () ──────────────────── ffffffffffffffffffff - ⟦► btn ◄⟧ + ⟦► btn ◄⟧ ──────────────────── ", _output @@ -529,7 +529,7 @@ public void Message_Without_Spaces_WrapMessage_False () ──────────────────── ffffffffffffffffffff - ⟦► btn ◄⟧ + ⟦► btn ◄⟧ ──────────────────── ", _output diff --git a/UnitTests/Drawing/JustifierTests.cs b/UnitTests/Drawing/JustifierTests.cs index 2f98ec4304..434a040096 100644 --- a/UnitTests/Drawing/JustifierTests.cs +++ b/UnitTests/Drawing/JustifierTests.cs @@ -62,6 +62,7 @@ public void Negative_Widths_Not_Allowed (Justification justification) [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 }, 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 (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 })] @@ -80,6 +81,9 @@ public void Negative_Widths_Not_Allowed (Justification justification) [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 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1. + [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 })] @@ -103,6 +107,7 @@ public void Negative_Widths_Not_Allowed (Justification justification) [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 }, 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 (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 })] @@ -160,6 +165,7 @@ public void Negative_Widths_Not_Allowed (Justification justification) [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 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1.})] [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 })] @@ -187,6 +193,7 @@ public void Negative_Widths_Not_Allowed (Justification justification) [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 }, 5, new [] { 0, 1, 3 })] [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 })] @@ -224,6 +231,8 @@ public void TestJustifications_PutSpaceBetweenItems (Justification justification [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 [] { 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 (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 })] @@ -240,6 +249,9 @@ public void TestJustifications_PutSpaceBetweenItems (Justification justification [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 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1. + [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 })] @@ -267,6 +279,8 @@ public void TestJustifications_PutSpaceBetweenItems (Justification justification [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 [] { 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 (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 })] @@ -408,7 +422,10 @@ public string RenderJustification (Justification justification, int [] sizes, in { for (var j = 0; j < sizes [position] && positions [position] + j < totalSize; j++) { - items [positions [position] + j] = (position + 1).ToString () [0]; + if (positions [position] + j >= 0) + { + items [positions [position] + j] = (position + 1).ToString () [0]; + } } } From 147fdb4889103bb89ac0a0055170361cf931b6bf Mon Sep 17 00:00:00 2001 From: Tig Date: Fri, 10 May 2024 07:56:38 -0600 Subject: [PATCH 024/173] Removed dead code from Dialog --- Terminal.Gui/Views/Dialog.cs | 137 +++-------------------------------- 1 file changed, 11 insertions(+), 126 deletions(-) diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index a987361a85..5bbda62732 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -46,19 +46,22 @@ public Dialog () 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); } @@ -88,6 +91,7 @@ public bool Canceled } #endif _canceled = value; + return; } } @@ -146,20 +150,6 @@ public void AddButton (Button button) } } - /// - //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 () { @@ -173,109 +163,4 @@ internal int GetButtonsWidth () return widths.Sum (); } - - //private void LayoutButtons () - //{ - // if (_buttons.Count == 0 || !IsInitialized) - // { - // return; - // } - - // var shiftLeft = 0; - - // int buttonsWidth = GetButtonsWidth (); - - // switch (ButtonAlignment) - // { - // case Justification.Centered: - // // 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 Justification.Justified: - // // 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 Justification.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 Justification.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; - // } - //} } From 831eecbd289d289c3b290d8b015b6f2d14025ca0 Mon Sep 17 00:00:00 2001 From: Tig Date: Fri, 10 May 2024 08:19:30 -0600 Subject: [PATCH 025/173] Default button just is now Right --- Terminal.Gui/Resources/config.json | 2 +- Terminal.Gui/Views/Dialog.cs | 4 ++-- Terminal.Gui/Views/MessageBox.cs | 11 +++++------ UICatalog/Scenarios/Dialogs.cs | 4 +++- UnitTests/Configuration/ThemeScopeTests.cs | 6 +++--- UnitTests/Configuration/ThemeTests.cs | 4 ++-- UnitTests/Dialogs/DialogTests.cs | 3 +++ 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Terminal.Gui/Resources/config.json b/Terminal.Gui/Resources/config.json index 4f82e43d6d..c073d5aadb 100644 --- a/Terminal.Gui/Resources/config.json +++ b/Terminal.Gui/Resources/config.json @@ -24,7 +24,7 @@ "Themes": [ { "Default": { - "Dialog.DefaultButtonAlignment": "Centered", + "Dialog.DefaultButtonJustification": "Right", "FrameView.DefaultBorderStyle": "Single", "Window.DefaultBorderStyle": "Single", "ColorSchemes": [ diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index 5bbda62732..fc1196be56 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -51,7 +51,7 @@ public Dialog () ColorScheme = Colors.ColorSchemes ["Dialog"]; Modal = true; - ButtonAlignment = DefaultButtonAlignment; + ButtonAlignment = DefaultButtonJustification; AddCommand ( Command.QuitToplevel, @@ -122,7 +122,7 @@ public Button [] Buttons /// This property can be set in a Theme. [SerializableConfigurationProperty (Scope = typeof (ThemeScope))] [JsonConverter (typeof (JsonStringEnumConverter))] - public static Justification DefaultButtonAlignment { get; set; } = Justification.Centered; + public static Justification DefaultButtonJustification { get; set; } = Justification.Right; /// /// Adds a to the , its layout will be controlled by the diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index b8d7f911d3..03942953eb 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -327,9 +327,7 @@ params string [] buttons { var b = new Button { - Text = s, - Y = Pos.AnchorEnd (), - X = Pos.Justify (Justification.Centered) + Text = s, }; if (count == defaultButton) @@ -342,9 +340,9 @@ params string [] buttons } } - Dialog d; - - d = new Dialog + Justification buttonJust = Dialog.DefaultButtonJustification; + Dialog.DefaultButtonJustification = Justification.Centered; + var d = new Dialog { Buttons = buttonList.ToArray (), Title = title, @@ -352,6 +350,7 @@ params string [] buttons Width = Dim.Percent (60), Height = 5 // Border + one line of text + vspace + buttons }; + Dialog.DefaultButtonJustification = buttonJust; if (width != 0) { diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs index e3a0d5f9b1..6a16ef5aa3 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -145,13 +145,15 @@ static IEnumerable GetUniqueEnumNames () where T : Enum } } + var labels = GetUniqueEnumNames (); var styleRadioGroup = new RadioGroup { X = Pos.Right (label) + 1, Y = Pos.Top (label), - RadioLabels = GetUniqueEnumNames ().ToArray (), + RadioLabels = labels.ToArray (), }; frame.Add (styleRadioGroup); + styleRadioGroup.SelectedItem = labels.ToList().IndexOf (Dialog.DefaultButtonJustification.ToString()); frame.ValidatePosDim = true; diff --git a/UnitTests/Configuration/ThemeScopeTests.cs b/UnitTests/Configuration/ThemeScopeTests.cs index 0eecd05b7f..928993ede8 100644 --- a/UnitTests/Configuration/ThemeScopeTests.cs +++ b/UnitTests/Configuration/ThemeScopeTests.cs @@ -29,12 +29,12 @@ public void Apply_ShouldApplyUpdatedProperties () { Reset (); Assert.NotEmpty (Themes); - Assert.Equal (Justification.Centered, Dialog.DefaultButtonAlignment); + Assert.Equal (Justification.Right, Dialog.DefaultButtonJustification); - Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = Justification.Right; + Themes ["Default"] ["Dialog.DefaultButtonJustification"].PropertyValue = Justification.Centered; ThemeManager.Themes! [ThemeManager.SelectedTheme]!.Apply (); - Assert.Equal (Justification.Right, Dialog.DefaultButtonAlignment); + Assert.Equal (Justification.Centered, Dialog.DefaultButtonJustification); Reset (); } diff --git a/UnitTests/Configuration/ThemeTests.cs b/UnitTests/Configuration/ThemeTests.cs index 5ecee6bbe3..6a32293c76 100644 --- a/UnitTests/Configuration/ThemeTests.cs +++ b/UnitTests/Configuration/ThemeTests.cs @@ -77,7 +77,7 @@ public void TestApply_UpdatesColors () public void TestSerialize_RoundTrip () { var theme = new ThemeScope (); - theme ["Dialog.DefaultButtonAlignment"].PropertyValue = Justification.Right; + theme ["Dialog.DefaultButtonJustification"].PropertyValue = Justification.Right; string json = JsonSerializer.Serialize (theme, _jsonOptions); @@ -85,7 +85,7 @@ public void TestSerialize_RoundTrip () Assert.Equal ( Justification.Right, - (Justification)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue + (Justification)deserialized ["Dialog.DefaultButtonJustification"].PropertyValue ); Reset (); } diff --git a/UnitTests/Dialogs/DialogTests.cs b/UnitTests/Dialogs/DialogTests.cs index 2a11406e20..d1520b1885 100644 --- a/UnitTests/Dialogs/DialogTests.cs +++ b/UnitTests/Dialogs/DialogTests.cs @@ -889,6 +889,7 @@ public void Dialog_In_Window_With_Size_One_Button_Aligns () win.Loaded += (s, a) => { + Dialog.DefaultButtonJustification = Justification.Centered; var dlg = new Dialog { Width = 18, Height = 3, Buttons = [new () { Text = "Ok" }] }; dlg.Loaded += (s, a) => @@ -972,6 +973,7 @@ public void Dialog_In_Window_Without_Size_One_Button_Aligns (int height, string var win = new Window (); int iterations = -1; + Dialog.DefaultButtonJustification = Justification.Centered; Iteration += (s, a) => { @@ -1006,6 +1008,7 @@ public void Dialog_In_Window_Without_Size_One_Button_Aligns (int height, string public void Dialog_Opened_From_Another_Dialog () { ((FakeDriver)Driver).SetBufferSize (30, 10); + Dialog.DefaultButtonJustification = Justification.Centered; var btn1 = new Button { Text = "press me 1" }; Button btn2 = null; From c84dade64dc666115ddce4c4a3017674f3ffa6b0 Mon Sep 17 00:00:00 2001 From: Tig Date: Fri, 10 May 2024 08:52:47 -0600 Subject: [PATCH 026/173] WIP -> Getting rid of old TextAlignment enums --- Terminal.Gui/Drawing/Thickness.cs | 4 +- Terminal.Gui/Text/TextAlignment.cs | 20 - Terminal.Gui/Text/TextFormatter.cs | 64 +- Terminal.Gui/Text/VerticalTextAlignment.cs | 20 - Terminal.Gui/View/ViewText.cs | 6 +- Terminal.Gui/Views/Button.cs | 4 +- Terminal.Gui/Views/CheckBox.cs | 10 +- Terminal.Gui/Views/ListView.cs | 2 +- Terminal.Gui/Views/Menu/Menu.cs | 2 +- Terminal.Gui/Views/MessageBox.cs | 2 +- Terminal.Gui/Views/ProgressBar.cs | 2 +- Terminal.Gui/Views/Slider.cs | 16 +- Terminal.Gui/Views/TableView/ColumnStyle.cs | 6 +- Terminal.Gui/Views/TableView/TableView.cs | 10 +- Terminal.Gui/Views/TextValidateField.cs | 16 +- Terminal.Gui/Views/TextView.cs | 2 +- UICatalog/Scenarios/BasicColors.cs | 4 +- UICatalog/Scenarios/Buttons.cs | 50 +- UICatalog/Scenarios/CharacterMap.cs | 2 +- .../Scenarios/CollectionNavigatorTester.cs | 4 +- UICatalog/Scenarios/ColorPicker.cs | 4 +- UICatalog/Scenarios/ComputedLayout.cs | 20 +- UICatalog/Scenarios/CsvEditor.cs | 22 +- UICatalog/Scenarios/Dialogs.cs | 14 +- UICatalog/Scenarios/DynamicMenuBar.cs | 4 +- UICatalog/Scenarios/Editor.cs | 18 +- UICatalog/Scenarios/ListColumns.cs | 2 +- UICatalog/Scenarios/MessageBoxes.cs | 18 +- UICatalog/Scenarios/Mouse.cs | 4 +- UICatalog/Scenarios/TableEditor.cs | 14 +- UICatalog/Scenarios/Text.cs | 2 +- UICatalog/Scenarios/TextAlignments.cs | 18 +- .../Scenarios/TextAlignmentsAndDirection.cs | 100 +-- UICatalog/Scenarios/TextFormatterDemo.cs | 14 +- UICatalog/Scenarios/TimeAndDate.cs | 12 +- UICatalog/Scenarios/Unicode.cs | 2 +- UICatalog/Scenarios/ViewExperiments.cs | 10 +- UICatalog/Scenarios/Wizards.cs | 8 +- UnitTests/Text/TextFormatterTests.cs | 816 +++++++++--------- UnitTests/View/DrawTests.cs | 4 +- UnitTests/View/Layout/Dim.AutoTests.cs | 12 +- UnitTests/View/Text/AutoSizeTrueTests.cs | 12 +- UnitTests/Views/ButtonTests.cs | 8 +- UnitTests/Views/CheckBoxTests.cs | 18 +- UnitTests/Views/LabelTests.cs | 2 +- UnitTests/Views/TextValidateFieldTests.cs | 40 +- UnitTests/Views/ToplevelTests.cs | 4 +- 47 files changed, 704 insertions(+), 744 deletions(-) delete mode 100644 Terminal.Gui/Text/TextAlignment.cs delete mode 100644 Terminal.Gui/Text/VerticalTextAlignment.cs diff --git a/Terminal.Gui/Drawing/Thickness.cs b/Terminal.Gui/Drawing/Thickness.cs index 40a30d590c..74458d2219 100644 --- a/Terminal.Gui/Drawing/Thickness.cs +++ b/Terminal.Gui/Drawing/Thickness.cs @@ -232,8 +232,8 @@ rect with var tf = new TextFormatter { Text = label is null ? string.Empty : $"{label} {this}", - Alignment = TextAlignment.Centered, - VerticalAlignment = VerticalTextAlignment.Bottom, + Alignment = Justification.Centered, + VerticalAlignment = Justification.Bottom, AutoSize = true }; tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute, rect); diff --git a/Terminal.Gui/Text/TextAlignment.cs b/Terminal.Gui/Text/TextAlignment.cs deleted file mode 100644 index 44950cfd5b..0000000000 --- a/Terminal.Gui/Text/TextAlignment.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Terminal.Gui; - -/// Text alignment enumeration, controls how text is displayed. -public enum TextAlignment -{ - /// The text will be left-aligned. - Left, - - /// The text will be right-aligned. - Right, - - /// The text will be centered horizontally. - Centered, - - /// - /// The text will be justified (spaces will be added to existing spaces such that the text fills the container - /// horizontally). - /// - Justified -} \ No newline at end of file diff --git a/Terminal.Gui/Text/TextFormatter.cs b/Terminal.Gui/Text/TextFormatter.cs index 925f89a389..5bdca378d5 100644 --- a/Terminal.Gui/Text/TextFormatter.cs +++ b/Terminal.Gui/Text/TextFormatter.cs @@ -15,14 +15,14 @@ public class TextFormatter private Size _size; private int _tabWidth = 4; private string _text; - private TextAlignment _textAlignment; + private Justification _textAlignment; private TextDirection _textDirection; - private VerticalTextAlignment _textVerticalAlignment; + private Justification _textVerticalAlignment; private bool _wordWrap = true; /// Controls the horizontal text-alignment property. /// The text alignment. - public TextAlignment Alignment + public Justification Alignment { get => _textAlignment; set => _textAlignment = EnableNeedsFormat (value); @@ -32,8 +32,8 @@ public TextAlignment Alignment /// /// Used when is using to resize the view's to fit . /// - /// AutoSize is ignored if and - /// are used. + /// AutoSize is ignored if and + /// are used. /// /// public bool AutoSize @@ -225,7 +225,7 @@ public virtual string Text /// Controls the vertical text-alignment property. /// The text vertical alignment. - public VerticalTextAlignment VerticalAlignment + public Justification VerticalAlignment { get => _textVerticalAlignment; set => _textVerticalAlignment = EnableNeedsFormat (value); @@ -321,7 +321,7 @@ public void Draw ( int x, y; // Horizontal Alignment - if (Alignment is TextAlignment.Right) + if (Alignment is Justification.Right) { if (isVertical) { @@ -336,7 +336,7 @@ public void Draw ( CursorPosition = screen.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0); } } - else if (Alignment is TextAlignment.Left) + else if (Alignment is Justification.Left) { if (isVertical) { @@ -352,7 +352,7 @@ public void Draw ( CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0; } - else if (Alignment is TextAlignment.Justified) + else if (Alignment is Justification.Justified) { if (isVertical) { @@ -375,7 +375,7 @@ public void Draw ( CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0; } - else if (Alignment is TextAlignment.Centered) + else if (Alignment is Justification.Centered) { if (isVertical) { @@ -399,7 +399,7 @@ public void Draw ( } // Vertical Alignment - if (VerticalAlignment is VerticalTextAlignment.Bottom) + if (VerticalAlignment is Justification.Bottom) { if (isVertical) { @@ -410,7 +410,7 @@ public void Draw ( y = screen.Bottom - linesFormatted.Count + line; } } - else if (VerticalAlignment is VerticalTextAlignment.Top) + else if (VerticalAlignment is Justification.Top) { if (isVertical) { @@ -421,7 +421,7 @@ public void Draw ( y = screen.Top + line; } } - else if (VerticalAlignment is VerticalTextAlignment.Justified) + else if (VerticalAlignment is Justification.Justified) { if (isVertical) { @@ -435,7 +435,7 @@ public void Draw ( 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 Justification.Centered) { if (isVertical) { @@ -471,8 +471,8 @@ public void Draw ( { if (idx < 0 || (isVertical - ? VerticalAlignment != VerticalTextAlignment.Bottom && current < 0 - : Alignment != TextAlignment.Right && x + current + colOffset < 0)) + ? VerticalAlignment != Justification.Bottom && current < 0 + : Alignment != Justification.Right && x + current + colOffset < 0)) { current++; @@ -561,7 +561,7 @@ public void Draw ( if (HotKeyPos > -1 && idx == HotKeyPos) { - if ((isVertical && VerticalAlignment == VerticalTextAlignment.Justified) || (!isVertical && Alignment == TextAlignment.Justified)) + if ((isVertical && VerticalAlignment == Justification.Justified) || (!isVertical && Alignment == Justification.Justified)) { CursorPosition = idx - start; } @@ -699,7 +699,7 @@ public List GetLines () _lines = Format ( text, Size.Height, - VerticalAlignment == VerticalTextAlignment.Justified, + VerticalAlignment == Justification.Justified, Size.Width > colsWidth && WordWrap, PreserveTrailingSpaces, TabWidth, @@ -723,7 +723,7 @@ public List GetLines () _lines = Format ( text, Size.Width, - Alignment == TextAlignment.Justified, + Alignment == Justification.Justified, Size.Height > 1 && WordWrap, PreserveTrailingSpaces, TabWidth, @@ -1031,7 +1031,7 @@ public static List WordWrapText ( List runes = StripCRLF (text).ToRuneList (); int start = Math.Max ( - !runes.Contains ((Rune)' ') && textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom } && IsVerticalDirection (textDirection) + !runes.Contains ((Rune)' ') && textFormatter is { VerticalAlignment: Justification.Bottom } && IsVerticalDirection (textDirection) ? runes.Count - width : 0, 0); @@ -1257,13 +1257,13 @@ int GetNextWhiteSpace (int from, int cWidth, out bool incomplete, int cLength = public static string ClipAndJustify ( string text, int width, - TextAlignment talign, + Justification talign, 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, talign == Justification.Justified, textDirection, tabWidth, textFormatter); } /// Justifies text within a specified width. @@ -1304,12 +1304,12 @@ public static string ClipAndJustify ( { if (IsHorizontalDirection (textDirection)) { - if (textFormatter is { Alignment: TextAlignment.Right }) + if (textFormatter is { Alignment: Justification.Right }) { return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection); } - if (textFormatter is { Alignment: TextAlignment.Centered }) + if (textFormatter is { Alignment: Justification.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1319,12 +1319,12 @@ public static string ClipAndJustify ( if (IsVerticalDirection (textDirection)) { - if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom }) + if (textFormatter is { VerticalAlignment: Justification.Bottom }) { return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection); } - if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Middle }) + if (textFormatter is { VerticalAlignment: Justification.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1342,14 +1342,14 @@ public static string ClipAndJustify ( if (IsHorizontalDirection (textDirection)) { - if (textFormatter is { Alignment: TextAlignment.Right }) + if (textFormatter is { Alignment: Justification.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: Justification.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1361,14 +1361,14 @@ public static string ClipAndJustify ( if (IsVerticalDirection (textDirection)) { - if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom }) + if (textFormatter is { VerticalAlignment: Justification.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: Justification.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1498,7 +1498,7 @@ public static string Justify ( public static List Format ( string text, int width, - TextAlignment talign, + Justification talign, bool wordWrap, bool preserveTrailingSpaces = false, int tabWidth = 0, @@ -1510,7 +1510,7 @@ public static List Format ( return Format ( text, width, - talign == TextAlignment.Justified, + talign == Justification.Justified, wordWrap, preserveTrailingSpaces, tabWidth, diff --git a/Terminal.Gui/Text/VerticalTextAlignment.cs b/Terminal.Gui/Text/VerticalTextAlignment.cs deleted file mode 100644 index ef77885772..0000000000 --- a/Terminal.Gui/Text/VerticalTextAlignment.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Terminal.Gui; - -/// Vertical text alignment enumeration, controls how text is displayed. -public enum VerticalTextAlignment -{ - /// The text will be top-aligned. - Top, - - /// The text will be bottom-aligned. - Bottom, - - /// The text will centered vertically. - Middle, - - /// - /// The text will be justified (spaces will be added to existing spaces such that the text fills the container - /// vertically). - /// - Justified -} \ No newline at end of file diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs index 63ad748c75..19f534ad5e 100644 --- a/Terminal.Gui/View/ViewText.cs +++ b/Terminal.Gui/View/ViewText.cs @@ -34,7 +34,7 @@ public virtual bool PreserveTrailingSpaces /// /// /// The text will be drawn starting at the view origin (0, 0) and will be formatted according - /// to and . + /// to and . /// /// /// The text will word-wrap to additional lines if it does not fit horizontally. If 's height @@ -87,7 +87,7 @@ public void OnTextChanged (string oldValue, string newValue) /// or are using , the will be adjusted to fit the text. /// /// The text alignment. - public virtual TextAlignment TextAlignment + public virtual Justification Justification { get => TextFormatter.Alignment; set @@ -130,7 +130,7 @@ public virtual TextDirection TextDirection /// or are using , the will be adjusted to fit the text. /// /// The text alignment. - public virtual VerticalTextAlignment VerticalTextAlignment + public virtual Justification VerticalJustification { get => TextFormatter.VerticalAlignment; set diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs index 8f0fb55c16..3530b42f65 100644 --- a/Terminal.Gui/Views/Button.cs +++ b/Terminal.Gui/Views/Button.cs @@ -37,8 +37,8 @@ public class Button : View /// The width of the is computed based on the text length. The height will always be 1. public Button () { - TextAlignment = TextAlignment.Centered; - VerticalTextAlignment = VerticalTextAlignment.Middle; + Justification = Justification.Centered; + VerticalJustification = Justification.Centered; _leftBracket = Glyphs.LeftBracket; _rightBracket = Glyphs.RightBracket; diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs index 0535f5f438..e97e3ca10b 100644 --- a/Terminal.Gui/Views/CheckBox.cs +++ b/Terminal.Gui/Views/CheckBox.cs @@ -153,15 +153,15 @@ public bool? Checked /// protected override void UpdateTextFormatterText () { - switch (TextAlignment) + switch (Justification) { - case TextAlignment.Left: - case TextAlignment.Centered: - case TextAlignment.Justified: + case Justification.Left: + case Justification.Centered: + case Justification.Justified: TextFormatter.Text = $"{GetCheckedState ()} {GetFormatterText ()}"; break; - case TextAlignment.Right: + case Justification.Right: TextFormatter.Text = $"{GetFormatterText ()} {GetCheckedState ()}"; break; diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index b91ede6cb1..77439ee8ef 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -1002,7 +1002,7 @@ private int GetMaxLengthItem () 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, Justification.Left); driver.AddStr (u); width -= u.GetColumns (); diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index 6d0353f9b2..1d6a92de6a 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -891,7 +891,7 @@ public override void OnDrawContent (Rectangle viewport) var tf = new TextFormatter { AutoSize = true, - Alignment = TextAlignment.Centered, HotKeySpecifier = MenuBar.HotKeySpecifier, Text = textToDraw + Alignment = Justification.Centered, HotKeySpecifier = MenuBar.HotKeySpecifier, Text = textToDraw }; // The -3 is left/right border + one space (not sure what for) diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index 03942953eb..da7342794e 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -374,7 +374,7 @@ params string [] buttons var messageLabel = new Label { Text = message, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, X = Pos.Center (), Y = 0 }; diff --git a/Terminal.Gui/Views/ProgressBar.cs b/Terminal.Gui/Views/ProgressBar.cs index fed490d692..47c520db9d 100644 --- a/Terminal.Gui/Views/ProgressBar.cs +++ b/Terminal.Gui/Views/ProgressBar.cs @@ -181,7 +181,7 @@ public override void OnDrawContent (Rectangle viewport) if (ProgressBarFormat != ProgressBarFormat.Simple && !_isActivity) { - var tf = new TextFormatter { Alignment = TextAlignment.Centered, Text = Text }; + var tf = new TextFormatter { Alignment = Justification.Centered, Text = Text }; var attr = new Attribute (ColorScheme.HotNormal.Foreground, ColorScheme.HotNormal.Background); if (_fraction > .5) diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs index 4a1c0ac577..4a904419fa 100644 --- a/Terminal.Gui/Views/Slider.cs +++ b/Terminal.Gui/Views/Slider.cs @@ -930,7 +930,7 @@ public override void OnDrawContent (Rectangle viewport) } } - private string AlignText (string text, int width, TextAlignment textAlignment) + private string AlignText (string text, int width, Justification Justification) { if (text is null) { @@ -947,20 +947,20 @@ private string AlignText (string text, int width, TextAlignment textAlignment) string s2 = new (' ', w % 2); // Note: The formatter doesn't handle all of this ??? - switch (textAlignment) + switch (Justification) { - case TextAlignment.Justified: + case Justification.Justified: return TextFormatter.Justify (text, width); - case TextAlignment.Left: + case Justification.Left: return text + s1 + s1 + s2; - case TextAlignment.Centered: + case Justification.Centered: if (text.Length % 2 != 0) { return s1 + text + s1 + s2; } return s1 + s2 + text + s1; - case TextAlignment.Right: + case Justification.Right: return s1 + s1 + s2 + text; default: return text; @@ -1293,7 +1293,7 @@ private void DrawLegends () switch (_config._legendsOrientation) { case Orientation.Horizontal: - text = AlignText (text, _config._innerSpacing + 1, TextAlignment.Centered); + text = AlignText (text, _config._innerSpacing + 1, Justification.Centered); break; case Orientation.Vertical: @@ -1311,7 +1311,7 @@ private void DrawLegends () break; case Orientation.Vertical: - text = AlignText (text, _config._innerSpacing + 1, TextAlignment.Centered); + text = AlignText (text, _config._innerSpacing + 1, Justification.Centered); break; } diff --git a/Terminal.Gui/Views/TableView/ColumnStyle.cs b/Terminal.Gui/Views/TableView/ColumnStyle.cs index cbbc2a3ac9..2490d66f63 100644 --- a/Terminal.Gui/Views/TableView/ColumnStyle.cs +++ b/Terminal.Gui/Views/TableView/ColumnStyle.cs @@ -11,7 +11,7 @@ public class ColumnStyle /// Defines a delegate for returning custom alignment per cell based on cell values. When specified this will /// override /// - public Func AlignmentGetter; + public Func AlignmentGetter; /// /// Defines a delegate for returning a custom color scheme per cell based on cell values. Return null for the @@ -32,7 +32,7 @@ public class ColumnStyle /// Defines the default alignment for all values rendered in this column. For custom alignment based on cell /// contents use . /// - public TextAlignment Alignment { get; set; } + public Justification Alignment { get; set; } /// Defines the format for values e.g. "yyyy-MM-dd" for dates public string Format { get; set; } @@ -74,7 +74,7 @@ public bool Visible /// /// /// - public TextAlignment GetAlignment (object cellValue) + public Justification GetAlignment (object cellValue) { if (AlignmentGetter is { }) { diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs index 2ae46c7fdb..190fef0417 100644 --- a/Terminal.Gui/Views/TableView/TableView.cs +++ b/Terminal.Gui/Views/TableView/TableView.cs @@ -2085,16 +2085,16 @@ ColumnStyle colStyle - (representation.EnumerateRunes ().Sum (c => c.GetColumns ()) + 1 /*leave 1 space for cell boundary*/); - switch (colStyle?.GetAlignment (originalCellValue) ?? TextAlignment.Left) + switch (colStyle?.GetAlignment (originalCellValue) ?? Justification.Left) { - case TextAlignment.Left: + case Justification.Left: return representation + new string (' ', toPad); - case TextAlignment.Right: + case Justification.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 Justification.Centered: + case Justification.Justified: return new string (' ', (int)Math.Floor (toPad / 2.0)) + // round down diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs index a51e55e540..f2d4cc1bf2 100644 --- a/Terminal.Gui/Views/TextValidateField.cs +++ b/Terminal.Gui/Views/TextValidateField.cs @@ -539,7 +539,7 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) { int c = _provider.Cursor (mouseEvent.X - GetMargins (Viewport.Width).left); - if (_provider.Fixed == false && TextAlignment == TextAlignment.Right && Text.Length > 0) + if (_provider.Fixed == false && Justification == Justification.Right && Text.Length > 0) { c++; } @@ -633,7 +633,7 @@ public override bool OnProcessKeyDown (Key a) // 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 && Justification == Justification.Right) { curPos = _cursorPosition + left - 1; } @@ -650,7 +650,7 @@ public override bool OnProcessKeyDown (Key a) /// private bool BackspaceKeyHandler () { - if (_provider.Fixed == false && TextAlignment == TextAlignment.Right && _cursorPosition <= 1) + if (_provider.Fixed == false && Justification == Justification.Right && _cursorPosition <= 1) { return false; } @@ -688,7 +688,7 @@ private bool CursorRight () /// private bool DeleteKeyHandler () { - if (_provider.Fixed == false && TextAlignment == TextAlignment.Right) + if (_provider.Fixed == false && Justification == Justification.Right) { _cursorPosition = _provider.CursorLeft (_cursorPosition); } @@ -717,13 +717,13 @@ private bool EndKeyHandler () int count = Text.Length; int total = width - count; - switch (TextAlignment) + switch (Justification) { - case TextAlignment.Left: + case Justification.Left: return (0, total); - case TextAlignment.Centered: + case Justification.Centered: return (total / 2, total / 2 + total % 2); - case TextAlignment.Right: + case Justification.Right: return (total, 0); default: return (0, total); diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index f7a095dd70..47ecca855a 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -1776,7 +1776,7 @@ public TextModel WrapModel ( TextFormatter.Format ( TextModel.ToString (line), width, - TextAlignment.Left, + Justification.Left, true, preserveTrailingSpaces, tabWidth diff --git a/UICatalog/Scenarios/BasicColors.cs b/UICatalog/Scenarios/BasicColors.cs index 1780d7cbbc..08a3c642d6 100644 --- a/UICatalog/Scenarios/BasicColors.cs +++ b/UICatalog/Scenarios/BasicColors.cs @@ -32,7 +32,7 @@ public override void Main () Y = 0, Width = 1, Height = 13, - VerticalTextAlignment = VerticalTextAlignment.Bottom, + VerticalJustification = Justification.Bottom, ColorScheme = new ColorScheme { Normal = attr }, Text = bg.ToString (), TextDirection = TextDirection.TopBottom_LeftRight @@ -45,7 +45,7 @@ public override void Main () Y = y, Width = 13, Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, ColorScheme = new ColorScheme { Normal = attr }, Text = bg.ToString () }; diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs index 9b4ed97fcb..57d7ba1791 100644 --- a/UICatalog/Scenarios/Buttons.cs +++ b/UICatalog/Scenarios/Buttons.cs @@ -287,39 +287,39 @@ string MoveHotkey (string txt) 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.Justification = Justification.Left; + sizeBtn.Justification = Justification.Left; + moveBtnA.Justification = Justification.Left; + sizeBtnA.Justification = Justification.Left; + moveHotKeyBtn.Justification = Justification.Left; + moveUnicodeHotKeyBtn.Justification = Justification.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.Justification = Justification.Right; + sizeBtn.Justification = Justification.Right; + moveBtnA.Justification = Justification.Right; + sizeBtnA.Justification = Justification.Right; + moveHotKeyBtn.Justification = Justification.Right; + moveUnicodeHotKeyBtn.Justification = Justification.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.Justification = Justification.Centered; + sizeBtn.Justification = Justification.Centered; + moveBtnA.Justification = Justification.Centered; + sizeBtnA.Justification = Justification.Centered; + moveHotKeyBtn.Justification = Justification.Centered; + moveUnicodeHotKeyBtn.Justification = Justification.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.Justification = Justification.Justified; + sizeBtn.Justification = Justification.Justified; + moveBtnA.Justification = Justification.Justified; + sizeBtnA.Justification = Justification.Justified; + moveHotKeyBtn.Justification = Justification.Justified; + moveUnicodeHotKeyBtn.Justification = Justification.Justified; break; } @@ -439,7 +439,7 @@ public NumericUpDown () Y = Pos.Top (_down), Width = Dim.Function (() => Digits), Height = 1, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, CanFocus = true }; diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index a3aa100a8c..c8d62b7166 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -958,7 +958,7 @@ private void ShowDetails () Y = 1, Width = Dim.Fill (), Height = Dim.Fill (1), - TextAlignment = TextAlignment.Centered + Justification = Justification.Centered }; var spinner = new SpinnerView { X = Pos.Center (), Y = Pos.Center (), Style = new Aesthetic () }; spinner.AutoSpin = true; diff --git a/UICatalog/Scenarios/CollectionNavigatorTester.cs b/UICatalog/Scenarios/CollectionNavigatorTester.cs index ef31ac6a7d..480e5f65fe 100644 --- a/UICatalog/Scenarios/CollectionNavigatorTester.cs +++ b/UICatalog/Scenarios/CollectionNavigatorTester.cs @@ -142,7 +142,7 @@ private void CreateListView () var label = new Label { Text = "ListView", - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, X = 0, Y = 1, // for menu Width = Dim.Percent (50), @@ -171,7 +171,7 @@ private void CreateTreeView () var label = new Label { Text = "TreeView", - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, X = Pos.Right (_listView) + 2, Y = 1, // for menu Width = Dim.Percent (50), diff --git a/UICatalog/Scenarios/ColorPicker.cs b/UICatalog/Scenarios/ColorPicker.cs index fe2b08fad3..cf2b7512ef 100644 --- a/UICatalog/Scenarios/ColorPicker.cs +++ b/UICatalog/Scenarios/ColorPicker.cs @@ -69,8 +69,8 @@ public override void Main () { Title = "Color Sample", Text = "Lorem Ipsum", - TextAlignment = TextAlignment.Centered, - VerticalTextAlignment = VerticalTextAlignment.Middle, + Justification = Justification.Centered, + VerticalJustification = Justification.Centered, BorderStyle = LineStyle.Heavy, X = Pos.Center (), Y = Pos.Center (), diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index a65050f52d..f880568439 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -91,7 +91,7 @@ public override void Main () labelList.Add ( new Label { - TextAlignment = TextAlignment.Left, + Justification = Justification.Left, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -103,7 +103,7 @@ public override void Main () labelList.Add ( new Label { - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -115,7 +115,7 @@ public override void Main () labelList.Add ( new Label { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -127,7 +127,7 @@ public override void Main () labelList.Add ( new Label { - TextAlignment = TextAlignment.Justified, + Justification = Justification.Justified, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -153,7 +153,7 @@ public override void Main () labelList.Add ( new Label { - TextAlignment = TextAlignment.Left, + Justification = Justification.Left, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -165,7 +165,7 @@ public override void Main () labelList.Add ( new Label { - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -177,7 +177,7 @@ public override void Main () labelList.Add ( new Label { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -189,7 +189,7 @@ public override void Main () labelList.Add ( new Label { - TextAlignment = TextAlignment.Justified, + Justification = Justification.Justified, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -324,7 +324,7 @@ public override void Main () var anchorEndLabel1 = new Label { Text = "This Label should be the 3rd to last line (AnchorEnd (3)).", - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, ColorScheme = Colors.ColorSchemes ["Menu"], Width = Dim.Fill (5), X = 5, @@ -338,7 +338,7 @@ public override void Main () { Text = "This TextField should be the 4th to last line (AnchorEnd (3) - 1).", - TextAlignment = TextAlignment.Left, + Justification = Justification.Left, ColorScheme = Colors.ColorSchemes ["Menu"], Width = Dim.Fill (5), X = 5, diff --git a/UICatalog/Scenarios/CsvEditor.cs b/UICatalog/Scenarios/CsvEditor.cs index 4279594abd..e7b48e4645 100644 --- a/UICatalog/Scenarios/CsvEditor.cs +++ b/UICatalog/Scenarios/CsvEditor.cs @@ -78,17 +78,17 @@ public override void Setup () _miLeft = new MenuItem ( "_Align Left", "", - () => Align (TextAlignment.Left) + () => Align (Justification.Left) ), _miRight = new MenuItem ( "_Align Right", "", - () => Align (TextAlignment.Right) + () => Align (Justification.Right) ), _miCentered = new MenuItem ( "_Align Centered", "", - () => Align (TextAlignment.Centered) + () => Align (Justification.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 override void Setup () Y = Pos.Bottom (_tableView), Text = "0,0", Width = Dim.Fill (), - TextAlignment = TextAlignment.Right + Justification = Justification.Right }; _selectedCellLabel.TextChanged += SelectedCellLabel_TextChanged; @@ -218,7 +218,7 @@ private void AddRow () _tableView.Update (); } - private void Align (TextAlignment newAlignment) + private void Align (Justification newAlignment) { if (NoTableLoaded ()) { @@ -228,9 +228,9 @@ private void Align (TextAlignment newAlignment) 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 == Justification.Left; + _miRight.Checked = style.Alignment == Justification.Right; + _miCentered.Checked = style.Alignment == Justification.Centered; _tableView.Update (); } @@ -437,9 +437,9 @@ private void OnSelectedCellChanged (object sender, SelectedCellChangedEventArgs 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 == Justification.Left; + _miRight.Checked = style?.Alignment == Justification.Right; + _miCentered.Checked = style?.Alignment == Justification.Centered; } private void Open () diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs index 6a16ef5aa3..8b21b066d1 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -18,7 +18,7 @@ public override void Setup () var numButtonsLabel = new Label { X = 0, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "_Number of Buttons:" }; @@ -28,7 +28,7 @@ public override void Setup () Y = 0, Width = Dim.Width (numButtonsLabel), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "_Width:" }; frame.Add (label); @@ -49,7 +49,7 @@ public override void Setup () Y = Pos.Bottom (label), Width = Dim.Width (numButtonsLabel), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "_Height:" }; frame.Add (label); @@ -83,7 +83,7 @@ public override void Setup () Y = Pos.Bottom (label), Width = Dim.Width (numButtonsLabel), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "_Title:" }; frame.Add (label); @@ -115,7 +115,7 @@ public override void Setup () { X = Pos.Right (numButtonsLabel) + 1, Y = Pos.Bottom (numButtonsLabel), - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = $"_Add {char.ConvertFromUtf32 (CODE_POINT)} to button text to stress wide char support", Checked = false }; @@ -127,7 +127,7 @@ public override void Setup () Y = Pos.Bottom (glyphsNotWords), Width = Dim.Width (numButtonsLabel), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Button St_yle:" }; frame.Add (label); @@ -175,7 +175,7 @@ void Top_LayoutComplete (object sender, EventArgs args) label = new() { - X = Pos.Center (), Y = Pos.Bottom (frame) + 4, TextAlignment = TextAlignment.Right, Text = "Button Pressed:" + X = Pos.Center (), Y = Pos.Bottom (frame) + 4, Justification = Justification.Right, Text = "Button Pressed:" }; Win.Add (label); diff --git a/UICatalog/Scenarios/DynamicMenuBar.cs b/UICatalog/Scenarios/DynamicMenuBar.cs index da0768f4f9..38445a1aa1 100644 --- a/UICatalog/Scenarios/DynamicMenuBar.cs +++ b/UICatalog/Scenarios/DynamicMenuBar.cs @@ -623,7 +623,7 @@ public DynamicMenuBarSample () var _lblMenuBar = new Label { ColorScheme = Colors.ColorSchemes ["Dialog"], - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, X = Pos.Right (_btnPrevious) + 1, Y = Pos.Top (_btnPrevious), @@ -636,7 +636,7 @@ public DynamicMenuBarSample () var _lblParent = new Label { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, X = Pos.Right (_btnPrevious) + 1, Y = Pos.Top (_btnPrevious) + 1, diff --git a/UICatalog/Scenarios/Editor.cs b/UICatalog/Scenarios/Editor.cs index 301b1b168f..18bcf11bb8 100644 --- a/UICatalog/Scenarios/Editor.cs +++ b/UICatalog/Scenarios/Editor.cs @@ -882,7 +882,7 @@ private View FindTab () { Y = 1, Width = lblWidth, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Find:" }; @@ -903,7 +903,7 @@ private View FindTab () Y = Pos.Top (label), Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, IsDefault = true, Text = "Find _Next" @@ -917,7 +917,7 @@ private View FindTab () Y = Pos.Top (btnFindNext) + 1, Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Text = "Find _Previous" }; @@ -937,7 +937,7 @@ private View FindTab () X = Pos.Right (txtToFind) + 1, Y = Pos.Top (btnFindPrevious) + 2, Width = 20, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Text = "Cancel" }; @@ -1134,7 +1134,7 @@ private View ReplaceTab () { Y = 1, Width = lblWidth, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Find:" }; @@ -1155,7 +1155,7 @@ private View ReplaceTab () Y = Pos.Top (label), Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, IsDefault = true, Text = "Replace _Next" @@ -1181,7 +1181,7 @@ private View ReplaceTab () Y = Pos.Top (btnFindNext) + 1, Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Text = "Replace _Previous" }; @@ -1194,7 +1194,7 @@ private View ReplaceTab () Y = Pos.Top (btnFindPrevious) + 1, Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Text = "Replace _All" }; @@ -1215,7 +1215,7 @@ private View ReplaceTab () X = Pos.Right (txtToFind) + 1, Y = Pos.Top (btnReplaceAll) + 1, Width = 20, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Text = "Cancel" }; diff --git a/UICatalog/Scenarios/ListColumns.cs b/UICatalog/Scenarios/ListColumns.cs index ea093b7690..bbbabb0a29 100644 --- a/UICatalog/Scenarios/ListColumns.cs +++ b/UICatalog/Scenarios/ListColumns.cs @@ -247,7 +247,7 @@ public override void Setup () Text = "0,0", Width = Dim.Fill (), - TextAlignment = TextAlignment.Right + Justification = Justification.Right }; Win.Add (selectedCellLabel); diff --git a/UICatalog/Scenarios/MessageBoxes.cs b/UICatalog/Scenarios/MessageBoxes.cs index df5a54050d..33bf34610c 100644 --- a/UICatalog/Scenarios/MessageBoxes.cs +++ b/UICatalog/Scenarios/MessageBoxes.cs @@ -14,7 +14,7 @@ public override void Setup () 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, Justification = Justification.Right, Text = "Width:" }; frame.Add (label); var widthEdit = new TextField @@ -34,7 +34,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Height:" }; frame.Add (label); @@ -69,7 +69,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Title:" }; frame.Add (label); @@ -91,7 +91,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Message:" }; frame.Add (label); @@ -113,7 +113,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Num Buttons:" }; frame.Add (label); @@ -135,7 +135,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Default Button:" }; frame.Add (label); @@ -157,7 +157,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Style:" }; frame.Add (label); @@ -195,7 +195,7 @@ void Top_LayoutComplete (object sender, EventArgs args) label = new() { - X = Pos.Center (), Y = Pos.Bottom (frame) + 2, TextAlignment = TextAlignment.Right, Text = "Button Pressed:" + X = Pos.Center (), Y = Pos.Bottom (frame) + 2, Justification = Justification.Right, Text = "Button Pressed:" }; Win.Add (label); @@ -204,7 +204,7 @@ void Top_LayoutComplete (object sender, EventArgs args) X = Pos.Center (), Y = Pos.Bottom (label) + 1, ColorScheme = Colors.ColorSchemes ["Error"], - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Text = " " }; diff --git a/UICatalog/Scenarios/Mouse.cs b/UICatalog/Scenarios/Mouse.cs index 0e55dbd8fd..005bbb360a 100644 --- a/UICatalog/Scenarios/Mouse.cs +++ b/UICatalog/Scenarios/Mouse.cs @@ -98,8 +98,8 @@ public override void Main () Width = 20, Height = 3, Text = "Enter/Leave Demo", - TextAlignment = TextAlignment.Centered, - VerticalTextAlignment = VerticalTextAlignment.Middle, + Justification = Justification.Centered, + VerticalJustification = Justification.Centered, ColorScheme = Colors.ColorSchemes ["Dialog"] }; win.Add (demo); diff --git a/UICatalog/Scenarios/TableEditor.cs b/UICatalog/Scenarios/TableEditor.cs index b73fa19d26..3c5f8e38df 100644 --- a/UICatalog/Scenarios/TableEditor.cs +++ b/UICatalog/Scenarios/TableEditor.cs @@ -707,7 +707,7 @@ public override void Setup () Text = "0,0", Width = Dim.Fill (), - TextAlignment = TextAlignment.Right + Justification = Justification.Right }; Win.Add (selectedCellLabel); @@ -1107,12 +1107,12 @@ private void SetDemoTableStyles () { _tableView.Style.ColumnStyles.Clear (); - var alignMid = new ColumnStyle { Alignment = TextAlignment.Centered }; - var alignRight = new ColumnStyle { Alignment = TextAlignment.Right }; + var alignMid = new ColumnStyle { Alignment = Justification.Centered }; + var alignRight = new ColumnStyle { Alignment = Justification.Right }; var dateFormatStyle = new ColumnStyle { - Alignment = TextAlignment.Right, + Alignment = Justification.Right, RepresentationGetter = v => v is DateTime d ? d.ToString ("yyyy-MM-dd") : v.ToString () }; @@ -1126,15 +1126,15 @@ private void SetDemoTableStyles () // align negative values right d < 0 - ? TextAlignment.Right + ? Justification.Right : // align positive values left - TextAlignment.Left + Justification.Left : // not a double - TextAlignment.Left, + Justification.Left, ColorGetter = a => a.CellValue is double d ? diff --git a/UICatalog/Scenarios/Text.cs b/UICatalog/Scenarios/Text.cs index 19dddd847b..7b0e829100 100644 --- a/UICatalog/Scenarios/Text.cs +++ b/UICatalog/Scenarios/Text.cs @@ -290,7 +290,7 @@ void TextView_DrawContent (object sender, DrawEventArgs e) X = Pos.Right (regexProvider) + 1, Y = Pos.Y (regexProvider), Width = 30, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Provider = provider2 }; Win.Add (regexProviderField); diff --git a/UICatalog/Scenarios/TextAlignments.cs b/UICatalog/Scenarios/TextAlignments.cs index 92ee344e1f..9897d7dccc 100644 --- a/UICatalog/Scenarios/TextAlignments.cs +++ b/UICatalog/Scenarios/TextAlignments.cs @@ -18,17 +18,17 @@ public override void Setup () var txt = "Hello world, how are you today? Pretty neat!"; var unicodeSampleText = "A Unicode sentence (пÑРвеÑ) has words."; - List alignments = Enum.GetValues (typeof (TextAlignment)).Cast ().ToList (); + List alignments = Enum.GetValues (typeof (Justification)).Cast ().ToList (); Label [] singleLines = new Label [alignments.Count]; Label [] multipleLines = new Label [alignments.Count]; var multiLineHeight = 5; - foreach (TextAlignment alignment in alignments) + foreach (Justification alignment in alignments) { singleLines [(int)alignment] = new() { - TextAlignment = alignment, + Justification = alignment, X = 1, Width = Dim.Fill (1), @@ -39,7 +39,7 @@ public override void Setup () multipleLines [(int)alignment] = new() { - TextAlignment = alignment, + Justification = alignment, X = 1, Width = Dim.Fill (1), @@ -65,7 +65,7 @@ public override void Setup () edit.TextChanged += (s, e) => { - foreach (TextAlignment alignment in alignments) + foreach (Justification alignment in alignments) { singleLines [(int)alignment].Text = edit.Text; multipleLines [(int)alignment].Text = edit.Text; @@ -81,7 +81,7 @@ public override void Setup () update.Accept += (s, e) => { - foreach (TextAlignment alignment in alignments) + foreach (Justification alignment in alignments) { singleLines [(int)alignment].Text = edit.Text; multipleLines [(int)alignment].Text = edit.Text; @@ -102,7 +102,7 @@ public override void Setup () }; Win.Add (label); - foreach (TextAlignment alignment in alignments) + foreach (Justification alignment in alignments) { label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" }; Win.Add (label); @@ -115,7 +115,7 @@ public override void Setup () label = new() { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" }; Win.Add (label); - foreach (TextAlignment alignment in alignments) + foreach (Justification alignment in alignments) { label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" }; Win.Add (label); @@ -126,7 +126,7 @@ public override void Setup () enableHotKeyCheckBox.Toggled += (s, e) => { - foreach (TextAlignment alignment in alignments) + foreach (Justification alignment in alignments) { singleLines [(int)alignment].HotKeySpecifier = e.OldValue == true ? (Rune)0xffff : (Rune)'_'; diff --git a/UICatalog/Scenarios/TextAlignmentsAndDirection.cs b/UICatalog/Scenarios/TextAlignmentsAndDirection.cs index 1f70f7d7aa..f55bec96aa 100644 --- a/UICatalog/Scenarios/TextAlignmentsAndDirection.cs +++ b/UICatalog/Scenarios/TextAlignmentsAndDirection.cs @@ -35,7 +35,7 @@ public override void Main () Y = 1, Width = 9, Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, ColorScheme = Colors.ColorSchemes ["Dialog"], Text = "Left" }; @@ -46,7 +46,7 @@ public override void Main () Y = 2, Width = 9, Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, ColorScheme = Colors.ColorSchemes ["Dialog"], Text = "Centered" }; @@ -57,7 +57,7 @@ public override void Main () Y = 3, Width = 9, Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, ColorScheme = Colors.ColorSchemes ["Dialog"], Text = "Right" }; @@ -68,7 +68,7 @@ public override void Main () Y = 4, Width = 9, Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, ColorScheme = Colors.ColorSchemes ["Dialog"], Text = "Justified" }; @@ -80,7 +80,7 @@ public override void Main () Width = Dim.Fill (1) - 9, Height = 1, ColorScheme = color1, - TextAlignment = TextAlignment.Left, + Justification = Justification.Left, Text = txt }; @@ -91,7 +91,7 @@ public override void Main () Width = Dim.Fill (1) - 9, Height = 1, ColorScheme = color2, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Text = txt }; @@ -102,7 +102,7 @@ public override void Main () Width = Dim.Fill (1) - 9, Height = 1, ColorScheme = color1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = txt }; @@ -113,7 +113,7 @@ public override void Main () Width = Dim.Fill (1) - 9, Height = 1, ColorScheme = color2, - TextAlignment = TextAlignment.Justified, + Justification = Justification.Justified, Text = txt }; @@ -141,7 +141,7 @@ public override void Main () Height = 9, ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Bottom, + VerticalJustification = Justification.Bottom, Text = "Top" }; labelVT.TextFormatter.WordWrap = false; @@ -154,8 +154,8 @@ public override void Main () Height = 9, ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Bottom, - Text = "Middle" + VerticalJustification = Justification.Bottom, + Text = "Centered" }; labelVM.TextFormatter.WordWrap = false; @@ -167,7 +167,7 @@ public override void Main () Height = 9, ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Bottom, + VerticalJustification = Justification.Bottom, Text = "Bottom" }; labelVB.TextFormatter.WordWrap = false; @@ -180,7 +180,7 @@ public override void Main () Height = 9, ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Bottom, + VerticalJustification = Justification.Bottom, Text = "Justified" }; labelVJ.TextFormatter.WordWrap = false; @@ -193,7 +193,7 @@ public override void Main () Height = Dim.Fill (1), ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Top, + VerticalJustification = Justification.Top, Text = txt }; txtLabelVT.TextFormatter.WordWrap = false; @@ -206,7 +206,7 @@ public override void Main () Height = Dim.Fill (1), ColorScheme = color2, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Middle, + VerticalJustification = Justification.Centered, Text = txt }; txtLabelVM.TextFormatter.WordWrap = false; @@ -219,7 +219,7 @@ public override void Main () Height = Dim.Fill (1), ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Bottom, + VerticalJustification = Justification.Bottom, Text = txt }; txtLabelVB.TextFormatter.WordWrap = false; @@ -232,7 +232,7 @@ public override void Main () Height = Dim.Fill (1), ColorScheme = color2, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Justified, + VerticalJustification = Justification.Justified, Text = txt }; txtLabelVJ.TextFormatter.WordWrap = false; @@ -268,8 +268,8 @@ public override void Main () Y = 1, Width = Dim.Percent (100f / 3f), Height = Dim.Percent (100f / 3f), - TextAlignment = TextAlignment.Left, - VerticalTextAlignment = VerticalTextAlignment.Top, + Justification = Justification.Left, + VerticalJustification = Justification.Top, ColorScheme = color1, Text = txt }; @@ -281,8 +281,8 @@ public override void Main () Y = 1, Width = Dim.Percent (100f / 3f), Height = Dim.Percent (100f / 3f), - TextAlignment = TextAlignment.Centered, - VerticalTextAlignment = VerticalTextAlignment.Top, + Justification = Justification.Centered, + VerticalJustification = Justification.Top, ColorScheme = color1, Text = txt }; @@ -294,8 +294,8 @@ public override void Main () Y = 1, Width = Dim.Percent (100f, true), Height = Dim.Percent (100f / 3f), - TextAlignment = TextAlignment.Right, - VerticalTextAlignment = VerticalTextAlignment.Top, + Justification = Justification.Right, + VerticalJustification = Justification.Top, ColorScheme = color1, Text = txt }; @@ -307,8 +307,8 @@ public override void Main () Y = Pos.Bottom (txtLabelTL) + 1, Width = Dim.Width (txtLabelTL), Height = Dim.Percent (100f / 3f), - TextAlignment = TextAlignment.Left, - VerticalTextAlignment = VerticalTextAlignment.Middle, + Justification = Justification.Left, + VerticalJustification = Justification.Centered, ColorScheme = color1, Text = txt }; @@ -320,8 +320,8 @@ public override void Main () Y = Pos.Bottom (txtLabelTC) + 1, Width = Dim.Width (txtLabelTC), Height = Dim.Percent (100f / 3f), - TextAlignment = TextAlignment.Centered, - VerticalTextAlignment = VerticalTextAlignment.Middle, + Justification = Justification.Centered, + VerticalJustification = Justification.Centered, ColorScheme = color1, Text = txt }; @@ -333,8 +333,8 @@ public override void Main () Y = Pos.Bottom (txtLabelTR) + 1, Width = Dim.Percent (100f, true), Height = Dim.Percent (100f / 3f), - TextAlignment = TextAlignment.Right, - VerticalTextAlignment = VerticalTextAlignment.Middle, + Justification = Justification.Right, + VerticalJustification = Justification.Centered, ColorScheme = color1, Text = txt }; @@ -346,8 +346,8 @@ public override void Main () Y = Pos.Bottom (txtLabelML) + 1, Width = Dim.Width (txtLabelML), Height = Dim.Percent (100f, true), - TextAlignment = TextAlignment.Left, - VerticalTextAlignment = VerticalTextAlignment.Bottom, + Justification = Justification.Left, + VerticalJustification = Justification.Bottom, ColorScheme = color1, Text = txt }; @@ -359,8 +359,8 @@ public override void Main () Y = Pos.Bottom (txtLabelMC) + 1, Width = Dim.Width (txtLabelMC), Height = Dim.Percent (100f, true), - TextAlignment = TextAlignment.Centered, - VerticalTextAlignment = VerticalTextAlignment.Bottom, + Justification = Justification.Centered, + VerticalJustification = Justification.Bottom, ColorScheme = color1, Text = txt }; @@ -372,8 +372,8 @@ public override void Main () Y = Pos.Bottom (txtLabelMR) + 1, Width = Dim.Percent (100f, true), Height = Dim.Percent (100f, true), - TextAlignment = TextAlignment.Right, - VerticalTextAlignment = VerticalTextAlignment.Bottom, + Justification = Justification.Right, + VerticalJustification = Justification.Bottom, ColorScheme = color1, Text = txt }; @@ -392,7 +392,7 @@ public override void Main () // Save Alignments in Data foreach (Label t in mtxts) { - t.Data = new { h = t.TextAlignment, v = t.VerticalTextAlignment }; + t.Data = new { h = t.Justification, v = t.VerticalJustification }; } container.Add (txtLabelTL); @@ -593,8 +593,8 @@ void ToggleJustify (bool oldValue, bool wasJustOptions = false) foreach (Label t in mtxts) { - t.TextAlignment = (TextAlignment)((dynamic)t.Data).h; - t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v; + t.Justification = (Justification)((dynamic)t.Data).h; + t.VerticalJustification = (Justification)((dynamic)t.Data).v; } } else @@ -611,16 +611,16 @@ void ToggleJustify (bool oldValue, bool wasJustOptions = false) switch (justifyOptions.SelectedItem) { case 0: - t.VerticalTextAlignment = VerticalTextAlignment.Justified; - t.TextAlignment = ((dynamic)t.Data).h; + t.VerticalJustification = Justification.Justified; + t.Justification = ((dynamic)t.Data).h; break; case 1: - t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v; - t.TextAlignment = TextAlignment.Justified; + t.VerticalJustification = (Justification)((dynamic)t.Data).v; + t.Justification = Justification.Justified; break; case 2: - t.VerticalTextAlignment = VerticalTextAlignment.Justified; - t.TextAlignment = TextAlignment.Justified; + t.VerticalJustification = Justification.Justified; + t.Justification = Justification.Justified; break; } } @@ -629,16 +629,16 @@ void ToggleJustify (bool oldValue, bool wasJustOptions = false) switch (justifyOptions.SelectedItem) { case 0: - t.TextAlignment = TextAlignment.Justified; - t.VerticalTextAlignment = ((dynamic)t.Data).v; + t.Justification = Justification.Justified; + t.VerticalJustification = ((dynamic)t.Data).v; break; case 1: - t.TextAlignment = (TextAlignment)((dynamic)t.Data).h; - t.VerticalTextAlignment = VerticalTextAlignment.Justified; + t.Justification = (Justification)((dynamic)t.Data).h; + t.VerticalJustification = Justification.Justified; break; case 2: - t.TextAlignment = TextAlignment.Justified; - t.VerticalTextAlignment = VerticalTextAlignment.Justified; + t.Justification = Justification.Justified; + t.VerticalJustification = Justification.Justified; break; } } diff --git a/UICatalog/Scenarios/TextFormatterDemo.cs b/UICatalog/Scenarios/TextFormatterDemo.cs index 00029c033e..e44b91d4cf 100644 --- a/UICatalog/Scenarios/TextFormatterDemo.cs +++ b/UICatalog/Scenarios/TextFormatterDemo.cs @@ -63,17 +63,17 @@ public override void Main () app.Add (unicodeCheckBox); - List alignments = Enum.GetValues (typeof (TextAlignment)).Cast ().ToList (); + List alignments = Enum.GetValues (typeof (Justification)).Cast ().ToList (); Label [] singleLines = new Label [alignments.Count]; Label [] multipleLines = new Label [alignments.Count]; var multiLineHeight = 5; - foreach (TextAlignment alignment in alignments) + foreach (Justification alignment in alignments) { singleLines [(int)alignment] = new() { - TextAlignment = alignment, + Justification = alignment, X = 0, Width = Dim.Fill (), @@ -84,7 +84,7 @@ public override void Main () multipleLines [(int)alignment] = new() { - TextAlignment = alignment, + Justification = alignment, X = 0, Width = Dim.Fill (), @@ -100,7 +100,7 @@ public override void Main () }; app.Add (label); - foreach (TextAlignment alignment in alignments) + foreach (Justification alignment in alignments) { label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" }; app.Add (label); @@ -112,7 +112,7 @@ public override void Main () label = new() { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" }; app.Add (label); - foreach (TextAlignment alignment in alignments) + foreach (Justification alignment in alignments) { label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" }; app.Add (label); @@ -123,7 +123,7 @@ public override void Main () unicodeCheckBox.Toggled += (s, e) => { - foreach (TextAlignment alignment in alignments) + foreach (Justification alignment in alignments) { singleLines [(int)alignment].Text = e.OldValue == true ? text : unicode; multipleLines [(int)alignment].Text = e.OldValue == true ? text : unicode; diff --git a/UICatalog/Scenarios/TimeAndDate.cs b/UICatalog/Scenarios/TimeAndDate.cs index ddfc8fc7d6..e36114ee07 100644 --- a/UICatalog/Scenarios/TimeAndDate.cs +++ b/UICatalog/Scenarios/TimeAndDate.cs @@ -57,7 +57,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (longDate) + 1, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = Dim.Fill (), Text = "Old Time: " @@ -68,7 +68,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (_lblOldTime) + 1, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = Dim.Fill (), Text = "New Time: " @@ -79,7 +79,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (_lblNewTime) + 1, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = Dim.Fill (), Text = "Time Format: " @@ -90,7 +90,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (_lblTimeFmt) + 2, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = Dim.Fill (), Text = "Old Date: " @@ -101,7 +101,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (_lblOldDate) + 1, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = Dim.Fill (), Text = "New Date: " @@ -112,7 +112,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (_lblNewDate) + 1, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = Dim.Fill (), Text = "Date Format: " diff --git a/UICatalog/Scenarios/Unicode.cs b/UICatalog/Scenarios/Unicode.cs index 987c509345..a16887b3c2 100644 --- a/UICatalog/Scenarios/Unicode.cs +++ b/UICatalog/Scenarios/Unicode.cs @@ -132,7 +132,7 @@ public override void Setup () Width = Dim.Percent (50), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = $"Align Right - {gitString}" }; Win.Add (checkBox, checkBoxRight); diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs index be9bbdf5c6..d80a98f5db 100644 --- a/UICatalog/Scenarios/ViewExperiments.cs +++ b/UICatalog/Scenarios/ViewExperiments.cs @@ -60,7 +60,7 @@ public override void Main () Width = 17, Title = "Window 1", Text = "Window #2", - TextAlignment = TextAlignment.Centered + Justification = Justification.Centered }; window1.Margin.Thickness = new (0); @@ -84,7 +84,7 @@ public override void Main () Width = 37, Title = "Window2", Text = "Window #2 (Right(window1)+1", - TextAlignment = TextAlignment.Centered + Justification = Justification.Centered }; //view3.InitializeFrames (); @@ -109,7 +109,7 @@ public override void Main () Width = 37, Title = "View4", Text = "View #4 (Right(window2)+1", - TextAlignment = TextAlignment.Centered + Justification = Justification.Centered }; //view4.InitializeFrames (); @@ -134,7 +134,7 @@ public override void Main () Width = Dim.Fill (), Title = "View5", Text = "View #5 (Right(view4)+1 Fill", - TextAlignment = TextAlignment.Centered + Justification = Justification.Centered }; //view5.InitializeFrames (); @@ -181,7 +181,7 @@ public override void Main () X = Pos.Center (), Y = Pos.Percent (50), Width = 30, - TextAlignment = TextAlignment.Centered + Justification = Justification.Centered }; label50.Border.Thickness = new (1, 3, 1, 1); label50.Height = 5; diff --git a/UICatalog/Scenarios/Wizards.cs b/UICatalog/Scenarios/Wizards.cs index 22f7e042ec..d034ffc7fb 100644 --- a/UICatalog/Scenarios/Wizards.cs +++ b/UICatalog/Scenarios/Wizards.cs @@ -21,7 +21,7 @@ public override void Setup () }; Win.Add (frame); - var label = new Label { X = 0, Y = 0, TextAlignment = TextAlignment.Right, Text = "Width:" }; + var label = new Label { X = 0, Y = 0, Justification = Justification.Right, Text = "Width:" }; frame.Add (label); var widthEdit = new TextField @@ -41,7 +41,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Height:" }; frame.Add (label); @@ -63,7 +63,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Text = "Title:" }; frame.Add (label); @@ -88,7 +88,7 @@ void Top_Loaded (object sender, EventArgs args) label = new() { - X = Pos.Center (), Y = Pos.AnchorEnd (1), TextAlignment = TextAlignment.Right, Text = "Action:" + X = Pos.Center (), Y = Pos.AnchorEnd (1), Justification = Justification.Right, Text = "Action:" }; Win.Add (label); diff --git a/UnitTests/Text/TextFormatterTests.cs b/UnitTests/Text/TextFormatterTests.cs index fda92ad8e3..d313aa12ae 100644 --- a/UnitTests/Text/TextFormatterTests.cs +++ b/UnitTests/Text/TextFormatterTests.cs @@ -53,36 +53,36 @@ public void Basic_Usage_With_AutoSize_True () tf.Text = testText; Size expectedSize = new (testText.Length, 1); Assert.Equal (testText, tf.Text); - Assert.Equal (TextAlignment.Left, tf.Alignment); + Assert.Equal (Justification.Left, tf.Alignment); Assert.Equal (expectedSize, tf.Size); tf.Draw (testBounds, new Attribute (), new Attribute ()); Assert.Equal (expectedSize, tf.Size); Assert.NotEmpty (tf.GetLines ()); - tf.Alignment = TextAlignment.Right; + tf.Alignment = Justification.Right; expectedSize = new (testText.Length, 1); Assert.Equal (testText, tf.Text); - Assert.Equal (TextAlignment.Right, tf.Alignment); + Assert.Equal (Justification.Right, tf.Alignment); Assert.Equal (expectedSize, tf.Size); tf.Draw (testBounds, new Attribute (), new Attribute ()); Assert.Equal (expectedSize, tf.Size); Assert.NotEmpty (tf.GetLines ()); - tf.Alignment = TextAlignment.Right; + tf.Alignment = Justification.Right; expectedSize = new (testText.Length, 1); tf.Size = expectedSize; Assert.Equal (testText, tf.Text); - Assert.Equal (TextAlignment.Right, tf.Alignment); + Assert.Equal (Justification.Right, tf.Alignment); Assert.Equal (expectedSize, tf.Size); tf.Draw (testBounds, new Attribute (), new Attribute ()); Assert.Equal (expectedSize, tf.Size); Assert.NotEmpty (tf.GetLines ()); - tf.Alignment = TextAlignment.Centered; + tf.Alignment = Justification.Centered; expectedSize = new (testText.Length, 1); tf.Size = expectedSize; Assert.Equal (testText, tf.Text); - Assert.Equal (TextAlignment.Centered, tf.Alignment); + Assert.Equal (Justification.Centered, tf.Alignment); Assert.Equal (expectedSize, tf.Size); tf.Draw (testBounds, new Attribute (), new Attribute ()); Assert.Equal (expectedSize, tf.Size); @@ -191,12 +191,12 @@ public void CalcRect_Vertical_Height_Correct (string text, TextDirection textDir public void ClipAndJustify_Invalid_Returns_Original (string text) { string expected = string.IsNullOrEmpty (text) ? text : ""; - Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, TextAlignment.Left)); - Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, TextAlignment.Left)); + Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, Justification.Left)); + Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, Justification.Left)); Assert.Throws ( () => - TextFormatter.ClipAndJustify (text, -1, TextAlignment.Left) + TextFormatter.ClipAndJustify (text, -1, Justification.Left) ); } @@ -219,7 +219,7 @@ public void ClipAndJustify_Invalid_Returns_Original (string text) [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit public void ClipAndJustify_Valid_Centered (string text, string justifiedText, int maxWidth) { - var align = TextAlignment.Centered; + var align = Justification.Centered; var textDirection = TextDirection.LeftRight_TopBottom; var tabWidth = 1; @@ -277,7 +277,7 @@ public void ClipAndJustify_Valid_Centered (string text, string justifiedText, in [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit public void ClipAndJustify_Valid_Justified (string text, string justifiedText, int maxWidth) { - var align = TextAlignment.Justified; + var align = Justification.Justified; var textDirection = TextDirection.LeftRight_TopBottom; var tabWidth = 1; @@ -328,7 +328,7 @@ public void ClipAndJustify_Valid_Justified (string text, string justifiedText, i [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit public void ClipAndJustify_Valid_Left (string text, string justifiedText, int maxWidth) { - var align = TextAlignment.Left; + var align = Justification.Left; var textDirection = TextDirection.LeftRight_BottomTop; var tabWidth = 1; @@ -377,7 +377,7 @@ public void ClipAndJustify_Valid_Left (string text, string justifiedText, int ma [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit public void ClipAndJustify_Valid_Right (string text, string justifiedText, int maxWidth) { - var align = TextAlignment.Right; + var align = Justification.Right; var textDirection = TextDirection.LeftRight_BottomTop; var tabWidth = 1; @@ -757,7 +757,7 @@ public void Format_Dont_Throw_ArgumentException_With_WordWrap_As_False_And_Keep_ TextFormatter.Format ( "Some text", 4, - TextAlignment.Left, + Justification.Left, false, true ) @@ -785,7 +785,7 @@ string justifiedText for (int i = text.GetRuneCount (); i < maxWidth; i++) { - fmtText = TextFormatter.Format (text, i, TextAlignment.Justified, false, true) [0]; + fmtText = TextFormatter.Format (text, i, Justification.Justified, false, true) [0]; Assert.Equal (i, fmtText.GetRuneCount ()); char c = fmtText [^1]; Assert.True (text.EndsWith (c)); @@ -817,7 +817,7 @@ string justifiedText fmtText = TextFormatter.Format ( text, i, - TextAlignment.Justified, + Justification.Justified, false, true, 0, @@ -862,7 +862,7 @@ IEnumerable expected " A sentence has words. \n This is the second Line - 2. ", 4, -50, - TextAlignment.Left, + Justification.Left, true, false, new [] { " A", "sent", "ence", "has", "word", "s. ", " Thi", "s is", "the", "seco", "nd", "Line", "- 2." }, @@ -872,7 +872,7 @@ IEnumerable expected " A sentence has words. \n This is the second Line - 2. ", 4, -50, - TextAlignment.Left, + Justification.Left, true, true, new [] @@ -900,7 +900,7 @@ public void Format_WordWrap_PreserveTrailingSpaces ( string text, int maxWidth, int widthOffset, - TextAlignment textAlignment, + Justification Justification, bool wrap, bool preserveTrailingSpaces, IEnumerable resultLines, @@ -908,7 +908,7 @@ string expectedWrappedText ) { Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset); - List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap, preserveTrailingSpaces); + List list = TextFormatter.Format (text, maxWidth, Justification, wrap, preserveTrailingSpaces); Assert.Equal (list.Count, resultLines.Count ()); Assert.Equal (resultLines, list); var wrappedText = string.Empty; @@ -1336,30 +1336,30 @@ public void NeedsFormat_Sets () Assert.NotEmpty (tf.GetLines ()); Assert.False (tf.NeedsFormat); // get_Lines causes a Format - tf.Alignment = TextAlignment.Centered; + tf.Alignment = Justification.Centered; Assert.True (tf.NeedsFormat); Assert.NotEmpty (tf.GetLines ()); Assert.False (tf.NeedsFormat); // get_Lines causes a Format } [Theory] - [InlineData ("", -1, TextAlignment.Left, false, 0)] - [InlineData (null, 0, TextAlignment.Left, false, 1)] - [InlineData (null, 0, TextAlignment.Left, true, 1)] - [InlineData ("", 0, TextAlignment.Left, false, 1)] - [InlineData ("", 0, TextAlignment.Left, true, 1)] - public void Reformat_Invalid (string text, int maxWidth, TextAlignment textAlignment, bool wrap, int linesCount) + [InlineData ("", -1, Justification.Left, false, 0)] + [InlineData (null, 0, Justification.Left, false, 1)] + [InlineData (null, 0, Justification.Left, true, 1)] + [InlineData ("", 0, Justification.Left, false, 1)] + [InlineData ("", 0, Justification.Left, true, 1)] + public void Reformat_Invalid (string text, int maxWidth, Justification Justification, bool wrap, int linesCount) { if (maxWidth < 0) { Assert.Throws ( () => - TextFormatter.Format (text, maxWidth, textAlignment, wrap) + TextFormatter.Format (text, maxWidth, Justification, wrap) ); } else { - List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap); + List list = TextFormatter.Format (text, maxWidth, Justification, wrap); Assert.NotEmpty (list); Assert.True (list.Count == linesCount); Assert.Equal (string.Empty, list [0]); @@ -1367,25 +1367,25 @@ public void Reformat_Invalid (string text, int maxWidth, TextAlignment textAlign } [Theory] - [InlineData ("A sentence has words.\nLine 2.", 0, -29, TextAlignment.Left, false, 1, true)] - [InlineData ("A sentence has words.\nLine 2.", 1, -28, TextAlignment.Left, false, 1, false)] - [InlineData ("A sentence has words.\nLine 2.", 5, -24, TextAlignment.Left, false, 1, false)] - [InlineData ("A sentence has words.\nLine 2.", 28, -1, TextAlignment.Left, false, 1, false)] + [InlineData ("A sentence has words.\nLine 2.", 0, -29, Justification.Left, false, 1, true)] + [InlineData ("A sentence has words.\nLine 2.", 1, -28, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.\nLine 2.", 5, -24, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.\nLine 2.", 28, -1, Justification.Left, false, 1, false)] // no clip - [InlineData ("A sentence has words.\nLine 2.", 29, 0, TextAlignment.Left, false, 1, false)] - [InlineData ("A sentence has words.\nLine 2.", 30, 1, TextAlignment.Left, false, 1, false)] - [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, TextAlignment.Left, false, 1, true)] - [InlineData ("A sentence has words.\r\nLine 2.", 1, -29, TextAlignment.Left, false, 1, false)] - [InlineData ("A sentence has words.\r\nLine 2.", 5, -25, TextAlignment.Left, false, 1, false)] - [InlineData ("A sentence has words.\r\nLine 2.", 29, -1, TextAlignment.Left, false, 1, false, 1)] - [InlineData ("A sentence has words.\r\nLine 2.", 30, 0, TextAlignment.Left, false, 1, false)] - [InlineData ("A sentence has words.\r\nLine 2.", 31, 1, TextAlignment.Left, false, 1, false)] + [InlineData ("A sentence has words.\nLine 2.", 29, 0, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.\nLine 2.", 30, 1, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Justification.Left, false, 1, true)] + [InlineData ("A sentence has words.\r\nLine 2.", 1, -29, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.\r\nLine 2.", 5, -25, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.\r\nLine 2.", 29, -1, Justification.Left, false, 1, false, 1)] + [InlineData ("A sentence has words.\r\nLine 2.", 30, 0, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.\r\nLine 2.", 31, 1, Justification.Left, false, 1, false)] public void Reformat_NoWordrap_NewLines_MultiLine_False ( string text, int maxWidth, int widthOffset, - TextAlignment textAlignment, + Justification Justification, bool wrap, int linesCount, bool stringEmpty, @@ -1394,7 +1394,7 @@ public void Reformat_NoWordrap_NewLines_MultiLine_False ( { Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset); int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth) + clipWidthOffset; - List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap); + List list = TextFormatter.Format (text, maxWidth, Justification, wrap); Assert.NotEmpty (list); Assert.True (list.Count == linesCount); @@ -1430,12 +1430,12 @@ list [0] } [Theory] - [InlineData ("A sentence has words.\nLine 2.", 0, -29, TextAlignment.Left, false, 1, true, new [] { "" })] + [InlineData ("A sentence has words.\nLine 2.", 0, -29, Justification.Left, false, 1, true, new [] { "" })] [InlineData ( "A sentence has words.\nLine 2.", 1, -28, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1445,7 +1445,7 @@ list [0] "A sentence has words.\nLine 2.", 5, -24, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1455,7 +1455,7 @@ list [0] "A sentence has words.\nLine 2.", 28, -1, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1466,7 +1466,7 @@ list [0] "A sentence has words.\nLine 2.", 29, 0, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1476,18 +1476,18 @@ list [0] "A sentence has words.\nLine 2.", 30, 1, - TextAlignment.Left, + Justification.Left, false, 2, false, new [] { "A sentence has words.", "Line 2." } )] - [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, TextAlignment.Left, false, 1, true, new [] { "" })] + [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Justification.Left, false, 1, true, new [] { "" })] [InlineData ( "A sentence has words.\r\nLine 2.", 1, -29, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1497,7 +1497,7 @@ list [0] "A sentence has words.\r\nLine 2.", 5, -25, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1507,7 +1507,7 @@ list [0] "A sentence has words.\r\nLine 2.", 29, -1, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1517,7 +1517,7 @@ list [0] "A sentence has words.\r\nLine 2.", 30, 0, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1527,7 +1527,7 @@ list [0] "A sentence has words.\r\nLine 2.", 31, 1, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1537,7 +1537,7 @@ public void Reformat_NoWordrap_NewLines_MultiLine_True ( string text, int maxWidth, int widthOffset, - TextAlignment textAlignment, + Justification Justification, bool wrap, int linesCount, bool stringEmpty, @@ -1549,7 +1549,7 @@ IEnumerable resultLines List list = TextFormatter.Format ( text, maxWidth, - textAlignment, + Justification, wrap, false, 0, @@ -1572,12 +1572,12 @@ IEnumerable resultLines } [Theory] - [InlineData ("A sentence has words.\nLine 2.", 0, -29, TextAlignment.Left, false, 1, true, new [] { "" })] + [InlineData ("A sentence has words.\nLine 2.", 0, -29, Justification.Left, false, 1, true, new [] { "" })] [InlineData ( "A sentence has words.\nLine 2.", 1, -28, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1587,7 +1587,7 @@ IEnumerable resultLines "A sentence has words.\nLine 2.", 5, -24, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1597,7 +1597,7 @@ IEnumerable resultLines "A sentence has words.\nLine 2.", 28, -1, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1608,7 +1608,7 @@ IEnumerable resultLines "A sentence has words.\nLine 2.", 29, 0, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1618,18 +1618,18 @@ IEnumerable resultLines "A sentence has words.\nLine 2.", 30, 1, - TextAlignment.Left, + Justification.Left, false, 2, false, new [] { "A sentence has words.", "Line 2." } )] - [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, TextAlignment.Left, false, 1, true, new [] { "" })] + [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Justification.Left, false, 1, true, new [] { "" })] [InlineData ( "A sentence has words.\r\nLine 2.", 1, -29, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1639,7 +1639,7 @@ IEnumerable resultLines "A sentence has words.\r\nLine 2.", 5, -25, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1649,7 +1649,7 @@ IEnumerable resultLines "A sentence has words.\r\nLine 2.", 29, -1, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1659,7 +1659,7 @@ IEnumerable resultLines "A sentence has words.\r\nLine 2.", 30, 0, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1669,7 +1669,7 @@ IEnumerable resultLines "A sentence has words.\r\nLine 2.", 31, 1, - TextAlignment.Left, + Justification.Left, false, 2, false, @@ -1679,7 +1679,7 @@ public void Reformat_NoWordrap_NewLines_MultiLine_True_Vertical ( string text, int maxWidth, int widthOffset, - TextAlignment textAlignment, + Justification Justification, bool wrap, int linesCount, bool stringEmpty, @@ -1691,7 +1691,7 @@ IEnumerable resultLines List list = TextFormatter.Format ( text, maxWidth, - textAlignment, + Justification, wrap, false, 0, @@ -1714,21 +1714,21 @@ IEnumerable resultLines } [Theory] - [InlineData ("", 0, 0, TextAlignment.Left, false, 1, true)] - [InlineData ("", 1, 1, TextAlignment.Left, false, 1, true)] - [InlineData ("A sentence has words.", 0, -21, TextAlignment.Left, false, 1, true)] - [InlineData ("A sentence has words.", 1, -20, TextAlignment.Left, false, 1, false)] - [InlineData ("A sentence has words.", 5, -16, TextAlignment.Left, false, 1, false)] - [InlineData ("A sentence has words.", 20, -1, TextAlignment.Left, false, 1, false)] + [InlineData ("", 0, 0, Justification.Left, false, 1, true)] + [InlineData ("", 1, 1, Justification.Left, false, 1, true)] + [InlineData ("A sentence has words.", 0, -21, Justification.Left, false, 1, true)] + [InlineData ("A sentence has words.", 1, -20, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.", 5, -16, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.", 20, -1, Justification.Left, false, 1, false)] // no clip - [InlineData ("A sentence has words.", 21, 0, TextAlignment.Left, false, 1, false)] - [InlineData ("A sentence has words.", 22, 1, TextAlignment.Left, false, 1, false)] + [InlineData ("A sentence has words.", 21, 0, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.", 22, 1, Justification.Left, false, 1, false)] public void Reformat_NoWordrap_SingleLine ( string text, int maxWidth, int widthOffset, - TextAlignment textAlignment, + Justification Justification, bool wrap, int linesCount, bool stringEmpty @@ -1736,7 +1736,7 @@ bool stringEmpty { Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset); int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth); - List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap); + List list = TextFormatter.Format (text, maxWidth, Justification, wrap); Assert.NotEmpty (list); Assert.True (list.Count == linesCount); @@ -1759,7 +1759,7 @@ bool stringEmpty "\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464", 8, -1, - TextAlignment.Left, + Justification.Left, true, false, new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" } @@ -1770,7 +1770,7 @@ bool stringEmpty "\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464", 9, 0, - TextAlignment.Left, + Justification.Left, true, false, new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" } @@ -1779,7 +1779,7 @@ bool stringEmpty "\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464", 10, 1, - TextAlignment.Left, + Justification.Left, true, false, new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" } @@ -1788,14 +1788,14 @@ public void Reformat_Unicode_Wrap_Spaces_NewLines ( string text, int maxWidth, int widthOffset, - TextAlignment textAlignment, + Justification Justification, bool wrap, bool preserveTrailingSpaces, IEnumerable resultLines ) { Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset); - List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap, preserveTrailingSpaces); + List list = TextFormatter.Format (text, maxWidth, Justification, wrap, preserveTrailingSpaces); Assert.Equal (list.Count, resultLines.Count ()); Assert.Equal (resultLines, list); } @@ -1805,32 +1805,32 @@ IEnumerable resultLines // Unicode // Even # of chars // 0123456789 - [InlineData ("\u2660пÑРвРÑ", 10, -1, TextAlignment.Left, true, false, new [] { "\u2660пÑРвÐ", "Ñ" })] + [InlineData ("\u2660пÑРвРÑ", 10, -1, Justification.Left, true, false, new [] { "\u2660пÑРвÐ", "Ñ" })] // no clip - [InlineData ("\u2660пÑРвРÑ", 11, 0, TextAlignment.Left, true, false, new [] { "\u2660пÑРвРÑ" })] - [InlineData ("\u2660пÑРвРÑ", 12, 1, TextAlignment.Left, true, false, new [] { "\u2660пÑРвРÑ" })] + [InlineData ("\u2660пÑРвРÑ", 11, 0, Justification.Left, true, false, new [] { "\u2660пÑРвРÑ" })] + [InlineData ("\u2660пÑРвРÑ", 12, 1, Justification.Left, true, false, new [] { "\u2660пÑРвРÑ" })] // Unicode // Odd # of chars // 0123456789 - [InlineData ("\u2660 ÑРвРÑ", 9, -1, TextAlignment.Left, true, false, new [] { "\u2660 ÑРвÐ", "Ñ" })] + [InlineData ("\u2660 ÑРвРÑ", 9, -1, Justification.Left, true, false, new [] { "\u2660 ÑРвÐ", "Ñ" })] // no clip - [InlineData ("\u2660 ÑРвРÑ", 10, 0, TextAlignment.Left, true, false, new [] { "\u2660 ÑРвРÑ" })] - [InlineData ("\u2660 ÑРвРÑ", 11, 1, TextAlignment.Left, true, false, new [] { "\u2660 ÑРвРÑ" })] + [InlineData ("\u2660 ÑРвРÑ", 10, 0, Justification.Left, true, false, new [] { "\u2660 ÑРвРÑ" })] + [InlineData ("\u2660 ÑРвРÑ", 11, 1, Justification.Left, true, false, new [] { "\u2660 ÑРвРÑ" })] public void Reformat_Unicode_Wrap_Spaces_No_NewLines ( string text, int maxWidth, int widthOffset, - TextAlignment textAlignment, + Justification Justification, bool wrap, bool preserveTrailingSpaces, IEnumerable resultLines ) { Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset); - List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap, preserveTrailingSpaces); + List list = TextFormatter.Format (text, maxWidth, Justification, wrap, preserveTrailingSpaces); Assert.Equal (list.Count, resultLines.Count ()); Assert.Equal (resultLines, list); } @@ -1839,37 +1839,37 @@ IEnumerable resultLines // Even # of spaces // 0123456789 - [InlineData ("012 456 89", 0, -10, TextAlignment.Left, true, true, true, new [] { "" })] + [InlineData ("012 456 89", 0, -10, Justification.Left, true, true, true, new [] { "" })] [InlineData ( "012 456 89", 1, -9, - TextAlignment.Left, + Justification.Left, true, true, false, new [] { "0", "1", "2", " ", "4", "5", "6", " ", "8", "9" }, "01245689" )] - [InlineData ("012 456 89", 5, -5, TextAlignment.Left, true, true, false, new [] { "012 ", "456 ", "89" })] - [InlineData ("012 456 89", 9, -1, TextAlignment.Left, true, true, false, new [] { "012 456 ", "89" })] + [InlineData ("012 456 89", 5, -5, Justification.Left, true, true, false, new [] { "012 ", "456 ", "89" })] + [InlineData ("012 456 89", 9, -1, Justification.Left, true, true, false, new [] { "012 456 ", "89" })] // no clip - [InlineData ("012 456 89", 10, 0, TextAlignment.Left, true, true, false, new [] { "012 456 89" })] - [InlineData ("012 456 89", 11, 1, TextAlignment.Left, true, true, false, new [] { "012 456 89" })] + [InlineData ("012 456 89", 10, 0, Justification.Left, true, true, false, new [] { "012 456 89" })] + [InlineData ("012 456 89", 11, 1, Justification.Left, true, true, false, new [] { "012 456 89" })] // Odd # of spaces // 01234567890123 - [InlineData ("012 456 89 end", 13, -1, TextAlignment.Left, true, true, false, new [] { "012 456 89 ", "end" })] + [InlineData ("012 456 89 end", 13, -1, Justification.Left, true, true, false, new [] { "012 456 89 ", "end" })] // no clip - [InlineData ("012 456 89 end", 14, 0, TextAlignment.Left, true, true, false, new [] { "012 456 89 end" })] - [InlineData ("012 456 89 end", 15, 1, TextAlignment.Left, true, true, false, new [] { "012 456 89 end" })] + [InlineData ("012 456 89 end", 14, 0, Justification.Left, true, true, false, new [] { "012 456 89 end" })] + [InlineData ("012 456 89 end", 15, 1, Justification.Left, true, true, false, new [] { "012 456 89 end" })] public void Reformat_Wrap_Spaces_No_NewLines ( string text, int maxWidth, int widthOffset, - TextAlignment textAlignment, + Justification Justification, bool wrap, bool preserveTrailingSpaces, bool stringEmpty, @@ -1879,7 +1879,7 @@ public void Reformat_Wrap_Spaces_No_NewLines ( { Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset); int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth); - List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap, preserveTrailingSpaces); + List list = TextFormatter.Format (text, maxWidth, Justification, wrap, preserveTrailingSpaces); Assert.NotEmpty (list); Assert.True (list.Count == resultLines.Count ()); @@ -1909,7 +1909,7 @@ public void Reformat_Wrap_Spaces_No_NewLines ( ); } - list = TextFormatter.Format (text, maxWidth, TextAlignment.Left, wrap); + list = TextFormatter.Format (text, maxWidth, Justification.Left, wrap); if (maxWidth == 1) { @@ -2224,25 +2224,25 @@ public void AutoSize_True_TextDirection_Correct_Size (string text, TextDirection } //[Theory] - //[InlineData (TextAlignment.Left, false)] - //[InlineData (TextAlignment.Centered, true)] - //[InlineData (TextAlignment.Right, false)] - //[InlineData (TextAlignment.Justified, true)] + //[InlineData (Justification.Left, false)] + //[InlineData (Justification.Centered, true)] + //[InlineData (Justification.Right, false)] + //[InlineData (Justification.Justified, true)] //public void TestSize_DirectionChange_AutoSize_True_Or_False_Horizontal ( - // TextAlignment textAlignment, + // Justification Justification, // bool autoSize //) //{ // var tf = new TextFormatter // { - // Direction = TextDirection.LeftRight_TopBottom, Text = "你你", Alignment = textAlignment, AutoSize = autoSize + // Direction = TextDirection.LeftRight_TopBottom, Text = "你你", Alignment = Justification, AutoSize = autoSize // }; // Assert.Equal (4, tf.Size.Width); // Assert.Equal (1, tf.Size.Height); // tf.Direction = TextDirection.TopBottom_LeftRight; - // if (autoSize/* && textAlignment != TextAlignment.Justified*/) + // if (autoSize/* && Justification != Justification.Justified*/) // { // Assert.Equal (2, tf.Size.Width); // Assert.Equal (2, tf.Size.Height); @@ -2255,12 +2255,12 @@ public void AutoSize_True_TextDirection_Correct_Size (string text, TextDirection //} //[Theory] - //[InlineData (VerticalTextAlignment.Top, false)] - //[InlineData (VerticalTextAlignment.Middle, true)] - //[InlineData (VerticalTextAlignment.Bottom, false)] - //[InlineData (VerticalTextAlignment.Justified, true)] + //[InlineData (Justification.Top, false)] + //[InlineData (Justification.Centered, true)] + //[InlineData (Justification.Bottom, false)] + //[InlineData (Justification.Justified, true)] //public void TestSize_DirectionChange_AutoSize_True_Or_False_Vertical ( - // VerticalTextAlignment textAlignment, + // Justification Justification, // bool autoSize //) //{ @@ -2268,7 +2268,7 @@ public void AutoSize_True_TextDirection_Correct_Size (string text, TextDirection // { // Direction = TextDirection.TopBottom_LeftRight, // Text = "你你", - // VerticalAlignment = textAlignment, + // VerticalAlignment = Justification, // AutoSize = autoSize // }; // Assert.Equal (2, tf.Size.Width); @@ -2276,7 +2276,7 @@ public void AutoSize_True_TextDirection_Correct_Size (string text, TextDirection // tf.Direction = TextDirection.LeftRight_TopBottom; - // if (autoSize/* && textAlignment != VerticalTextAlignment.Justified*/) + // if (autoSize/* && Justification != Justification.Justified*/) // { // Assert.Equal (4, tf.Size.Width); // Assert.Equal (1, tf.Size.Height); @@ -2331,15 +2331,15 @@ public void AutoSize_True_TextDirection_Correct_Size (string text, TextDirection //} //[Theory] - //[InlineData (TextAlignment.Left, false)] - //[InlineData (TextAlignment.Centered, true)] - //[InlineData (TextAlignment.Right, false)] - //[InlineData (TextAlignment.Justified, true)] - //public void TestSize_SizeChange_AutoSize_True_Or_False_Horizontal (TextAlignment textAlignment, bool autoSize) + //[InlineData (Justification.Left, false)] + //[InlineData (Justification.Centered, true)] + //[InlineData (Justification.Right, false)] + //[InlineData (Justification.Justified, true)] + //public void TestSize_SizeChange_AutoSize_True_Or_False_Horizontal (Justification Justification, bool autoSize) //{ // var tf = new TextFormatter // { - // Direction = TextDirection.LeftRight_TopBottom, Text = "你你", Alignment = textAlignment, AutoSize = autoSize + // Direction = TextDirection.LeftRight_TopBottom, Text = "你你", Alignment = Justification, AutoSize = autoSize // }; // Assert.Equal (4, tf.Size.Width); // Assert.Equal (1, tf.Size.Height); @@ -2359,12 +2359,12 @@ public void AutoSize_True_TextDirection_Correct_Size (string text, TextDirection //} //[Theory] - //[InlineData (VerticalTextAlignment.Top, false)] - //[InlineData (VerticalTextAlignment.Middle, true)] - //[InlineData (VerticalTextAlignment.Bottom, false)] - //[InlineData (VerticalTextAlignment.Justified, true)] + //[InlineData (Justification.Top, false)] + //[InlineData (Justification.Centered, true)] + //[InlineData (Justification.Bottom, false)] + //[InlineData (Justification.Justified, true)] //public void TestSize_SizeChange_AutoSize_True_Or_False_Vertical ( - // VerticalTextAlignment textAlignment, + // Justification Justification, // bool autoSize //) //{ @@ -2372,7 +2372,7 @@ public void AutoSize_True_TextDirection_Correct_Size (string text, TextDirection // { // Direction = TextDirection.TopBottom_LeftRight, // Text = "你你", - // VerticalAlignment = textAlignment, + // VerticalAlignment = Justification, // AutoSize = autoSize // }; // Assert.Equal (2, tf.Size.Width); @@ -3362,7 +3362,7 @@ public void Draw_Horizontal_Left (string text, int width, bool autoSize, string TextFormatter tf = new () { Text = text, - Alignment = TextAlignment.Left, + Alignment = Justification.Left, AutoSize = autoSize, }; @@ -3399,7 +3399,7 @@ public void Draw_Horizontal_Right (string text, int width, bool autoSize, string TextFormatter tf = new () { Text = text, - Alignment = TextAlignment.Right, + Alignment = Justification.Right, AutoSize = autoSize, }; @@ -3442,7 +3442,7 @@ public void Draw_Horizontal_Centered (string text, int width, bool autoSize, str TextFormatter tf = new () { Text = text, - Alignment = TextAlignment.Centered, + Alignment = Justification.Centered, AutoSize = autoSize, }; @@ -3487,7 +3487,7 @@ public void Draw_Horizontal_Justified (string text, int width, bool autoSize, st TextFormatter tf = new () { Text = text, - Alignment = TextAlignment.Justified, + Alignment = Justification.Justified, AutoSize = autoSize, }; @@ -3577,7 +3577,7 @@ public void Justify_Horizontal (string text, int width, int height, string expec TextFormatter tf = new () { Text = text, - Alignment = TextAlignment.Justified, + Alignment = Justification.Justified, Size = new Size (width, height), MultiLine = true }; @@ -3629,7 +3629,7 @@ public void Justify_Vertical (string text, int width, int height, string expecte { Text = text, Direction = TextDirection.TopBottom_LeftRight, - VerticalAlignment = VerticalTextAlignment.Justified, + VerticalAlignment = Justification.Justified, Size = new Size (width, height), MultiLine = true }; @@ -3685,9 +3685,9 @@ public void Draw_Vertical_Bottom_Horizontal_Right (string text, int width, int h TextFormatter tf = new () { Text = text, - Alignment = TextAlignment.Right, + Alignment = Justification.Right, Direction = TextDirection.TopBottom_LeftRight, - VerticalAlignment = VerticalTextAlignment.Bottom, + VerticalAlignment = Justification.Bottom, AutoSize = autoSize, }; @@ -3827,7 +3827,7 @@ public void Draw_Vertical_TopBottom_LeftRight_Middle (string text, int height, b { Text = text, Direction = TextDirection.TopBottom_LeftRight, - VerticalAlignment = VerticalTextAlignment.Middle, + VerticalAlignment = Justification.Centered, AutoSize = autoSize, }; @@ -4083,9 +4083,9 @@ public void Draw_Vertical_Throws_IndexOutOfRangeException_With_Negative_Bounds ( [SetupFakeDriver] [Theory] - // Horizontal with VerticalTextAlignment.Top + // Horizontal with Justification.Top // LeftRight_TopBottom - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.LeftRight_TopBottom, @" 0 2 4** ******* ******* @@ -4093,7 +4093,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.LeftRight_TopBottom, @" **0 2 4 ******* ******* @@ -4101,7 +4101,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.LeftRight_TopBottom, @" *0 2 4* ******* ******* @@ -4109,7 +4109,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.LeftRight_TopBottom, @" 0 2 4 ******* ******* @@ -4118,7 +4118,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.LeftRight_TopBottom, @" 0 你 4* ******* ******* @@ -4126,7 +4126,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.LeftRight_TopBottom, @" *0 你 4 ******* ******* @@ -4134,7 +4134,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.LeftRight_TopBottom, @" 0 你 4* ******* ******* @@ -4142,7 +4142,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.LeftRight_TopBottom, @" 0 你 4 ******* ******* @@ -4152,7 +4152,7 @@ 0 你 4 *******")] // LeftRight_BottomTop - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.LeftRight_BottomTop, @" 0 2 4** ******* ******* @@ -4160,7 +4160,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.LeftRight_BottomTop, @" **0 2 4 ******* ******* @@ -4168,7 +4168,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.LeftRight_BottomTop, @" *0 2 4* ******* ******* @@ -4176,7 +4176,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.LeftRight_BottomTop, @" 0 2 4 ******* ******* @@ -4185,7 +4185,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.LeftRight_BottomTop, @" 0 你 4* ******* ******* @@ -4193,7 +4193,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.LeftRight_BottomTop, @" *0 你 4 ******* ******* @@ -4201,7 +4201,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.LeftRight_BottomTop, @" 0 你 4* ******* ******* @@ -4209,7 +4209,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.LeftRight_BottomTop, @" 0 你 4 ******* ******* @@ -4219,7 +4219,7 @@ 0 你 4 *******")] // RightLeft_TopBottom - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.RightLeft_TopBottom, @" 4 2 0** ******* ******* @@ -4227,7 +4227,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.RightLeft_TopBottom, @" **4 2 0 ******* ******* @@ -4235,7 +4235,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.RightLeft_TopBottom, @" *4 2 0* ******* ******* @@ -4243,7 +4243,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.RightLeft_TopBottom, @" 4 2 0 ******* ******* @@ -4252,7 +4252,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.RightLeft_TopBottom, @" 4 你 0* ******* ******* @@ -4260,7 +4260,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.RightLeft_TopBottom, @" *4 你 0 ******* ******* @@ -4268,7 +4268,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.RightLeft_TopBottom, @" 4 你 0* ******* ******* @@ -4276,7 +4276,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.RightLeft_TopBottom, @" 4 你 0 ******* ******* @@ -4286,7 +4286,7 @@ 4 你 0 *******")] // RightLeft_BottomTop - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.RightLeft_BottomTop, @" 4 2 0** ******* ******* @@ -4294,7 +4294,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.RightLeft_BottomTop, @" **4 2 0 ******* ******* @@ -4302,7 +4302,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.RightLeft_BottomTop, @" *4 2 0* ******* ******* @@ -4310,7 +4310,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.RightLeft_BottomTop, @" 4 2 0 ******* ******* @@ -4319,7 +4319,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.RightLeft_BottomTop, @" 4 你 0* ******* ******* @@ -4327,7 +4327,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.RightLeft_BottomTop, @" *4 你 0 ******* ******* @@ -4335,7 +4335,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.RightLeft_BottomTop, @" 4 你 0* ******* ******* @@ -4343,7 +4343,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.RightLeft_BottomTop, @" 4 你 0 ******* ******* @@ -4352,9 +4352,9 @@ 4 你 0 ******* *******")] - // Horizontal with VerticalTextAlignment.Bottom + // Horizontal with Justification.Bottom // LeftRight_TopBottom - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4362,7 +4362,7 @@ 4 你 0 ******* ******* 0 2 4**")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4370,7 +4370,7 @@ 4 你 0 ******* ******* **0 2 4")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4378,7 +4378,7 @@ 4 你 0 ******* ******* *0 2 4*")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4387,7 +4387,7 @@ 4 你 0 ******* 0 2 4")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4395,7 +4395,7 @@ 4 你 0 ******* ******* 0 你 4*")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4403,7 +4403,7 @@ 4 你 0 ******* ******* *0 你 4")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4411,7 +4411,7 @@ 4 你 0 ******* ******* 0 你 4*")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4421,7 +4421,7 @@ 4 你 0 0 你 4")] // LeftRight_BottomTop - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4429,7 +4429,7 @@ 4 你 0 ******* ******* 0 2 4**")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4437,7 +4437,7 @@ 4 你 0 ******* ******* **0 2 4")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4445,7 +4445,7 @@ 4 你 0 ******* ******* *0 2 4*")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4454,7 +4454,7 @@ 4 你 0 ******* 0 2 4")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4462,7 +4462,7 @@ 4 你 0 ******* ******* 0 你 4*")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4470,7 +4470,7 @@ 4 你 0 ******* ******* *0 你 4")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4478,7 +4478,7 @@ 4 你 0 ******* ******* 0 你 4*")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4488,7 +4488,7 @@ 4 你 0 0 你 4")] // RightLeft_TopBottom - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4496,7 +4496,7 @@ 4 你 0 ******* ******* 4 2 0**")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4504,7 +4504,7 @@ 4 你 0 ******* ******* **4 2 0")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4512,7 +4512,7 @@ 4 你 0 ******* ******* *4 2 0*")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4521,7 +4521,7 @@ 4 你 0 ******* 4 2 0")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4529,7 +4529,7 @@ 4 你 0 ******* ******* 4 你 0*")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4537,7 +4537,7 @@ 4 你 0 ******* ******* *4 你 0")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4545,7 +4545,7 @@ 4 你 0 ******* ******* 4 你 0*")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4555,7 +4555,7 @@ 4 你 0 4 你 0")] // RightLeft_BottomTop - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4563,7 +4563,7 @@ 4 你 0 ******* ******* 4 2 0**")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4571,7 +4571,7 @@ 4 你 0 ******* ******* **4 2 0")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4579,7 +4579,7 @@ 4 你 0 ******* ******* *4 2 0*")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4588,7 +4588,7 @@ 4 你 0 ******* 4 2 0")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4596,7 +4596,7 @@ 4 你 0 ******* ******* 4 你 0*")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4604,7 +4604,7 @@ 4 你 0 ******* ******* *4 你 0")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4612,7 +4612,7 @@ 4 你 0 ******* ******* 4 你 0*")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4621,9 +4621,9 @@ 4 你 0 ******* 4 你 0")] - // Horizontal with VerticalTextAlignment.Middle + // Horizontal with Justification.Centered // LeftRight_TopBottom - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4631,7 +4631,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4639,7 +4639,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4647,7 +4647,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4656,7 +4656,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4664,7 +4664,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4672,7 +4672,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4680,7 +4680,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4690,7 +4690,7 @@ 0 你 4 *******")] // LeftRight_BottomTop - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4698,7 +4698,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4706,7 +4706,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4714,7 +4714,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4723,7 +4723,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4731,7 +4731,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4739,7 +4739,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4747,7 +4747,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4757,7 +4757,7 @@ 0 你 4 *******")] // RightLeft_TopBottom - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4765,7 +4765,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4773,7 +4773,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4781,7 +4781,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4790,7 +4790,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4798,7 +4798,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4806,7 +4806,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4814,7 +4814,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4824,7 +4824,7 @@ 4 你 0 *******")] // RightLeft_BottomTop - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4832,7 +4832,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4840,7 +4840,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4848,7 +4848,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4857,7 +4857,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4865,7 +4865,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4873,7 +4873,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4881,7 +4881,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4890,9 +4890,9 @@ 4 你 0 ******* *******")] - // Horizontal with VerticalTextAlignment.Justified + // Horizontal with Justification.Justified // LeftRight_TopBottom - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.LeftRight_TopBottom, @" 0 2 4** ******* ******* @@ -4900,7 +4900,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.LeftRight_TopBottom, @" **0 2 4 ******* ******* @@ -4908,7 +4908,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.LeftRight_TopBottom, @" *0 2 4* ******* ******* @@ -4916,7 +4916,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.LeftRight_TopBottom, @" 0 2 4 ******* ******* @@ -4925,7 +4925,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.LeftRight_TopBottom, @" 0 你 4* ******* ******* @@ -4933,7 +4933,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.LeftRight_TopBottom, @" *0 你 4 ******* ******* @@ -4941,7 +4941,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.LeftRight_TopBottom, @" 0 你 4* ******* ******* @@ -4949,7 +4949,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.LeftRight_TopBottom, @" 0 你 4 ******* ******* @@ -4959,7 +4959,7 @@ 0 你 4 *******")] // LeftRight_BottomTop - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.LeftRight_BottomTop, @" 0 2 4** ******* ******* @@ -4967,7 +4967,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.LeftRight_BottomTop, @" **0 2 4 ******* ******* @@ -4975,7 +4975,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.LeftRight_BottomTop, @" *0 2 4* ******* ******* @@ -4983,7 +4983,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.LeftRight_BottomTop, @" 0 2 4 ******* ******* @@ -4992,7 +4992,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.LeftRight_BottomTop, @" 0 你 4* ******* ******* @@ -5000,7 +5000,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.LeftRight_BottomTop, @" *0 你 4 ******* ******* @@ -5008,7 +5008,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.LeftRight_BottomTop, @" 0 你 4* ******* ******* @@ -5016,7 +5016,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.LeftRight_BottomTop, @" 0 你 4 ******* ******* @@ -5026,7 +5026,7 @@ 0 你 4 *******")] // RightLeft_TopBottom - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.RightLeft_TopBottom, @" 4 2 0** ******* ******* @@ -5034,7 +5034,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.RightLeft_TopBottom, @" **4 2 0 ******* ******* @@ -5042,7 +5042,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.RightLeft_TopBottom, @" *4 2 0* ******* ******* @@ -5050,7 +5050,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.RightLeft_TopBottom, @" 4 2 0 ******* ******* @@ -5059,7 +5059,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.RightLeft_TopBottom, @" 4 你 0* ******* ******* @@ -5067,7 +5067,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.RightLeft_TopBottom, @" *4 你 0 ******* ******* @@ -5075,7 +5075,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.RightLeft_TopBottom, @" 4 你 0* ******* ******* @@ -5083,7 +5083,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.RightLeft_TopBottom, @" 4 你 0 ******* ******* @@ -5093,7 +5093,7 @@ 4 你 0 *******")] // RightLeft_BottomTop - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.RightLeft_BottomTop, @" 4 2 0** ******* ******* @@ -5101,7 +5101,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.RightLeft_BottomTop, @" **4 2 0 ******* ******* @@ -5109,7 +5109,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.RightLeft_BottomTop, @" *4 2 0* ******* ******* @@ -5117,7 +5117,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.RightLeft_BottomTop, @" 4 2 0 ******* ******* @@ -5126,7 +5126,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.RightLeft_BottomTop, @" 4 你 0* ******* ******* @@ -5134,7 +5134,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.RightLeft_BottomTop, @" *4 你 0 ******* ******* @@ -5142,7 +5142,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.RightLeft_BottomTop, @" 4 你 0* ******* ******* @@ -5150,7 +5150,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.RightLeft_BottomTop, @" 4 你 0 ******* ******* @@ -5159,9 +5159,9 @@ 4 你 0 ******* *******")] - // Vertical with TextAlignment.Left + // Vertical with Justification.Left // TopBottom_LeftRight - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.TopBottom_LeftRight, @" 0****** ****** 2****** @@ -5169,7 +5169,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* 0****** @@ -5177,7 +5177,7 @@ 4 你 0 2****** ****** 4******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.TopBottom_LeftRight, @" ******* 0****** ****** @@ -5185,7 +5185,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.TopBottom_LeftRight, @" 0****** ****** ****** @@ -5194,7 +5194,7 @@ 4 你 0 ****** 4******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.TopBottom_LeftRight, @" 0****** ****** 你***** @@ -5202,7 +5202,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* 0****** @@ -5210,7 +5210,7 @@ 4 你 0 你***** ****** 4******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.TopBottom_LeftRight, @" ******* 0****** ****** @@ -5218,7 +5218,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.TopBottom_LeftRight, @" 0****** ****** ****** @@ -5228,7 +5228,7 @@ 4 你 0 4******")] // TopBottom_RightLeft - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.TopBottom_RightLeft, @" 0****** ****** 2****** @@ -5236,7 +5236,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* 0****** @@ -5244,7 +5244,7 @@ 4 你 0 2****** ****** 4******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.TopBottom_RightLeft, @" ******* 0****** ****** @@ -5252,7 +5252,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.TopBottom_RightLeft, @" 0****** ****** ****** @@ -5261,7 +5261,7 @@ 4 你 0 ****** 4******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.TopBottom_RightLeft, @" 0****** ****** 你***** @@ -5269,7 +5269,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* 0****** @@ -5277,7 +5277,7 @@ 4 你 0 你***** ****** 4******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.TopBottom_RightLeft, @" ******* 0****** ****** @@ -5285,7 +5285,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.TopBottom_RightLeft, @" 0****** ****** ****** @@ -5295,7 +5295,7 @@ 4 你 0 4******")] // BottomTop_LeftRight - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.BottomTop_LeftRight, @" 4****** ****** 2****** @@ -5303,7 +5303,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* 4****** @@ -5311,7 +5311,7 @@ 4 你 0 2****** ****** 0******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.BottomTop_LeftRight, @" ******* 4****** ****** @@ -5319,7 +5319,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.BottomTop_LeftRight, @" 4****** ****** ****** @@ -5328,7 +5328,7 @@ 4 你 0 ****** 0******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.BottomTop_LeftRight, @" 4****** ****** 你***** @@ -5336,7 +5336,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* 4****** @@ -5344,7 +5344,7 @@ 4 你 0 你***** ****** 0******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.BottomTop_LeftRight, @" ******* 4****** ****** @@ -5352,7 +5352,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.BottomTop_LeftRight, @" 4****** ****** ****** @@ -5362,7 +5362,7 @@ 4 你 0 0******")] // BottomTop_RightLeft - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.BottomTop_RightLeft, @" 4****** ****** 2****** @@ -5370,7 +5370,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* 4****** @@ -5378,7 +5378,7 @@ 4 你 0 2****** ****** 0******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.BottomTop_RightLeft, @" ******* 4****** ****** @@ -5386,7 +5386,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.BottomTop_RightLeft, @" 4****** ****** ****** @@ -5395,7 +5395,7 @@ 4 你 0 ****** 0******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.BottomTop_RightLeft, @" 4****** ****** 你***** @@ -5403,7 +5403,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* 4****** @@ -5411,7 +5411,7 @@ 4 你 0 你***** ****** 0******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.BottomTop_RightLeft, @" ******* 4****** ****** @@ -5419,7 +5419,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.BottomTop_RightLeft, @" 4****** ****** ****** @@ -5428,9 +5428,9 @@ 4 你 0 ****** 0******")] - // Vertical with TextAlignment.Right + // Vertical with Justification.Right // TopBottom_LeftRight - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.TopBottom_LeftRight, @" ******0 ****** ******2 @@ -5438,7 +5438,7 @@ 4 你 0 ******4 ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* ******0 @@ -5446,7 +5446,7 @@ 4 你 0 ******2 ****** ******4")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.TopBottom_LeftRight, @" ******* ******0 ****** @@ -5454,7 +5454,7 @@ 4 你 0 ****** ******4 *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.TopBottom_LeftRight, @" ******0 ****** ****** @@ -5463,7 +5463,7 @@ 4 你 0 ****** ******4")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.TopBottom_LeftRight, @" *****0* ***** * *****你 @@ -5471,7 +5471,7 @@ 4 你 0 *****4* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* *****0* @@ -5479,7 +5479,7 @@ 4 你 0 *****你 ***** * *****4*")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.TopBottom_LeftRight, @" ******* *****0* ***** * @@ -5487,7 +5487,7 @@ 4 你 0 ***** * *****4* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.TopBottom_LeftRight, @" *****0* ***** * ***** * @@ -5497,7 +5497,7 @@ 4 你 0 *****4*")] // TopBottom_RightLeft - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.TopBottom_RightLeft, @" ******0 ****** ******2 @@ -5505,7 +5505,7 @@ 4 你 0 ******4 ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* ******0 @@ -5513,7 +5513,7 @@ 4 你 0 ******2 ****** ******4")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.TopBottom_RightLeft, @" ******* ******0 ****** @@ -5521,7 +5521,7 @@ 4 你 0 ****** ******4 *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.TopBottom_RightLeft, @" ******0 ****** ****** @@ -5530,7 +5530,7 @@ 4 你 0 ****** ******4")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.TopBottom_RightLeft, @" *****0* ***** * *****你 @@ -5538,7 +5538,7 @@ 4 你 0 *****4* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* *****0* @@ -5546,7 +5546,7 @@ 4 你 0 *****你 ***** * *****4*")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.TopBottom_RightLeft, @" ******* *****0* ***** * @@ -5554,7 +5554,7 @@ 4 你 0 ***** * *****4* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.TopBottom_RightLeft, @" *****0* ***** * ***** * @@ -5564,7 +5564,7 @@ 4 你 0 *****4*")] // BottomTop_LeftRight - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.BottomTop_LeftRight, @" ******4 ****** ******2 @@ -5572,7 +5572,7 @@ 4 你 0 ******0 ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* ******4 @@ -5580,7 +5580,7 @@ 4 你 0 ******2 ****** ******0")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.BottomTop_LeftRight, @" ******* ******4 ****** @@ -5588,7 +5588,7 @@ 4 你 0 ****** ******0 *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.BottomTop_LeftRight, @" ******4 ****** ****** @@ -5597,7 +5597,7 @@ 4 你 0 ****** ******0")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.BottomTop_LeftRight, @" *****4* ***** * *****你 @@ -5605,7 +5605,7 @@ 4 你 0 *****0* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* *****4* @@ -5613,7 +5613,7 @@ 4 你 0 *****你 ***** * *****0*")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.BottomTop_LeftRight, @" ******* *****4* ***** * @@ -5621,7 +5621,7 @@ 4 你 0 ***** * *****0* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.BottomTop_LeftRight, @" *****4* ***** * ***** * @@ -5631,7 +5631,7 @@ 4 你 0 *****0*")] // BottomTop_RightLeft - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.BottomTop_RightLeft, @" ******4 ****** ******2 @@ -5639,7 +5639,7 @@ 4 你 0 ******0 ******* *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* ******4 @@ -5647,7 +5647,7 @@ 4 你 0 ******2 ****** ******0")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.BottomTop_RightLeft, @" ******* ******4 ****** @@ -5655,7 +5655,7 @@ 4 你 0 ****** ******0 *******")] - [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.BottomTop_RightLeft, @" ******4 ****** ****** @@ -5664,7 +5664,7 @@ 4 你 0 ****** ******0")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.BottomTop_RightLeft, @" *****4* ***** * *****你 @@ -5672,7 +5672,7 @@ 4 你 0 *****0* ******* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* *****4* @@ -5680,7 +5680,7 @@ 4 你 0 *****你 ***** * *****0*")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.BottomTop_RightLeft, @" ******* *****4* ***** * @@ -5688,7 +5688,7 @@ 4 你 0 ***** * *****0* *******")] - [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.BottomTop_RightLeft, @" *****4* ***** * ***** * @@ -5697,9 +5697,9 @@ 4 你 0 ***** * *****0*")] - // Vertical with TextAlignment.Centered + // Vertical with Justification.Centered // TopBottom_LeftRight - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.TopBottom_LeftRight, @" ***0*** *** *** ***2*** @@ -5707,7 +5707,7 @@ 4 你 0 ***4*** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* ***0*** @@ -5715,7 +5715,7 @@ 4 你 0 ***2*** *** *** ***4***")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.TopBottom_LeftRight, @" ******* ***0*** *** *** @@ -5723,7 +5723,7 @@ 4 你 0 *** *** ***4*** *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.TopBottom_LeftRight, @" ***0*** *** *** *** *** @@ -5732,7 +5732,7 @@ 4 你 0 *** *** ***4***")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.TopBottom_LeftRight, @" **0**** ** **** **你*** @@ -5740,7 +5740,7 @@ 4 你 0 **4**** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* **0**** @@ -5748,7 +5748,7 @@ 4 你 0 **你*** ** **** **4****")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.TopBottom_LeftRight, @" ******* **0**** ** **** @@ -5756,7 +5756,7 @@ 4 你 0 ** **** **4**** *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.TopBottom_LeftRight, @" **0**** ** **** ** **** @@ -5766,7 +5766,7 @@ 4 你 0 **4****")] // TopBottom_RightLeft - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.TopBottom_RightLeft, @" ***0*** *** *** ***2*** @@ -5774,7 +5774,7 @@ 4 你 0 ***4*** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* ***0*** @@ -5782,7 +5782,7 @@ 4 你 0 ***2*** *** *** ***4***")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.TopBottom_RightLeft, @" ******* ***0*** *** *** @@ -5790,7 +5790,7 @@ 4 你 0 *** *** ***4*** *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.TopBottom_RightLeft, @" ***0*** *** *** *** *** @@ -5799,7 +5799,7 @@ 4 你 0 *** *** ***4***")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.TopBottom_RightLeft, @" **0**** ** **** **你*** @@ -5807,7 +5807,7 @@ 4 你 0 **4**** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* **0**** @@ -5815,7 +5815,7 @@ 4 你 0 **你*** ** **** **4****")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.TopBottom_RightLeft, @" ******* **0**** ** **** @@ -5823,7 +5823,7 @@ 4 你 0 ** **** **4**** *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.TopBottom_RightLeft, @" **0**** ** **** ** **** @@ -5833,7 +5833,7 @@ 4 你 0 **4****")] // BottomTop_LeftRight - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.BottomTop_LeftRight, @" ***4*** *** *** ***2*** @@ -5841,7 +5841,7 @@ 4 你 0 ***0*** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* ***4*** @@ -5849,7 +5849,7 @@ 4 你 0 ***2*** *** *** ***0***")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.BottomTop_LeftRight, @" ******* ***4*** *** *** @@ -5857,7 +5857,7 @@ 4 你 0 *** *** ***0*** *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.BottomTop_LeftRight, @" ***4*** *** *** *** *** @@ -5866,7 +5866,7 @@ 4 你 0 *** *** ***0***")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.BottomTop_LeftRight, @" **4**** ** **** **你*** @@ -5874,7 +5874,7 @@ 4 你 0 **0**** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* **4**** @@ -5882,7 +5882,7 @@ 4 你 0 **你*** ** **** **0****")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.BottomTop_LeftRight, @" ******* **4**** ** **** @@ -5890,7 +5890,7 @@ 4 你 0 ** **** **0**** *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.BottomTop_LeftRight, @" **4**** ** **** ** **** @@ -5900,7 +5900,7 @@ 4 你 0 **0****")] // BottomTop_RightLeft - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.BottomTop_RightLeft, @" ***4*** *** *** ***2*** @@ -5908,7 +5908,7 @@ 4 你 0 ***0*** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* ***4*** @@ -5916,7 +5916,7 @@ 4 你 0 ***2*** *** *** ***0***")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.BottomTop_RightLeft, @" ******* ***4*** *** *** @@ -5924,7 +5924,7 @@ 4 你 0 *** *** ***0*** *******")] - [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.BottomTop_RightLeft, @" ***4*** *** *** *** *** @@ -5933,7 +5933,7 @@ 4 你 0 *** *** ***0***")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.BottomTop_RightLeft, @" **4**** ** **** **你*** @@ -5941,7 +5941,7 @@ 4 你 0 **0**** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* **4**** @@ -5949,7 +5949,7 @@ 4 你 0 **你*** ** **** **0****")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.BottomTop_RightLeft, @" ******* **4**** ** **** @@ -5957,7 +5957,7 @@ 4 你 0 ** **** **0**** *******")] - [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.BottomTop_RightLeft, @" **4**** ** **** ** **** @@ -5966,9 +5966,9 @@ 4 你 0 ** **** **0****")] - // Vertical with TextAlignment.Justified + // Vertical with Justification.Justified // TopBottom_LeftRight - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.TopBottom_LeftRight, @" 0****** ****** 2****** @@ -5976,7 +5976,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* 0****** @@ -5984,7 +5984,7 @@ 4 你 0 2****** ****** 4******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.TopBottom_LeftRight, @" ******* 0****** ****** @@ -5992,7 +5992,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.TopBottom_LeftRight, @" 0****** ****** ****** @@ -6001,7 +6001,7 @@ 4 你 0 ****** 4******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.TopBottom_LeftRight, @" 0****** ****** 你***** @@ -6009,7 +6009,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* 0****** @@ -6017,7 +6017,7 @@ 4 你 0 你***** ****** 4******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.TopBottom_LeftRight, @" ******* 0****** ****** @@ -6025,7 +6025,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.TopBottom_LeftRight, @" 0****** ****** ****** @@ -6035,7 +6035,7 @@ 4 你 0 4******")] // TopBottom_RightLeft - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.TopBottom_RightLeft, @" 0****** ****** 2****** @@ -6043,7 +6043,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* 0****** @@ -6051,7 +6051,7 @@ 4 你 0 2****** ****** 4******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.TopBottom_RightLeft, @" ******* 0****** ****** @@ -6059,7 +6059,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.TopBottom_RightLeft, @" 0****** ****** ****** @@ -6068,7 +6068,7 @@ 4 你 0 ****** 4******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.TopBottom_RightLeft, @" 0****** ****** 你***** @@ -6076,7 +6076,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* 0****** @@ -6084,7 +6084,7 @@ 4 你 0 你***** ****** 4******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.TopBottom_RightLeft, @" ******* 0****** ****** @@ -6092,7 +6092,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.TopBottom_RightLeft, @" 0****** ****** ****** @@ -6102,7 +6102,7 @@ 4 你 0 4******")] // BottomTop_LeftRight - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.BottomTop_LeftRight, @" 4****** ****** 2****** @@ -6110,7 +6110,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* 4****** @@ -6118,7 +6118,7 @@ 4 你 0 2****** ****** 0******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.BottomTop_LeftRight, @" ******* 4****** ****** @@ -6126,7 +6126,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.BottomTop_LeftRight, @" 4****** ****** ****** @@ -6135,7 +6135,7 @@ 4 你 0 ****** 0******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.BottomTop_LeftRight, @" 4****** ****** 你***** @@ -6143,7 +6143,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* 4****** @@ -6151,7 +6151,7 @@ 4 你 0 你***** ****** 0******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.BottomTop_LeftRight, @" ******* 4****** ****** @@ -6159,7 +6159,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.BottomTop_LeftRight, @" 4****** ****** ****** @@ -6169,7 +6169,7 @@ 4 你 0 0******")] // BottomTop_RightLeft - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.BottomTop_RightLeft, @" 4****** ****** 2****** @@ -6177,7 +6177,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* 4****** @@ -6185,7 +6185,7 @@ 4 你 0 2****** ****** 0******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.BottomTop_RightLeft, @" ******* 4****** ****** @@ -6193,7 +6193,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.BottomTop_RightLeft, @" 4****** ****** ****** @@ -6202,7 +6202,7 @@ 4 你 0 ****** 0******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.BottomTop_RightLeft, @" 4****** ****** 你***** @@ -6210,7 +6210,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* 4****** @@ -6218,7 +6218,7 @@ 4 你 0 你***** ****** 0******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.BottomTop_RightLeft, @" ******* 4****** ****** @@ -6226,7 +6226,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.BottomTop_RightLeft, @" 4****** ****** ****** @@ -6235,12 +6235,12 @@ 4 你 0 ****** 0******")] - public void Draw_Text_Alignment (string text, TextAlignment horizontalTextAlignment, VerticalTextAlignment verticalTextAlignment, TextDirection textDirection, string expectedText) + public void Draw_Text_Alignment (string text, Justification horizontalTextAlignment, Justification Justification, TextDirection textDirection, string expectedText) { TextFormatter tf = new () { Alignment = horizontalTextAlignment, - VerticalAlignment = verticalTextAlignment, + VerticalAlignment = Justification, Direction = textDirection, Size = new (7, 7), Text = text diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs index 6d9c4b0af1..8d1043046b 100644 --- a/UnitTests/View/DrawTests.cs +++ b/UnitTests/View/DrawTests.cs @@ -339,7 +339,7 @@ public void Colors_On_TextAlignment_Right_And_Bottom () Text = "Test", Width = 6, Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, ColorScheme = Colors.ColorSchemes ["Base"] }; @@ -350,7 +350,7 @@ public void Colors_On_TextAlignment_Right_And_Bottom () Y = 1, Width = 1, Height = 6, - VerticalTextAlignment = VerticalTextAlignment.Bottom, + VerticalJustification = Justification.Bottom, ColorScheme = Colors.ColorSchemes ["Base"] }; Toplevel top = new (); diff --git a/UnitTests/View/Layout/Dim.AutoTests.cs b/UnitTests/View/Layout/Dim.AutoTests.cs index ed25008775..c5517b2d47 100644 --- a/UnitTests/View/Layout/Dim.AutoTests.cs +++ b/UnitTests/View/Layout/Dim.AutoTests.cs @@ -681,11 +681,11 @@ public void DimAuto_Not_Used_TextFormatter_Does_Not_Change_View_Size () Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); - view.TextFormatter.Alignment = TextAlignment.Justified; + view.TextFormatter.Alignment = Justification.Justified; Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); - view.TextFormatter.VerticalAlignment = VerticalTextAlignment.Middle; + view.TextFormatter.VerticalAlignment = Justification.Centered; Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); @@ -709,11 +709,11 @@ public void DimAuto_Not_Used_TextSettings_Do_Not_Change_View_Size () Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); - view.TextAlignment = TextAlignment.Justified; + view.Justification = Justification.Justified; Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); - view.VerticalTextAlignment = VerticalTextAlignment.Middle; + view.VerticalJustification = Justification.Centered; Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); @@ -738,7 +738,7 @@ public void DimAuto_TextSettings_Change_View_Size () Assert.True (view.TextFormatter.AutoSize); Assert.NotEqual (Size.Empty, view.Frame.Size); - view.TextAlignment = TextAlignment.Justified; + view.Justification = Justification.Justified; Assert.True (view.TextFormatter.AutoSize); Assert.NotEqual (Size.Empty, view.Frame.Size); @@ -747,7 +747,7 @@ public void DimAuto_TextSettings_Change_View_Size () Text = "_1234", Width = Dim.Auto () }; - view.VerticalTextAlignment = VerticalTextAlignment.Middle; + view.VerticalJustification = Justification.Centered; Assert.True (view.TextFormatter.AutoSize); Assert.NotEqual (Size.Empty, view.Frame.Size); diff --git a/UnitTests/View/Text/AutoSizeTrueTests.cs b/UnitTests/View/Text/AutoSizeTrueTests.cs index 78939f7795..62e93e0006 100644 --- a/UnitTests/View/Text/AutoSizeTrueTests.cs +++ b/UnitTests/View/Text/AutoSizeTrueTests.cs @@ -1811,7 +1811,7 @@ public void View_Draw_Horizontal_Simple_TextAlignments (bool autoSize) Y = 1, Width = width, Height = 1, - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, }; if (autoSize) @@ -1826,7 +1826,7 @@ public void View_Draw_Horizontal_Simple_TextAlignments (bool autoSize) Y = 2, Width = width, Height = 1, - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, }; if (autoSize) { @@ -1840,7 +1840,7 @@ public void View_Draw_Horizontal_Simple_TextAlignments (bool autoSize) Y = 3, Width = width, Height = 1, - TextAlignment = TextAlignment.Justified, + Justification = Justification.Justified, }; if (autoSize) { @@ -1937,7 +1937,7 @@ public void View_Draw_Vertical_Simple_TextAlignments (bool autoSize) Width = 1, Height = height, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Middle + Justification = Justification.Centered }; if (autoSize) { @@ -1952,7 +1952,7 @@ public void View_Draw_Vertical_Simple_TextAlignments (bool autoSize) Width = 1, Height = height, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Bottom + VerticalJustification = Justification.Bottom }; if (autoSize) { @@ -1967,7 +1967,7 @@ public void View_Draw_Vertical_Simple_TextAlignments (bool autoSize) Width = 1, Height = height, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalTextAlignment = VerticalTextAlignment.Justified + VerticalJustification = Justification.Justified }; if (autoSize) { diff --git a/UnitTests/Views/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs index 0d91bc151f..0aa841c440 100644 --- a/UnitTests/Views/ButtonTests.cs +++ b/UnitTests/Views/ButtonTests.cs @@ -155,14 +155,14 @@ public void Constructors_Defaults () Assert.Equal ($"{CM.Glyphs.LeftBracket} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text); Assert.False (btn.IsDefault); - Assert.Equal (TextAlignment.Centered, btn.TextAlignment); + Assert.Equal (Justification.Centered, btn.Justification); 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 (Justification.Centered, btn.Justification); Assert.Equal ('_', btn.HotKeySpecifier.Value); Assert.True (btn.CanFocus); Assert.Equal (new (0, 0, 4, 1), btn.Viewport); @@ -195,7 +195,7 @@ public void Constructors_Defaults () btn.TextFormatter.Format () ); Assert.True (btn.IsDefault); - Assert.Equal (TextAlignment.Centered, btn.TextAlignment); + Assert.Equal (Justification.Centered, btn.Justification); Assert.True (btn.CanFocus); btn.SetRelativeLayout (new (100, 100)); @@ -222,7 +222,7 @@ public void Constructors_Defaults () btn.TextFormatter.Format () ); Assert.True (btn.IsDefault); - Assert.Equal (TextAlignment.Centered, btn.TextAlignment); + Assert.Equal (Justification.Centered, btn.Justification); Assert.Equal ('_', btn.HotKeySpecifier.Value); Assert.True (btn.CanFocus); diff --git a/UnitTests/Views/CheckBoxTests.cs b/UnitTests/Views/CheckBoxTests.cs index ef938c748c..0ff1f75c35 100644 --- a/UnitTests/Views/CheckBoxTests.cs +++ b/UnitTests/Views/CheckBoxTests.cs @@ -251,7 +251,7 @@ public void TextAlignment_Centered () X = 1, Y = Pos.Center (), Text = "Check this out 你", - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 25 }; var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" }; @@ -262,7 +262,7 @@ public void TextAlignment_Centered () Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (30, 5); - Assert.Equal (TextAlignment.Centered, checkBox.TextAlignment); + Assert.Equal (Justification.Centered, checkBox.Justification); Assert.Equal (new (1, 1, 25, 1), checkBox.Frame); Assert.Equal (_size25x1, checkBox.TextFormatter.Size); @@ -301,7 +301,7 @@ public void TextAlignment_Justified () X = 1, Y = Pos.Center (), Text = "Check first out 你", - TextAlignment = TextAlignment.Justified, + Justification = Justification.Justified, Width = 25 }; @@ -310,7 +310,7 @@ public void TextAlignment_Justified () X = 1, Y = Pos.Bottom (checkBox1), Text = "Check second out 你", - TextAlignment = TextAlignment.Justified, + Justification = Justification.Justified, Width = 25 }; var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" }; @@ -321,9 +321,9 @@ public void TextAlignment_Justified () Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (30, 6); - Assert.Equal (TextAlignment.Justified, checkBox1.TextAlignment); + Assert.Equal (Justification.Justified, checkBox1.Justification); Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame); - Assert.Equal (TextAlignment.Justified, checkBox2.TextAlignment); + Assert.Equal (Justification.Justified, checkBox2.Justification); Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame); var expected = @$" @@ -378,7 +378,7 @@ public void TextAlignment_Left () Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (30, 5); - Assert.Equal (TextAlignment.Left, checkBox.TextAlignment); + Assert.Equal (Justification.Left, checkBox.Justification); Assert.Equal (new (1, 1, 25, 1), checkBox.Frame); Assert.Equal (_size25x1, checkBox.TextFormatter.Size); @@ -417,7 +417,7 @@ public void TextAlignment_Right () X = 1, Y = Pos.Center (), Text = "Check this out 你", - TextAlignment = TextAlignment.Right, + Justification = Justification.Right, Width = 25 }; var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" }; @@ -428,7 +428,7 @@ public void TextAlignment_Right () Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (30, 5); - Assert.Equal (TextAlignment.Right, checkBox.TextAlignment); + Assert.Equal (Justification.Right, checkBox.Justification); Assert.Equal (new (1, 1, 25, 1), checkBox.Frame); Assert.Equal (_size25x1, checkBox.TextFormatter.Size); diff --git a/UnitTests/Views/LabelTests.cs b/UnitTests/Views/LabelTests.cs index 959eecbb80..3989ff9ba3 100644 --- a/UnitTests/Views/LabelTests.cs +++ b/UnitTests/Views/LabelTests.cs @@ -206,7 +206,7 @@ public void Constructors_Defaults () { var label = new Label (); Assert.Equal (string.Empty, label.Text); - Assert.Equal (TextAlignment.Left, label.TextAlignment); + Assert.Equal (Justification.Left, label.Justification); Assert.False (label.CanFocus); Assert.Equal (new Rectangle (0, 0, 0, 0), label.Frame); Assert.Equal (KeyCode.Null, label.HotKey); diff --git a/UnitTests/Views/TextValidateFieldTests.cs b/UnitTests/Views/TextValidateFieldTests.cs index 5e9aa6e689..62686f59f4 100644 --- a/UnitTests/Views/TextValidateFieldTests.cs +++ b/UnitTests/Views/TextValidateFieldTests.cs @@ -10,7 +10,7 @@ public void Backspace_Key_Deletes_Previous_Character () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // **** @@ -44,7 +44,7 @@ public void Changing_The_Mask_Tries_To_Keep_The_Previous_Text () { var field = new TextValidateField { - TextAlignment = TextAlignment.Left, + Justification = Justification.Left, Width = 30, // **** @@ -81,7 +81,7 @@ public void Delete_Key_Doesnt_Move_Cursor () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // **** @@ -115,7 +115,7 @@ public void End_Key_Last_Editable_Character () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // * @@ -137,7 +137,7 @@ public void Home_Key_First_Editable_Character () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // * @@ -161,7 +161,7 @@ public void Initial_Value_Bigger_Than_Mask_Discarded () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // **** @@ -179,7 +179,7 @@ public void Initial_Value_Exact_Valid () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // **** @@ -196,7 +196,7 @@ public void Initial_Value_Smaller_Than_Mask_Accepted () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // **** @@ -214,7 +214,7 @@ public void Initialized_With_Cursor_On_First_Editable_Character () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // * @@ -233,7 +233,7 @@ public void Input_Ilegal_Character () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // * @@ -253,7 +253,7 @@ public void Insert_Skips_Non_Editable_Characters () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // ** ** @@ -283,7 +283,7 @@ public void Left_Key_Stops_In_First_Editable_Character () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // * @@ -308,7 +308,7 @@ public void MouseClick_Right_X_Greater_Than_Text_Width_Goes_To_Last_Editable_Pos { var field = new TextValidateField { - TextAlignment = TextAlignment.Left, + Justification = Justification.Left, Width = 30, // **** @@ -338,7 +338,7 @@ public void OnTextChanged_TextChanged_Event () var field = new TextValidateField { - TextAlignment = TextAlignment.Left, Width = 30, Provider = new NetMaskedTextProvider ("--(0000)--") + Justification = Justification.Left, Width = 30, Provider = new NetMaskedTextProvider ("--(0000)--") }; field.Provider.TextChanged += (sender, e) => wasTextChanged = true; @@ -356,7 +356,7 @@ public void Right_Key_Stops_In_Last_Editable_Character () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // * @@ -381,7 +381,7 @@ public void Set_Text_After_Initialization () { var field = new TextValidateField { - TextAlignment = TextAlignment.Left, + Justification = Justification.Left, Width = 30, // **** @@ -400,7 +400,7 @@ public void When_Valid_Is_Valid_True () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, // **** @@ -540,7 +540,7 @@ public void Left_Key_Stops_At_Start_And_Insert () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false } }; @@ -596,7 +596,7 @@ public void OnTextChanged_TextChanged_Event () var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false } }; @@ -616,7 +616,7 @@ public void Right_Key_Stops_At_End_And_Insert () { var field = new TextValidateField { - TextAlignment = TextAlignment.Centered, + Justification = Justification.Centered, Width = 20, Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false } }; diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs index 28d9b94f41..eebd7aef75 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -1482,8 +1482,8 @@ public void Modal_As_Top_Will_Drag_Cleanly () Y = Pos.Center (), Width = Dim.Fill (), Height = Dim.Fill (), - TextAlignment = TextAlignment.Centered, - VerticalTextAlignment = VerticalTextAlignment.Middle, + Justification = Justification.Centered, + VerticalJustification = Justification.Centered, Text = "Test" } ); From 37073d29b5126d31457b1f26c8c80f467bc4fce1 Mon Sep 17 00:00:00 2001 From: Tig Date: Fri, 10 May 2024 09:56:14 -0600 Subject: [PATCH 027/173] Alignment->Justification --- Terminal.Gui/Drawing/Thickness.cs | 4 +- Terminal.Gui/Text/TextFormatter.cs | 119 ++++++++------- Terminal.Gui/View/ViewText.cs | 18 +-- Terminal.Gui/Views/Dialog.cs | 10 +- Terminal.Gui/Views/Menu/Menu.cs | 2 +- Terminal.Gui/Views/ProgressBar.cs | 2 +- Terminal.Gui/Views/TableView/ColumnStyle.cs | 42 +++--- Terminal.Gui/Views/TableView/TableStyle.cs | 4 +- Terminal.Gui/Views/TableView/TableView.cs | 2 +- Terminal.Gui/Views/TextValidateField.cs | 2 +- Terminal.Gui/Views/Wizard/Wizard.cs | 2 +- UICatalog/Scenarios/Buttons.cs | 2 +- UICatalog/Scenarios/ComputedLayout.cs | 4 +- UICatalog/Scenarios/CsvEditor.cs | 16 +- UICatalog/Scenarios/Dialogs.cs | 2 +- UICatalog/Scenarios/TableEditor.cs | 8 +- UICatalog/Scenarios/TextAlignments.cs | 142 ------------------ UICatalog/Scenarios/TextFormatterDemo.cs | 14 +- ...on.cs => TextJustificationAndDirection.cs} | 6 +- UnitTests/Dialogs/DialogTests.cs | 10 +- UnitTests/Text/TextFormatterTests.cs | 38 ++--- UnitTests/View/Layout/Dim.AutoTests.cs | 4 +- UnitTests/View/Text/AutoSizeTrueTests.cs | 2 +- 23 files changed, 164 insertions(+), 291 deletions(-) delete mode 100644 UICatalog/Scenarios/TextAlignments.cs rename UICatalog/Scenarios/{TextAlignmentsAndDirection.cs => TextJustificationAndDirection.cs} (98%) diff --git a/Terminal.Gui/Drawing/Thickness.cs b/Terminal.Gui/Drawing/Thickness.cs index 74458d2219..68f78c3d3b 100644 --- a/Terminal.Gui/Drawing/Thickness.cs +++ b/Terminal.Gui/Drawing/Thickness.cs @@ -232,8 +232,8 @@ rect with var tf = new TextFormatter { Text = label is null ? string.Empty : $"{label} {this}", - Alignment = Justification.Centered, - VerticalAlignment = Justification.Bottom, + Justification = Justification.Centered, + VerticalJustification = Justification.Bottom, AutoSize = true }; tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute, rect); diff --git a/Terminal.Gui/Text/TextFormatter.cs b/Terminal.Gui/Text/TextFormatter.cs index 5bdca378d5..efa179a7e2 100644 --- a/Terminal.Gui/Text/TextFormatter.cs +++ b/Terminal.Gui/Text/TextFormatter.cs @@ -1,7 +1,9 @@ +using System.Diagnostics; + namespace Terminal.Gui; /// -/// Provides text formatting. Supports s, horizontal alignment, vertical alignment, +/// Provides text formatting. Supports s, horizontal justification, vertical justification, /// multiple lines, and word-based line wrap. /// public class TextFormatter @@ -15,25 +17,24 @@ public class TextFormatter private Size _size; private int _tabWidth = 4; private string _text; - private Justification _textAlignment; + private Justification _textJustification; private TextDirection _textDirection; - private Justification _textVerticalAlignment; + private Justification _textVerticalJustification; private bool _wordWrap = true; - /// Controls the horizontal text-alignment property. - /// The text alignment. - public Justification Alignment + /// Get or sets the horizontal text justification. + /// The text justification. + public Justification Justification { - get => _textAlignment; - set => _textAlignment = EnableNeedsFormat (value); + get => _textJustification; + set => _textJustification = EnableNeedsFormat (value); } /// Gets or sets whether the should be automatically changed to fit the . /// /// Used when is using to resize the view's to fit . /// - /// AutoSize is ignored if and - /// are used. + /// AutoSize is ignored if is used. /// /// public bool AutoSize @@ -68,9 +69,8 @@ private Size GetAutoSize () /// Only the first HotKey specifier found in is supported. /// /// - /// If (the default) the width required for the HotKey specifier is returned. Otherwise the - /// height - /// is returned. + /// If (the default) the width required for the HotKey specifier is returned. Otherwise, the + /// height is returned. /// /// /// The number of characters required for the . If the text @@ -97,8 +97,8 @@ public int GetHotKeySpecifierLength (bool isWidth = true) /// public int CursorPosition { get; internal set; } - /// Controls the text-direction property. - /// The text vertical alignment. + /// Gets or sets the text-direction. + /// The text direction. public TextDirection Direction { get => _textDirection; @@ -112,8 +112,7 @@ public TextDirection Direction } } } - - + /// /// Determines if the viewport width will be used or only the text width will be used, /// If all the viewport area will be filled with whitespaces and the same background color @@ -223,12 +222,12 @@ public virtual string Text } } - /// Controls the vertical text-alignment property. - /// The text vertical alignment. - public Justification VerticalAlignment + /// Gets or sets the vertical text-justification. + /// The text vertical justification. + public Justification VerticalJustification { - get => _textVerticalAlignment; - set => _textVerticalAlignment = EnableNeedsFormat (value); + get => _textVerticalJustification; + set => _textVerticalJustification = EnableNeedsFormat (value); } /// Gets or sets whether word wrap will be used to fit to . @@ -318,10 +317,10 @@ public void Draw ( // 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 Justification.Right) + // Horizontal Justification + if (Justification is Justification.Right) { if (isVertical) { @@ -336,7 +335,7 @@ public void Draw ( CursorPosition = screen.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0); } } - else if (Alignment is Justification.Left) + else if (Justification is Justification.Left) { if (isVertical) { @@ -352,7 +351,7 @@ public void Draw ( CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0; } - else if (Alignment is Justification.Justified) + else if (Justification is Justification.Justified) { if (isVertical) { @@ -375,7 +374,7 @@ public void Draw ( CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0; } - else if (Alignment is Justification.Centered) + else if (Justification is Justification.Centered) { if (isVertical) { @@ -395,11 +394,13 @@ public void Draw ( } else { - throw new ArgumentOutOfRangeException ($"{nameof (Alignment)}"); + Debug.WriteLine ($"Unsupported Justification: {nameof (VerticalJustification)}"); + + return; } - // Vertical Alignment - if (VerticalAlignment is Justification.Bottom) + // Vertical Justification + if (VerticalJustification is Justification.Bottom) { if (isVertical) { @@ -410,7 +411,7 @@ public void Draw ( y = screen.Bottom - linesFormatted.Count + line; } } - else if (VerticalAlignment is Justification.Top) + else if (VerticalJustification is Justification.Top) { if (isVertical) { @@ -421,7 +422,7 @@ public void Draw ( y = screen.Top + line; } } - else if (VerticalAlignment is Justification.Justified) + else if (VerticalJustification is Justification.Justified) { if (isVertical) { @@ -435,7 +436,7 @@ public void Draw ( line < linesFormatted.Count - 1 ? screen.Height - interval <= 1 ? screen.Top + 1 : screen.Top + line * interval : screen.Bottom - 1; } } - else if (VerticalAlignment is Justification.Centered) + else if (VerticalJustification is Justification.Centered) { if (isVertical) { @@ -450,7 +451,9 @@ public void Draw ( } else { - throw new ArgumentOutOfRangeException ($"{nameof (VerticalAlignment)}"); + Debug.WriteLine ($"Unsupported Justification: {nameof (VerticalJustification)}"); + + return; } int colOffset = screen.X < 0 ? Math.Abs (screen.X) : 0; @@ -471,8 +474,8 @@ public void Draw ( { if (idx < 0 || (isVertical - ? VerticalAlignment != Justification.Bottom && current < 0 - : Alignment != Justification.Right && x + current + colOffset < 0)) + ? VerticalJustification != Justification.Bottom && current < 0 + : Justification != Justification.Right && x + current + colOffset < 0)) { current++; @@ -561,7 +564,7 @@ public void Draw ( if (HotKeyPos > -1 && idx == HotKeyPos) { - if ((isVertical && VerticalAlignment == Justification.Justified) || (!isVertical && Alignment == Justification.Justified)) + if ((isVertical && VerticalJustification == Justification.Justified) || (!isVertical && Justification == Justification.Justified)) { CursorPosition = idx - start; } @@ -699,7 +702,7 @@ public List GetLines () _lines = Format ( text, Size.Height, - VerticalAlignment == Justification.Justified, + VerticalJustification == Justification.Justified, Size.Width > colsWidth && WordWrap, PreserveTrailingSpaces, TabWidth, @@ -723,7 +726,7 @@ public List GetLines () _lines = Format ( text, Size.Width, - Alignment == Justification.Justified, + Justification == Justification.Justified, Size.Height > 1 && WordWrap, PreserveTrailingSpaces, TabWidth, @@ -977,7 +980,7 @@ public static string ClipOrPad (string text, int width) // 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 Justification int toPad = width - text.EnumerateRunes ().Sum (c => c.GetColumns ()); return text + new string (' ', toPad); @@ -1031,7 +1034,7 @@ public static List WordWrapText ( List runes = StripCRLF (text).ToRuneList (); int start = Math.Max ( - !runes.Contains ((Rune)' ') && textFormatter is { VerticalAlignment: Justification.Bottom } && IsVerticalDirection (textDirection) + !runes.Contains ((Rune)' ') && textFormatter is { VerticalJustification: Justification.Bottom } && IsVerticalDirection (textDirection) ? runes.Count - width : 0, 0); @@ -1249,7 +1252,7 @@ int GetNextWhiteSpace (int from, int cWidth, out bool incomplete, int cLength = /// The number of columns to clip the text to. Text longer than will be /// clipped. /// - /// Alignment. + /// Justification. /// The text direction. /// The number of columns used for a tab. /// instance to access any of his objects. @@ -1257,13 +1260,13 @@ int GetNextWhiteSpace (int from, int cWidth, out bool incomplete, int cLength = public static string ClipAndJustify ( string text, int width, - Justification talign, + Justification textJustification, TextDirection textDirection = TextDirection.LeftRight_TopBottom, int tabWidth = 0, TextFormatter textFormatter = null ) { - return ClipAndJustify (text, width, talign == Justification.Justified, textDirection, tabWidth, textFormatter); + return ClipAndJustify (text, width, textJustification == Justification.Justified, textDirection, tabWidth, textFormatter); } /// Justifies text within a specified width. @@ -1304,12 +1307,12 @@ public static string ClipAndJustify ( { if (IsHorizontalDirection (textDirection)) { - if (textFormatter is { Alignment: Justification.Right }) + if (textFormatter is { Justification: Justification.Right }) { return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection); } - if (textFormatter is { Alignment: Justification.Centered }) + if (textFormatter is { Justification: Justification.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1319,12 +1322,12 @@ public static string ClipAndJustify ( if (IsVerticalDirection (textDirection)) { - if (textFormatter is { VerticalAlignment: Justification.Bottom }) + if (textFormatter is { VerticalJustification: Justification.Bottom }) { return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection); } - if (textFormatter is { VerticalAlignment: Justification.Centered }) + if (textFormatter is { VerticalJustification: Justification.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1342,14 +1345,14 @@ public static string ClipAndJustify ( if (IsHorizontalDirection (textDirection)) { - if (textFormatter is { Alignment: Justification.Right }) + if (textFormatter is { Justification: Justification.Right }) { if (GetRuneWidth (text, tabWidth, textDirection) > width) { return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection); } } - else if (textFormatter is { Alignment: Justification.Centered }) + else if (textFormatter is { Justification: Justification.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1361,14 +1364,14 @@ public static string ClipAndJustify ( if (IsVerticalDirection (textDirection)) { - if (textFormatter is { VerticalAlignment: Justification.Bottom }) + if (textFormatter is { VerticalJustification: Justification.Bottom }) { if (runes.Count - zeroLength > width) { return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection); } } - else if (textFormatter is { VerticalAlignment: Justification.Centered }) + else if (textFormatter is { VerticalJustification: Justification.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1472,10 +1475,10 @@ public static string Justify ( return s.ToString (); } - /// Formats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries. + /// Formats text into lines, applying text justification and optionally wrapping text to new lines on word boundaries. /// /// The number of columns to constrain the text to for word wrapping and clipping. - /// Specifies how the text will be aligned horizontally. + /// Specifies how the text will be justified horizontally. /// /// If , the text will be wrapped to new lines no longer than /// . If , forces text to fit a single line. Line breaks are converted @@ -1498,7 +1501,7 @@ public static string Justify ( public static List Format ( string text, int width, - Justification talign, + Justification textJustification, bool wordWrap, bool preserveTrailingSpaces = false, int tabWidth = 0, @@ -1510,7 +1513,7 @@ public static List Format ( return Format ( text, width, - talign == Justification.Justified, + textJustification == Justification.Justified, wordWrap, preserveTrailingSpaces, tabWidth, @@ -1520,7 +1523,7 @@ public static List Format ( ); } - /// Formats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries. + /// Formats text into lines, applying text justification and optionally wrapping text to new lines on word boundaries. /// /// The number of columns to constrain the text to for word wrapping and clipping. /// Specifies whether the text should be justified. diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs index 19f534ad5e..d6490020fe 100644 --- a/Terminal.Gui/View/ViewText.cs +++ b/Terminal.Gui/View/ViewText.cs @@ -80,19 +80,19 @@ public void OnTextChanged (string oldValue, string newValue) public event EventHandler> TextChanged; /// - /// Gets or sets how the View's is aligned horizontally when drawn. Changing this property will + /// Gets or sets how the View's is justified horizontally when drawn. Changing this property will /// redisplay the . /// /// /// or are using , the will be adjusted to fit the text. /// - /// The text alignment. + /// The text justification. public virtual Justification Justification { - get => TextFormatter.Alignment; + get => TextFormatter.Justification; set { - TextFormatter.Alignment = value; + TextFormatter.Justification = value; UpdateTextFormatterText (); OnResizeNeeded (); } @@ -105,7 +105,7 @@ public virtual Justification Justification /// /// or are using , the will be adjusted to fit the text. /// - /// The text alignment. + /// The text direction. public virtual TextDirection TextDirection { get => TextFormatter.Direction; @@ -122,20 +122,20 @@ public virtual TextDirection TextDirection public TextFormatter TextFormatter { get; init; } = new () { }; /// - /// Gets or sets how the View's is aligned vertically when drawn. Changing this property will + /// Gets or sets how the View's is justified vertically when drawn. Changing this property will /// redisplay /// the . /// /// /// or are using , the will be adjusted to fit the text. /// - /// The text alignment. + /// The vertical text justification. public virtual Justification VerticalJustification { - get => TextFormatter.VerticalAlignment; + get => TextFormatter.VerticalJustification; set { - TextFormatter.VerticalAlignment = value; + TextFormatter.VerticalJustification = value; SetNeedsDisplay (); } } diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index fc1196be56..6f9c251f7e 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -51,7 +51,7 @@ public Dialog () ColorScheme = Colors.ColorSchemes ["Dialog"]; Modal = true; - ButtonAlignment = DefaultButtonJustification; + ButtonJustification = DefaultButtonJustification; AddCommand ( Command.QuitToplevel, @@ -96,9 +96,9 @@ public bool Canceled } } - // TODO: Update button.X = Pos.Justify when alignment changes - /// Determines how the s are aligned along the bottom of the dialog. - public Justification ButtonAlignment { get; set; } + // TODO: Update button.X = Pos.Justify when justification changes + /// Determines how the s are justified along the bottom of the dialog. + public Justification ButtonJustification { get; set; } /// Optional buttons to lay out at the bottom of the dialog. public Button [] Buttons @@ -136,7 +136,7 @@ public void AddButton (Button button) return; } - button.X = Pos.Justify (ButtonAlignment); + button.X = Pos.Justify (ButtonJustification); button.Y = Pos.AnchorEnd () - 1; _buttons.Add (button); diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index 1d6a92de6a..3033985ab1 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -891,7 +891,7 @@ public override void OnDrawContent (Rectangle viewport) var tf = new TextFormatter { AutoSize = true, - Alignment = Justification.Centered, HotKeySpecifier = MenuBar.HotKeySpecifier, Text = textToDraw + Justification = Justification.Centered, HotKeySpecifier = MenuBar.HotKeySpecifier, Text = textToDraw }; // The -3 is left/right border + one space (not sure what for) diff --git a/Terminal.Gui/Views/ProgressBar.cs b/Terminal.Gui/Views/ProgressBar.cs index 47c520db9d..cebe9900a6 100644 --- a/Terminal.Gui/Views/ProgressBar.cs +++ b/Terminal.Gui/Views/ProgressBar.cs @@ -181,7 +181,7 @@ public override void OnDrawContent (Rectangle viewport) if (ProgressBarFormat != ProgressBarFormat.Simple && !_isActivity) { - var tf = new TextFormatter { Alignment = Justification.Centered, Text = Text }; + var tf = new TextFormatter { Justification = Justification.Centered, Text = Text }; var attr = new Attribute (ColorScheme.HotNormal.Foreground, ColorScheme.HotNormal.Background); if (_fraction > .5) diff --git a/Terminal.Gui/Views/TableView/ColumnStyle.cs b/Terminal.Gui/Views/TableView/ColumnStyle.cs index 2490d66f63..17b22dc5b0 100644 --- a/Terminal.Gui/Views/TableView/ColumnStyle.cs +++ b/Terminal.Gui/Views/TableView/ColumnStyle.cs @@ -1,17 +1,17 @@ namespace Terminal.Gui; /// -/// Describes how to render a given column in a including and +/// Describes how to render a given column in a including and /// textual representation of cells (e.g. date formats) /// See TableView Deep Dive for more information. /// public class ColumnStyle { /// - /// Defines a delegate for returning custom alignment per cell based on cell values. When specified this will - /// override + /// Defines a delegate for returning custom justification per cell based on cell values. When specified this will + /// override /// - public Func AlignmentGetter; + public Func JustificationGetter; /// /// 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; /// - /// Defines a delegate for returning custom representations of cell values. If not set then - /// 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 + /// is used. Return values from your delegate may be truncated e.g. based on /// /// public Func RepresentationGetter; - private bool visible = true; + private bool _visible = true; /// - /// Defines the default alignment for all values rendered in this column. For custom alignment based on cell - /// contents use . + /// Defines the default justification for all values rendered in this column. For custom justification based on cell + /// contents use . /// - public Justification Alignment { get; set; } + public Justification Justification { get; set; } /// Defines the format for values e.g. "yyyy-MM-dd" for dates public string Format { get; set; } /// - /// Set the maximum width of the column in characters. This value will be ignored if more than the tables - /// . Defaults to + /// Set the maximum width of the column in characters. This value will be ignored if more than the tables + /// . Defaults to /// public int MaxWidth { get; set; } = TableView.DefaultMaxCellWidth; @@ -47,7 +47,7 @@ public class ColumnStyle public int MinAcceptableWidth { get; set; } = TableView.DefaultMinAcceptableWidth; /// - /// 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. /// /// This value will be ignored if more than the tables or the @@ -64,24 +64,24 @@ public class ColumnStyle /// If is 0 then will always return false. public bool Visible { - get => MaxWidth >= 0 && visible; - set => visible = value; + get => MaxWidth >= 0 && _visible; + set => _visible = value; } /// - /// Returns the alignment for the cell based on and / - /// + /// Returns the justification for the cell based on and / + /// /// /// /// - public Justification GetAlignment (object cellValue) + public Justification GetJustification (object cellValue) { - if (AlignmentGetter is { }) + if (JustificationGetter is { }) { - return AlignmentGetter (cellValue); + return JustificationGetter (cellValue); } - return Alignment; + return Justification; } /// diff --git a/Terminal.Gui/Views/TableView/TableStyle.cs b/Terminal.Gui/Views/TableView/TableStyle.cs index 2cf258bee6..4dd9477342 100644 --- a/Terminal.Gui/Views/TableView/TableStyle.cs +++ b/Terminal.Gui/Views/TableView/TableStyle.cs @@ -15,11 +15,11 @@ public class TableStyle /// public bool AlwaysUseNormalColorForVerticalCellLines { get; set; } = false; - /// Collection of columns for which you want special rendering (e.g. custom column lengths, text alignment etc) + /// Collection of columns for which you want special rendering (e.g. custom column lengths, text justification, etc.) public Dictionary ColumnStyles { get; set; } = new (); /// - /// 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 /// 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. diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs index 190fef0417..4aab25ac1e 100644 --- a/Terminal.Gui/Views/TableView/TableView.cs +++ b/Terminal.Gui/Views/TableView/TableView.cs @@ -2085,7 +2085,7 @@ ColumnStyle colStyle - (representation.EnumerateRunes ().Sum (c => c.GetColumns ()) + 1 /*leave 1 space for cell boundary*/); - switch (colStyle?.GetAlignment (originalCellValue) ?? Justification.Left) + switch (colStyle?.GetJustification (originalCellValue) ?? Justification.Left) { case Justification.Left: return representation + new string (' ', toPad); diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs index f2d4cc1bf2..9ffa318b7f 100644 --- a/Terminal.Gui/Views/TextValidateField.cs +++ b/Terminal.Gui/Views/TextValidateField.cs @@ -709,7 +709,7 @@ private bool EndKeyHandler () return true; } - /// Margins for text alignment. + /// Margins for text justification. /// Total width /// Left and right margins private (int left, int right) GetMargins (int width) diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index 5161ca1efd..8046106ebb 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -85,7 +85,7 @@ public Wizard () { // Using Justify causes the Back and Next buttons to be hard justified against // the left and right edge - ButtonAlignment = Justification.Justified; + ButtonJustification = Justification.Justified; BorderStyle = LineStyle.Double; //// Add a horiz separator diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs index 57d7ba1791..bd2e9de04c 100644 --- a/UICatalog/Scenarios/Buttons.cs +++ b/UICatalog/Scenarios/Buttons.cs @@ -209,7 +209,7 @@ static void DoMessage (Button button, string txt) var label = new Label { - X = 2, Y = Pos.Bottom (computedFrame) + 1, Text = "Text Alignment (changes the four buttons above): " + X = 2, Y = Pos.Bottom (computedFrame) + 1, Text = "Text Justification (changes the four buttons above): " }; main.Add (label); diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index f880568439..83a679d91f 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -86,7 +86,7 @@ public override void Main () var i = 1; var txt = "Resize the terminal to see computed layout in action."; List /// /// - public Justification GetJustification (object cellValue) + public Alignment GetJustification (object cellValue) { if (JustificationGetter is { }) { diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs index db03e33abb..0931faa31a 100644 --- a/Terminal.Gui/Views/TableView/TableView.cs +++ b/Terminal.Gui/Views/TableView/TableView.cs @@ -2085,16 +2085,16 @@ ColumnStyle colStyle - (representation.EnumerateRunes ().Sum (c => c.GetColumns ()) + 1 /*leave 1 space for cell boundary*/); - switch (colStyle?.GetJustification (originalCellValue) ?? Justification.Left) + switch (colStyle?.GetJustification (originalCellValue) ?? Alignment.Left) { - case Justification.Left: + case Alignment.Left: return representation + new string (' ', toPad); - case Justification.Right: + case Alignment.Right: return new string (' ', toPad) + representation; // TODO: With single line cells, centered and justified are the same right? - case Justification.Centered: - case Justification.Justified: + case Alignment.Centered: + case Alignment.Justified: return new string (' ', (int)Math.Floor (toPad / 2.0)) + // round down diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs index 9ffa318b7f..034a0a69bb 100644 --- a/Terminal.Gui/Views/TextValidateField.cs +++ b/Terminal.Gui/Views/TextValidateField.cs @@ -539,7 +539,7 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) { int c = _provider.Cursor (mouseEvent.X - GetMargins (Viewport.Width).left); - if (_provider.Fixed == false && Justification == Justification.Right && Text.Length > 0) + if (_provider.Fixed == false && TextJustification == Alignment.Right && Text.Length > 0) { c++; } @@ -633,7 +633,7 @@ public override bool OnProcessKeyDown (Key a) // When it's right-aligned and it's a normal input, the cursor behaves differently. int curPos; - if (_provider?.Fixed == false && Justification == Justification.Right) + if (_provider?.Fixed == false && TextJustification == Alignment.Right) { curPos = _cursorPosition + left - 1; } @@ -650,7 +650,7 @@ public override bool OnProcessKeyDown (Key a) /// private bool BackspaceKeyHandler () { - if (_provider.Fixed == false && Justification == Justification.Right && _cursorPosition <= 1) + if (_provider.Fixed == false && TextJustification == Alignment.Right && _cursorPosition <= 1) { return false; } @@ -688,7 +688,7 @@ private bool CursorRight () /// private bool DeleteKeyHandler () { - if (_provider.Fixed == false && Justification == Justification.Right) + if (_provider.Fixed == false && TextJustification == Alignment.Right) { _cursorPosition = _provider.CursorLeft (_cursorPosition); } @@ -717,13 +717,13 @@ private bool EndKeyHandler () int count = Text.Length; int total = width - count; - switch (Justification) + switch (TextJustification) { - case Justification.Left: + case Alignment.Left: return (0, total); - case Justification.Centered: + case Alignment.Centered: return (total / 2, total / 2 + total % 2); - case Justification.Right: + case Alignment.Right: return (total, 0); default: return (0, total); diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index 47ecca855a..6d6e4db510 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -1776,7 +1776,7 @@ public TextModel WrapModel ( TextFormatter.Format ( TextModel.ToString (line), width, - Justification.Left, + Alignment.Left, true, preserveTrailingSpaces, tabWidth diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index 8046106ebb..049668e5ee 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -85,7 +85,7 @@ public Wizard () { // Using Justify causes the Back and Next buttons to be hard justified against // the left and right edge - ButtonJustification = Justification.Justified; + ButtonJustification = Alignment.Justified; BorderStyle = LineStyle.Double; //// Add a horiz separator diff --git a/UICatalog/Scenarios/BasicColors.cs b/UICatalog/Scenarios/BasicColors.cs index 08a3c642d6..510d36d40b 100644 --- a/UICatalog/Scenarios/BasicColors.cs +++ b/UICatalog/Scenarios/BasicColors.cs @@ -32,7 +32,7 @@ public override void Main () Y = 0, Width = 1, Height = 13, - VerticalJustification = Justification.Bottom, + VerticalTextJustification = Alignment.Bottom, ColorScheme = new ColorScheme { Normal = attr }, Text = bg.ToString (), TextDirection = TextDirection.TopBottom_LeftRight @@ -45,7 +45,7 @@ public override void Main () Y = y, Width = 13, Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, ColorScheme = new ColorScheme { Normal = attr }, Text = bg.ToString () }; diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs index bd2e9de04c..1f0943d285 100644 --- a/UICatalog/Scenarios/Buttons.cs +++ b/UICatalog/Scenarios/Buttons.cs @@ -287,39 +287,39 @@ string MoveHotkey (string txt) switch (args.SelectedItem) { case 0: - moveBtn.Justification = Justification.Left; - sizeBtn.Justification = Justification.Left; - moveBtnA.Justification = Justification.Left; - sizeBtnA.Justification = Justification.Left; - moveHotKeyBtn.Justification = Justification.Left; - moveUnicodeHotKeyBtn.Justification = Justification.Left; + moveBtn.TextJustification = Alignment.Left; + sizeBtn.TextJustification = Alignment.Left; + moveBtnA.TextJustification = Alignment.Left; + sizeBtnA.TextJustification = Alignment.Left; + moveHotKeyBtn.TextJustification = Alignment.Left; + moveUnicodeHotKeyBtn.TextJustification = Alignment.Left; break; case 1: - moveBtn.Justification = Justification.Right; - sizeBtn.Justification = Justification.Right; - moveBtnA.Justification = Justification.Right; - sizeBtnA.Justification = Justification.Right; - moveHotKeyBtn.Justification = Justification.Right; - moveUnicodeHotKeyBtn.Justification = Justification.Right; + moveBtn.TextJustification = Alignment.Right; + sizeBtn.TextJustification = Alignment.Right; + moveBtnA.TextJustification = Alignment.Right; + sizeBtnA.TextJustification = Alignment.Right; + moveHotKeyBtn.TextJustification = Alignment.Right; + moveUnicodeHotKeyBtn.TextJustification = Alignment.Right; break; case 2: - moveBtn.Justification = Justification.Centered; - sizeBtn.Justification = Justification.Centered; - moveBtnA.Justification = Justification.Centered; - sizeBtnA.Justification = Justification.Centered; - moveHotKeyBtn.Justification = Justification.Centered; - moveUnicodeHotKeyBtn.Justification = Justification.Centered; + moveBtn.TextJustification = Alignment.Centered; + sizeBtn.TextJustification = Alignment.Centered; + moveBtnA.TextJustification = Alignment.Centered; + sizeBtnA.TextJustification = Alignment.Centered; + moveHotKeyBtn.TextJustification = Alignment.Centered; + moveUnicodeHotKeyBtn.TextJustification = Alignment.Centered; break; case 3: - moveBtn.Justification = Justification.Justified; - sizeBtn.Justification = Justification.Justified; - moveBtnA.Justification = Justification.Justified; - sizeBtnA.Justification = Justification.Justified; - moveHotKeyBtn.Justification = Justification.Justified; - moveUnicodeHotKeyBtn.Justification = Justification.Justified; + moveBtn.TextJustification = Alignment.Justified; + sizeBtn.TextJustification = Alignment.Justified; + moveBtnA.TextJustification = Alignment.Justified; + sizeBtnA.TextJustification = Alignment.Justified; + moveHotKeyBtn.TextJustification = Alignment.Justified; + moveUnicodeHotKeyBtn.TextJustification = Alignment.Justified; break; } @@ -439,7 +439,7 @@ public NumericUpDown () Y = Pos.Top (_down), Width = Dim.Function (() => Digits), Height = 1, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, CanFocus = true }; diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index c8d62b7166..cb4d77a70a 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -958,7 +958,7 @@ private void ShowDetails () Y = 1, Width = Dim.Fill (), Height = Dim.Fill (1), - Justification = Justification.Centered + TextJustification = Alignment.Centered }; var spinner = new SpinnerView { X = Pos.Center (), Y = Pos.Center (), Style = new Aesthetic () }; spinner.AutoSpin = true; diff --git a/UICatalog/Scenarios/CollectionNavigatorTester.cs b/UICatalog/Scenarios/CollectionNavigatorTester.cs index 480e5f65fe..69d8f51a19 100644 --- a/UICatalog/Scenarios/CollectionNavigatorTester.cs +++ b/UICatalog/Scenarios/CollectionNavigatorTester.cs @@ -142,7 +142,7 @@ private void CreateListView () var label = new Label { Text = "ListView", - Justification = Justification.Centered, + TextJustification = Alignment.Centered, X = 0, Y = 1, // for menu Width = Dim.Percent (50), @@ -171,7 +171,7 @@ private void CreateTreeView () var label = new Label { Text = "TreeView", - Justification = Justification.Centered, + TextJustification = Alignment.Centered, X = Pos.Right (_listView) + 2, Y = 1, // for menu Width = Dim.Percent (50), diff --git a/UICatalog/Scenarios/ColorPicker.cs b/UICatalog/Scenarios/ColorPicker.cs index cf2b7512ef..5b92f96dd9 100644 --- a/UICatalog/Scenarios/ColorPicker.cs +++ b/UICatalog/Scenarios/ColorPicker.cs @@ -69,8 +69,8 @@ public override void Main () { Title = "Color Sample", Text = "Lorem Ipsum", - Justification = Justification.Centered, - VerticalJustification = Justification.Centered, + TextJustification = Alignment.Centered, + VerticalTextJustification = Alignment.Centered, BorderStyle = LineStyle.Heavy, X = Pos.Center (), Y = Pos.Center (), diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index 83a679d91f..ac19ff82b6 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -91,7 +91,7 @@ public override void Main () labelList.Add ( new Label { - Justification = Justification.Left, + TextJustification = Alignment.Left, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -103,7 +103,7 @@ public override void Main () labelList.Add ( new Label { - Justification = Justification.Right, + TextJustification = Alignment.Right, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -115,7 +115,7 @@ public override void Main () labelList.Add ( new Label { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -127,7 +127,7 @@ public override void Main () labelList.Add ( new Label { - Justification = Justification.Justified, + TextJustification = Alignment.Justified, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -153,7 +153,7 @@ public override void Main () labelList.Add ( new Label { - Justification = Justification.Left, + TextJustification = Alignment.Left, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -165,7 +165,7 @@ public override void Main () labelList.Add ( new Label { - Justification = Justification.Right, + TextJustification = Alignment.Right, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -177,7 +177,7 @@ public override void Main () labelList.Add ( new Label { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -189,7 +189,7 @@ public override void Main () labelList.Add ( new Label { - Justification = Justification.Justified, + TextJustification = Alignment.Justified, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), @@ -324,7 +324,7 @@ public override void Main () var anchorEndLabel1 = new Label { Text = "This Label should be the 3rd to last line (AnchorEnd (3)).", - Justification = Justification.Centered, + TextJustification = Alignment.Centered, ColorScheme = Colors.ColorSchemes ["Menu"], Width = Dim.Fill (5), X = 5, @@ -338,7 +338,7 @@ public override void Main () { Text = "This TextField should be the 4th to last line (AnchorEnd (3) - 1).", - Justification = Justification.Left, + TextJustification = Alignment.Left, ColorScheme = Colors.ColorSchemes ["Menu"], Width = Dim.Fill (5), X = 5, @@ -397,9 +397,9 @@ public override void Main () // Center three buttons with - leftButton.X = Pos.Justify (Justification.Centered); - centerButton.X = Pos.Justify (Justification.Centered); - rightButton.X = Pos.Justify (Justification.Centered); + leftButton.X = Pos.Justify (Alignment.Centered); + centerButton.X = Pos.Justify (Alignment.Centered); + rightButton.X = Pos.Justify (Alignment.Centered); Application.Run (app); app.Dispose (); diff --git a/UICatalog/Scenarios/CsvEditor.cs b/UICatalog/Scenarios/CsvEditor.cs index 73fbd747eb..1d5762fff9 100644 --- a/UICatalog/Scenarios/CsvEditor.cs +++ b/UICatalog/Scenarios/CsvEditor.cs @@ -78,17 +78,17 @@ public override void Setup () _miLeft = new MenuItem ( "_Justify Left", "", - () => Justify (Justification.Left) + () => Justify (Alignment.Left) ), _miRight = new MenuItem ( "_Justify Right", "", - () => Justify (Justification.Right) + () => Justify (Alignment.Right) ), _miCentered = new MenuItem ( "_Justify Centered", "", - () => Justify (Justification.Centered) + () => Justify (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 override void Setup () Y = Pos.Bottom (_tableView), Text = "0,0", Width = Dim.Fill (), - Justification = Justification.Right + TextJustification = Alignment.Right }; _selectedCellLabel.TextChanged += SelectedCellLabel_TextChanged; @@ -218,7 +218,7 @@ private void AddRow () _tableView.Update (); } - private void Justify (Justification newJustification) + private void Justify (Alignment newJustification) { if (NoTableLoaded ()) { @@ -228,9 +228,9 @@ private void Justify (Justification newJustification) ColumnStyle style = _tableView.Style.GetOrCreateColumnStyle (_tableView.SelectedColumn); style.Justification = newJustification; - _miLeft.Checked = style.Justification == Justification.Left; - _miRight.Checked = style.Justification == Justification.Right; - _miCentered.Checked = style.Justification == Justification.Centered; + _miLeft.Checked = style.Justification == Alignment.Left; + _miRight.Checked = style.Justification == Alignment.Right; + _miCentered.Checked = style.Justification == Alignment.Centered; _tableView.Update (); } @@ -437,9 +437,9 @@ private void OnSelectedCellChanged (object sender, SelectedCellChangedEventArgs ColumnStyle style = _tableView.Style.GetColumnStyleIfAny (_tableView.SelectedColumn); - _miLeft.Checked = style?.Justification == Justification.Left; - _miRight.Checked = style?.Justification == Justification.Right; - _miCentered.Checked = style?.Justification == Justification.Centered; + _miLeft.Checked = style?.Justification == Alignment.Left; + _miRight.Checked = style?.Justification == Alignment.Right; + _miCentered.Checked = style?.Justification == Alignment.Centered; } private void Open () diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs index c206f05c26..e4ac61b2a4 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -18,7 +18,7 @@ public override void Setup () var numButtonsLabel = new Label { X = 0, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "_Number of Buttons:" }; @@ -28,7 +28,7 @@ public override void Setup () Y = 0, Width = Dim.Width (numButtonsLabel), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "_Width:" }; frame.Add (label); @@ -49,7 +49,7 @@ public override void Setup () Y = Pos.Bottom (label), Width = Dim.Width (numButtonsLabel), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "_Height:" }; frame.Add (label); @@ -83,7 +83,7 @@ public override void Setup () Y = Pos.Bottom (label), Width = Dim.Width (numButtonsLabel), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "_Title:" }; frame.Add (label); @@ -115,7 +115,7 @@ public override void Setup () { X = Pos.Right (numButtonsLabel) + 1, Y = Pos.Bottom (numButtonsLabel), - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = $"_Add {char.ConvertFromUtf32 (CODE_POINT)} to button text to stress wide char support", Checked = false }; @@ -127,7 +127,7 @@ public override void Setup () Y = Pos.Bottom (glyphsNotWords), Width = Dim.Width (numButtonsLabel), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Button St_yle:" }; frame.Add (label); @@ -145,7 +145,7 @@ static IEnumerable GetUniqueEnumNames () where T : Enum } } - var labels = GetUniqueEnumNames (); + var labels = GetUniqueEnumNames (); var styleRadioGroup = new RadioGroup { X = Pos.Right (label) + 1, @@ -175,7 +175,7 @@ void Top_LayoutComplete (object sender, EventArgs args) label = new() { - X = Pos.Center (), Y = Pos.Bottom (frame) + 4, Justification = Justification.Right, Text = "Button Pressed:" + X = Pos.Center (), Y = Pos.Bottom (frame) + 4, TextJustification = Alignment.Right, Text = "Button Pressed:" }; Win.Add (label); @@ -282,7 +282,7 @@ Label buttonPressedLabel dialog = new() { Title = titleEdit.Text, - ButtonJustification = (Justification)styleRadioGroup.SelectedItem, + ButtonJustification = (Alignment)styleRadioGroup.SelectedItem, Buttons = buttons.ToArray () }; diff --git a/UICatalog/Scenarios/DynamicMenuBar.cs b/UICatalog/Scenarios/DynamicMenuBar.cs index 38445a1aa1..dd0b0d8795 100644 --- a/UICatalog/Scenarios/DynamicMenuBar.cs +++ b/UICatalog/Scenarios/DynamicMenuBar.cs @@ -623,7 +623,7 @@ public DynamicMenuBarSample () var _lblMenuBar = new Label { ColorScheme = Colors.ColorSchemes ["Dialog"], - Justification = Justification.Centered, + TextJustification = Alignment.Centered, X = Pos.Right (_btnPrevious) + 1, Y = Pos.Top (_btnPrevious), @@ -636,7 +636,7 @@ public DynamicMenuBarSample () var _lblParent = new Label { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, X = Pos.Right (_btnPrevious) + 1, Y = Pos.Top (_btnPrevious) + 1, diff --git a/UICatalog/Scenarios/Editor.cs b/UICatalog/Scenarios/Editor.cs index 18bcf11bb8..c4588b9133 100644 --- a/UICatalog/Scenarios/Editor.cs +++ b/UICatalog/Scenarios/Editor.cs @@ -882,7 +882,7 @@ private View FindTab () { Y = 1, Width = lblWidth, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Find:" }; @@ -903,7 +903,7 @@ private View FindTab () Y = Pos.Top (label), Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), - Justification = Justification.Centered, + TextJustification = Alignment.Centered, IsDefault = true, Text = "Find _Next" @@ -917,7 +917,7 @@ private View FindTab () Y = Pos.Top (btnFindNext) + 1, Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Text = "Find _Previous" }; @@ -937,7 +937,7 @@ private View FindTab () X = Pos.Right (txtToFind) + 1, Y = Pos.Top (btnFindPrevious) + 2, Width = 20, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Text = "Cancel" }; @@ -1134,7 +1134,7 @@ private View ReplaceTab () { Y = 1, Width = lblWidth, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Find:" }; @@ -1155,7 +1155,7 @@ private View ReplaceTab () Y = Pos.Top (label), Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), - Justification = Justification.Centered, + TextJustification = Alignment.Centered, IsDefault = true, Text = "Replace _Next" @@ -1181,7 +1181,7 @@ private View ReplaceTab () Y = Pos.Top (btnFindNext) + 1, Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Text = "Replace _Previous" }; @@ -1194,7 +1194,7 @@ private View ReplaceTab () Y = Pos.Top (btnFindPrevious) + 1, Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Text = "Replace _All" }; @@ -1215,7 +1215,7 @@ private View ReplaceTab () X = Pos.Right (txtToFind) + 1, Y = Pos.Top (btnReplaceAll) + 1, Width = 20, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Text = "Cancel" }; diff --git a/UICatalog/Scenarios/ListColumns.cs b/UICatalog/Scenarios/ListColumns.cs index bbbabb0a29..09bc2149f0 100644 --- a/UICatalog/Scenarios/ListColumns.cs +++ b/UICatalog/Scenarios/ListColumns.cs @@ -247,7 +247,7 @@ public override void Setup () Text = "0,0", Width = Dim.Fill (), - Justification = Justification.Right + TextJustification = Alignment.Right }; Win.Add (selectedCellLabel); diff --git a/UICatalog/Scenarios/MessageBoxes.cs b/UICatalog/Scenarios/MessageBoxes.cs index 33bf34610c..9ecba02bb0 100644 --- a/UICatalog/Scenarios/MessageBoxes.cs +++ b/UICatalog/Scenarios/MessageBoxes.cs @@ -14,7 +14,7 @@ public override void Setup () 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, Justification = Justification.Right, Text = "Width:" }; + var label = new Label { X = 0, Y = 0, TextJustification = Alignment.Right, Text = "Width:" }; frame.Add (label); var widthEdit = new TextField @@ -34,7 +34,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Height:" }; frame.Add (label); @@ -69,7 +69,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Title:" }; frame.Add (label); @@ -91,7 +91,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Message:" }; frame.Add (label); @@ -113,7 +113,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Num Buttons:" }; frame.Add (label); @@ -135,7 +135,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Default Button:" }; frame.Add (label); @@ -157,7 +157,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Style:" }; frame.Add (label); @@ -195,7 +195,7 @@ void Top_LayoutComplete (object sender, EventArgs args) label = new() { - X = Pos.Center (), Y = Pos.Bottom (frame) + 2, Justification = Justification.Right, Text = "Button Pressed:" + X = Pos.Center (), Y = Pos.Bottom (frame) + 2, TextJustification = Alignment.Right, Text = "Button Pressed:" }; Win.Add (label); @@ -204,7 +204,7 @@ void Top_LayoutComplete (object sender, EventArgs args) X = Pos.Center (), Y = Pos.Bottom (label) + 1, ColorScheme = Colors.ColorSchemes ["Error"], - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Text = " " }; diff --git a/UICatalog/Scenarios/Mouse.cs b/UICatalog/Scenarios/Mouse.cs index 005bbb360a..2fd5bd2096 100644 --- a/UICatalog/Scenarios/Mouse.cs +++ b/UICatalog/Scenarios/Mouse.cs @@ -98,8 +98,8 @@ public override void Main () Width = 20, Height = 3, Text = "Enter/Leave Demo", - Justification = Justification.Centered, - VerticalJustification = Justification.Centered, + TextJustification = Alignment.Centered, + VerticalTextJustification = Alignment.Centered, ColorScheme = Colors.ColorSchemes ["Dialog"] }; win.Add (demo); diff --git a/UICatalog/Scenarios/PosJustification.cs b/UICatalog/Scenarios/PosJustification.cs index 14a687100f..a564b6cfe1 100644 --- a/UICatalog/Scenarios/PosJustification.cs +++ b/UICatalog/Scenarios/PosJustification.cs @@ -9,9 +9,9 @@ namespace UICatalog.Scenarios; [ScenarioCategory ("Layout")] public sealed class PosJustification : Scenario { - private readonly Justifier _horizJustifier = new (); + private readonly Aligner _horizJustifier = new (); private int _leftMargin; - private readonly Justifier _vertJustifier = new (); + private readonly Aligner _vertJustifier = new (); private int _topMargin; public override void Main () @@ -45,22 +45,22 @@ private void SetupHorizontalControls (Window appWindow) RadioGroup justification = new () { - X = Pos.Justify (_horizJustifier.Justification), + X = Pos.Justify (_horizJustifier.Alignment), Y = Pos.Center (), - RadioLabels = GetUniqueEnumNames (false).ToArray (), + RadioLabels = GetUniqueEnumNames (false).ToArray (), ColorScheme = colorScheme }; justification.SelectedItemChanged += (s, e) => { - _horizJustifier.Justification = - (Justification)Enum.Parse (typeof (Justification), justification.SelectedItem.ToString ()); + _horizJustifier.Alignment = + (Alignment)Enum.Parse (typeof (Alignment), justification.SelectedItem.ToString ()); foreach (View view in appWindow.Subviews.Where (v => v.X is Pos.PosJustify)) { if (view.X is Pos.PosJustify j) { - var newJust = new Pos.PosJustify (_horizJustifier.Justification) + var newJust = new Pos.PosJustify (_horizJustifier.Alignment) { Justifier = { @@ -75,7 +75,7 @@ private void SetupHorizontalControls (Window appWindow) CheckBox putSpaces = new () { - X = Pos.Justify (_horizJustifier.Justification), + X = Pos.Justify (_horizJustifier.Alignment), Y = Pos.Top (justification), ColorScheme = colorScheme, Text = "Spaces" @@ -125,14 +125,14 @@ private void SetupHorizontalControls (Window appWindow) addedViews.Add ( new() { - X = Pos.Justify (_horizJustifier.Justification), + X = Pos.Justify (_horizJustifier.Alignment), Y = Pos.Center (), Text = NumberToWords.Convert (0) }); Buttons.NumericUpDown addedViewsUpDown = new Buttons.NumericUpDown { - X = Pos.Justify (_horizJustifier.Justification), + X = Pos.Justify (_horizJustifier.Alignment), Y = Pos.Top (justification), Width = 9, Title = "Added", @@ -171,7 +171,7 @@ private void SetupHorizontalControls (Window appWindow) { var button = new Button { - X = Pos.Justify (_horizJustifier.Justification), + X = Pos.Justify (_horizJustifier.Alignment), Y = Pos.Center (), Text = NumberToWords.Convert (i + 1) }; @@ -192,21 +192,21 @@ private void SetupVerticalControls (Window appWindow) RadioGroup justification = new () { X = 0, - Y = Pos.Justify (_vertJustifier.Justification), - RadioLabels = GetUniqueEnumNames (true).Reverse ().ToArray (), + Y = Pos.Justify (_vertJustifier.Alignment), + RadioLabels = GetUniqueEnumNames (true).Reverse ().ToArray (), ColorScheme = colorScheme }; justification.SelectedItemChanged += (s, e) => { - _vertJustifier.Justification = - (Justification)Enum.Parse (typeof (Justification), justification.SelectedItem.ToString ()); + _vertJustifier.Alignment = + (Alignment)Enum.Parse (typeof (Alignment), justification.SelectedItem.ToString ()); foreach (View view in appWindow.Subviews.Where (v => v.Y is Pos.PosJustify)) { if (view.Y is Pos.PosJustify j) { - var newJust = new Pos.PosJustify (_vertJustifier.Justification) + var newJust = new Pos.PosJustify (_vertJustifier.Alignment) { Justifier = { @@ -222,7 +222,7 @@ private void SetupVerticalControls (Window appWindow) CheckBox putSpaces = new () { X = 0, - Y = Pos.Justify (_vertJustifier.Justification), + Y = Pos.Justify (_vertJustifier.Alignment), ColorScheme = colorScheme, Text = "Spaces" }; @@ -272,14 +272,14 @@ private void SetupVerticalControls (Window appWindow) new() { X = 0, - Y = Pos.Justify (_vertJustifier.Justification), + Y = Pos.Justify (_vertJustifier.Alignment), Text = NumberToWords.Convert (0) }); Buttons.NumericUpDown addedViewsUpDown = new Buttons.NumericUpDown { X = 0, - Y = Pos.Justify (_vertJustifier.Justification), + Y = Pos.Justify (_vertJustifier.Alignment), Width = 9, Title = "Added", ColorScheme = colorScheme, @@ -318,7 +318,7 @@ private void SetupVerticalControls (Window appWindow) var button = new CheckBox { X = 0, - Y = Pos.Justify (_vertJustifier.Justification), + Y = Pos.Justify (_vertJustifier.Alignment), Text = NumberToWords.Convert (i + 1) }; appWindow.Add (button); @@ -375,8 +375,8 @@ private void Setup3by3Grid (Window appWindow) Width = 5 }; - v.X = Pos.Justify (Justification.Right, i / 3); - v.Y = Pos.Justify (Justification.Justified, i % 3 + 10); + v.X = Pos.Justify (Alignment.Right, i / 3); + v.Y = Pos.Justify (Alignment.Justified, i % 3 + 10); container.Add (v); } diff --git a/UICatalog/Scenarios/TableEditor.cs b/UICatalog/Scenarios/TableEditor.cs index 04c9684854..0bada2611a 100644 --- a/UICatalog/Scenarios/TableEditor.cs +++ b/UICatalog/Scenarios/TableEditor.cs @@ -707,7 +707,7 @@ public override void Setup () Text = "0,0", Width = Dim.Fill (), - Justification = Justification.Right + TextJustification = Alignment.Right }; Win.Add (selectedCellLabel); @@ -1107,12 +1107,12 @@ private void SetDemoTableStyles () { _tableView.Style.ColumnStyles.Clear (); - var alignMid = new ColumnStyle { Justification = Justification.Centered }; - var alignRight = new ColumnStyle { Justification = Justification.Right }; + var alignMid = new ColumnStyle { Justification = Alignment.Centered }; + var alignRight = new ColumnStyle { Justification = Alignment.Right }; var dateFormatStyle = new ColumnStyle { - Justification = Justification.Right, + Justification = Alignment.Right, RepresentationGetter = v => v is DateTime d ? d.ToString ("yyyy-MM-dd") : v.ToString () }; @@ -1126,15 +1126,15 @@ private void SetDemoTableStyles () // align negative values right d < 0 - ? Justification.Right + ? Alignment.Right : // align positive values left - Justification.Left + Alignment.Left : // not a double - Justification.Left, + Alignment.Left, ColorGetter = a => a.CellValue is double d ? diff --git a/UICatalog/Scenarios/Text.cs b/UICatalog/Scenarios/Text.cs index 7b0e829100..eb48af78ca 100644 --- a/UICatalog/Scenarios/Text.cs +++ b/UICatalog/Scenarios/Text.cs @@ -290,7 +290,7 @@ void TextView_DrawContent (object sender, DrawEventArgs e) X = Pos.Right (regexProvider) + 1, Y = Pos.Y (regexProvider), Width = 30, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Provider = provider2 }; Win.Add (regexProviderField); diff --git a/UICatalog/Scenarios/TextFormatterDemo.cs b/UICatalog/Scenarios/TextFormatterDemo.cs index 340385b905..672315755d 100644 --- a/UICatalog/Scenarios/TextFormatterDemo.cs +++ b/UICatalog/Scenarios/TextFormatterDemo.cs @@ -75,17 +75,17 @@ static IEnumerable GetUniqueEnumValues () where T : Enum } } - List justifications = GetUniqueEnumValues().ToList (); + List justifications = GetUniqueEnumValues().ToList (); Label [] singleLines = new Label [justifications.Count]; Label [] multipleLines = new Label [justifications.Count]; var multiLineHeight = 5; - foreach (Justification justification in justifications) + foreach (Alignment justification in justifications) { singleLines [(int)justification] = new() { - Justification = justification, + TextJustification = justification, X = 0, Width = Dim.Fill (), @@ -96,7 +96,7 @@ static IEnumerable GetUniqueEnumValues () where T : Enum multipleLines [(int)justification] = new() { - Justification = justification, + TextJustification = justification, X = 0, Width = Dim.Fill (), @@ -112,7 +112,7 @@ static IEnumerable GetUniqueEnumValues () where T : Enum }; app.Add (label); - foreach (Justification justification in justifications) + foreach (Alignment justification in justifications) { label = new() { Y = Pos.Bottom (label), Text = $"{justification}:" }; app.Add (label); @@ -124,7 +124,7 @@ static IEnumerable GetUniqueEnumValues () where T : Enum label = new() { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" }; app.Add (label); - foreach (Justification justification in justifications) + foreach (Alignment justification in justifications) { label = new() { Y = Pos.Bottom (label), Text = $"{justification}:" }; app.Add (label); @@ -135,7 +135,7 @@ static IEnumerable GetUniqueEnumValues () where T : Enum unicodeCheckBox.Toggled += (s, e) => { - foreach (Justification justification in justifications) + foreach (Alignment justification in justifications) { singleLines [(int)justification].Text = e.OldValue == true ? text : unicode; multipleLines [(int)justification].Text = e.OldValue == true ? text : unicode; diff --git a/UICatalog/Scenarios/TextJustificationAndDirection.cs b/UICatalog/Scenarios/TextJustificationAndDirection.cs index bafdbfce24..7aa1d1333b 100644 --- a/UICatalog/Scenarios/TextJustificationAndDirection.cs +++ b/UICatalog/Scenarios/TextJustificationAndDirection.cs @@ -35,7 +35,7 @@ public override void Main () Y = 1, Width = 9, Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, ColorScheme = Colors.ColorSchemes ["Dialog"], Text = "Left" }; @@ -46,7 +46,7 @@ public override void Main () Y = 2, Width = 9, Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, ColorScheme = Colors.ColorSchemes ["Dialog"], Text = "Centered" }; @@ -57,7 +57,7 @@ public override void Main () Y = 3, Width = 9, Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, ColorScheme = Colors.ColorSchemes ["Dialog"], Text = "Right" }; @@ -68,7 +68,7 @@ public override void Main () Y = 4, Width = 9, Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, ColorScheme = Colors.ColorSchemes ["Dialog"], Text = "Justified" }; @@ -80,7 +80,7 @@ public override void Main () Width = Dim.Fill (1) - 9, Height = 1, ColorScheme = color1, - Justification = Justification.Left, + TextJustification = Alignment.Left, Text = txt }; @@ -91,7 +91,7 @@ public override void Main () Width = Dim.Fill (1) - 9, Height = 1, ColorScheme = color2, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Text = txt }; @@ -102,7 +102,7 @@ public override void Main () Width = Dim.Fill (1) - 9, Height = 1, ColorScheme = color1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = txt }; @@ -113,7 +113,7 @@ public override void Main () Width = Dim.Fill (1) - 9, Height = 1, ColorScheme = color2, - Justification = Justification.Justified, + TextJustification = Alignment.Justified, Text = txt }; @@ -141,7 +141,7 @@ public override void Main () Height = 9, ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Bottom, + VerticalTextJustification = Alignment.Bottom, Text = "Top" }; labelVT.TextFormatter.WordWrap = false; @@ -154,7 +154,7 @@ public override void Main () Height = 9, ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Bottom, + VerticalTextJustification = Alignment.Bottom, Text = "Centered" }; labelVM.TextFormatter.WordWrap = false; @@ -167,7 +167,7 @@ public override void Main () Height = 9, ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Bottom, + VerticalTextJustification = Alignment.Bottom, Text = "Bottom" }; labelVB.TextFormatter.WordWrap = false; @@ -180,7 +180,7 @@ public override void Main () Height = 9, ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Bottom, + VerticalTextJustification = Alignment.Bottom, Text = "Justified" }; labelVJ.TextFormatter.WordWrap = false; @@ -193,7 +193,7 @@ public override void Main () Height = Dim.Fill (1), ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Top, + VerticalTextJustification = Alignment.Top, Text = txt }; txtLabelVT.TextFormatter.WordWrap = false; @@ -206,7 +206,7 @@ public override void Main () Height = Dim.Fill (1), ColorScheme = color2, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Centered, + VerticalTextJustification = Alignment.Centered, Text = txt }; txtLabelVM.TextFormatter.WordWrap = false; @@ -219,7 +219,7 @@ public override void Main () Height = Dim.Fill (1), ColorScheme = color1, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Bottom, + VerticalTextJustification = Alignment.Bottom, Text = txt }; txtLabelVB.TextFormatter.WordWrap = false; @@ -232,7 +232,7 @@ public override void Main () Height = Dim.Fill (1), ColorScheme = color2, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Justified, + VerticalTextJustification = Alignment.Justified, Text = txt }; txtLabelVJ.TextFormatter.WordWrap = false; @@ -268,8 +268,8 @@ public override void Main () Y = 1, Width = Dim.Percent (100f / 3f), Height = Dim.Percent (100f / 3f), - Justification = Justification.Left, - VerticalJustification = Justification.Top, + TextJustification = Alignment.Left, + VerticalTextJustification = Alignment.Top, ColorScheme = color1, Text = txt }; @@ -281,8 +281,8 @@ public override void Main () Y = 1, Width = Dim.Percent (100f / 3f), Height = Dim.Percent (100f / 3f), - Justification = Justification.Centered, - VerticalJustification = Justification.Top, + TextJustification = Alignment.Centered, + VerticalTextJustification = Alignment.Top, ColorScheme = color1, Text = txt }; @@ -294,8 +294,8 @@ public override void Main () Y = 1, Width = Dim.Percent (100f, true), Height = Dim.Percent (100f / 3f), - Justification = Justification.Right, - VerticalJustification = Justification.Top, + TextJustification = Alignment.Right, + VerticalTextJustification = Alignment.Top, ColorScheme = color1, Text = txt }; @@ -307,8 +307,8 @@ public override void Main () Y = Pos.Bottom (txtLabelTL) + 1, Width = Dim.Width (txtLabelTL), Height = Dim.Percent (100f / 3f), - Justification = Justification.Left, - VerticalJustification = Justification.Centered, + TextJustification = Alignment.Left, + VerticalTextJustification = Alignment.Centered, ColorScheme = color1, Text = txt }; @@ -320,8 +320,8 @@ public override void Main () Y = Pos.Bottom (txtLabelTC) + 1, Width = Dim.Width (txtLabelTC), Height = Dim.Percent (100f / 3f), - Justification = Justification.Centered, - VerticalJustification = Justification.Centered, + TextJustification = Alignment.Centered, + VerticalTextJustification = Alignment.Centered, ColorScheme = color1, Text = txt }; @@ -333,8 +333,8 @@ public override void Main () Y = Pos.Bottom (txtLabelTR) + 1, Width = Dim.Percent (100f, true), Height = Dim.Percent (100f / 3f), - Justification = Justification.Right, - VerticalJustification = Justification.Centered, + TextJustification = Alignment.Right, + VerticalTextJustification = Alignment.Centered, ColorScheme = color1, Text = txt }; @@ -346,8 +346,8 @@ public override void Main () Y = Pos.Bottom (txtLabelML) + 1, Width = Dim.Width (txtLabelML), Height = Dim.Percent (100f, true), - Justification = Justification.Left, - VerticalJustification = Justification.Bottom, + TextJustification = Alignment.Left, + VerticalTextJustification = Alignment.Bottom, ColorScheme = color1, Text = txt }; @@ -359,8 +359,8 @@ public override void Main () Y = Pos.Bottom (txtLabelMC) + 1, Width = Dim.Width (txtLabelMC), Height = Dim.Percent (100f, true), - Justification = Justification.Centered, - VerticalJustification = Justification.Bottom, + TextJustification = Alignment.Centered, + VerticalTextJustification = Alignment.Bottom, ColorScheme = color1, Text = txt }; @@ -372,8 +372,8 @@ public override void Main () Y = Pos.Bottom (txtLabelMR) + 1, Width = Dim.Percent (100f, true), Height = Dim.Percent (100f, true), - Justification = Justification.Right, - VerticalJustification = Justification.Bottom, + TextJustification = Alignment.Right, + VerticalTextJustification = Alignment.Bottom, ColorScheme = color1, Text = txt }; @@ -392,7 +392,7 @@ public override void Main () // Save Justification in Data foreach (Label t in mtxts) { - t.Data = new { h = t.Justification, v = t.VerticalJustification }; + t.Data = new { h = t.TextJustification, v = t.VerticalTextJustification }; } container.Add (txtLabelTL); @@ -593,8 +593,8 @@ void ToggleJustify (bool oldValue, bool wasJustOptions = false) foreach (Label t in mtxts) { - t.Justification = (Justification)((dynamic)t.Data).h; - t.VerticalJustification = (Justification)((dynamic)t.Data).v; + t.TextJustification = (Alignment)((dynamic)t.Data).h; + t.VerticalTextJustification = (Alignment)((dynamic)t.Data).v; } } else @@ -611,16 +611,16 @@ void ToggleJustify (bool oldValue, bool wasJustOptions = false) switch (justifyOptions.SelectedItem) { case 0: - t.VerticalJustification = Justification.Justified; - t.Justification = ((dynamic)t.Data).h; + t.VerticalTextJustification = Alignment.Justified; + t.TextJustification = ((dynamic)t.Data).h; break; case 1: - t.VerticalJustification = (Justification)((dynamic)t.Data).v; - t.Justification = Justification.Justified; + t.VerticalTextJustification = (Alignment)((dynamic)t.Data).v; + t.TextJustification = Alignment.Justified; break; case 2: - t.VerticalJustification = Justification.Justified; - t.Justification = Justification.Justified; + t.VerticalTextJustification = Alignment.Justified; + t.TextJustification = Alignment.Justified; break; } } @@ -629,16 +629,16 @@ void ToggleJustify (bool oldValue, bool wasJustOptions = false) switch (justifyOptions.SelectedItem) { case 0: - t.Justification = Justification.Justified; - t.VerticalJustification = ((dynamic)t.Data).v; + t.TextJustification = Alignment.Justified; + t.VerticalTextJustification = ((dynamic)t.Data).v; break; case 1: - t.Justification = (Justification)((dynamic)t.Data).h; - t.VerticalJustification = Justification.Justified; + t.TextJustification = (Alignment)((dynamic)t.Data).h; + t.VerticalTextJustification = Alignment.Justified; break; case 2: - t.Justification = Justification.Justified; - t.VerticalJustification = Justification.Justified; + t.TextJustification = Alignment.Justified; + t.VerticalTextJustification = Alignment.Justified; break; } } diff --git a/UICatalog/Scenarios/TimeAndDate.cs b/UICatalog/Scenarios/TimeAndDate.cs index e36114ee07..b61d1d50be 100644 --- a/UICatalog/Scenarios/TimeAndDate.cs +++ b/UICatalog/Scenarios/TimeAndDate.cs @@ -57,7 +57,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (longDate) + 1, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = Dim.Fill (), Text = "Old Time: " @@ -68,7 +68,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (_lblOldTime) + 1, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = Dim.Fill (), Text = "New Time: " @@ -79,7 +79,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (_lblNewTime) + 1, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = Dim.Fill (), Text = "Time Format: " @@ -90,7 +90,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (_lblTimeFmt) + 2, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = Dim.Fill (), Text = "Old Date: " @@ -101,7 +101,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (_lblOldDate) + 1, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = Dim.Fill (), Text = "New Date: " @@ -112,7 +112,7 @@ public override void Setup () { X = Pos.Center (), Y = Pos.Bottom (_lblNewDate) + 1, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = Dim.Fill (), Text = "Date Format: " diff --git a/UICatalog/Scenarios/Unicode.cs b/UICatalog/Scenarios/Unicode.cs index 214156b8d3..a8f2fbe42a 100644 --- a/UICatalog/Scenarios/Unicode.cs +++ b/UICatalog/Scenarios/Unicode.cs @@ -132,7 +132,7 @@ public override void Setup () Width = Dim.Percent (50), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = $"Justify Right - {gitString}" }; Win.Add (checkBox, checkBoxRight); diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs index d80a98f5db..fd908dfde7 100644 --- a/UICatalog/Scenarios/ViewExperiments.cs +++ b/UICatalog/Scenarios/ViewExperiments.cs @@ -60,7 +60,7 @@ public override void Main () Width = 17, Title = "Window 1", Text = "Window #2", - Justification = Justification.Centered + TextJustification = Alignment.Centered }; window1.Margin.Thickness = new (0); @@ -84,7 +84,7 @@ public override void Main () Width = 37, Title = "Window2", Text = "Window #2 (Right(window1)+1", - Justification = Justification.Centered + TextJustification = Alignment.Centered }; //view3.InitializeFrames (); @@ -109,7 +109,7 @@ public override void Main () Width = 37, Title = "View4", Text = "View #4 (Right(window2)+1", - Justification = Justification.Centered + TextJustification = Alignment.Centered }; //view4.InitializeFrames (); @@ -134,7 +134,7 @@ public override void Main () Width = Dim.Fill (), Title = "View5", Text = "View #5 (Right(view4)+1 Fill", - Justification = Justification.Centered + TextJustification = Alignment.Centered }; //view5.InitializeFrames (); @@ -181,7 +181,7 @@ public override void Main () X = Pos.Center (), Y = Pos.Percent (50), Width = 30, - Justification = Justification.Centered + TextJustification = Alignment.Centered }; label50.Border.Thickness = new (1, 3, 1, 1); label50.Height = 5; diff --git a/UICatalog/Scenarios/Wizards.cs b/UICatalog/Scenarios/Wizards.cs index d034ffc7fb..d8d99d8a84 100644 --- a/UICatalog/Scenarios/Wizards.cs +++ b/UICatalog/Scenarios/Wizards.cs @@ -21,7 +21,7 @@ public override void Setup () }; Win.Add (frame); - var label = new Label { X = 0, Y = 0, Justification = Justification.Right, Text = "Width:" }; + var label = new Label { X = 0, Y = 0, TextJustification = Alignment.Right, Text = "Width:" }; frame.Add (label); var widthEdit = new TextField @@ -41,7 +41,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Height:" }; frame.Add (label); @@ -63,7 +63,7 @@ public override void Setup () Width = Dim.Width (label), Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, Text = "Title:" }; frame.Add (label); @@ -88,7 +88,7 @@ void Top_Loaded (object sender, EventArgs args) label = new() { - X = Pos.Center (), Y = Pos.AnchorEnd (1), Justification = Justification.Right, Text = "Action:" + X = Pos.Center (), Y = Pos.AnchorEnd (1), TextJustification = Alignment.Right, Text = "Action:" }; Win.Add (label); diff --git a/UnitTests/Configuration/ThemeScopeTests.cs b/UnitTests/Configuration/ThemeScopeTests.cs index 928993ede8..1103d92fe3 100644 --- a/UnitTests/Configuration/ThemeScopeTests.cs +++ b/UnitTests/Configuration/ThemeScopeTests.cs @@ -29,12 +29,12 @@ public void Apply_ShouldApplyUpdatedProperties () { Reset (); Assert.NotEmpty (Themes); - Assert.Equal (Justification.Right, Dialog.DefaultButtonJustification); + Assert.Equal (Alignment.Right, Dialog.DefaultButtonJustification); - Themes ["Default"] ["Dialog.DefaultButtonJustification"].PropertyValue = Justification.Centered; + Themes ["Default"] ["Dialog.DefaultButtonJustification"].PropertyValue = Alignment.Centered; ThemeManager.Themes! [ThemeManager.SelectedTheme]!.Apply (); - Assert.Equal (Justification.Centered, Dialog.DefaultButtonJustification); + Assert.Equal (Alignment.Centered, Dialog.DefaultButtonJustification); Reset (); } diff --git a/UnitTests/Configuration/ThemeTests.cs b/UnitTests/Configuration/ThemeTests.cs index 6a32293c76..e63e775155 100644 --- a/UnitTests/Configuration/ThemeTests.cs +++ b/UnitTests/Configuration/ThemeTests.cs @@ -77,15 +77,15 @@ public void TestApply_UpdatesColors () public void TestSerialize_RoundTrip () { var theme = new ThemeScope (); - theme ["Dialog.DefaultButtonJustification"].PropertyValue = Justification.Right; + theme ["Dialog.DefaultButtonJustification"].PropertyValue = Alignment.Right; string json = JsonSerializer.Serialize (theme, _jsonOptions); var deserialized = JsonSerializer.Deserialize (json, _jsonOptions); Assert.Equal ( - Justification.Right, - (Justification)deserialized ["Dialog.DefaultButtonJustification"].PropertyValue + Alignment.Right, + (Alignment)deserialized ["Dialog.DefaultButtonJustification"].PropertyValue ); Reset (); } diff --git a/UnitTests/Dialogs/DialogTests.cs b/UnitTests/Dialogs/DialogTests.cs index 2c9e6df040..6595b8753d 100644 --- a/UnitTests/Dialogs/DialogTests.cs +++ b/UnitTests/Dialogs/DialogTests.cs @@ -32,7 +32,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonJustification = Justification.Centered, + ButtonJustification = Alignment.Centered, Buttons = [new Button { Text = btn1Text }] }; @@ -57,7 +57,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonJustification = Justification.Justified, + ButtonJustification = Alignment.Justified, Buttons = [new Button { Text = btn1Text }] }; @@ -82,7 +82,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonJustification = Justification.Right, + ButtonJustification = Alignment.Right, Buttons = [new Button { Text = btn1Text }] }; @@ -107,7 +107,7 @@ public void Add_Button_Works () Title = title, Width = width, Height = 1, - ButtonJustification = Justification.Left, + ButtonJustification = Alignment.Left, Buttons = [new Button { Text = btn1Text }] }; @@ -155,7 +155,7 @@ public void ButtonJustification_Four () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Justification.Centered, + Alignment.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -172,7 +172,7 @@ public void ButtonJustification_Four () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Justified, + Alignment.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -189,7 +189,7 @@ public void ButtonJustification_Four () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Right, + Alignment.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -206,7 +206,7 @@ public void ButtonJustification_Four () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Left, + Alignment.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -248,7 +248,7 @@ public void ButtonJustification_Four_On_Too_Small_Width () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Justification.Centered, + Alignment.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -266,7 +266,7 @@ public void ButtonJustification_Four_On_Too_Small_Width () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Justified, + Alignment.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -283,7 +283,7 @@ public void ButtonJustification_Four_On_Too_Small_Width () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Right, + Alignment.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -299,7 +299,7 @@ public void ButtonJustification_Four_On_Too_Small_Width () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Left, + Alignment.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -340,7 +340,7 @@ public void ButtonJustification_Four_WideOdd () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Justification.Centered, + Alignment.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -357,7 +357,7 @@ public void ButtonJustification_Four_WideOdd () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Justified, + Alignment.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -374,7 +374,7 @@ public void ButtonJustification_Four_WideOdd () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Right, + Alignment.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -391,7 +391,7 @@ public void ButtonJustification_Four_WideOdd () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Left, + Alignment.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -434,7 +434,7 @@ public void ButtonJustification_Four_Wider () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Justification.Centered, + Alignment.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -451,7 +451,7 @@ public void ButtonJustification_Four_Wider () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Justified, + Alignment.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -468,7 +468,7 @@ public void ButtonJustification_Four_Wider () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Right, + Alignment.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -485,7 +485,7 @@ public void ButtonJustification_Four_Wider () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Left, + Alignment.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text }, @@ -517,7 +517,7 @@ public void ButtonJustification_One () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Justification.Centered, + Alignment.Centered, new Button { Text = btnText } ); @@ -534,7 +534,7 @@ public void ButtonJustification_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Justified, + Alignment.Justified, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -549,7 +549,7 @@ public void ButtonJustification_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Right, + Alignment.Right, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -564,7 +564,7 @@ public void ButtonJustification_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Left, + Alignment.Left, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -581,7 +581,7 @@ public void ButtonJustification_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Centered, + Alignment.Centered, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -596,7 +596,7 @@ public void ButtonJustification_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Justified, + Alignment.Justified, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -611,7 +611,7 @@ public void ButtonJustification_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Right, + Alignment.Right, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -626,7 +626,7 @@ public void ButtonJustification_One () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Left, + Alignment.Left, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -660,7 +660,7 @@ public void ButtonJustification_Three () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Justification.Centered, + Alignment.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -676,7 +676,7 @@ public void ButtonJustification_Three () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Justified, + Alignment.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -692,7 +692,7 @@ public void ButtonJustification_Three () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Right, + Alignment.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -708,7 +708,7 @@ public void ButtonJustification_Three () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Left, + Alignment.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text }, new Button { Text = btn3Text } @@ -742,7 +742,7 @@ public void ButtonJustification_Two () (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Justification.Centered, + Alignment.Centered, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -757,7 +757,7 @@ public void ButtonJustification_Two () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Justified, + Alignment.Justified, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -772,7 +772,7 @@ public void ButtonJustification_Two () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Right, + Alignment.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -787,7 +787,7 @@ public void ButtonJustification_Two () (runstate, dlg) = RunButtonTestDialog ( title, width, - Justification.Left, + Alignment.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -824,7 +824,7 @@ public void ButtonJustification_Two_Hidden () // Default (Center) button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, Justification.Centered, button1, button2); + (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}"; @@ -836,7 +836,7 @@ public void ButtonJustification_Two_Hidden () Assert.Equal (width, buttonRow.Length); button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, Justification.Justified, button1, button2); + (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}"; @@ -848,7 +848,7 @@ public void ButtonJustification_Two_Hidden () Assert.Equal (width, buttonRow.Length); button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, Justification.Right, button1, button2); + (runstate, dlg) = RunButtonTestDialog (title, width, Alignment.Right, button1, button2); button1.Visible = false; RunIteration (ref runstate, ref firstIteration); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -859,7 +859,7 @@ public void ButtonJustification_Two_Hidden () Assert.Equal (width, buttonRow.Length); button1 = new Button { Text = btn1Text }; button2 = new Button { Text = btn2Text }; - (runstate, dlg) = RunButtonTestDialog (title, width, Justification.Left, button1, button2); + (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}"; @@ -889,7 +889,7 @@ public void Dialog_In_Window_With_Size_One_Button_Aligns () win.Loaded += (s, a) => { - Dialog.DefaultButtonJustification = Justification.Centered; + Dialog.DefaultButtonJustification = Alignment.Centered; var dlg = new Dialog { Width = 18, Height = 3, Buttons = [new () { Text = "Ok" }] }; dlg.Loaded += (s, a) => @@ -973,7 +973,7 @@ public void Dialog_In_Window_Without_Size_One_Button_Aligns (int height, string var win = new Window (); int iterations = -1; - Dialog.DefaultButtonJustification = Justification.Centered; + Dialog.DefaultButtonJustification = Alignment.Centered; Iteration += (s, a) => { @@ -1008,7 +1008,7 @@ public void Dialog_In_Window_Without_Size_One_Button_Aligns (int height, string public void Dialog_Opened_From_Another_Dialog () { ((FakeDriver)Driver).SetBufferSize (30, 10); - Dialog.DefaultButtonJustification = Justification.Centered; + Dialog.DefaultButtonJustification = Alignment.Centered; var btn1 = new Button { Text = "press me 1" }; Button btn2 = null; @@ -1285,7 +1285,7 @@ public void One_Button_Works () (runstate, Dialog _) = RunButtonTestDialog ( title, width, - Justification.Centered, + Alignment.Centered, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -1338,7 +1338,7 @@ public void Zero_Buttons_Works () int width = buttonRow.Length; d.SetBufferSize (buttonRow.Length, 3); - (runstate, Dialog dlg) = RunButtonTestDialog (title, width, Justification.Centered, null); + (runstate, Dialog dlg) = RunButtonTestDialog (title, width, Alignment.Centered, null); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); End (runstate); @@ -1348,7 +1348,7 @@ public void Zero_Buttons_Works () private (RunState, Dialog) RunButtonTestDialog ( string title, int width, - Justification align, + Alignment align, params Button [] btns ) { diff --git a/UnitTests/Drawing/AlignerTests.cs b/UnitTests/Drawing/AlignerTests.cs new file mode 100644 index 0000000000..0b1f661caa --- /dev/null +++ b/UnitTests/Drawing/AlignerTests.cs @@ -0,0 +1,452 @@ +using System.Text; +using Xunit.Abstractions; + +namespace Terminal.Gui.DrawingTests; + +public class AlignerTests (ITestOutputHelper output) +{ + private readonly ITestOutputHelper _output = output; + + public static IEnumerable AlignmentEnumValues () + { + foreach (object number in Enum.GetValues (typeof (Alignment))) + { + yield return new [] { number }; + } + } + + [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 ( + () => new Aligner + { + Alignment = alignment, + ContainerSize = 100 + }.Align (new [] { -10, 20, 30 })); + + Assert.Throws ( + () => new Aligner + { + Alignment = alignment, + ContainerSize = 100 + }.Align (new [] { 10, -20, 30 })); + + Assert.Throws ( + () => 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, 3, 3 }, 21, new [] { 0, 14, 18 })] + [InlineData (Alignment.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })] + public void Alignment_PutSpaceBetweenItems (Alignment alignment, int [] sizes, int containerSize, int [] expected) + { + int [] positions = new Aligner + { + PutSpaceBetweenItems = 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 + { + PutSpaceBetweenItems = 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 (); + } +} diff --git a/UnitTests/Drawing/JustifierTests.cs b/UnitTests/Drawing/JustifierTests.cs deleted file mode 100644 index 434a040096..0000000000 --- a/UnitTests/Drawing/JustifierTests.cs +++ /dev/null @@ -1,445 +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 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 (() => new Justifier () - { - Justification = justification, - ContainerSize = 100 - }.Justify (new [] { -10, 20, 30 })); - Assert.Throws (() => new Justifier () - { - Justification = justification, - ContainerSize = 100 - }.Justify (new [] { 10, -20, 30 })); - Assert.Throws (() => 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 }, 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 (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 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1. - - [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 }, 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 (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 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1.})] - [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 }, 5, new [] { 0, 1, 3 })] - [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 })] - [InlineData (Justification.FirstLeftRestRight, new [] { 3, 3, 3 }, 21, new [] { 0, 14, 18 })] - [InlineData (Justification.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })] - 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 [] { 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 (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 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1. - - [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 [] { 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 (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++) - { - if (positions [position] + j >= 0) - { - 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 (); - } -} diff --git a/UnitTests/Text/TextFormatterTests.cs b/UnitTests/Text/TextFormatterTests.cs index de89c5394a..b7ec532179 100644 --- a/UnitTests/Text/TextFormatterTests.cs +++ b/UnitTests/Text/TextFormatterTests.cs @@ -53,36 +53,36 @@ public void Basic_Usage_With_AutoSize_True () tf.Text = testText; Size expectedSize = new (testText.Length, 1); Assert.Equal (testText, tf.Text); - Assert.Equal (Justification.Left, tf.Justification); + Assert.Equal (Alignment.Left, tf.Justification); Assert.Equal (expectedSize, tf.Size); tf.Draw (testBounds, new Attribute (), new Attribute ()); Assert.Equal (expectedSize, tf.Size); Assert.NotEmpty (tf.GetLines ()); - tf.Justification = Justification.Right; + tf.Justification = Alignment.Right; expectedSize = new (testText.Length, 1); Assert.Equal (testText, tf.Text); - Assert.Equal (Justification.Right, tf.Justification); + Assert.Equal (Alignment.Right, tf.Justification); Assert.Equal (expectedSize, tf.Size); tf.Draw (testBounds, new Attribute (), new Attribute ()); Assert.Equal (expectedSize, tf.Size); Assert.NotEmpty (tf.GetLines ()); - tf.Justification = Justification.Right; + tf.Justification = Alignment.Right; expectedSize = new (testText.Length, 1); tf.Size = expectedSize; Assert.Equal (testText, tf.Text); - Assert.Equal (Justification.Right, tf.Justification); + Assert.Equal (Alignment.Right, tf.Justification); Assert.Equal (expectedSize, tf.Size); tf.Draw (testBounds, new Attribute (), new Attribute ()); Assert.Equal (expectedSize, tf.Size); Assert.NotEmpty (tf.GetLines ()); - tf.Justification = Justification.Centered; + tf.Justification = Alignment.Centered; expectedSize = new (testText.Length, 1); tf.Size = expectedSize; Assert.Equal (testText, tf.Text); - Assert.Equal (Justification.Centered, tf.Justification); + Assert.Equal (Alignment.Centered, tf.Justification); Assert.Equal (expectedSize, tf.Size); tf.Draw (testBounds, new Attribute (), new Attribute ()); Assert.Equal (expectedSize, tf.Size); @@ -191,12 +191,12 @@ public void CalcRect_Vertical_Height_Correct (string text, TextDirection textDir public void ClipAndJustify_Invalid_Returns_Original (string text) { string expected = string.IsNullOrEmpty (text) ? text : ""; - Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, Justification.Left)); - Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, Justification.Left)); + Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, Alignment.Left)); + Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, Alignment.Left)); Assert.Throws ( () => - TextFormatter.ClipAndJustify (text, -1, Justification.Left) + TextFormatter.ClipAndJustify (text, -1, Alignment.Left) ); } @@ -219,7 +219,7 @@ public void ClipAndJustify_Invalid_Returns_Original (string text) [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit public void ClipAndJustify_Valid_Centered (string text, string justifiedText, int maxWidth) { - var justify = Justification.Centered; + var justify = Alignment.Centered; var textDirection = TextDirection.LeftRight_TopBottom; var tabWidth = 1; @@ -277,7 +277,7 @@ public void ClipAndJustify_Valid_Centered (string text, string justifiedText, in [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit public void ClipAndJustify_Valid_Justified (string text, string justifiedText, int maxWidth) { - var justify = Justification.Justified; + var justify = Alignment.Justified; var textDirection = TextDirection.LeftRight_TopBottom; var tabWidth = 1; @@ -328,7 +328,7 @@ public void ClipAndJustify_Valid_Justified (string text, string justifiedText, i [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit public void ClipAndJustify_Valid_Left (string text, string justifiedText, int maxWidth) { - var justify = Justification.Left; + var justify = Alignment.Left; var textDirection = TextDirection.LeftRight_BottomTop; var tabWidth = 1; @@ -377,7 +377,7 @@ public void ClipAndJustify_Valid_Left (string text, string justifiedText, int ma [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit public void ClipAndJustify_Valid_Right (string text, string justifiedText, int maxWidth) { - var justify = Justification.Right; + var justify = Alignment.Right; var textDirection = TextDirection.LeftRight_BottomTop; var tabWidth = 1; @@ -757,7 +757,7 @@ public void Format_Dont_Throw_ArgumentException_With_WordWrap_As_False_And_Keep_ TextFormatter.Format ( "Some text", 4, - Justification.Left, + Alignment.Left, false, true ) @@ -785,7 +785,7 @@ string justifiedText for (int i = text.GetRuneCount (); i < maxWidth; i++) { - fmtText = TextFormatter.Format (text, i, Justification.Justified, false, true) [0]; + fmtText = TextFormatter.Format (text, i, Alignment.Justified, false, true) [0]; Assert.Equal (i, fmtText.GetRuneCount ()); char c = fmtText [^1]; Assert.True (text.EndsWith (c)); @@ -817,7 +817,7 @@ string justifiedText fmtText = TextFormatter.Format ( text, i, - Justification.Justified, + Alignment.Justified, false, true, 0, @@ -862,7 +862,7 @@ IEnumerable expected " A sentence has words. \n This is the second Line - 2. ", 4, -50, - Justification.Left, + Alignment.Left, true, false, new [] { " A", "sent", "ence", "has", "word", "s. ", " Thi", "s is", "the", "seco", "nd", "Line", "- 2." }, @@ -872,7 +872,7 @@ IEnumerable expected " A sentence has words. \n This is the second Line - 2. ", 4, -50, - Justification.Left, + Alignment.Left, true, true, new [] @@ -900,7 +900,7 @@ public void Format_WordWrap_PreserveTrailingSpaces ( string text, int maxWidth, int widthOffset, - Justification Justification, + Alignment Justification, bool wrap, bool preserveTrailingSpaces, IEnumerable resultLines, @@ -1336,19 +1336,19 @@ public void NeedsFormat_Sets () Assert.NotEmpty (tf.GetLines ()); Assert.False (tf.NeedsFormat); // get_Lines causes a Format - tf.Justification = Justification.Centered; + tf.Justification = Alignment.Centered; Assert.True (tf.NeedsFormat); Assert.NotEmpty (tf.GetLines ()); Assert.False (tf.NeedsFormat); // get_Lines causes a Format } [Theory] - [InlineData ("", -1, Justification.Left, false, 0)] - [InlineData (null, 0, Justification.Left, false, 1)] - [InlineData (null, 0, Justification.Left, true, 1)] - [InlineData ("", 0, Justification.Left, false, 1)] - [InlineData ("", 0, Justification.Left, true, 1)] - public void Reformat_Invalid (string text, int maxWidth, Justification Justification, bool wrap, int linesCount) + [InlineData ("", -1, Alignment.Left, false, 0)] + [InlineData (null, 0, Alignment.Left, false, 1)] + [InlineData (null, 0, Alignment.Left, true, 1)] + [InlineData ("", 0, Alignment.Left, false, 1)] + [InlineData ("", 0, Alignment.Left, true, 1)] + public void Reformat_Invalid (string text, int maxWidth, Alignment Justification, bool wrap, int linesCount) { if (maxWidth < 0) { @@ -1367,25 +1367,25 @@ public void Reformat_Invalid (string text, int maxWidth, Justification Justifica } [Theory] - [InlineData ("A sentence has words.\nLine 2.", 0, -29, Justification.Left, false, 1, true)] - [InlineData ("A sentence has words.\nLine 2.", 1, -28, Justification.Left, false, 1, false)] - [InlineData ("A sentence has words.\nLine 2.", 5, -24, Justification.Left, false, 1, false)] - [InlineData ("A sentence has words.\nLine 2.", 28, -1, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.\nLine 2.", 0, -29, Alignment.Left, false, 1, true)] + [InlineData ("A sentence has words.\nLine 2.", 1, -28, Alignment.Left, false, 1, false)] + [InlineData ("A sentence has words.\nLine 2.", 5, -24, Alignment.Left, false, 1, false)] + [InlineData ("A sentence has words.\nLine 2.", 28, -1, Alignment.Left, false, 1, false)] // no clip - [InlineData ("A sentence has words.\nLine 2.", 29, 0, Justification.Left, false, 1, false)] - [InlineData ("A sentence has words.\nLine 2.", 30, 1, Justification.Left, false, 1, false)] - [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Justification.Left, false, 1, true)] - [InlineData ("A sentence has words.\r\nLine 2.", 1, -29, Justification.Left, false, 1, false)] - [InlineData ("A sentence has words.\r\nLine 2.", 5, -25, Justification.Left, false, 1, false)] - [InlineData ("A sentence has words.\r\nLine 2.", 29, -1, Justification.Left, false, 1, false, 1)] - [InlineData ("A sentence has words.\r\nLine 2.", 30, 0, Justification.Left, false, 1, false)] - [InlineData ("A sentence has words.\r\nLine 2.", 31, 1, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.\nLine 2.", 29, 0, Alignment.Left, false, 1, false)] + [InlineData ("A sentence has words.\nLine 2.", 30, 1, Alignment.Left, false, 1, false)] + [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Alignment.Left, false, 1, true)] + [InlineData ("A sentence has words.\r\nLine 2.", 1, -29, Alignment.Left, false, 1, false)] + [InlineData ("A sentence has words.\r\nLine 2.", 5, -25, Alignment.Left, false, 1, false)] + [InlineData ("A sentence has words.\r\nLine 2.", 29, -1, Alignment.Left, false, 1, false, 1)] + [InlineData ("A sentence has words.\r\nLine 2.", 30, 0, Alignment.Left, false, 1, false)] + [InlineData ("A sentence has words.\r\nLine 2.", 31, 1, Alignment.Left, false, 1, false)] public void Reformat_NoWordrap_NewLines_MultiLine_False ( string text, int maxWidth, int widthOffset, - Justification Justification, + Alignment Justification, bool wrap, int linesCount, bool stringEmpty, @@ -1430,12 +1430,12 @@ list [0] } [Theory] - [InlineData ("A sentence has words.\nLine 2.", 0, -29, Justification.Left, false, 1, true, new [] { "" })] + [InlineData ("A sentence has words.\nLine 2.", 0, -29, Alignment.Left, false, 1, true, new [] { "" })] [InlineData ( "A sentence has words.\nLine 2.", 1, -28, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1445,7 +1445,7 @@ list [0] "A sentence has words.\nLine 2.", 5, -24, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1455,7 +1455,7 @@ list [0] "A sentence has words.\nLine 2.", 28, -1, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1466,7 +1466,7 @@ list [0] "A sentence has words.\nLine 2.", 29, 0, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1476,18 +1476,18 @@ list [0] "A sentence has words.\nLine 2.", 30, 1, - Justification.Left, + Alignment.Left, false, 2, false, new [] { "A sentence has words.", "Line 2." } )] - [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Justification.Left, false, 1, true, new [] { "" })] + [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Alignment.Left, false, 1, true, new [] { "" })] [InlineData ( "A sentence has words.\r\nLine 2.", 1, -29, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1497,7 +1497,7 @@ list [0] "A sentence has words.\r\nLine 2.", 5, -25, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1507,7 +1507,7 @@ list [0] "A sentence has words.\r\nLine 2.", 29, -1, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1517,7 +1517,7 @@ list [0] "A sentence has words.\r\nLine 2.", 30, 0, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1527,7 +1527,7 @@ list [0] "A sentence has words.\r\nLine 2.", 31, 1, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1537,7 +1537,7 @@ public void Reformat_NoWordrap_NewLines_MultiLine_True ( string text, int maxWidth, int widthOffset, - Justification Justification, + Alignment Justification, bool wrap, int linesCount, bool stringEmpty, @@ -1572,12 +1572,12 @@ IEnumerable resultLines } [Theory] - [InlineData ("A sentence has words.\nLine 2.", 0, -29, Justification.Left, false, 1, true, new [] { "" })] + [InlineData ("A sentence has words.\nLine 2.", 0, -29, Alignment.Left, false, 1, true, new [] { "" })] [InlineData ( "A sentence has words.\nLine 2.", 1, -28, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1587,7 +1587,7 @@ IEnumerable resultLines "A sentence has words.\nLine 2.", 5, -24, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1597,7 +1597,7 @@ IEnumerable resultLines "A sentence has words.\nLine 2.", 28, -1, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1608,7 +1608,7 @@ IEnumerable resultLines "A sentence has words.\nLine 2.", 29, 0, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1618,18 +1618,18 @@ IEnumerable resultLines "A sentence has words.\nLine 2.", 30, 1, - Justification.Left, + Alignment.Left, false, 2, false, new [] { "A sentence has words.", "Line 2." } )] - [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Justification.Left, false, 1, true, new [] { "" })] + [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Alignment.Left, false, 1, true, new [] { "" })] [InlineData ( "A sentence has words.\r\nLine 2.", 1, -29, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1639,7 +1639,7 @@ IEnumerable resultLines "A sentence has words.\r\nLine 2.", 5, -25, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1649,7 +1649,7 @@ IEnumerable resultLines "A sentence has words.\r\nLine 2.", 29, -1, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1659,7 +1659,7 @@ IEnumerable resultLines "A sentence has words.\r\nLine 2.", 30, 0, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1669,7 +1669,7 @@ IEnumerable resultLines "A sentence has words.\r\nLine 2.", 31, 1, - Justification.Left, + Alignment.Left, false, 2, false, @@ -1679,7 +1679,7 @@ public void Reformat_NoWordrap_NewLines_MultiLine_True_Vertical ( string text, int maxWidth, int widthOffset, - Justification Justification, + Alignment Justification, bool wrap, int linesCount, bool stringEmpty, @@ -1714,21 +1714,21 @@ IEnumerable resultLines } [Theory] - [InlineData ("", 0, 0, Justification.Left, false, 1, true)] - [InlineData ("", 1, 1, Justification.Left, false, 1, true)] - [InlineData ("A sentence has words.", 0, -21, Justification.Left, false, 1, true)] - [InlineData ("A sentence has words.", 1, -20, Justification.Left, false, 1, false)] - [InlineData ("A sentence has words.", 5, -16, Justification.Left, false, 1, false)] - [InlineData ("A sentence has words.", 20, -1, Justification.Left, false, 1, false)] + [InlineData ("", 0, 0, Alignment.Left, false, 1, true)] + [InlineData ("", 1, 1, Alignment.Left, false, 1, true)] + [InlineData ("A sentence has words.", 0, -21, Alignment.Left, false, 1, true)] + [InlineData ("A sentence has words.", 1, -20, Alignment.Left, false, 1, false)] + [InlineData ("A sentence has words.", 5, -16, Alignment.Left, false, 1, false)] + [InlineData ("A sentence has words.", 20, -1, Alignment.Left, false, 1, false)] // no clip - [InlineData ("A sentence has words.", 21, 0, Justification.Left, false, 1, false)] - [InlineData ("A sentence has words.", 22, 1, Justification.Left, false, 1, false)] + [InlineData ("A sentence has words.", 21, 0, Alignment.Left, false, 1, false)] + [InlineData ("A sentence has words.", 22, 1, Alignment.Left, false, 1, false)] public void Reformat_NoWordrap_SingleLine ( string text, int maxWidth, int widthOffset, - Justification Justification, + Alignment Justification, bool wrap, int linesCount, bool stringEmpty @@ -1759,7 +1759,7 @@ bool stringEmpty "\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464", 8, -1, - Justification.Left, + Alignment.Left, true, false, new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" } @@ -1770,7 +1770,7 @@ bool stringEmpty "\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464", 9, 0, - Justification.Left, + Alignment.Left, true, false, new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" } @@ -1779,7 +1779,7 @@ bool stringEmpty "\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464", 10, 1, - Justification.Left, + Alignment.Left, true, false, new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" } @@ -1788,7 +1788,7 @@ public void Reformat_Unicode_Wrap_Spaces_NewLines ( string text, int maxWidth, int widthOffset, - Justification Justification, + Alignment Justification, bool wrap, bool preserveTrailingSpaces, IEnumerable resultLines @@ -1805,25 +1805,25 @@ IEnumerable resultLines // Unicode // Even # of chars // 0123456789 - [InlineData ("\u2660пÑРвРÑ", 10, -1, Justification.Left, true, false, new [] { "\u2660пÑРвÐ", "Ñ" })] + [InlineData ("\u2660пÑРвРÑ", 10, -1, Alignment.Left, true, false, new [] { "\u2660пÑРвÐ", "Ñ" })] // no clip - [InlineData ("\u2660пÑРвРÑ", 11, 0, Justification.Left, true, false, new [] { "\u2660пÑРвРÑ" })] - [InlineData ("\u2660пÑРвРÑ", 12, 1, Justification.Left, true, false, new [] { "\u2660пÑРвРÑ" })] + [InlineData ("\u2660пÑРвРÑ", 11, 0, Alignment.Left, true, false, new [] { "\u2660пÑРвРÑ" })] + [InlineData ("\u2660пÑРвРÑ", 12, 1, Alignment.Left, true, false, new [] { "\u2660пÑРвРÑ" })] // Unicode // Odd # of chars // 0123456789 - [InlineData ("\u2660 ÑРвРÑ", 9, -1, Justification.Left, true, false, new [] { "\u2660 ÑРвÐ", "Ñ" })] + [InlineData ("\u2660 ÑРвРÑ", 9, -1, Alignment.Left, true, false, new [] { "\u2660 ÑРвÐ", "Ñ" })] // no clip - [InlineData ("\u2660 ÑРвРÑ", 10, 0, Justification.Left, true, false, new [] { "\u2660 ÑРвРÑ" })] - [InlineData ("\u2660 ÑРвРÑ", 11, 1, Justification.Left, true, false, new [] { "\u2660 ÑРвРÑ" })] + [InlineData ("\u2660 ÑРвРÑ", 10, 0, Alignment.Left, true, false, new [] { "\u2660 ÑРвРÑ" })] + [InlineData ("\u2660 ÑРвРÑ", 11, 1, Alignment.Left, true, false, new [] { "\u2660 ÑРвРÑ" })] public void Reformat_Unicode_Wrap_Spaces_No_NewLines ( string text, int maxWidth, int widthOffset, - Justification Justification, + Alignment Justification, bool wrap, bool preserveTrailingSpaces, IEnumerable resultLines @@ -1839,37 +1839,37 @@ IEnumerable resultLines // Even # of spaces // 0123456789 - [InlineData ("012 456 89", 0, -10, Justification.Left, true, true, true, new [] { "" })] + [InlineData ("012 456 89", 0, -10, Alignment.Left, true, true, true, new [] { "" })] [InlineData ( "012 456 89", 1, -9, - Justification.Left, + Alignment.Left, true, true, false, new [] { "0", "1", "2", " ", "4", "5", "6", " ", "8", "9" }, "01245689" )] - [InlineData ("012 456 89", 5, -5, Justification.Left, true, true, false, new [] { "012 ", "456 ", "89" })] - [InlineData ("012 456 89", 9, -1, Justification.Left, true, true, false, new [] { "012 456 ", "89" })] + [InlineData ("012 456 89", 5, -5, Alignment.Left, true, true, false, new [] { "012 ", "456 ", "89" })] + [InlineData ("012 456 89", 9, -1, Alignment.Left, true, true, false, new [] { "012 456 ", "89" })] // no clip - [InlineData ("012 456 89", 10, 0, Justification.Left, true, true, false, new [] { "012 456 89" })] - [InlineData ("012 456 89", 11, 1, Justification.Left, true, true, false, new [] { "012 456 89" })] + [InlineData ("012 456 89", 10, 0, Alignment.Left, true, true, false, new [] { "012 456 89" })] + [InlineData ("012 456 89", 11, 1, Alignment.Left, true, true, false, new [] { "012 456 89" })] // Odd # of spaces // 01234567890123 - [InlineData ("012 456 89 end", 13, -1, Justification.Left, true, true, false, new [] { "012 456 89 ", "end" })] + [InlineData ("012 456 89 end", 13, -1, Alignment.Left, true, true, false, new [] { "012 456 89 ", "end" })] // no clip - [InlineData ("012 456 89 end", 14, 0, Justification.Left, true, true, false, new [] { "012 456 89 end" })] - [InlineData ("012 456 89 end", 15, 1, Justification.Left, true, true, false, new [] { "012 456 89 end" })] + [InlineData ("012 456 89 end", 14, 0, Alignment.Left, true, true, false, new [] { "012 456 89 end" })] + [InlineData ("012 456 89 end", 15, 1, Alignment.Left, true, true, false, new [] { "012 456 89 end" })] public void Reformat_Wrap_Spaces_No_NewLines ( string text, int maxWidth, int widthOffset, - Justification Justification, + Alignment Justification, bool wrap, bool preserveTrailingSpaces, bool stringEmpty, @@ -1909,7 +1909,7 @@ public void Reformat_Wrap_Spaces_No_NewLines ( ); } - list = TextFormatter.Format (text, maxWidth, Justification.Left, wrap); + list = TextFormatter.Format (text, maxWidth, Alignment.Left, wrap); if (maxWidth == 1) { @@ -3159,7 +3159,7 @@ public void Draw_Horizontal_Left (string text, int width, bool autoSize, string TextFormatter tf = new () { Text = text, - Justification = Justification.Left, + Justification = Alignment.Left, AutoSize = autoSize, }; @@ -3196,7 +3196,7 @@ public void Draw_Horizontal_Right (string text, int width, bool autoSize, string TextFormatter tf = new () { Text = text, - Justification = Justification.Right, + Justification = Alignment.Right, AutoSize = autoSize, }; @@ -3239,7 +3239,7 @@ public void Draw_Horizontal_Centered (string text, int width, bool autoSize, str TextFormatter tf = new () { Text = text, - Justification = Justification.Centered, + Justification = Alignment.Centered, AutoSize = autoSize, }; @@ -3284,7 +3284,7 @@ public void Draw_Horizontal_Justified (string text, int width, bool autoSize, st TextFormatter tf = new () { Text = text, - Justification = Justification.Justified, + Justification = Alignment.Justified, AutoSize = autoSize, }; @@ -3374,7 +3374,7 @@ public void Justify_Horizontal (string text, int width, int height, string expec TextFormatter tf = new () { Text = text, - Justification = Justification.Justified, + Justification = Alignment.Justified, Size = new Size (width, height), MultiLine = true }; @@ -3426,7 +3426,7 @@ public void Justify_Vertical (string text, int width, int height, string expecte { Text = text, Direction = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Justified, + VerticalJustification = Alignment.Justified, Size = new Size (width, height), MultiLine = true }; @@ -3482,9 +3482,9 @@ public void Draw_Vertical_Bottom_Horizontal_Right (string text, int width, int h TextFormatter tf = new () { Text = text, - Justification = Justification.Right, + Justification = Alignment.Right, Direction = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Bottom, + VerticalJustification = Alignment.Bottom, AutoSize = autoSize, }; @@ -3624,7 +3624,7 @@ public void Draw_Vertical_TopBottom_LeftRight_Middle (string text, int height, b { Text = text, Direction = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Centered, + VerticalJustification = Alignment.Centered, AutoSize = autoSize, }; @@ -3882,7 +3882,7 @@ public void Draw_Vertical_Throws_IndexOutOfRangeException_With_Negative_Bounds ( // Horizontal with Justification.Top // LeftRight_TopBottom - [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Top, TextDirection.LeftRight_TopBottom, @" 0 2 4** ******* ******* @@ -3890,7 +3890,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Top, TextDirection.LeftRight_TopBottom, @" **0 2 4 ******* ******* @@ -3898,7 +3898,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Top, TextDirection.LeftRight_TopBottom, @" *0 2 4* ******* ******* @@ -3906,7 +3906,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Top, TextDirection.LeftRight_TopBottom, @" 0 2 4 ******* ******* @@ -3915,7 +3915,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Top, TextDirection.LeftRight_TopBottom, @" 0 你 4* ******* ******* @@ -3923,7 +3923,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Top, TextDirection.LeftRight_TopBottom, @" *0 你 4 ******* ******* @@ -3931,7 +3931,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Top, TextDirection.LeftRight_TopBottom, @" 0 你 4* ******* ******* @@ -3939,7 +3939,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Top, TextDirection.LeftRight_TopBottom, @" 0 你 4 ******* ******* @@ -3949,7 +3949,7 @@ 0 你 4 *******")] // LeftRight_BottomTop - [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Top, TextDirection.LeftRight_BottomTop, @" 0 2 4** ******* ******* @@ -3957,7 +3957,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Top, TextDirection.LeftRight_BottomTop, @" **0 2 4 ******* ******* @@ -3965,7 +3965,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Top, TextDirection.LeftRight_BottomTop, @" *0 2 4* ******* ******* @@ -3973,7 +3973,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Top, TextDirection.LeftRight_BottomTop, @" 0 2 4 ******* ******* @@ -3982,7 +3982,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Top, TextDirection.LeftRight_BottomTop, @" 0 你 4* ******* ******* @@ -3990,7 +3990,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Top, TextDirection.LeftRight_BottomTop, @" *0 你 4 ******* ******* @@ -3998,7 +3998,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Top, TextDirection.LeftRight_BottomTop, @" 0 你 4* ******* ******* @@ -4006,7 +4006,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Top, TextDirection.LeftRight_BottomTop, @" 0 你 4 ******* ******* @@ -4016,7 +4016,7 @@ 0 你 4 *******")] // RightLeft_TopBottom - [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Top, TextDirection.RightLeft_TopBottom, @" 4 2 0** ******* ******* @@ -4024,7 +4024,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Top, TextDirection.RightLeft_TopBottom, @" **4 2 0 ******* ******* @@ -4032,7 +4032,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Top, TextDirection.RightLeft_TopBottom, @" *4 2 0* ******* ******* @@ -4040,7 +4040,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Top, TextDirection.RightLeft_TopBottom, @" 4 2 0 ******* ******* @@ -4049,7 +4049,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Top, TextDirection.RightLeft_TopBottom, @" 4 你 0* ******* ******* @@ -4057,7 +4057,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Top, TextDirection.RightLeft_TopBottom, @" *4 你 0 ******* ******* @@ -4065,7 +4065,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Top, TextDirection.RightLeft_TopBottom, @" 4 你 0* ******* ******* @@ -4073,7 +4073,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Top, TextDirection.RightLeft_TopBottom, @" 4 你 0 ******* ******* @@ -4083,7 +4083,7 @@ 4 你 0 *******")] // RightLeft_BottomTop - [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Top, TextDirection.RightLeft_BottomTop, @" 4 2 0** ******* ******* @@ -4091,7 +4091,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Top, TextDirection.RightLeft_BottomTop, @" **4 2 0 ******* ******* @@ -4099,7 +4099,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Top, TextDirection.RightLeft_BottomTop, @" *4 2 0* ******* ******* @@ -4107,7 +4107,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Top, TextDirection.RightLeft_BottomTop, @" 4 2 0 ******* ******* @@ -4116,7 +4116,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Top, TextDirection.RightLeft_BottomTop, @" 4 你 0* ******* ******* @@ -4124,7 +4124,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Top, TextDirection.RightLeft_BottomTop, @" *4 你 0 ******* ******* @@ -4132,7 +4132,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Top, TextDirection.RightLeft_BottomTop, @" 4 你 0* ******* ******* @@ -4140,7 +4140,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Top, TextDirection.RightLeft_BottomTop, @" 4 你 0 ******* ******* @@ -4151,7 +4151,7 @@ 4 你 0 // Horizontal with Justification.Bottom // LeftRight_TopBottom - [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4159,7 +4159,7 @@ 4 你 0 ******* ******* 0 2 4**")] - [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4167,7 +4167,7 @@ 4 你 0 ******* ******* **0 2 4")] - [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4175,7 +4175,7 @@ 4 你 0 ******* ******* *0 2 4*")] - [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4184,7 +4184,7 @@ 4 你 0 ******* 0 2 4")] - [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4192,7 +4192,7 @@ 4 你 0 ******* ******* 0 你 4*")] - [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4200,7 +4200,7 @@ 4 你 0 ******* ******* *0 你 4")] - [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4208,7 +4208,7 @@ 4 你 0 ******* ******* 0 你 4*")] - [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Bottom, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4218,7 +4218,7 @@ 4 你 0 0 你 4")] // LeftRight_BottomTop - [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4226,7 +4226,7 @@ 4 你 0 ******* ******* 0 2 4**")] - [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4234,7 +4234,7 @@ 4 你 0 ******* ******* **0 2 4")] - [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4242,7 +4242,7 @@ 4 你 0 ******* ******* *0 2 4*")] - [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4251,7 +4251,7 @@ 4 你 0 ******* 0 2 4")] - [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4259,7 +4259,7 @@ 4 你 0 ******* ******* 0 你 4*")] - [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4267,7 +4267,7 @@ 4 你 0 ******* ******* *0 你 4")] - [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4275,7 +4275,7 @@ 4 你 0 ******* ******* 0 你 4*")] - [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Bottom, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4285,7 +4285,7 @@ 4 你 0 0 你 4")] // RightLeft_TopBottom - [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4293,7 +4293,7 @@ 4 你 0 ******* ******* 4 2 0**")] - [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4301,7 +4301,7 @@ 4 你 0 ******* ******* **4 2 0")] - [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4309,7 +4309,7 @@ 4 你 0 ******* ******* *4 2 0*")] - [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4318,7 +4318,7 @@ 4 你 0 ******* 4 2 0")] - [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4326,7 +4326,7 @@ 4 你 0 ******* ******* 4 你 0*")] - [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4334,7 +4334,7 @@ 4 你 0 ******* ******* *4 你 0")] - [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4342,7 +4342,7 @@ 4 你 0 ******* ******* 4 你 0*")] - [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Bottom, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4352,7 +4352,7 @@ 4 你 0 4 你 0")] // RightLeft_BottomTop - [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4360,7 +4360,7 @@ 4 你 0 ******* ******* 4 2 0**")] - [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4368,7 +4368,7 @@ 4 你 0 ******* ******* **4 2 0")] - [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4376,7 +4376,7 @@ 4 你 0 ******* ******* *4 2 0*")] - [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4385,7 +4385,7 @@ 4 你 0 ******* 4 2 0")] - [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4393,7 +4393,7 @@ 4 你 0 ******* ******* 4 你 0*")] - [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4401,7 +4401,7 @@ 4 你 0 ******* ******* *4 你 0")] - [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4409,7 +4409,7 @@ 4 你 0 ******* ******* 4 你 0*")] - [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Bottom, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4420,7 +4420,7 @@ 4 你 0 // Horizontal with Justification.Centered // LeftRight_TopBottom - [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4428,7 +4428,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4436,7 +4436,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4444,7 +4444,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4453,7 +4453,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4461,7 +4461,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4469,7 +4469,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4477,7 +4477,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Centered, TextDirection.LeftRight_TopBottom, @" ******* ******* ******* @@ -4487,7 +4487,7 @@ 0 你 4 *******")] // LeftRight_BottomTop - [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4495,7 +4495,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4503,7 +4503,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4511,7 +4511,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4520,7 +4520,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4528,7 +4528,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4536,7 +4536,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4544,7 +4544,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Centered, TextDirection.LeftRight_BottomTop, @" ******* ******* ******* @@ -4554,7 +4554,7 @@ 0 你 4 *******")] // RightLeft_TopBottom - [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4562,7 +4562,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4570,7 +4570,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4578,7 +4578,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4587,7 +4587,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4595,7 +4595,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4603,7 +4603,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4611,7 +4611,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Centered, TextDirection.RightLeft_TopBottom, @" ******* ******* ******* @@ -4621,7 +4621,7 @@ 4 你 0 *******")] // RightLeft_BottomTop - [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4629,7 +4629,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4637,7 +4637,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4645,7 +4645,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4654,7 +4654,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4662,7 +4662,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4670,7 +4670,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4678,7 +4678,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Centered, TextDirection.RightLeft_BottomTop, @" ******* ******* ******* @@ -4689,7 +4689,7 @@ 4 你 0 // Horizontal with Justification.Justified // LeftRight_TopBottom - [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Justified, TextDirection.LeftRight_TopBottom, @" 0 2 4** ******* ******* @@ -4697,7 +4697,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Justified, TextDirection.LeftRight_TopBottom, @" **0 2 4 ******* ******* @@ -4705,7 +4705,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Justified, TextDirection.LeftRight_TopBottom, @" *0 2 4* ******* ******* @@ -4713,7 +4713,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Justified, TextDirection.LeftRight_TopBottom, @" 0 2 4 ******* ******* @@ -4722,7 +4722,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Justified, TextDirection.LeftRight_TopBottom, @" 0 你 4* ******* ******* @@ -4730,7 +4730,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Justified, TextDirection.LeftRight_TopBottom, @" *0 你 4 ******* ******* @@ -4738,7 +4738,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Justified, TextDirection.LeftRight_TopBottom, @" 0 你 4* ******* ******* @@ -4746,7 +4746,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.LeftRight_TopBottom, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Justified, TextDirection.LeftRight_TopBottom, @" 0 你 4 ******* ******* @@ -4756,7 +4756,7 @@ 0 你 4 *******")] // LeftRight_BottomTop - [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Justified, TextDirection.LeftRight_BottomTop, @" 0 2 4** ******* ******* @@ -4764,7 +4764,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Justified, TextDirection.LeftRight_BottomTop, @" **0 2 4 ******* ******* @@ -4772,7 +4772,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Justified, TextDirection.LeftRight_BottomTop, @" *0 2 4* ******* ******* @@ -4780,7 +4780,7 @@ 0 2 4** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Justified, TextDirection.LeftRight_BottomTop, @" 0 2 4 ******* ******* @@ -4789,7 +4789,7 @@ 0 2 4 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Justified, TextDirection.LeftRight_BottomTop, @" 0 你 4* ******* ******* @@ -4797,7 +4797,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Justified, TextDirection.LeftRight_BottomTop, @" *0 你 4 ******* ******* @@ -4805,7 +4805,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Justified, TextDirection.LeftRight_BottomTop, @" 0 你 4* ******* ******* @@ -4813,7 +4813,7 @@ 0 你 4* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.LeftRight_BottomTop, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Justified, TextDirection.LeftRight_BottomTop, @" 0 你 4 ******* ******* @@ -4823,7 +4823,7 @@ 0 你 4 *******")] // RightLeft_TopBottom - [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Justified, TextDirection.RightLeft_TopBottom, @" 4 2 0** ******* ******* @@ -4831,7 +4831,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Justified, TextDirection.RightLeft_TopBottom, @" **4 2 0 ******* ******* @@ -4839,7 +4839,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Justified, TextDirection.RightLeft_TopBottom, @" *4 2 0* ******* ******* @@ -4847,7 +4847,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Justified, TextDirection.RightLeft_TopBottom, @" 4 2 0 ******* ******* @@ -4856,7 +4856,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Justified, TextDirection.RightLeft_TopBottom, @" 4 你 0* ******* ******* @@ -4864,7 +4864,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Justified, TextDirection.RightLeft_TopBottom, @" *4 你 0 ******* ******* @@ -4872,7 +4872,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Justified, TextDirection.RightLeft_TopBottom, @" 4 你 0* ******* ******* @@ -4880,7 +4880,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.RightLeft_TopBottom, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Justified, TextDirection.RightLeft_TopBottom, @" 4 你 0 ******* ******* @@ -4890,7 +4890,7 @@ 4 你 0 *******")] // RightLeft_BottomTop - [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Justified, TextDirection.RightLeft_BottomTop, @" 4 2 0** ******* ******* @@ -4898,7 +4898,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Justified, TextDirection.RightLeft_BottomTop, @" **4 2 0 ******* ******* @@ -4906,7 +4906,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Justified, TextDirection.RightLeft_BottomTop, @" *4 2 0* ******* ******* @@ -4914,7 +4914,7 @@ 4 2 0** ******* ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Justified, TextDirection.RightLeft_BottomTop, @" 4 2 0 ******* ******* @@ -4923,7 +4923,7 @@ 4 2 0 ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Justified, TextDirection.RightLeft_BottomTop, @" 4 你 0* ******* ******* @@ -4931,7 +4931,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Justified, TextDirection.RightLeft_BottomTop, @" *4 你 0 ******* ******* @@ -4939,7 +4939,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Justified, TextDirection.RightLeft_BottomTop, @" 4 你 0* ******* ******* @@ -4947,7 +4947,7 @@ 4 你 0* ******* ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.RightLeft_BottomTop, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Justified, TextDirection.RightLeft_BottomTop, @" 4 你 0 ******* ******* @@ -4958,7 +4958,7 @@ 4 你 0 // Vertical with Justification.Left // TopBottom_LeftRight - [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Top, TextDirection.TopBottom_LeftRight, @" 0****** ****** 2****** @@ -4966,7 +4966,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* 0****** @@ -4974,7 +4974,7 @@ 4 你 0 2****** ****** 4******")] - [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Centered, TextDirection.TopBottom_LeftRight, @" ******* 0****** ****** @@ -4982,7 +4982,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Justified, TextDirection.TopBottom_LeftRight, @" 0****** ****** ****** @@ -4991,7 +4991,7 @@ 4 你 0 ****** 4******")] - [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Top, TextDirection.TopBottom_LeftRight, @" 0****** ****** 你***** @@ -4999,7 +4999,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* 0****** @@ -5007,7 +5007,7 @@ 4 你 0 你***** ****** 4******")] - [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Centered, TextDirection.TopBottom_LeftRight, @" ******* 0****** ****** @@ -5015,7 +5015,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Justified, TextDirection.TopBottom_LeftRight, @" 0****** ****** ****** @@ -5025,7 +5025,7 @@ 4 你 0 4******")] // TopBottom_RightLeft - [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Top, TextDirection.TopBottom_RightLeft, @" 0****** ****** 2****** @@ -5033,7 +5033,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* 0****** @@ -5041,7 +5041,7 @@ 4 你 0 2****** ****** 4******")] - [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Centered, TextDirection.TopBottom_RightLeft, @" ******* 0****** ****** @@ -5049,7 +5049,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Justified, TextDirection.TopBottom_RightLeft, @" 0****** ****** ****** @@ -5058,7 +5058,7 @@ 4 你 0 ****** 4******")] - [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Top, TextDirection.TopBottom_RightLeft, @" 0****** ****** 你***** @@ -5066,7 +5066,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* 0****** @@ -5074,7 +5074,7 @@ 4 你 0 你***** ****** 4******")] - [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Centered, TextDirection.TopBottom_RightLeft, @" ******* 0****** ****** @@ -5082,7 +5082,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Justified, TextDirection.TopBottom_RightLeft, @" 0****** ****** ****** @@ -5092,7 +5092,7 @@ 4 你 0 4******")] // BottomTop_LeftRight - [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Top, TextDirection.BottomTop_LeftRight, @" 4****** ****** 2****** @@ -5100,7 +5100,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* 4****** @@ -5108,7 +5108,7 @@ 4 你 0 2****** ****** 0******")] - [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Centered, TextDirection.BottomTop_LeftRight, @" ******* 4****** ****** @@ -5116,7 +5116,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Justified, TextDirection.BottomTop_LeftRight, @" 4****** ****** ****** @@ -5125,7 +5125,7 @@ 4 你 0 ****** 0******")] - [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Top, TextDirection.BottomTop_LeftRight, @" 4****** ****** 你***** @@ -5133,7 +5133,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* 4****** @@ -5141,7 +5141,7 @@ 4 你 0 你***** ****** 0******")] - [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Centered, TextDirection.BottomTop_LeftRight, @" ******* 4****** ****** @@ -5149,7 +5149,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Justified, TextDirection.BottomTop_LeftRight, @" 4****** ****** ****** @@ -5159,7 +5159,7 @@ 4 你 0 0******")] // BottomTop_RightLeft - [InlineData ("0 2 4", Justification.Left, Justification.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Top, TextDirection.BottomTop_RightLeft, @" 4****** ****** 2****** @@ -5167,7 +5167,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 2 4", Justification.Left, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* 4****** @@ -5175,7 +5175,7 @@ 4 你 0 2****** ****** 0******")] - [InlineData ("0 2 4", Justification.Left, Justification.Centered, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Centered, TextDirection.BottomTop_RightLeft, @" ******* 4****** ****** @@ -5183,7 +5183,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 2 4", Justification.Left, Justification.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Left, Alignment.Justified, TextDirection.BottomTop_RightLeft, @" 4****** ****** ****** @@ -5192,7 +5192,7 @@ 4 你 0 ****** 0******")] - [InlineData ("0 你 4", Justification.Left, Justification.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Top, TextDirection.BottomTop_RightLeft, @" 4****** ****** 你***** @@ -5200,7 +5200,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* 4****** @@ -5208,7 +5208,7 @@ 4 你 0 你***** ****** 0******")] - [InlineData ("0 你 4", Justification.Left, Justification.Centered, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Centered, TextDirection.BottomTop_RightLeft, @" ******* 4****** ****** @@ -5216,7 +5216,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 你 4", Justification.Left, Justification.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Left, Alignment.Justified, TextDirection.BottomTop_RightLeft, @" 4****** ****** ****** @@ -5227,7 +5227,7 @@ 4 你 0 // Vertical with Justification.Right // TopBottom_LeftRight - [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Top, TextDirection.TopBottom_LeftRight, @" ******0 ****** ******2 @@ -5235,7 +5235,7 @@ 4 你 0 ******4 ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* ******0 @@ -5243,7 +5243,7 @@ 4 你 0 ******2 ****** ******4")] - [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Centered, TextDirection.TopBottom_LeftRight, @" ******* ******0 ****** @@ -5251,7 +5251,7 @@ 4 你 0 ****** ******4 *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Justified, TextDirection.TopBottom_LeftRight, @" ******0 ****** ****** @@ -5260,7 +5260,7 @@ 4 你 0 ****** ******4")] - [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Top, TextDirection.TopBottom_LeftRight, @" *****0* ***** * *****你 @@ -5268,7 +5268,7 @@ 4 你 0 *****4* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* *****0* @@ -5276,7 +5276,7 @@ 4 你 0 *****你 ***** * *****4*")] - [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Centered, TextDirection.TopBottom_LeftRight, @" ******* *****0* ***** * @@ -5284,7 +5284,7 @@ 4 你 0 ***** * *****4* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Justified, TextDirection.TopBottom_LeftRight, @" *****0* ***** * ***** * @@ -5294,7 +5294,7 @@ 4 你 0 *****4*")] // TopBottom_RightLeft - [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Top, TextDirection.TopBottom_RightLeft, @" ******0 ****** ******2 @@ -5302,7 +5302,7 @@ 4 你 0 ******4 ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* ******0 @@ -5310,7 +5310,7 @@ 4 你 0 ******2 ****** ******4")] - [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Centered, TextDirection.TopBottom_RightLeft, @" ******* ******0 ****** @@ -5318,7 +5318,7 @@ 4 你 0 ****** ******4 *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Justified, TextDirection.TopBottom_RightLeft, @" ******0 ****** ****** @@ -5327,7 +5327,7 @@ 4 你 0 ****** ******4")] - [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Top, TextDirection.TopBottom_RightLeft, @" *****0* ***** * *****你 @@ -5335,7 +5335,7 @@ 4 你 0 *****4* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* *****0* @@ -5343,7 +5343,7 @@ 4 你 0 *****你 ***** * *****4*")] - [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Centered, TextDirection.TopBottom_RightLeft, @" ******* *****0* ***** * @@ -5351,7 +5351,7 @@ 4 你 0 ***** * *****4* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Justified, TextDirection.TopBottom_RightLeft, @" *****0* ***** * ***** * @@ -5361,7 +5361,7 @@ 4 你 0 *****4*")] // BottomTop_LeftRight - [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Top, TextDirection.BottomTop_LeftRight, @" ******4 ****** ******2 @@ -5369,7 +5369,7 @@ 4 你 0 ******0 ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* ******4 @@ -5377,7 +5377,7 @@ 4 你 0 ******2 ****** ******0")] - [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Centered, TextDirection.BottomTop_LeftRight, @" ******* ******4 ****** @@ -5385,7 +5385,7 @@ 4 你 0 ****** ******0 *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Justified, TextDirection.BottomTop_LeftRight, @" ******4 ****** ****** @@ -5394,7 +5394,7 @@ 4 你 0 ****** ******0")] - [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Top, TextDirection.BottomTop_LeftRight, @" *****4* ***** * *****你 @@ -5402,7 +5402,7 @@ 4 你 0 *****0* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* *****4* @@ -5410,7 +5410,7 @@ 4 你 0 *****你 ***** * *****0*")] - [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Centered, TextDirection.BottomTop_LeftRight, @" ******* *****4* ***** * @@ -5418,7 +5418,7 @@ 4 你 0 ***** * *****0* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Justified, TextDirection.BottomTop_LeftRight, @" *****4* ***** * ***** * @@ -5428,7 +5428,7 @@ 4 你 0 *****0*")] // BottomTop_RightLeft - [InlineData ("0 2 4", Justification.Right, Justification.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Top, TextDirection.BottomTop_RightLeft, @" ******4 ****** ******2 @@ -5436,7 +5436,7 @@ 4 你 0 ******0 ******* *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* ******4 @@ -5444,7 +5444,7 @@ 4 你 0 ******2 ****** ******0")] - [InlineData ("0 2 4", Justification.Right, Justification.Centered, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Centered, TextDirection.BottomTop_RightLeft, @" ******* ******4 ****** @@ -5452,7 +5452,7 @@ 4 你 0 ****** ******0 *******")] - [InlineData ("0 2 4", Justification.Right, Justification.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Right, Alignment.Justified, TextDirection.BottomTop_RightLeft, @" ******4 ****** ****** @@ -5461,7 +5461,7 @@ 4 你 0 ****** ******0")] - [InlineData ("0 你 4", Justification.Right, Justification.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Top, TextDirection.BottomTop_RightLeft, @" *****4* ***** * *****你 @@ -5469,7 +5469,7 @@ 4 你 0 *****0* ******* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* *****4* @@ -5477,7 +5477,7 @@ 4 你 0 *****你 ***** * *****0*")] - [InlineData ("0 你 4", Justification.Right, Justification.Centered, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Centered, TextDirection.BottomTop_RightLeft, @" ******* *****4* ***** * @@ -5485,7 +5485,7 @@ 4 你 0 ***** * *****0* *******")] - [InlineData ("0 你 4", Justification.Right, Justification.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Right, Alignment.Justified, TextDirection.BottomTop_RightLeft, @" *****4* ***** * ***** * @@ -5496,7 +5496,7 @@ 4 你 0 // Vertical with Justification.Centered // TopBottom_LeftRight - [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Top, TextDirection.TopBottom_LeftRight, @" ***0*** *** *** ***2*** @@ -5504,7 +5504,7 @@ 4 你 0 ***4*** ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* ***0*** @@ -5512,7 +5512,7 @@ 4 你 0 ***2*** *** *** ***4***")] - [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Centered, TextDirection.TopBottom_LeftRight, @" ******* ***0*** *** *** @@ -5520,7 +5520,7 @@ 4 你 0 *** *** ***4*** *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Justified, TextDirection.TopBottom_LeftRight, @" ***0*** *** *** *** *** @@ -5529,7 +5529,7 @@ 4 你 0 *** *** ***4***")] - [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Top, TextDirection.TopBottom_LeftRight, @" **0**** ** **** **你*** @@ -5537,7 +5537,7 @@ 4 你 0 **4**** ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* **0**** @@ -5545,7 +5545,7 @@ 4 你 0 **你*** ** **** **4****")] - [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Centered, TextDirection.TopBottom_LeftRight, @" ******* **0**** ** **** @@ -5553,7 +5553,7 @@ 4 你 0 ** **** **4**** *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Justified, TextDirection.TopBottom_LeftRight, @" **0**** ** **** ** **** @@ -5563,7 +5563,7 @@ 4 你 0 **4****")] // TopBottom_RightLeft - [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Top, TextDirection.TopBottom_RightLeft, @" ***0*** *** *** ***2*** @@ -5571,7 +5571,7 @@ 4 你 0 ***4*** ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* ***0*** @@ -5579,7 +5579,7 @@ 4 你 0 ***2*** *** *** ***4***")] - [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Centered, TextDirection.TopBottom_RightLeft, @" ******* ***0*** *** *** @@ -5587,7 +5587,7 @@ 4 你 0 *** *** ***4*** *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Justified, TextDirection.TopBottom_RightLeft, @" ***0*** *** *** *** *** @@ -5596,7 +5596,7 @@ 4 你 0 *** *** ***4***")] - [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Top, TextDirection.TopBottom_RightLeft, @" **0**** ** **** **你*** @@ -5604,7 +5604,7 @@ 4 你 0 **4**** ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* **0**** @@ -5612,7 +5612,7 @@ 4 你 0 **你*** ** **** **4****")] - [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Centered, TextDirection.TopBottom_RightLeft, @" ******* **0**** ** **** @@ -5620,7 +5620,7 @@ 4 你 0 ** **** **4**** *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Justified, TextDirection.TopBottom_RightLeft, @" **0**** ** **** ** **** @@ -5630,7 +5630,7 @@ 4 你 0 **4****")] // BottomTop_LeftRight - [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Top, TextDirection.BottomTop_LeftRight, @" ***4*** *** *** ***2*** @@ -5638,7 +5638,7 @@ 4 你 0 ***0*** ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* ***4*** @@ -5646,7 +5646,7 @@ 4 你 0 ***2*** *** *** ***0***")] - [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Centered, TextDirection.BottomTop_LeftRight, @" ******* ***4*** *** *** @@ -5654,7 +5654,7 @@ 4 你 0 *** *** ***0*** *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Justified, TextDirection.BottomTop_LeftRight, @" ***4*** *** *** *** *** @@ -5663,7 +5663,7 @@ 4 你 0 *** *** ***0***")] - [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Top, TextDirection.BottomTop_LeftRight, @" **4**** ** **** **你*** @@ -5671,7 +5671,7 @@ 4 你 0 **0**** ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* **4**** @@ -5679,7 +5679,7 @@ 4 你 0 **你*** ** **** **0****")] - [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Centered, TextDirection.BottomTop_LeftRight, @" ******* **4**** ** **** @@ -5687,7 +5687,7 @@ 4 你 0 ** **** **0**** *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Justified, TextDirection.BottomTop_LeftRight, @" **4**** ** **** ** **** @@ -5697,7 +5697,7 @@ 4 你 0 **0****")] // BottomTop_RightLeft - [InlineData ("0 2 4", Justification.Centered, Justification.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Top, TextDirection.BottomTop_RightLeft, @" ***4*** *** *** ***2*** @@ -5705,7 +5705,7 @@ 4 你 0 ***0*** ******* *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* ***4*** @@ -5713,7 +5713,7 @@ 4 你 0 ***2*** *** *** ***0***")] - [InlineData ("0 2 4", Justification.Centered, Justification.Centered, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Centered, TextDirection.BottomTop_RightLeft, @" ******* ***4*** *** *** @@ -5721,7 +5721,7 @@ 4 你 0 *** *** ***0*** *******")] - [InlineData ("0 2 4", Justification.Centered, Justification.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Centered, Alignment.Justified, TextDirection.BottomTop_RightLeft, @" ***4*** *** *** *** *** @@ -5730,7 +5730,7 @@ 4 你 0 *** *** ***0***")] - [InlineData ("0 你 4", Justification.Centered, Justification.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Top, TextDirection.BottomTop_RightLeft, @" **4**** ** **** **你*** @@ -5738,7 +5738,7 @@ 4 你 0 **0**** ******* *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* **4**** @@ -5746,7 +5746,7 @@ 4 你 0 **你*** ** **** **0****")] - [InlineData ("0 你 4", Justification.Centered, Justification.Centered, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Centered, TextDirection.BottomTop_RightLeft, @" ******* **4**** ** **** @@ -5754,7 +5754,7 @@ 4 你 0 ** **** **0**** *******")] - [InlineData ("0 你 4", Justification.Centered, Justification.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Centered, Alignment.Justified, TextDirection.BottomTop_RightLeft, @" **4**** ** **** ** **** @@ -5765,7 +5765,7 @@ 4 你 0 // Vertical with Justification.Justified // TopBottom_LeftRight - [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Top, TextDirection.TopBottom_LeftRight, @" 0****** ****** 2****** @@ -5773,7 +5773,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* 0****** @@ -5781,7 +5781,7 @@ 4 你 0 2****** ****** 4******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Centered, TextDirection.TopBottom_LeftRight, @" ******* 0****** ****** @@ -5789,7 +5789,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Justified, TextDirection.TopBottom_LeftRight, @" 0****** ****** ****** @@ -5798,7 +5798,7 @@ 4 你 0 ****** 4******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Top, TextDirection.TopBottom_LeftRight, @" 0****** ****** 你***** @@ -5806,7 +5806,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Bottom, TextDirection.TopBottom_LeftRight, @" ******* ******* 0****** @@ -5814,7 +5814,7 @@ 4 你 0 你***** ****** 4******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Centered, TextDirection.TopBottom_LeftRight, @" ******* 0****** ****** @@ -5822,7 +5822,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.TopBottom_LeftRight, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Justified, TextDirection.TopBottom_LeftRight, @" 0****** ****** ****** @@ -5832,7 +5832,7 @@ 4 你 0 4******")] // TopBottom_RightLeft - [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Top, TextDirection.TopBottom_RightLeft, @" 0****** ****** 2****** @@ -5840,7 +5840,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* 0****** @@ -5848,7 +5848,7 @@ 4 你 0 2****** ****** 4******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Centered, TextDirection.TopBottom_RightLeft, @" ******* 0****** ****** @@ -5856,7 +5856,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Justified, TextDirection.TopBottom_RightLeft, @" 0****** ****** ****** @@ -5865,7 +5865,7 @@ 4 你 0 ****** 4******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Top, TextDirection.TopBottom_RightLeft, @" 0****** ****** 你***** @@ -5873,7 +5873,7 @@ 4 你 0 4****** ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Bottom, TextDirection.TopBottom_RightLeft, @" ******* ******* 0****** @@ -5881,7 +5881,7 @@ 4 你 0 你***** ****** 4******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Centered, TextDirection.TopBottom_RightLeft, @" ******* 0****** ****** @@ -5889,7 +5889,7 @@ 4 你 0 ****** 4****** *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.TopBottom_RightLeft, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Justified, TextDirection.TopBottom_RightLeft, @" 0****** ****** ****** @@ -5899,7 +5899,7 @@ 4 你 0 4******")] // BottomTop_LeftRight - [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Top, TextDirection.BottomTop_LeftRight, @" 4****** ****** 2****** @@ -5907,7 +5907,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* 4****** @@ -5915,7 +5915,7 @@ 4 你 0 2****** ****** 0******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Centered, TextDirection.BottomTop_LeftRight, @" ******* 4****** ****** @@ -5923,7 +5923,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Justified, TextDirection.BottomTop_LeftRight, @" 4****** ****** ****** @@ -5932,7 +5932,7 @@ 4 你 0 ****** 0******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Top, TextDirection.BottomTop_LeftRight, @" 4****** ****** 你***** @@ -5940,7 +5940,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Bottom, TextDirection.BottomTop_LeftRight, @" ******* ******* 4****** @@ -5948,7 +5948,7 @@ 4 你 0 你***** ****** 0******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Centered, TextDirection.BottomTop_LeftRight, @" ******* 4****** ****** @@ -5956,7 +5956,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.BottomTop_LeftRight, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Justified, TextDirection.BottomTop_LeftRight, @" 4****** ****** ****** @@ -5966,7 +5966,7 @@ 4 你 0 0******")] // BottomTop_RightLeft - [InlineData ("0 2 4", Justification.Justified, Justification.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Top, TextDirection.BottomTop_RightLeft, @" 4****** ****** 2****** @@ -5974,7 +5974,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* 4****** @@ -5982,7 +5982,7 @@ 4 你 0 2****** ****** 0******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Centered, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Centered, TextDirection.BottomTop_RightLeft, @" ******* 4****** ****** @@ -5990,7 +5990,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 2 4", Justification.Justified, Justification.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 2 4", Alignment.Justified, Alignment.Justified, TextDirection.BottomTop_RightLeft, @" 4****** ****** ****** @@ -5999,7 +5999,7 @@ 4 你 0 ****** 0******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Top, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Top, TextDirection.BottomTop_RightLeft, @" 4****** ****** 你***** @@ -6007,7 +6007,7 @@ 4 你 0 0****** ******* *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Bottom, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Bottom, TextDirection.BottomTop_RightLeft, @" ******* ******* 4****** @@ -6015,7 +6015,7 @@ 4 你 0 你***** ****** 0******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Centered, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Centered, TextDirection.BottomTop_RightLeft, @" ******* 4****** ****** @@ -6023,7 +6023,7 @@ 4 你 0 ****** 0****** *******")] - [InlineData ("0 你 4", Justification.Justified, Justification.Justified, TextDirection.BottomTop_RightLeft, @" + [InlineData ("0 你 4", Alignment.Justified, Alignment.Justified, TextDirection.BottomTop_RightLeft, @" 4****** ****** ****** @@ -6032,7 +6032,7 @@ 4 你 0 ****** 0******")] - public void Draw_Text_Justification (string text, Justification horizontalTextJustification, Justification justification, TextDirection textDirection, string expectedText) + public void Draw_Text_Justification (string text, Alignment horizontalTextJustification, Alignment justification, TextDirection textDirection, string expectedText) { TextFormatter tf = new () { diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs index b28e74c98d..7326616fce 100644 --- a/UnitTests/View/DrawTests.cs +++ b/UnitTests/View/DrawTests.cs @@ -339,7 +339,7 @@ public void Colors_On_TextJustification_Right_And_Bottom () Text = "Test", Width = 6, Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, ColorScheme = Colors.ColorSchemes ["Base"] }; @@ -350,7 +350,7 @@ public void Colors_On_TextJustification_Right_And_Bottom () Y = 1, Width = 1, Height = 6, - VerticalJustification = Justification.Bottom, + VerticalTextJustification = Alignment.Bottom, ColorScheme = Colors.ColorSchemes ["Base"] }; Toplevel top = new (); diff --git a/UnitTests/View/Layout/Dim.AutoTests.cs b/UnitTests/View/Layout/Dim.AutoTests.cs index 7bb58c799e..fe189e4e4e 100644 --- a/UnitTests/View/Layout/Dim.AutoTests.cs +++ b/UnitTests/View/Layout/Dim.AutoTests.cs @@ -681,11 +681,11 @@ public void DimAuto_Not_Used_TextFormatter_Does_Not_Change_View_Size () Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); - view.TextFormatter.Justification = Justification.Justified; + view.TextFormatter.Justification = Alignment.Justified; Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); - view.TextFormatter.VerticalJustification = Justification.Centered; + view.TextFormatter.VerticalJustification = Alignment.Centered; Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); @@ -709,11 +709,11 @@ public void DimAuto_Not_Used_TextSettings_Do_Not_Change_View_Size () Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); - view.Justification = Justification.Justified; + view.TextJustification = Alignment.Justified; Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); - view.VerticalJustification = Justification.Centered; + view.VerticalTextJustification = Alignment.Centered; Assert.False (view.TextFormatter.AutoSize); Assert.Equal (Size.Empty, view.Frame.Size); @@ -738,7 +738,7 @@ public void DimAuto_TextSettings_Change_View_Size () Assert.True (view.TextFormatter.AutoSize); Assert.NotEqual (Size.Empty, view.Frame.Size); - view.Justification = Justification.Justified; + view.TextJustification = Alignment.Justified; Assert.True (view.TextFormatter.AutoSize); Assert.NotEqual (Size.Empty, view.Frame.Size); @@ -747,7 +747,7 @@ public void DimAuto_TextSettings_Change_View_Size () Text = "_1234", Width = Dim.Auto () }; - view.VerticalJustification = Justification.Centered; + view.VerticalTextJustification = Alignment.Centered; Assert.True (view.TextFormatter.AutoSize); Assert.NotEqual (Size.Empty, view.Frame.Size); diff --git a/UnitTests/View/Text/AutoSizeTrueTests.cs b/UnitTests/View/Text/AutoSizeTrueTests.cs index e89b791c2c..5fafff7a69 100644 --- a/UnitTests/View/Text/AutoSizeTrueTests.cs +++ b/UnitTests/View/Text/AutoSizeTrueTests.cs @@ -1811,7 +1811,7 @@ public void View_Draw_Horizontal_Simple_TextJustifications (bool autoSize) Y = 1, Width = width, Height = 1, - Justification = Justification.Centered, + TextJustification = Alignment.Centered, }; if (autoSize) @@ -1826,7 +1826,7 @@ public void View_Draw_Horizontal_Simple_TextJustifications (bool autoSize) Y = 2, Width = width, Height = 1, - Justification = Justification.Right, + TextJustification = Alignment.Right, }; if (autoSize) { @@ -1840,7 +1840,7 @@ public void View_Draw_Horizontal_Simple_TextJustifications (bool autoSize) Y = 3, Width = width, Height = 1, - Justification = Justification.Justified, + TextJustification = Alignment.Justified, }; if (autoSize) { @@ -1937,7 +1937,7 @@ public void View_Draw_Vertical_Simple_TextJustifications (bool autoSize) Width = 1, Height = height, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Centered + VerticalTextJustification = Alignment.Centered }; if (autoSize) { @@ -1952,7 +1952,7 @@ public void View_Draw_Vertical_Simple_TextJustifications (bool autoSize) Width = 1, Height = height, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Bottom + VerticalTextJustification = Alignment.Bottom }; if (autoSize) { @@ -1967,7 +1967,7 @@ public void View_Draw_Vertical_Simple_TextJustifications (bool autoSize) Width = 1, Height = height, TextDirection = TextDirection.TopBottom_LeftRight, - VerticalJustification = Justification.Justified + VerticalTextJustification = Alignment.Justified }; if (autoSize) { diff --git a/UnitTests/Views/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs index 0aa841c440..aa32b62efd 100644 --- a/UnitTests/Views/ButtonTests.cs +++ b/UnitTests/Views/ButtonTests.cs @@ -155,14 +155,14 @@ public void Constructors_Defaults () Assert.Equal ($"{CM.Glyphs.LeftBracket} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text); Assert.False (btn.IsDefault); - Assert.Equal (Justification.Centered, btn.Justification); + Assert.Equal (Alignment.Centered, btn.TextJustification); 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 (Justification.Centered, btn.Justification); + Assert.Equal (Alignment.Centered, btn.TextJustification); Assert.Equal ('_', btn.HotKeySpecifier.Value); Assert.True (btn.CanFocus); Assert.Equal (new (0, 0, 4, 1), btn.Viewport); @@ -195,7 +195,7 @@ public void Constructors_Defaults () btn.TextFormatter.Format () ); Assert.True (btn.IsDefault); - Assert.Equal (Justification.Centered, btn.Justification); + Assert.Equal (Alignment.Centered, btn.TextJustification); Assert.True (btn.CanFocus); btn.SetRelativeLayout (new (100, 100)); @@ -222,7 +222,7 @@ public void Constructors_Defaults () btn.TextFormatter.Format () ); Assert.True (btn.IsDefault); - Assert.Equal (Justification.Centered, btn.Justification); + Assert.Equal (Alignment.Centered, btn.TextJustification); Assert.Equal ('_', btn.HotKeySpecifier.Value); Assert.True (btn.CanFocus); diff --git a/UnitTests/Views/CheckBoxTests.cs b/UnitTests/Views/CheckBoxTests.cs index 53335ffce0..465d55a1e4 100644 --- a/UnitTests/Views/CheckBoxTests.cs +++ b/UnitTests/Views/CheckBoxTests.cs @@ -251,7 +251,7 @@ public void TextJustification_Centered () X = 1, Y = Pos.Center (), Text = "Check this out 你", - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 25 }; var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" }; @@ -262,7 +262,7 @@ public void TextJustification_Centered () Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (30, 5); - Assert.Equal (Justification.Centered, checkBox.Justification); + Assert.Equal (Alignment.Centered, checkBox.TextJustification); Assert.Equal (new (1, 1, 25, 1), checkBox.Frame); Assert.Equal (_size25x1, checkBox.TextFormatter.Size); @@ -301,7 +301,7 @@ public void TextJustification_Justified () X = 1, Y = Pos.Center (), Text = "Check first out 你", - Justification = Justification.Justified, + TextJustification = Alignment.Justified, Width = 25 }; @@ -310,7 +310,7 @@ public void TextJustification_Justified () X = 1, Y = Pos.Bottom (checkBox1), Text = "Check second out 你", - Justification = Justification.Justified, + TextJustification = Alignment.Justified, Width = 25 }; var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" }; @@ -321,9 +321,9 @@ public void TextJustification_Justified () Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (30, 6); - Assert.Equal (Justification.Justified, checkBox1.Justification); + Assert.Equal (Alignment.Justified, checkBox1.TextJustification); Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame); - Assert.Equal (Justification.Justified, checkBox2.Justification); + Assert.Equal (Alignment.Justified, checkBox2.TextJustification); Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame); var expected = @$" @@ -378,7 +378,7 @@ public void TextJustification_Left () Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (30, 5); - Assert.Equal (Justification.Left, checkBox.Justification); + Assert.Equal (Alignment.Left, checkBox.TextJustification); Assert.Equal (new (1, 1, 25, 1), checkBox.Frame); Assert.Equal (_size25x1, checkBox.TextFormatter.Size); @@ -417,7 +417,7 @@ public void TextJustification_Right () X = 1, Y = Pos.Center (), Text = "Check this out 你", - Justification = Justification.Right, + TextJustification = Alignment.Right, Width = 25 }; var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" }; @@ -428,7 +428,7 @@ public void TextJustification_Right () Application.Begin (top); ((FakeDriver)Application.Driver).SetBufferSize (30, 5); - Assert.Equal (Justification.Right, checkBox.Justification); + Assert.Equal (Alignment.Right, checkBox.TextJustification); Assert.Equal (new (1, 1, 25, 1), checkBox.Frame); Assert.Equal (_size25x1, checkBox.TextFormatter.Size); diff --git a/UnitTests/Views/LabelTests.cs b/UnitTests/Views/LabelTests.cs index 3989ff9ba3..85166f7e60 100644 --- a/UnitTests/Views/LabelTests.cs +++ b/UnitTests/Views/LabelTests.cs @@ -206,7 +206,7 @@ public void Constructors_Defaults () { var label = new Label (); Assert.Equal (string.Empty, label.Text); - Assert.Equal (Justification.Left, label.Justification); + Assert.Equal (Alignment.Left, label.TextJustification); Assert.False (label.CanFocus); Assert.Equal (new Rectangle (0, 0, 0, 0), label.Frame); Assert.Equal (KeyCode.Null, label.HotKey); diff --git a/UnitTests/Views/TextValidateFieldTests.cs b/UnitTests/Views/TextValidateFieldTests.cs index 62686f59f4..a826380ed1 100644 --- a/UnitTests/Views/TextValidateFieldTests.cs +++ b/UnitTests/Views/TextValidateFieldTests.cs @@ -10,7 +10,7 @@ public void Backspace_Key_Deletes_Previous_Character () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // **** @@ -44,7 +44,7 @@ public void Changing_The_Mask_Tries_To_Keep_The_Previous_Text () { var field = new TextValidateField { - Justification = Justification.Left, + TextJustification = Alignment.Left, Width = 30, // **** @@ -81,7 +81,7 @@ public void Delete_Key_Doesnt_Move_Cursor () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // **** @@ -115,7 +115,7 @@ public void End_Key_Last_Editable_Character () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // * @@ -137,7 +137,7 @@ public void Home_Key_First_Editable_Character () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // * @@ -161,7 +161,7 @@ public void Initial_Value_Bigger_Than_Mask_Discarded () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // **** @@ -179,7 +179,7 @@ public void Initial_Value_Exact_Valid () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // **** @@ -196,7 +196,7 @@ public void Initial_Value_Smaller_Than_Mask_Accepted () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // **** @@ -214,7 +214,7 @@ public void Initialized_With_Cursor_On_First_Editable_Character () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // * @@ -233,7 +233,7 @@ public void Input_Ilegal_Character () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // * @@ -253,7 +253,7 @@ public void Insert_Skips_Non_Editable_Characters () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // ** ** @@ -283,7 +283,7 @@ public void Left_Key_Stops_In_First_Editable_Character () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // * @@ -308,7 +308,7 @@ public void MouseClick_Right_X_Greater_Than_Text_Width_Goes_To_Last_Editable_Pos { var field = new TextValidateField { - Justification = Justification.Left, + TextJustification = Alignment.Left, Width = 30, // **** @@ -338,7 +338,7 @@ public void OnTextChanged_TextChanged_Event () var field = new TextValidateField { - Justification = Justification.Left, Width = 30, Provider = new NetMaskedTextProvider ("--(0000)--") + TextJustification = Alignment.Left, Width = 30, Provider = new NetMaskedTextProvider ("--(0000)--") }; field.Provider.TextChanged += (sender, e) => wasTextChanged = true; @@ -356,7 +356,7 @@ public void Right_Key_Stops_In_Last_Editable_Character () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // * @@ -381,7 +381,7 @@ public void Set_Text_After_Initialization () { var field = new TextValidateField { - Justification = Justification.Left, + TextJustification = Alignment.Left, Width = 30, // **** @@ -400,7 +400,7 @@ public void When_Valid_Is_Valid_True () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, // **** @@ -540,7 +540,7 @@ public void Left_Key_Stops_At_Start_And_Insert () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false } }; @@ -596,7 +596,7 @@ public void OnTextChanged_TextChanged_Event () var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false } }; @@ -616,7 +616,7 @@ public void Right_Key_Stops_At_End_And_Insert () { var field = new TextValidateField { - Justification = Justification.Centered, + TextJustification = Alignment.Centered, Width = 20, Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false } }; diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs index eebd7aef75..2e418d576f 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -1482,8 +1482,8 @@ public void Modal_As_Top_Will_Drag_Cleanly () Y = Pos.Center (), Width = Dim.Fill (), Height = Dim.Fill (), - Justification = Justification.Centered, - VerticalJustification = Justification.Centered, + TextJustification = Alignment.Centered, + VerticalTextJustification = Alignment.Centered, Text = "Test" } ); From ce1e243df27e3a2dc1b10061fa162655f86d4e98 Mon Sep 17 00:00:00 2001 From: Tig Date: Fri, 10 May 2024 11:27:02 -0600 Subject: [PATCH 032/173] Justification->Alignment --- .../Drawing/{Justification.cs => Aligner.cs} | 28 +++-- Terminal.Gui/Drawing/Thickness.cs | 4 +- Terminal.Gui/Resources/config.json | 2 +- Terminal.Gui/Text/TextFormatter.cs | 100 +++++++-------- Terminal.Gui/View/Layout/PosDim.cs | 88 +++++++------ Terminal.Gui/View/ViewText.cs | 22 ++-- Terminal.Gui/Views/Button.cs | 4 +- Terminal.Gui/Views/CheckBox.cs | 2 +- Terminal.Gui/Views/Dialog.cs | 12 +- Terminal.Gui/Views/Menu/Menu.cs | 2 +- Terminal.Gui/Views/MessageBox.cs | 8 +- Terminal.Gui/Views/ProgressBar.cs | 2 +- Terminal.Gui/Views/Slider.cs | 8 +- Terminal.Gui/Views/TableView/ColumnStyle.cs | 26 ++-- Terminal.Gui/Views/TableView/TableView.cs | 6 +- Terminal.Gui/Views/TextValidateField.cs | 12 +- Terminal.Gui/Views/Wizard/Wizard.cs | 2 +- UICatalog/Scenarios/BasicColors.cs | 4 +- UICatalog/Scenarios/Buttons.cs | 52 ++++---- UICatalog/Scenarios/CharacterMap.cs | 2 +- .../Scenarios/CollectionNavigatorTester.cs | 4 +- UICatalog/Scenarios/ColorPicker.cs | 4 +- UICatalog/Scenarios/ComputedLayout.cs | 30 ++--- UICatalog/Scenarios/CsvEditor.cs | 30 ++--- UICatalog/Scenarios/Dialogs.cs | 18 +-- UICatalog/Scenarios/DynamicMenuBar.cs | 4 +- UICatalog/Scenarios/Editor.cs | 18 +-- UICatalog/Scenarios/ListColumns.cs | 2 +- UICatalog/Scenarios/MessageBoxes.cs | 18 +-- UICatalog/Scenarios/Mouse.cs | 4 +- .../{PosJustification.cs => PosAlign.cs} | 100 +++++++-------- UICatalog/Scenarios/TableEditor.cs | 10 +- UICatalog/Scenarios/Text.cs | 2 +- ...ection.cs => TextAlignmentAndDirection.cs} | 104 +++++++-------- UICatalog/Scenarios/TextFormatterDemo.cs | 42 +++---- UICatalog/Scenarios/TimeAndDate.cs | 12 +- UICatalog/Scenarios/Unicode.cs | 2 +- UICatalog/Scenarios/ViewExperiments.cs | 10 +- UICatalog/Scenarios/Wizards.cs | 8 +- UnitTests/Configuration/ThemeScopeTests.cs | 6 +- UnitTests/Configuration/ThemeTests.cs | 4 +- UnitTests/Dialogs/DialogTests.cs | 32 ++--- UnitTests/Text/TextFormatterTests.cs | 118 +++++++++--------- UnitTests/View/DrawTests.cs | 6 +- UnitTests/View/Layout/Dim.AutoTests.cs | 12 +- UnitTests/View/Text/AutoSizeTrueTests.cs | 16 +-- UnitTests/Views/ButtonTests.cs | 8 +- UnitTests/Views/CheckBoxTests.cs | 26 ++-- UnitTests/Views/LabelTests.cs | 2 +- UnitTests/Views/TextValidateFieldTests.cs | 40 +++--- UnitTests/Views/ToplevelTests.cs | 4 +- docfx/docs/layout.md | 2 +- docfx/docs/migratingfromv1.md | 8 +- docfx/docs/newinv2.md | 2 +- 54 files changed, 551 insertions(+), 543 deletions(-) rename Terminal.Gui/Drawing/{Justification.cs => Aligner.cs} (93%) rename UICatalog/Scenarios/{PosJustification.cs => PosAlign.cs} (81%) rename UICatalog/Scenarios/{TextJustificationAndDirection.cs => TextAlignmentAndDirection.cs} (84%) diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Aligner.cs similarity index 93% rename from Terminal.Gui/Drawing/Justification.cs rename to Terminal.Gui/Drawing/Aligner.cs index d2b87a9a65..97f5073915 100644 --- a/Terminal.Gui/Drawing/Justification.cs +++ b/Terminal.Gui/Drawing/Aligner.cs @@ -1,5 +1,4 @@ using System.ComponentModel; -using static Terminal.Gui.Pos; namespace Terminal.Gui; @@ -15,7 +14,8 @@ public enum Alignment /// /// /// - /// 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). + /// 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). /// /// /// @@ -39,7 +39,8 @@ public enum Alignment /// /// /// - /// If the container is smaller than the total size of the items, the left items will be clipped (their locations will be negative). + /// If the container is smaller than the total size of the items, the left items will be clipped (their locations + /// will be negative). /// /// /// @@ -99,7 +100,8 @@ public enum Alignment /// /// /// - /// 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). + /// 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). /// /// /// @@ -123,7 +125,8 @@ public enum Alignment /// /// /// - /// If the container is smaller than the total size of the items, the left items will be clipped (their locations will be negative). + /// If the container is smaller than the total size of the items, the left items will be clipped (their locations + /// will be negative). /// /// /// @@ -138,7 +141,7 @@ public enum Alignment /// Set to to ensure at least one line between /// each item. /// - LastBottomRestTop = LastRightRestLeft, + LastBottomRestTop = LastRightRestLeft } /// @@ -157,7 +160,7 @@ public Alignment Alignment set { _alignment = value; - PropertyChanged?.Invoke (this, new PropertyChangedEventArgs (nameof (Alignment))); + PropertyChanged?.Invoke (this, new (nameof (Alignment))); } } @@ -172,7 +175,7 @@ public int ContainerSize set { _containerSize = value; - PropertyChanged?.Invoke (this, new PropertyChangedEventArgs (nameof (ContainerSize))); + PropertyChanged?.Invoke (this, new (nameof (ContainerSize))); } } @@ -185,8 +188,9 @@ public int ContainerSize /// /// /// - /// If the total size of the items is greater than the container size, the space between items will be ignored starting - /// from the right. + /// If the total size of the items is greater than the container size, the space between items will be ignored + /// starting + /// from the right. /// /// public bool PutSpaceBetweenItems @@ -195,11 +199,11 @@ public bool PutSpaceBetweenItems set { _putSpaceBetweenItems = value; - PropertyChanged?.Invoke (this, new PropertyChangedEventArgs (nameof (PutSpaceBetweenItems))); + PropertyChanged?.Invoke (this, new (nameof (PutSpaceBetweenItems))); } } - /// + /// public event PropertyChangedEventHandler PropertyChanged; /// diff --git a/Terminal.Gui/Drawing/Thickness.cs b/Terminal.Gui/Drawing/Thickness.cs index 3ee360f504..f541465d21 100644 --- a/Terminal.Gui/Drawing/Thickness.cs +++ b/Terminal.Gui/Drawing/Thickness.cs @@ -232,8 +232,8 @@ rect with var tf = new TextFormatter { Text = label is null ? string.Empty : $"{label} {this}", - Justification = Alignment.Centered, - VerticalJustification = Alignment.Bottom, + Alignment = Alignment.Centered, + VerticalAlignment = Alignment.Bottom, AutoSize = true }; tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute, rect); diff --git a/Terminal.Gui/Resources/config.json b/Terminal.Gui/Resources/config.json index c073d5aadb..c2a63fe15b 100644 --- a/Terminal.Gui/Resources/config.json +++ b/Terminal.Gui/Resources/config.json @@ -24,7 +24,7 @@ "Themes": [ { "Default": { - "Dialog.DefaultButtonJustification": "Right", + "Dialog.DefaultButtonAlignment": "Right", "FrameView.DefaultBorderStyle": "Single", "Window.DefaultBorderStyle": "Single", "ColorSchemes": [ diff --git a/Terminal.Gui/Text/TextFormatter.cs b/Terminal.Gui/Text/TextFormatter.cs index c05b84e7e6..3d2e0d61dd 100644 --- a/Terminal.Gui/Text/TextFormatter.cs +++ b/Terminal.Gui/Text/TextFormatter.cs @@ -3,7 +3,7 @@ namespace Terminal.Gui; /// -/// Provides text formatting. Supports s, horizontal justification, vertical justification, +/// Provides text formatting. Supports s, horizontal alignment, vertical alignment, /// multiple lines, and word-based line wrap. /// public class TextFormatter @@ -17,17 +17,17 @@ public class TextFormatter private Size _size; private int _tabWidth = 4; private string _text; - private Alignment _textJustification; + private Alignment _textAlignment; private TextDirection _textDirection; - private Alignment _textVerticalJustification; + private Alignment _textVerticalAlignment; private bool _wordWrap = true; - /// Get or sets the horizontal text justification. - /// The text justification. - public Alignment Justification + /// Get or sets the horizontal text alignment. + /// The text alignment. + public Alignment Alignment { - get => _textJustification; - set => _textJustification = EnableNeedsFormat (value); + get => _textAlignment; + set => _textAlignment = EnableNeedsFormat (value); } /// Gets or sets whether the should be automatically changed to fit the . @@ -222,12 +222,12 @@ public virtual string Text } } - /// Gets or sets the vertical text-justification. - /// The text vertical justification. - public Alignment VerticalJustification + /// Gets or sets the vertical text-alignment. + /// The text vertical alignment. + public Alignment VerticalAlignment { - get => _textVerticalJustification; - set => _textVerticalJustification = EnableNeedsFormat (value); + get => _textVerticalAlignment; + set => _textVerticalAlignment = EnableNeedsFormat (value); } /// Gets or sets whether word wrap will be used to fit to . @@ -319,8 +319,8 @@ public void Draw ( int x = 0, y = 0; - // Horizontal Justification - if (Justification is Alignment.Right) + // Horizontal Alignment + if (Alignment is Alignment.Right) { if (isVertical) { @@ -335,7 +335,7 @@ public void Draw ( CursorPosition = screen.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0); } } - else if (Justification is Alignment.Left) + else if (Alignment is Alignment.Left) { if (isVertical) { @@ -351,7 +351,7 @@ public void Draw ( CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0; } - else if (Justification is Alignment.Justified) + else if (Alignment is Alignment.Justified) { if (isVertical) { @@ -374,7 +374,7 @@ public void Draw ( CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0; } - else if (Justification is Alignment.Centered) + else if (Alignment is Alignment.Centered) { if (isVertical) { @@ -394,13 +394,13 @@ public void Draw ( } else { - Debug.WriteLine ($"Unsupported Justification: {nameof (VerticalJustification)}"); + Debug.WriteLine ($"Unsupported Alignment: {nameof (VerticalAlignment)}"); return; } - // Vertical Justification - if (VerticalJustification is Alignment.Bottom) + // Vertical Alignment + if (VerticalAlignment is Alignment.Bottom) { if (isVertical) { @@ -411,7 +411,7 @@ public void Draw ( y = screen.Bottom - linesFormatted.Count + line; } } - else if (VerticalJustification is Alignment.Top) + else if (VerticalAlignment is Alignment.Top) { if (isVertical) { @@ -422,7 +422,7 @@ public void Draw ( y = screen.Top + line; } } - else if (VerticalJustification is Alignment.Justified) + else if (VerticalAlignment is Alignment.Justified) { if (isVertical) { @@ -436,7 +436,7 @@ public void Draw ( line < linesFormatted.Count - 1 ? screen.Height - interval <= 1 ? screen.Top + 1 : screen.Top + line * interval : screen.Bottom - 1; } } - else if (VerticalJustification is Alignment.Centered) + else if (VerticalAlignment is Alignment.Centered) { if (isVertical) { @@ -451,7 +451,7 @@ public void Draw ( } else { - Debug.WriteLine ($"Unsupported Justification: {nameof (VerticalJustification)}"); + Debug.WriteLine ($"Unsupported Alignment: {nameof (VerticalAlignment)}"); return; } @@ -474,8 +474,8 @@ public void Draw ( { if (idx < 0 || (isVertical - ? VerticalJustification != Alignment.Bottom && current < 0 - : Justification != Alignment.Right && x + current + colOffset < 0)) + ? VerticalAlignment != Alignment.Bottom && current < 0 + : Alignment != Alignment.Right && x + current + colOffset < 0)) { current++; @@ -564,7 +564,7 @@ public void Draw ( if (HotKeyPos > -1 && idx == HotKeyPos) { - if ((isVertical && VerticalJustification == Alignment.Justified) || (!isVertical && Justification == Alignment.Justified)) + if ((isVertical && VerticalAlignment == Alignment.Justified) || (!isVertical && Alignment == Alignment.Justified)) { CursorPosition = idx - start; } @@ -702,7 +702,7 @@ public List GetLines () _lines = Format ( text, Size.Height, - VerticalJustification == Alignment.Justified, + VerticalAlignment == Alignment.Justified, Size.Width > colsWidth && WordWrap, PreserveTrailingSpaces, TabWidth, @@ -726,7 +726,7 @@ public List GetLines () _lines = Format ( text, Size.Width, - Justification == Alignment.Justified, + Alignment == Alignment.Justified, Size.Height > 1 && WordWrap, PreserveTrailingSpaces, TabWidth, @@ -980,7 +980,7 @@ public static string ClipOrPad (string text, int width) // if value is not wide enough if (text.EnumerateRunes ().Sum (c => c.GetColumns ()) < width) { - // pad it out with spaces to the given Justification + // pad it out with spaces to the given Alignment int toPad = width - text.EnumerateRunes ().Sum (c => c.GetColumns ()); return text + new string (' ', toPad); @@ -1002,7 +1002,7 @@ public static string ClipOrPad (string text, int width) /// instance to access any of his objects. /// A list of word wrapped lines. /// - /// This method does not do any justification. + /// This method does not do any alignment. /// This method strips Newline ('\n' and '\r\n') sequences before processing. /// /// If is at most one space will be preserved @@ -1034,7 +1034,7 @@ public static List WordWrapText ( List runes = StripCRLF (text).ToRuneList (); int start = Math.Max ( - !runes.Contains ((Rune)' ') && textFormatter is { VerticalJustification: Alignment.Bottom } && IsVerticalDirection (textDirection) + !runes.Contains ((Rune)' ') && textFormatter is { VerticalAlignment: Alignment.Bottom } && IsVerticalDirection (textDirection) ? runes.Count - width : 0, 0); @@ -1252,7 +1252,7 @@ int GetNextWhiteSpace (int from, int cWidth, out bool incomplete, int cLength = /// The number of columns to clip the text to. Text longer than will be /// clipped. /// - /// Justification. + /// Alignment. /// The text direction. /// The number of columns used for a tab. /// instance to access any of his objects. @@ -1260,13 +1260,13 @@ int GetNextWhiteSpace (int from, int cWidth, out bool incomplete, int cLength = public static string ClipAndJustify ( string text, int width, - Alignment textJustification, + Alignment textAlignment, TextDirection textDirection = TextDirection.LeftRight_TopBottom, int tabWidth = 0, TextFormatter textFormatter = null ) { - return ClipAndJustify (text, width, textJustification == Alignment.Justified, textDirection, tabWidth, textFormatter); + return ClipAndJustify (text, width, textAlignment == Alignment.Justified, textDirection, tabWidth, textFormatter); } /// Justifies text within a specified width. @@ -1307,12 +1307,12 @@ public static string ClipAndJustify ( { if (IsHorizontalDirection (textDirection)) { - if (textFormatter is { Justification: Alignment.Right }) + if (textFormatter is { Alignment: Alignment.Right }) { return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection); } - if (textFormatter is { Justification: Alignment.Centered }) + if (textFormatter is { Alignment: Alignment.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1322,12 +1322,12 @@ public static string ClipAndJustify ( if (IsVerticalDirection (textDirection)) { - if (textFormatter is { VerticalJustification: Alignment.Bottom }) + if (textFormatter is { VerticalAlignment: Alignment.Bottom }) { return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection); } - if (textFormatter is { VerticalJustification: Alignment.Centered }) + if (textFormatter is { VerticalAlignment: Alignment.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1345,14 +1345,14 @@ public static string ClipAndJustify ( if (IsHorizontalDirection (textDirection)) { - if (textFormatter is { Justification: Alignment.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 { Justification: Alignment.Centered }) + else if (textFormatter is { Alignment: Alignment.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1364,14 +1364,14 @@ public static string ClipAndJustify ( if (IsVerticalDirection (textDirection)) { - if (textFormatter is { VerticalJustification: Alignment.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 { VerticalJustification: Alignment.Centered }) + else if (textFormatter is { VerticalAlignment: Alignment.Centered }) { return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection); } @@ -1475,10 +1475,10 @@ public static string Justify ( return s.ToString (); } - /// Formats text into lines, applying text justification and optionally wrapping text to new lines on word boundaries. + /// Formats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries. /// /// The number of columns to constrain the text to for word wrapping and clipping. - /// Specifies how the text will be justified horizontally. + /// Specifies how the text will be aligned horizontally. /// /// If , the text will be wrapped to new lines no longer than /// . If , forces text to fit a single line. Line breaks are converted @@ -1501,7 +1501,7 @@ public static string Justify ( public static List Format ( string text, int width, - Alignment textJustification, + Alignment textAlignment, bool wordWrap, bool preserveTrailingSpaces = false, int tabWidth = 0, @@ -1513,7 +1513,7 @@ public static List Format ( return Format ( text, width, - textJustification == Alignment.Justified, + textAlignment == Alignment.Justified, wordWrap, preserveTrailingSpaces, tabWidth, @@ -1523,7 +1523,7 @@ public static List Format ( ); } - /// Formats text into lines, applying text justification and optionally wrapping text to new lines on word boundaries. + /// Formats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries. /// /// The number of columns to constrain the text to for word wrapping and clipping. /// Specifies whether the text should be justified. @@ -1887,7 +1887,7 @@ public static int GetMaxColsForWidth (List lines, int width, int tabWidt return lineIdx; } - /// Calculates the rectangle required to hold text, assuming no word wrapping or justification. + /// Calculates the rectangle required to hold text, assuming no word wrapping or alignment. /// /// This API will return incorrect results if the text includes glyphs who's width is dependent on surrounding /// glyphs (e.g. Arabic). diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs index 79bd498b29..d6737b2209 100644 --- a/Terminal.Gui/View/Layout/PosDim.cs +++ b/Terminal.Gui/View/Layout/PosDim.cs @@ -46,6 +46,14 @@ namespace Terminal.Gui; /// /// /// +/// +/// +/// +/// Creates a object that aligns a set of views. +/// +/// +/// +/// /// /// /// @@ -206,12 +214,12 @@ public static Pos AnchorEnd (int offset) /// - /// Creates a object that justifies a set of views according to the specified justification. + /// Creates a object that aligns a set of views according to the specified alignment setting. /// - /// - /// The optional, unique identifier for the set of views to justify according to . + /// + /// The optional, unique identifier for the set of views to align according to . /// - public static Pos Justify (Alignment justification, int groupId = 0) { return new PosJustify (justification, groupId); } + public static Pos Align (Alignment alignment, int groupId = 0) { return new PosAlign (alignment, groupId); } /// Serves as the default hash function. /// A hash code for the current object. @@ -496,47 +504,45 @@ internal class PosFactor (float factor) : Pos /// - /// Enables justification of a set of views. + /// Enables alignment of a set of views. /// /// /// - /// The Group ID is used to identify a set of views that should be justified together. When only a single - /// set of views is justified, setting the Group ID is not needed because it defaults to 0. + /// The Group ID is used to identify a set of views that should be alignment together. When only a single + /// set of views is aligned, setting the Group ID is not needed because it defaults to 0. /// /// - /// The first view added to the Superview with a given Group ID is used to determine the justification of the group. - /// The justification is applied to all views with the same Group ID. + /// The first view added to the Superview with a given Group ID is used to determine the alignment of the group. + /// The alignment is applied to all views with the same Group ID. /// /// - public class PosJustify : Pos + public class PosAlign : Pos { - // TODO: Figure out how to invalidate _location if Justifier changes. - /// /// The cached location. Used to store the calculated location to avoid recalculating it. /// private int? _location; /// - /// Gets the identifier of a set of views that should be justified together. When only a single - /// set of views is justified, setting the is not needed because it defaults to 0. + /// Gets the identifier of a set of views that should be aligned together. When only a single + /// set of views is aligned, setting the is not needed because it defaults to 0. /// private readonly int _groupId; /// - /// Gets the justification settings. + /// Gets the alignment settings. /// - public Aligner Justifier { get; } = new (); + public Aligner Aligner { get; } = new (); /// - /// Justifies the views in that have the same group ID as . + /// Aligns the views in that have the same group ID as . /// /// /// /// /// - private static void JustifyGroup (int groupId, IList views, Dim.Dimension dimension, int size) + private static void AlignGroup (int groupId, IList views, Dim.Dimension dimension, int size) { if (views is null) { @@ -547,14 +553,14 @@ private static void JustifyGroup (int groupId, IList views, Dim.Dimension List viewsInGroup = views.Where ( v => { - if (dimension == Dimension.Width && v.X is PosJustify justifyX) + if (dimension == Dimension.Width && v.X is PosAlign alignX) { - return justifyX._groupId == groupId; + return alignX._groupId == groupId; } - if (dimension == Dimension.Height && v.Y is PosJustify justifyY) + if (dimension == Dimension.Height && v.Y is PosAlign alignY) { - return justifyY._groupId == groupId; + return alignY._groupId == groupId; } return false; @@ -566,13 +572,13 @@ private static void JustifyGroup (int groupId, IList views, Dim.Dimension foreach (var view in viewsInGroup) { - var posJustify = dimension == Dimension.Width ? view.X as PosJustify : view.Y as PosJustify; + var posAlign = dimension == Dimension.Width ? view.X as PosAlign : view.Y as PosAlign; - if (posJustify is { }) + if (posAlign is { }) { if (firstInGroup is null) { - firstInGroup = posJustify.Justifier; + firstInGroup = posAlign.Aligner; } dimensionsList.Add (dimension == Dimension.Width ? view.Frame.Width : view.Frame.Height); @@ -590,29 +596,29 @@ private static void JustifyGroup (int groupId, IList views, Dim.Dimension for (var index = 0; index < viewsInGroup.Count; index++) { View view = viewsInGroup [index]; - PosJustify justify = dimension == Dimension.Width ? view.X as PosJustify : view.Y as PosJustify; + PosAlign align = dimension == Dimension.Width ? view.X as PosAlign : view.Y as PosAlign; - if (justify is { }) + if (align is { }) { - justify._location = locations [index]; + align._location = locations [index]; } } } /// - /// Enables justification of a set of views. + /// Enables alignment of a set of views. /// - /// - /// The unique identifier for the set of views to justify according to . - public PosJustify (Alignment justification, int groupId = 0) + /// + /// The unique identifier for the set of views to align according to . + public PosAlign (Alignment alignment, int groupId = 0) { - Justifier.PutSpaceBetweenItems = true; - Justifier.Alignment = justification; + Aligner.PutSpaceBetweenItems = true; + Aligner.Alignment = alignment; _groupId = groupId; - Justifier.PropertyChanged += Justifier_PropertyChanged; + Aligner.PropertyChanged += Aligner_PropertyChanged; } - private void Justifier_PropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e) + private void Aligner_PropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e) { _location = null; } @@ -620,19 +626,19 @@ private void Justifier_PropertyChanged (object sender, System.ComponentModel.Pro /// public override bool Equals (object other) { - return other is PosJustify justify && _groupId == justify._groupId && _location == justify._location && justify.Justifier.Equals (Justifier); + return other is PosAlign align && _groupId == align._groupId && _location == align._location && align.Aligner.Equals (Aligner); } /// public override int GetHashCode () { - return Justifier.GetHashCode () ^ _groupId.GetHashCode (); + return Aligner.GetHashCode () ^ _groupId.GetHashCode (); } /// public override string ToString () { - return $"Justify(groupId={_groupId}, justification={Justifier.Alignment})"; + return $"Align(groupId={_groupId}, alignment={Aligner.Alignment})"; } internal override int Anchor (int width) @@ -642,7 +648,7 @@ internal override int Anchor (int width) internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension) { - if (_location.HasValue && Justifier.ContainerSize == superviewDimension) + if (_location.HasValue && Aligner.ContainerSize == superviewDimension) { return _location.Value; } @@ -652,7 +658,7 @@ internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.D return 0; } - JustifyGroup (_groupId, us.SuperView.Subviews, dimension, superviewDimension); + AlignGroup (_groupId, us.SuperView.Subviews, dimension, superviewDimension); if (_location.HasValue) { diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs index 6e2ec991a8..b45e0061fe 100644 --- a/Terminal.Gui/View/ViewText.cs +++ b/Terminal.Gui/View/ViewText.cs @@ -34,7 +34,7 @@ public virtual bool PreserveTrailingSpaces /// /// /// The text will be drawn starting at the view origin (0, 0) and will be formatted according - /// to and . + /// to and . /// /// /// The text will word-wrap to additional lines if it does not fit horizontally. If 's height @@ -80,19 +80,19 @@ public void OnTextChanged (string oldValue, string newValue) public event EventHandler> TextChanged; /// - /// Gets or sets how the View's is justified horizontally when drawn. Changing this property will + /// Gets or sets how the View's is aligned horizontally when drawn. Changing this property will /// redisplay the . /// /// /// or are using , the will be adjusted to fit the text. /// - /// The text justification. - public virtual Alignment TextJustification + /// The text alignment. + public virtual Alignment TextAlignment { - get => TextFormatter.Justification; + get => TextFormatter.Alignment; set { - TextFormatter.Justification = value; + TextFormatter.Alignment = value; UpdateTextFormatterText (); OnResizeNeeded (); } @@ -122,20 +122,20 @@ public virtual TextDirection TextDirection public TextFormatter TextFormatter { get; init; } = new () { }; /// - /// Gets or sets how the View's is justified vertically when drawn. Changing this property will + /// Gets or sets how the View's is aligned vertically when drawn. Changing this property will /// redisplay /// the . /// /// /// or are using , the will be adjusted to fit the text. /// - /// The vertical text justification. - public virtual Alignment VerticalTextJustification + /// The vertical text alignment. + public virtual Alignment VerticalTextAlignment { - get => TextFormatter.VerticalJustification; + get => TextFormatter.VerticalAlignment; set { - TextFormatter.VerticalJustification = value; + TextFormatter.VerticalAlignment = value; SetNeedsDisplay (); } } diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs index 0a0fa50407..5fa80b70d8 100644 --- a/Terminal.Gui/Views/Button.cs +++ b/Terminal.Gui/Views/Button.cs @@ -37,8 +37,8 @@ public class Button : View /// The width of the is computed based on the text length. The height will always be 1. public Button () { - TextJustification = Alignment.Centered; - VerticalTextJustification = Alignment.Centered; + TextAlignment = Alignment.Centered; + VerticalTextAlignment = Alignment.Centered; _leftBracket = Glyphs.LeftBracket; _rightBracket = Glyphs.RightBracket; diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs index 8d598be2e4..7bc069b02f 100644 --- a/Terminal.Gui/Views/CheckBox.cs +++ b/Terminal.Gui/Views/CheckBox.cs @@ -153,7 +153,7 @@ public bool? Checked /// protected override void UpdateTextFormatterText () { - switch (TextJustification) + switch (TextAlignment) { case Alignment.Left: case Alignment.Centered: diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index f7210744b3..232830da54 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -51,7 +51,7 @@ public Dialog () ColorScheme = Colors.ColorSchemes ["Dialog"]; Modal = true; - ButtonJustification = DefaultButtonJustification; + ButtonAlignment = DefaultButtonAlignment; AddCommand ( Command.QuitToplevel, @@ -96,9 +96,9 @@ public bool Canceled } } - // TODO: Update button.X = Pos.Justify when justification changes - /// Determines how the s are justified along the bottom of the dialog. - public Alignment ButtonJustification { get; set; } + // TODO: Update button.X = Pos.Justify when alignment changes + /// Determines how the s are aligned along the bottom of the dialog. + public Alignment ButtonAlignment { get; set; } /// Optional buttons to lay out at the bottom of the dialog. public Button [] Buttons @@ -122,7 +122,7 @@ public Button [] Buttons /// This property can be set in a Theme. [SerializableConfigurationProperty (Scope = typeof (ThemeScope))] [JsonConverter (typeof (JsonStringEnumConverter))] - public static Alignment DefaultButtonJustification { get; set; } = Alignment.Right; + public static Alignment DefaultButtonAlignment { get; set; } = Alignment.Right; /// /// Adds a to the , its layout will be controlled by the @@ -136,7 +136,7 @@ public void AddButton (Button button) return; } - button.X = Pos.Justify (ButtonJustification); + button.X = Pos.Align (ButtonAlignment); button.Y = Pos.AnchorEnd () - 1; _buttons.Add (button); diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index b55bdfac5a..4e2fa3320a 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -891,7 +891,7 @@ public override void OnDrawContent (Rectangle viewport) var tf = new TextFormatter { AutoSize = true, - Justification = Alignment.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) diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index 72e0f42b1c..bf391997b1 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -340,8 +340,8 @@ params string [] buttons } } - Alignment buttonJust = Dialog.DefaultButtonJustification; - Dialog.DefaultButtonJustification = Alignment.Centered; + Alignment buttonJust = Dialog.DefaultButtonAlignment; + Dialog.DefaultButtonAlignment = Alignment.Centered; var d = new Dialog { Buttons = buttonList.ToArray (), @@ -350,7 +350,7 @@ params string [] buttons Width = Dim.Percent (60), Height = 5 // Border + one line of text + vspace + buttons }; - Dialog.DefaultButtonJustification = buttonJust; + Dialog.DefaultButtonAlignment = buttonJust; if (width != 0) { @@ -374,7 +374,7 @@ params string [] buttons var messageLabel = new Label { Text = message, - TextJustification = Alignment.Centered, + TextAlignment = Alignment.Centered, X = Pos.Center (), Y = 0 }; diff --git a/Terminal.Gui/Views/ProgressBar.cs b/Terminal.Gui/Views/ProgressBar.cs index 9c56625b2e..26760c04d1 100644 --- a/Terminal.Gui/Views/ProgressBar.cs +++ b/Terminal.Gui/Views/ProgressBar.cs @@ -181,7 +181,7 @@ public override void OnDrawContent (Rectangle viewport) if (ProgressBarFormat != ProgressBarFormat.Simple && !_isActivity) { - var tf = new TextFormatter { Justification = Alignment.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) diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs index 95ed09fd82..efddec1d31 100644 --- a/Terminal.Gui/Views/Slider.cs +++ b/Terminal.Gui/Views/Slider.cs @@ -930,7 +930,7 @@ public override void OnDrawContent (Rectangle viewport) } } - private string JustifyText (string text, int width, Alignment justification) + private string AlignText (string text, int width, Alignment alignment) { if (text is null) { @@ -947,7 +947,7 @@ private string JustifyText (string text, int width, Alignment justification) string s2 = new (' ', w % 2); // Note: The formatter doesn't handle all of this ??? - switch (justification) + switch (alignment) { case Alignment.Justified: return TextFormatter.Justify (text, width); @@ -1293,7 +1293,7 @@ private void DrawLegends () switch (_config._legendsOrientation) { case Orientation.Horizontal: - text = JustifyText (text, _config._innerSpacing + 1, Alignment.Centered); + text = AlignText (text, _config._innerSpacing + 1, Alignment.Centered); break; case Orientation.Vertical: @@ -1311,7 +1311,7 @@ private void DrawLegends () break; case Orientation.Vertical: - text = JustifyText (text, _config._innerSpacing + 1, Alignment.Centered); + text = AlignText (text, _config._innerSpacing + 1, Alignment.Centered); break; } diff --git a/Terminal.Gui/Views/TableView/ColumnStyle.cs b/Terminal.Gui/Views/TableView/ColumnStyle.cs index 02615e6965..2d277abd91 100644 --- a/Terminal.Gui/Views/TableView/ColumnStyle.cs +++ b/Terminal.Gui/Views/TableView/ColumnStyle.cs @@ -1,17 +1,17 @@ namespace Terminal.Gui; /// -/// Describes how to render a given column in a including and +/// Describes how to render a given column in a including and /// textual representation of cells (e.g. date formats) /// See TableView Deep Dive for more information. /// public class ColumnStyle { /// - /// Defines a delegate for returning custom justification per cell based on cell values. When specified this will - /// override + /// Defines a delegate for returning custom alignment per cell based on cell values. When specified this will + /// override /// - public Func JustificationGetter; + public Func AlignmentGetter; /// /// Defines a delegate for returning a custom color scheme per cell based on cell values. Return null for the @@ -29,10 +29,10 @@ public class ColumnStyle private bool _visible = true; /// - /// Defines the default justification for all values rendered in this column. For custom justification based on cell - /// contents use . + /// Defines the default alignment for all values rendered in this column. For custom alignment based on cell + /// contents use . /// - public Alignment Justification { get; set; } + public Alignment Alignment { get; set; } /// Defines the format for values e.g. "yyyy-MM-dd" for dates public string Format { get; set; } @@ -69,19 +69,19 @@ public bool Visible } /// - /// Returns the justification for the cell based on and / - /// + /// Returns the alignment for the cell based on and / + /// /// /// /// - public Alignment GetJustification (object cellValue) + public Alignment GetAlignment (object cellValue) { - if (JustificationGetter is { }) + if (AlignmentGetter is { }) { - return JustificationGetter (cellValue); + return AlignmentGetter (cellValue); } - return Justification; + return Alignment; } /// diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs index 0931faa31a..8689521e5b 100644 --- a/Terminal.Gui/Views/TableView/TableView.cs +++ b/Terminal.Gui/Views/TableView/TableView.cs @@ -2057,13 +2057,13 @@ private void ToggleCurrentCellSelection () /// /// Truncates or pads so that it occupies a exactly - /// using the justification specified in (or left + /// using the alignment specified in (or left /// if no style is defined) /// /// The object in this cell of the /// The string representation of /// - /// Optional style indicating custom justification for the cell + /// Optional style indicating custom alignment for the cell /// private string TruncateOrPad ( object originalCellValue, @@ -2085,7 +2085,7 @@ ColumnStyle colStyle - (representation.EnumerateRunes ().Sum (c => c.GetColumns ()) + 1 /*leave 1 space for cell boundary*/); - switch (colStyle?.GetJustification (originalCellValue) ?? Alignment.Left) + switch (colStyle?.GetAlignment (originalCellValue) ?? Alignment.Left) { case Alignment.Left: return representation + new string (' ', toPad); diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs index 034a0a69bb..11ed140892 100644 --- a/Terminal.Gui/Views/TextValidateField.cs +++ b/Terminal.Gui/Views/TextValidateField.cs @@ -539,7 +539,7 @@ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) { int c = _provider.Cursor (mouseEvent.X - GetMargins (Viewport.Width).left); - if (_provider.Fixed == false && TextJustification == Alignment.Right && Text.Length > 0) + if (_provider.Fixed == false && TextAlignment == Alignment.Right && Text.Length > 0) { c++; } @@ -633,7 +633,7 @@ public override bool OnProcessKeyDown (Key a) // When it's right-aligned and it's a normal input, the cursor behaves differently. int curPos; - if (_provider?.Fixed == false && TextJustification == Alignment.Right) + if (_provider?.Fixed == false && TextAlignment == Alignment.Right) { curPos = _cursorPosition + left - 1; } @@ -650,7 +650,7 @@ public override bool OnProcessKeyDown (Key a) /// private bool BackspaceKeyHandler () { - if (_provider.Fixed == false && TextJustification == Alignment.Right && _cursorPosition <= 1) + if (_provider.Fixed == false && TextAlignment == Alignment.Right && _cursorPosition <= 1) { return false; } @@ -688,7 +688,7 @@ private bool CursorRight () /// private bool DeleteKeyHandler () { - if (_provider.Fixed == false && TextJustification == Alignment.Right) + if (_provider.Fixed == false && TextAlignment == Alignment.Right) { _cursorPosition = _provider.CursorLeft (_cursorPosition); } @@ -709,7 +709,7 @@ private bool EndKeyHandler () return true; } - /// Margins for text justification. + /// Margins for text alignment. /// Total width /// Left and right margins private (int left, int right) GetMargins (int width) @@ -717,7 +717,7 @@ private bool EndKeyHandler () int count = Text.Length; int total = width - count; - switch (TextJustification) + switch (TextAlignment) { case Alignment.Left: return (0, total); diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index 049668e5ee..f9283b9c85 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -85,7 +85,7 @@ public Wizard () { // Using Justify causes the Back and Next buttons to be hard justified against // the left and right edge - ButtonJustification = Alignment.Justified; + ButtonAlignment = Alignment.Justified; BorderStyle = LineStyle.Double; //// Add a horiz separator diff --git a/UICatalog/Scenarios/BasicColors.cs b/UICatalog/Scenarios/BasicColors.cs index 510d36d40b..58bbcce88e 100644 --- a/UICatalog/Scenarios/BasicColors.cs +++ b/UICatalog/Scenarios/BasicColors.cs @@ -32,7 +32,7 @@ public override void Main () Y = 0, Width = 1, Height = 13, - VerticalTextJustification = Alignment.Bottom, + VerticalTextAlignment = Alignment.Bottom, ColorScheme = new ColorScheme { Normal = attr }, Text = bg.ToString (), TextDirection = TextDirection.TopBottom_LeftRight @@ -45,7 +45,7 @@ public override void Main () Y = y, Width = 13, Height = 1, - TextJustification = Alignment.Right, + TextAlignment = Alignment.Right, ColorScheme = new ColorScheme { Normal = attr }, Text = bg.ToString () }; diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs index 1f0943d285..d5beae1fa0 100644 --- a/UICatalog/Scenarios/Buttons.cs +++ b/UICatalog/Scenarios/Buttons.cs @@ -209,7 +209,7 @@ static void DoMessage (Button button, string txt) var label = new Label { - X = 2, Y = Pos.Bottom (computedFrame) + 1, Text = "Text Justification (changes the four buttons above): " + X = 2, Y = Pos.Bottom (computedFrame) + 1, Text = "Text Alignment (changes the four buttons above): " }; main.Add (label); @@ -287,39 +287,39 @@ string MoveHotkey (string txt) switch (args.SelectedItem) { case 0: - moveBtn.TextJustification = Alignment.Left; - sizeBtn.TextJustification = Alignment.Left; - moveBtnA.TextJustification = Alignment.Left; - sizeBtnA.TextJustification = Alignment.Left; - moveHotKeyBtn.TextJustification = Alignment.Left; - moveUnicodeHotKeyBtn.TextJustification = Alignment.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.TextJustification = Alignment.Right; - sizeBtn.TextJustification = Alignment.Right; - moveBtnA.TextJustification = Alignment.Right; - sizeBtnA.TextJustification = Alignment.Right; - moveHotKeyBtn.TextJustification = Alignment.Right; - moveUnicodeHotKeyBtn.TextJustification = Alignment.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.TextJustification = Alignment.Centered; - sizeBtn.TextJustification = Alignment.Centered; - moveBtnA.TextJustification = Alignment.Centered; - sizeBtnA.TextJustification = Alignment.Centered; - moveHotKeyBtn.TextJustification = Alignment.Centered; - moveUnicodeHotKeyBtn.TextJustification = Alignment.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.TextJustification = Alignment.Justified; - sizeBtn.TextJustification = Alignment.Justified; - moveBtnA.TextJustification = Alignment.Justified; - sizeBtnA.TextJustification = Alignment.Justified; - moveHotKeyBtn.TextJustification = Alignment.Justified; - moveUnicodeHotKeyBtn.TextJustification = Alignment.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; } @@ -439,7 +439,7 @@ public NumericUpDown () Y = Pos.Top (_down), Width = Dim.Function (() => Digits), Height = 1, - TextJustification = Alignment.Centered, + TextAlignment = Alignment.Centered, CanFocus = true }; diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index cb4d77a70a..4fdfeebc86 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -958,7 +958,7 @@ private void ShowDetails () Y = 1, Width = Dim.Fill (), Height = Dim.Fill (1), - TextJustification = Alignment.Centered + TextAlignment = Alignment.Centered }; var spinner = new SpinnerView { X = Pos.Center (), Y = Pos.Center (), Style = new Aesthetic () }; spinner.AutoSpin = true; diff --git a/UICatalog/Scenarios/CollectionNavigatorTester.cs b/UICatalog/Scenarios/CollectionNavigatorTester.cs index 69d8f51a19..0c9b3ab141 100644 --- a/UICatalog/Scenarios/CollectionNavigatorTester.cs +++ b/UICatalog/Scenarios/CollectionNavigatorTester.cs @@ -142,7 +142,7 @@ private void CreateListView () var label = new Label { Text = "ListView", - TextJustification = Alignment.Centered, + TextAlignment = Alignment.Centered, X = 0, Y = 1, // for menu Width = Dim.Percent (50), @@ -171,7 +171,7 @@ private void CreateTreeView () var label = new Label { Text = "TreeView", - TextJustification = Alignment.Centered, + TextAlignment = Alignment.Centered, X = Pos.Right (_listView) + 2, Y = 1, // for menu Width = Dim.Percent (50), diff --git a/UICatalog/Scenarios/ColorPicker.cs b/UICatalog/Scenarios/ColorPicker.cs index 5b92f96dd9..6d5f618140 100644 --- a/UICatalog/Scenarios/ColorPicker.cs +++ b/UICatalog/Scenarios/ColorPicker.cs @@ -69,8 +69,8 @@ public override void Main () { Title = "Color Sample", Text = "Lorem Ipsum", - TextJustification = Alignment.Centered, - VerticalTextJustification = Alignment.Centered, + TextAlignment = Alignment.Centered, + VerticalTextAlignment = Alignment.Centered, BorderStyle = LineStyle.Heavy, X = Pos.Center (), Y = Pos.Center (), diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index ac19ff82b6..5fcf85c75a 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -86,12 +86,12 @@ public override void Main () var i = 1; var txt = "Resize the terminal to see computed layout in action."; List