Accepted changed

This commit is contained in:
Tig
2024-08-19 08:21:09 -06:00
parent dccc06366a
commit bb85f9099a
4 changed files with 12 additions and 43 deletions

View File

@@ -170,31 +170,6 @@ public abstract record Dim : IEqualityOperators<Dim, Dim, bool>
#endregion static Dim creation methods
/// <summary>
/// Indicates whether the specified type is in the hierarchy of this Dim object.
/// </summary>
/// <param name="type"></param>
/// <param name="dim"></param>
/// <returns></returns>
[Obsolete ("Not AoT-safe. Use generic form Has<T> 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;
}
/// <summary>
/// Indicates whether the specified type <typeparamref name="T"/> is in the hierarchy of this Dim object.
@@ -207,15 +182,9 @@ public abstract record Dim : IEqualityOperators<Dim, Dim, bool>
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<T> (out dim) || combine.Right.Has<T> (out dim),
_ => false
T => true,
_ => false
};
}

View File

@@ -15,7 +15,7 @@ namespace Terminal.Gui;
/// methods on the <see cref="Dim"/> class to create <see cref="Dim"/> objects instead.
/// </para>
/// </remarks>
/// <param name="MaximumContentDim">The maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED.</param>
/// <param name="MaximumContentDim">The maximum dimension the View's ContentSize will be fit to.</param>
/// <param name="MinimumContentDim">The minimum dimension the View's ContentSize will be constrained to.</param>
/// <param name="Style">The <see cref="DimAutoStyle"/> of the <see cref="DimAuto"/>.</param>
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<DimFill> (out _)
&& !v.Width.Has<DimPercent> (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<DimFill> (out _)
&& !v.Height.Has<DimPercent> (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<DimView> (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<DimView> (out _)).ToList ();
}
for (var i = 0; i < dimViewSubViews.Count; i++)

View File

@@ -4,7 +4,7 @@ namespace Terminal.Gui;
/// <summary>
/// Represents a position that is computed by executing a function that returns an integer position.
/// </summary>
/// <param name="Pos">The function that computes the position.</param>
/// <param name="Fn">The function that computes the position.</param>
public record PosFunc (Func<int> Fn) : Pos
{
/// <inheritdoc/>

View File

@@ -474,7 +474,7 @@ public partial class View // Layout APIs
return;
}
if (_height is { } && _height.Has (typeof (DimAuto), out _))
if (_height is { } && _height.Has<DimAuto> (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<DimAuto> (out _))
{
// Reset ContentSize to Viewport
_contentSize = null;