From 24ca95fd5eb8cb43aa5a6ba385093662e6730395 Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 27 May 2024 07:09:51 -0600 Subject: [PATCH] Removed LayoutStyle --- Terminal.Gui/Application.cs | 3 - Terminal.Gui/View/Layout/Dim.cs | 2 +- Terminal.Gui/View/Layout/LayoutStyle.cs | 38 ----- Terminal.Gui/View/Layout/ViewLayout.cs | 76 ++------- Terminal.Gui/View/View.cs | 21 +-- Terminal.Gui/View/ViewContent.cs | 5 - Terminal.Gui/Views/Button.cs | 4 +- Terminal.Gui/Views/CheckBox.cs | 3 +- Terminal.Gui/Views/DateField.cs | 4 +- Terminal.Gui/Views/Dialog.cs | 8 +- Terminal.Gui/Views/FrameView.cs | 5 +- Terminal.Gui/Views/HexView.cs | 4 +- Terminal.Gui/Views/RadioGroup.cs | 3 +- Terminal.Gui/Views/ScrollBarView.cs | 6 +- Terminal.Gui/Views/ScrollView.cs | 3 +- Terminal.Gui/Views/TabView.cs | 2 +- Terminal.Gui/Views/TableView/TableView.cs | 4 +- Terminal.Gui/Views/TextField.cs | 3 +- Terminal.Gui/Views/TextValidateField.cs | 3 +- Terminal.Gui/Views/TimeField.cs | 2 +- Terminal.Gui/Views/Toplevel.cs | 6 +- Terminal.Gui/Views/Window.cs | 3 +- Terminal.Gui/Views/Wizard/Wizard.cs | 3 +- Terminal.Gui/Views/Wizard/WizardStep.cs | 3 +- UICatalog/Scenarios/AllViewsTester.cs | 166 +++++++++---------- UnitTests/UICatalog/ScenarioTests.cs | 22 +-- UnitTests/View/Layout/AbsoluteLayoutTests.cs | 93 ++++------- UnitTests/View/Layout/Dim.Tests.cs | 87 ---------- UnitTests/View/Layout/FrameTests.cs | 6 - UnitTests/View/Layout/ViewportTests.cs | 2 - UnitTests/View/ViewTests.cs | 7 - UnitTests/Views/ScrollViewTests.cs | 2 - UnitTests/Views/WindowTests.cs | 14 -- docfx/docs/View.md | 2 +- docfx/docs/index.md | 2 +- docfx/docs/layout.md | 2 - docfx/docs/migratingfromv1.md | 3 +- 37 files changed, 156 insertions(+), 466 deletions(-) delete mode 100644 Terminal.Gui/View/Layout/LayoutStyle.cs diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs index d825fb872..95689655e 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -526,11 +526,8 @@ public static partial class Application MoveCurrent (Current); } - //if (Toplevel.LayoutStyle == LayoutStyle.Computed) { toplevel.SetRelativeLayout (Driver.Screen.Size); - //} - // BUGBUG: This call is likely not needed. toplevel.LayoutSubviews (); toplevel.PositionToplevels (); diff --git a/Terminal.Gui/View/Layout/Dim.cs b/Terminal.Gui/View/Layout/Dim.cs index cc31d41b1..411b0fded 100644 --- a/Terminal.Gui/View/Layout/Dim.cs +++ b/Terminal.Gui/View/Layout/Dim.cs @@ -7,7 +7,7 @@ namespace Terminal.Gui; /// /// A Dim object describes the dimensions of a . Dim is the type of the /// and properties of . Dim objects enable -/// Computed Layout (see ) to automatically manage the dimensions of a view. +/// automatic management of the dimensions of a view. /// /// /// Integer values are implicitly convertible to an absolute . These objects are created using diff --git a/Terminal.Gui/View/Layout/LayoutStyle.cs b/Terminal.Gui/View/Layout/LayoutStyle.cs deleted file mode 100644 index 81883bfcc..000000000 --- a/Terminal.Gui/View/Layout/LayoutStyle.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Terminal.Gui.Analyzers.Internal.Attributes; - -namespace Terminal.Gui; - -/// -/// Indicates the LayoutStyle for the . -/// -/// If Absolute, the , , , and -/// objects are all absolute values and are not relative. The position and size of the -/// view is described by . -/// -/// -/// If Computed, one or more of the , , , or -/// objects are relative to the and are computed at layout -/// time. -/// -/// -[GenerateEnumExtensionMethods] -public enum LayoutStyle -{ - /// - /// Indicates the , , , and - /// objects are all absolute values and are not relative. The position and size of the view - /// is described by . - /// - Absolute, - - /// - /// Indicates one or more of the , , , or - /// - /// objects are relative to the and are computed at layout time. The position and size of - /// the - /// view - /// will be computed based on these objects at layout time. will provide the absolute computed - /// values. - /// - Computed -} \ No newline at end of file diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 94348fc75..020fa7211 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -20,7 +20,6 @@ public partial class View /// /// Setting Frame will set , , , and to the /// values of the corresponding properties of the parameter. - /// This causes to be . /// /// /// Altering the Frame will eventually (when the view hierarchy is next laid out via see @@ -41,8 +40,7 @@ public partial class View SetFrame (value with { Width = Math.Max (value.Width, 0), Height = Math.Max (value.Height, 0) }); - // If Frame gets set, by definition, the View is now LayoutStyle.Absolute, so - // set all Pos/Dim to Absolute values. + // If Frame gets set, set all Pos/Dim to Absolute values. _x = _frame.X; _y = _frame.Y; _width = _frame.Width; @@ -148,8 +146,7 @@ public partial class View /// and methods to be called. /// /// - /// Changing this property will cause to be updated. If the new value is not of type - /// the will change to . + /// Changing this property will cause to be updated. /// /// The default value is Pos.At (0). /// @@ -187,8 +184,7 @@ public partial class View /// and methods to be called. /// /// - /// Changing this property will cause to be updated. If the new value is not of type - /// the will change to . + /// Changing this property will cause to be updated. /// /// The default value is Pos.At (0). /// @@ -226,8 +222,7 @@ public partial class View /// and methods to be called. /// /// - /// Changing this property will cause to be updated. If the new value is not of type - /// the will change to . + /// Changing this property will cause to be updated. /// /// The default value is Dim.Sized (0). /// @@ -272,8 +267,7 @@ public partial class View /// and methods to be called. /// /// - /// Changing this property will cause to be updated. If the new value is not of type - /// the will change to . + /// Changing this property will cause to be updated. /// /// The default value is Dim.Sized (0). /// @@ -303,55 +297,6 @@ public partial class View #region Layout Engine - - // @tig Notes on layout flow. Ignore for now. - // BeginLayout - // If !LayoutNeeded return - // If !SizeNeeded return - // Call OnLayoutStarted - // Views and subviews can update things - // - - - // EndLayout - - /// - /// Controls how the View's is computed during . If the style is - /// set to , LayoutSubviews does not change the . If the style is - /// the is updated using the , , - /// , and properties. - /// - /// - /// - /// Setting this property to will cause to determine the - /// size and position of the view. and will be set to - /// using . - /// - /// - /// Setting this property to will cause the view to use the - /// method to size and position of the view. If either of the and - /// properties are `null` they will be set to using the current value - /// of . If either of the and properties are `null` - /// they will be set to using . - /// - /// - /// The layout style. - public LayoutStyle LayoutStyle - { - get - { - if (_x is PosAbsolute - && _y is PosAbsolute - && _width is DimAbsolute - && _height is DimAbsolute) - { - return LayoutStyle.Absolute; - } - - return LayoutStyle.Computed; - } - } - #endregion Layout Engine /// @@ -796,8 +741,7 @@ public partial class View if (Frame != newFrame) { - // Set the frame. Do NOT use `Frame` as it overwrites X, Y, Width, and Height, making - // the view LayoutStyle.Absolute. + // Set the frame. Do NOT use `Frame` as it overwrites X, Y, Width, and Height SetFrame (newFrame); if (_x is PosAbsolute) @@ -836,10 +780,10 @@ public partial class View { nNodes.Add (v); - if (v.LayoutStyle != LayoutStyle.Computed) - { - continue; - } + //if (v.LayoutStyle != LayoutStyle.Computed) + //{ + // continue; + //} CollectPos (v.X, v, ref nNodes, ref nEdges); CollectPos (v.Y, v, ref nNodes, ref nEdges); diff --git a/Terminal.Gui/View/View.cs b/Terminal.Gui/View/View.cs index 1632eca2f..28ba6a27c 100644 --- a/Terminal.Gui/View/View.cs +++ b/Terminal.Gui/View/View.cs @@ -43,13 +43,6 @@ namespace Terminal.Gui; /// more subviews, can respond to user input and render themselves on the screen. /// /// -/// View supports two layout styles: or . -/// The style is determined by the values of , , , and -/// . If any of these is set to non-absolute or object, -/// then the layout style is . Otherwise it is -/// . -/// -/// /// To create a View using Absolute layout, call a constructor that takes a Rect parameter to specify the /// absolute position and size or simply set ). To create a View using Computed layout use /// a constructor that does not take a Rect parameter and set the X, Y, Width and Height properties on the view to @@ -79,9 +72,7 @@ namespace Terminal.Gui; /// To flag the entire view for redraw call . /// /// -/// The method is invoked when the size or layout of a view has changed. The default -/// processing system will keep the size and dimensions for views that use the , -/// and will recompute the Adornments for the views that use . +/// The method is invoked when the size or layout of a view has changed. /// /// /// Views have a property that defines the default colors that subviews should use for @@ -127,15 +118,7 @@ public partial class View : Responder, ISupportInitializeNotification /// /// /// Use , , , and properties to dynamically - /// control the size and location of the view. The will be created using - /// coordinates. The initial size ( ) will be adjusted - /// to fit the contents of , including newlines ('\n') for multiple lines. - /// - /// If is greater than one, word wrapping is provided. - /// - /// This constructor initialize a View with a of . - /// Use , , , and properties to dynamically - /// control the size and location of the view, changing it to . + /// control the size and location of the view. /// /// public View () diff --git a/Terminal.Gui/View/ViewContent.cs b/Terminal.Gui/View/ViewContent.cs index 7fa48ed38..cdba2aa09 100644 --- a/Terminal.Gui/View/ViewContent.cs +++ b/Terminal.Gui/View/ViewContent.cs @@ -183,11 +183,6 @@ public partial class View /// The property controls how scrolling is handled. /// /// - /// If is the value of Viewport is indeterminate until - /// the view has been initialized ( is true) and has been - /// called. - /// - /// /// Updates to the Viewport Size updates , and has the same impact as updating the /// . /// diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs index 5b1cfcf3d..dffa7cb9f 100644 --- a/Terminal.Gui/Views/Button.cs +++ b/Terminal.Gui/Views/Button.cs @@ -33,8 +33,8 @@ public class Button : View private readonly Rune _rightDefault; private bool _isDefault; - /// Initializes a new instance of using layout. - /// The width of the is computed based on the text length. The height will always be 1. + /// Initializes a new instance of . + /// The width and height of the is computed based on the text. public Button () { TextAlignment = Alignment.Center; diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs index cf0adeefc..471ab5203 100644 --- a/Terminal.Gui/Views/CheckBox.cs +++ b/Terminal.Gui/Views/CheckBox.cs @@ -11,8 +11,7 @@ public class CheckBox : View private bool? _checked = false; /// - /// Initializes a new instance of based on the given text, using - /// layout. + /// Initializes a new instance of . /// public CheckBox () { diff --git a/Terminal.Gui/Views/DateField.cs b/Terminal.Gui/Views/DateField.cs index 5640e5b87..7a4797fb6 100644 --- a/Terminal.Gui/Views/DateField.cs +++ b/Terminal.Gui/Views/DateField.cs @@ -21,10 +21,10 @@ public class DateField : TextField private string _format; private string _separator; - /// Initializes a new instance of using layout. + /// Initializes a new instance of . public DateField () : this (DateTime.MinValue) { } - /// Initializes a new instance of using layout. + /// Initializes a new instance of . /// public DateField (DateTime date) { diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index d0376ca84..5ed0a4ef5 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -55,13 +55,11 @@ public class Dialog : Window private readonly List