From bb85f9099a928def3d1d4ecc747127772cd8c481 Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 19 Aug 2024 08:21:09 -0600 Subject: [PATCH] Accepted changed --- Terminal.Gui/View/Layout/Dim.cs | 35 ++--------------------------- Terminal.Gui/View/Layout/DimAuto.cs | 14 ++++++------ Terminal.Gui/View/Layout/PosFunc.cs | 2 +- Terminal.Gui/View/View.Layout.cs | 4 ++-- 4 files changed, 12 insertions(+), 43 deletions(-) diff --git a/Terminal.Gui/View/Layout/Dim.cs b/Terminal.Gui/View/Layout/Dim.cs index 979d83fff..cfb286b6c 100644 --- a/Terminal.Gui/View/Layout/Dim.cs +++ b/Terminal.Gui/View/Layout/Dim.cs @@ -170,31 +170,6 @@ public abstract record Dim : IEqualityOperators #endregion static Dim creation methods - /// - /// Indicates whether the specified type is in the hierarchy of this Dim object. - /// - /// - /// - /// - [Obsolete ("Not AoT-safe. Use generic form Has instead.")] - public bool Has (Type type, out Dim dim) - { - dim = this; - - if (type == GetType ()) - { - return true; - } - - // If we are a DimCombine, we have to check the left and right - // to see if they are of the type we are looking for. - if (this is DimCombine { } combine && (combine.Left.Has (type, out dim) || combine.Right.Has (type, out dim))) - { - return true; - } - - return false; - } /// /// Indicates whether the specified type is in the hierarchy of this Dim object. @@ -207,15 +182,9 @@ public abstract record Dim : IEqualityOperators return this switch { - T => true, - - // INTENT: Is it intentional that, when T is already DimCombine, this won't get called? - // If not, the fix is to do this one first. - // (That's also the case in the original) - // If we are a DimCombine, we have to check the left and right - // to see if they are of the type we are looking for. DimCombine combine => combine.Left.Has (out dim) || combine.Right.Has (out dim), - _ => false + T => true, + _ => false }; } diff --git a/Terminal.Gui/View/Layout/DimAuto.cs b/Terminal.Gui/View/Layout/DimAuto.cs index b8b53505f..e552d1028 100644 --- a/Terminal.Gui/View/Layout/DimAuto.cs +++ b/Terminal.Gui/View/Layout/DimAuto.cs @@ -15,7 +15,7 @@ namespace Terminal.Gui; /// methods on the class to create objects instead. /// /// -/// The maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED. +/// The maximum dimension the View's ContentSize will be fit to. /// The minimum dimension the View's ContentSize will be constrained to. /// The of the . public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoStyle Style) : Dim @@ -134,8 +134,8 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt && !v.X.Has (typeof (PosAnchorEnd), out _) && !v.X.Has (typeof (PosAlign), out _) && !v.X.Has (typeof (PosCenter), out _) - && !v.Width.Has (typeof (DimFill), out _) - && !v.Width.Has (typeof (DimPercent), out _) + && !v.Width.Has (out _) + && !v.Width.Has (out _) ) .ToList (); } @@ -147,8 +147,8 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt && !v.Y.Has (typeof (PosAnchorEnd), out _) && !v.Y.Has (typeof (PosAlign), out _) && !v.Y.Has (typeof (PosCenter), out _) - && !v.Height.Has (typeof (DimFill), out _) - && !v.Height.Has (typeof (DimPercent), out _) + && !v.Height.Has (out _) + && !v.Height.Has (out _) ) .ToList (); } @@ -372,11 +372,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt if (dimension == Dimension.Width) { - dimViewSubViews = includedSubviews.Where (v => v.Width is { } && v.Width.Has (typeof (DimView), out _)).ToList (); + dimViewSubViews = includedSubviews.Where (v => v.Width is { } && v.Width.Has (out _)).ToList (); } else { - dimViewSubViews = includedSubviews.Where (v => v.Height is { } && v.Height.Has (typeof (DimView), out _)).ToList (); + dimViewSubViews = includedSubviews.Where (v => v.Height is { } && v.Height.Has (out _)).ToList (); } for (var i = 0; i < dimViewSubViews.Count; i++) diff --git a/Terminal.Gui/View/Layout/PosFunc.cs b/Terminal.Gui/View/Layout/PosFunc.cs index c449add14..0bd819ad5 100644 --- a/Terminal.Gui/View/Layout/PosFunc.cs +++ b/Terminal.Gui/View/Layout/PosFunc.cs @@ -4,7 +4,7 @@ namespace Terminal.Gui; /// /// Represents a position that is computed by executing a function that returns an integer position. /// -/// The function that computes the position. +/// The function that computes the position. public record PosFunc (Func Fn) : Pos { /// diff --git a/Terminal.Gui/View/View.Layout.cs b/Terminal.Gui/View/View.Layout.cs index 54554eae1..d77ceba2b 100644 --- a/Terminal.Gui/View/View.Layout.cs +++ b/Terminal.Gui/View/View.Layout.cs @@ -474,7 +474,7 @@ public partial class View // Layout APIs return; } - if (_height is { } && _height.Has (typeof (DimAuto), out _)) + if (_height is { } && _height.Has (out _)) { // Reset ContentSize to Viewport _contentSize = null; @@ -523,7 +523,7 @@ public partial class View // Layout APIs return; } - if (_width is { } && _width.Has (typeof (DimAuto), out _)) + if (_width is { } && _width.Has (out _)) { // Reset ContentSize to Viewport _contentSize = null;