From 4ed5ed8bb68f54876c0bf4b6840c28709145c416 Mon Sep 17 00:00:00 2001 From: Tig Date: Wed, 17 Apr 2024 12:51:19 -0600 Subject: [PATCH] Initial commit. Just a prototype --- Terminal.Gui/View/Layout/PosDim.cs | 220 +++++++++++++++------ 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, 242 insertions(+), 140 deletions(-) diff --git a/Terminal.Gui/View/Layout/PosDim.cs b/Terminal.Gui/View/Layout/PosDim.cs index 4438fb844..f94209390 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 class Pos /// 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 class Pos /// 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 class Pos /// 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,6 +304,34 @@ public class Pos return new PosFactor (percent / 100); } + /// 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); } + + /// 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); } + + /// 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 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 tracks the Right (X+Width) coordinate of the specified /// . @@ -301,21 +340,6 @@ public class Pos /// The that will be tracked. public static Pos Right (View view) { return new PosView (view, Side.Right); } - /// 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); } - - /// 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 . - /// The that depends on the other view. - /// The that will be tracked. - public static Pos Y (View view) { return new PosView (view, Side.Y); } - /// /// Gets a position that is anchored to a certain point in the layout. This method is typically used /// internally by the layout system to determine where a View should be positioned. @@ -460,7 +484,7 @@ public class Pos internal override int Anchor (int width) { return _function (); } } - internal enum Side + public enum Side { X = 0, Y = 1, @@ -478,13 +502,13 @@ public class 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,15 +521,101 @@ public class Pos 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 @@ public class Dim internal override int Anchor (int width) { return _function (); } } - internal enum Side + public enum Side { Height = 0, Width = 1 @@ -850,11 +960,11 @@ public class Dim } 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 class Dim 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 1afa0994b..5c6f0cc64 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 46787265e..cd859ac0b 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 class Dialog : Window } /// 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 class Dialog : Window } } - /// 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 @@ public class Dialog : Window switch (ButtonAlignment) { - case ButtonAlignments.Center: + case ViewAlignments.Center: // Center Buttons shiftLeft = (Viewport.Width - buttonsWidth - _buttons.Count - 1) / 2 + 1; @@ -223,7 +208,7 @@ public class Dialog : Window 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 @@ public class Dialog : Window break; - case ButtonAlignments.Left: + case ViewAlignments.Left: // Left Align Buttons Button prevButton = _buttons [0]; prevButton.X = 0; @@ -274,7 +259,7 @@ public class Dialog : Window 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 a20b4cbbc..12cdc5961 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -4180,7 +4180,10 @@ public class TextView : View } else { - PositionCursor (); + if (IsInitialized) + { + PositionCursor (); + } } OnUnwrappedCursorPosition (); diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index c3691b3e1..eddef7f4c 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -85,7 +85,7 @@ public class Wizard : Dialog { // 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 c8013c46a..fea26eab9 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 class ComputedLayout : Scenario // This is intentionally convoluted to illustrate potential bugs. var anchorEndLabel1 = new Label { - Text = "This Label should be the 2nd to last line (AnchorEnd (2)).", + 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 class ComputedLayout : Scenario 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 class ComputedLayout : Scenario // show positioning vertically using Pos.AnchorEnd var centerButton = new Button { - Text = "Center", X = Pos.Center (), Y = Pos.AnchorEnd (1) // Pos.AnchorEnd(1) + Text = "Center", Y = Pos.AnchorEnd (2) // Pos.AnchorEnd(1) }; centerButton.Accept += (s, e) => @@ -402,14 +402,17 @@ public class ComputedLayout : Scenario app.LayoutSubviews (); }; - // Center three buttons with 5 spaces between them - leftButton.X = Pos.Left (centerButton) - (Pos.Right (leftButton) - Pos.Left (leftButton)) - 5; - rightButton.X = Pos.Right (centerButton) + 5; - + View [] buttons = { leftButton, centerButton, rightButton }; app.Add (leftButton); app.Add (centerButton); app.Add (rightButton); + + // Center three buttons with 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 fa8cacd21..cc2399317 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -265,7 +265,7 @@ public class Dialogs : Scenario 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 3da7f881a..b22ae60ee 100644 --- a/UnitTests/Configuration/ThemeScopeTests.cs +++ b/UnitTests/Configuration/ThemeScopeTests.cs @@ -29,12 +29,12 @@ public class ThemeScopeTests { 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 f7d8c732f..c9c2ba2bb 100644 --- a/UnitTests/Configuration/ThemeTests.cs +++ b/UnitTests/Configuration/ThemeTests.cs @@ -77,15 +77,15 @@ public class ThemeTests public void TestSerialize_RoundTrip () { var theme = new ThemeScope (); - theme ["Dialog.DefaultButtonAlignment"].PropertyValue = Dialog.ButtonAlignments.Right; + theme ["Dialog.DefaultButtonAlignment"].PropertyValue = 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 6c7eb754a..f74ea5b12 100644 --- a/UnitTests/Dialogs/DialogTests.cs +++ b/UnitTests/Dialogs/DialogTests.cs @@ -32,7 +32,7 @@ public class DialogTests Title = title, Width = width, Height = 1, - ButtonAlignment = Dialog.ButtonAlignments.Center, + ButtonAlignment = ViewAlignments.Center, Buttons = [new Button { Text = btn1Text }] }; @@ -57,7 +57,7 @@ public class DialogTests Title = title, Width = width, Height = 1, - ButtonAlignment = Dialog.ButtonAlignments.Justify, + ButtonAlignment = ViewAlignments.Justify, Buttons = [new Button { Text = btn1Text }] }; @@ -82,7 +82,7 @@ public class DialogTests Title = title, Width = width, Height = 1, - ButtonAlignment = Dialog.ButtonAlignments.Right, + ButtonAlignment = ViewAlignments.Right, Buttons = [new Button { Text = btn1Text }] }; @@ -107,7 +107,7 @@ public class DialogTests Title = title, Width = width, Height = 1, - ButtonAlignment = Dialog.ButtonAlignments.Left, + ButtonAlignment = ViewAlignments.Left, Buttons = [new Button { Text = btn1Text }] }; @@ -155,7 +155,7 @@ public class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btnText } ); @@ -547,7 +547,7 @@ public class DialogTests (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -562,7 +562,7 @@ public class DialogTests (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -577,7 +577,7 @@ public class DialogTests (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -594,7 +594,7 @@ public class DialogTests (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -609,7 +609,7 @@ public class DialogTests (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -624,7 +624,7 @@ public class DialogTests (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -639,7 +639,7 @@ public class DialogTests (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -673,7 +673,7 @@ public class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (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 class DialogTests (runstate, Dialog dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -770,7 +770,7 @@ public class DialogTests (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Justify, + ViewAlignments.Justify, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -785,7 +785,7 @@ public class DialogTests (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Right, + ViewAlignments.Right, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -800,7 +800,7 @@ public class DialogTests (runstate, dlg) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Left, + ViewAlignments.Left, new Button { Text = btn1Text }, new Button { Text = btn2Text } ); @@ -837,7 +837,7 @@ public class DialogTests // 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 class DialogTests 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 class DialogTests 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 class DialogTests 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 class DialogTests (runstate, Dialog _) = RunButtonTestDialog ( title, width, - Dialog.ButtonAlignments.Center, + ViewAlignments.Center, new Button { Text = btnText } ); TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output); @@ -1347,7 +1347,7 @@ public class DialogTests 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 class DialogTests private (RunState, Dialog) RunButtonTestDialog ( string title, int width, - Dialog.ButtonAlignments align, + ViewAlignments align, params Button [] btns ) {