|
@@ -1,5 +1,5 @@
|
|
|
|
+#nullable enable
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
-using System.Drawing;
|
|
|
|
|
|
|
|
namespace Terminal.Gui;
|
|
namespace Terminal.Gui;
|
|
|
|
|
|
@@ -149,7 +149,7 @@ public class Dim
|
|
/// <summary>Creates an Absolute <see cref="Dim"/> from the specified integer value.</summary>
|
|
/// <summary>Creates an Absolute <see cref="Dim"/> from the specified integer value.</summary>
|
|
/// <returns>The Absolute <see cref="Dim"/>.</returns>
|
|
/// <returns>The Absolute <see cref="Dim"/>.</returns>
|
|
/// <param name="size">The value to convert to the <see cref="Dim"/>.</param>
|
|
/// <param name="size">The value to convert to the <see cref="Dim"/>.</param>
|
|
- public static Dim Absolute (int size) { return new DimAbsolute (size); }
|
|
|
|
|
|
+ public static Dim? Absolute (int size) { return new DimAbsolute (size); }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Creates a <see cref="Dim"/> object that automatically sizes the view to fit all the view's Content, Subviews, and/or Text.
|
|
/// Creates a <see cref="Dim"/> object that automatically sizes the view to fit all the view's Content, Subviews, and/or Text.
|
|
@@ -175,7 +175,7 @@ public class Dim
|
|
/// </param>
|
|
/// </param>
|
|
/// <param name="minimumContentDim">The minimum dimension the View's ContentSize will be constrained to.</param>
|
|
/// <param name="minimumContentDim">The minimum dimension the View's ContentSize will be constrained to.</param>
|
|
/// <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. NOT CURRENTLY SUPPORTED.</param>
|
|
- public static Dim Auto (DimAutoStyle style = DimAutoStyle.Auto, Dim minimumContentDim = null, Dim maximumContentDim = null)
|
|
|
|
|
|
+ public static Dim? Auto (DimAutoStyle style = DimAutoStyle.Auto, Dim? minimumContentDim = null, Dim? maximumContentDim = null)
|
|
{
|
|
{
|
|
//if (maximumContentDim != null)
|
|
//if (maximumContentDim != null)
|
|
//{
|
|
//{
|
|
@@ -190,7 +190,7 @@ public class Dim
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns>The Fill dimension.</returns>
|
|
/// <returns>The Fill dimension.</returns>
|
|
/// <param name="margin">Margin to use.</param>
|
|
/// <param name="margin">Margin to use.</param>
|
|
- public static Dim Fill (int margin = 0) { return new DimFill (margin); }
|
|
|
|
|
|
+ public static Dim? Fill (int margin = 0) { return new DimFill (margin); }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Creates a function <see cref="Dim"/> object that computes the dimension by executing the provided function.
|
|
/// Creates a function <see cref="Dim"/> object that computes the dimension by executing the provided function.
|
|
@@ -226,7 +226,7 @@ public class Dim
|
|
/// };
|
|
/// };
|
|
/// </code>
|
|
/// </code>
|
|
/// </example>
|
|
/// </example>
|
|
- public static Dim Percent (float percent, bool usePosition = false)
|
|
|
|
|
|
+ public static Dim? Percent (float percent, bool usePosition = false)
|
|
{
|
|
{
|
|
if (percent is < 0 or > 100)
|
|
if (percent is < 0 or > 100)
|
|
{
|
|
{
|
|
@@ -249,7 +249,7 @@ public class Dim
|
|
/// Gets a dimension that is anchored to a certain point in the layout.
|
|
/// Gets a dimension that is anchored to a certain point in the layout.
|
|
/// This method is typically used internally by the layout system to determine the size of a View.
|
|
/// This method is typically used internally by the layout system to determine the size of a View.
|
|
/// </summary>
|
|
/// </summary>
|
|
- /// <param name="width">The width of the area where the View is being sized (Superview.ContentSize).</param>
|
|
|
|
|
|
+ /// <param name="size">The width of the area where the View is being sized (Superview.ContentSize).</param>
|
|
/// <returns>
|
|
/// <returns>
|
|
/// An integer representing the calculated dimension. The way this dimension is calculated depends on the specific
|
|
/// An integer representing the calculated dimension. The way this dimension is calculated depends on the specific
|
|
/// subclass of Dim that is used. For example, DimAbsolute returns a fixed dimension, DimFactor returns a
|
|
/// subclass of Dim that is used. For example, DimAbsolute returns a fixed dimension, DimFactor returns a
|
|
@@ -286,7 +286,7 @@ public class Dim
|
|
/// <param name="left">The first <see cref="Dim"/> to add.</param>
|
|
/// <param name="left">The first <see cref="Dim"/> to add.</param>
|
|
/// <param name="right">The second <see cref="Dim"/> to add.</param>
|
|
/// <param name="right">The second <see cref="Dim"/> to add.</param>
|
|
/// <returns>The <see cref="Dim"/> that is the sum of the values of <c>left</c> and <c>right</c>.</returns>
|
|
/// <returns>The <see cref="Dim"/> that is the sum of the values of <c>left</c> and <c>right</c>.</returns>
|
|
- public static Dim operator + (Dim left, Dim right)
|
|
|
|
|
|
+ public static Dim operator + (Dim? left, Dim? right)
|
|
{
|
|
{
|
|
if (left is DimAbsolute && right is DimAbsolute)
|
|
if (left is DimAbsolute && right is DimAbsolute)
|
|
{
|
|
{
|
|
@@ -311,7 +311,7 @@ public class Dim
|
|
/// <param name="left">The <see cref="Dim"/> to subtract from (the minuend).</param>
|
|
/// <param name="left">The <see cref="Dim"/> to subtract from (the minuend).</param>
|
|
/// <param name="right">The <see cref="Dim"/> to subtract (the subtrahend).</param>
|
|
/// <param name="right">The <see cref="Dim"/> to subtract (the subtrahend).</param>
|
|
/// <returns>The <see cref="Dim"/> that is the <c>left</c> minus <c>right</c>.</returns>
|
|
/// <returns>The <see cref="Dim"/> that is the <c>left</c> minus <c>right</c>.</returns>
|
|
- public static Dim operator - (Dim left, Dim right)
|
|
|
|
|
|
+ public static Dim operator - (Dim? left, Dim? right)
|
|
{
|
|
{
|
|
if (left is DimAbsolute && right is DimAbsolute)
|
|
if (left is DimAbsolute && right is DimAbsolute)
|
|
{
|
|
{
|
|
@@ -335,7 +335,7 @@ public class Dim
|
|
internal virtual bool ReferencesOtherViews () { return false; }
|
|
internal virtual bool ReferencesOtherViews () { return false; }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public override bool Equals (object other) { return other is Dim abs && abs == this; }
|
|
|
|
|
|
+ public override bool Equals (object? other) { return other is Dim abs && abs == this; }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override int GetHashCode () { return Anchor (0).GetHashCode (); }
|
|
public override int GetHashCode () { return Anchor (0).GetHashCode (); }
|
|
@@ -356,7 +356,7 @@ public class Dim
|
|
public class DimAbsolute (int size) : Dim
|
|
public class DimAbsolute (int size) : Dim
|
|
{
|
|
{
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public override bool Equals (object other) { return other is DimAbsolute abs && abs.Size == Size; }
|
|
|
|
|
|
+ public override bool Equals (object? other) { return other is DimAbsolute abs && abs.Size == Size; }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override int GetHashCode () { return Size.GetHashCode (); }
|
|
public override int GetHashCode () { return Size.GetHashCode (); }
|
|
@@ -395,10 +395,10 @@ public class DimAbsolute (int size) : Dim
|
|
/// </param>
|
|
/// </param>
|
|
/// <param name="minimumContentDim">The minimum dimension the View's ContentSize will be constrained to.</param>
|
|
/// <param name="minimumContentDim">The minimum dimension the View's ContentSize will be constrained to.</param>
|
|
/// <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. NOT CURRENTLY SUPPORTED.</param>
|
|
-public class DimAuto (DimAutoStyle style, Dim minimumContentDim, Dim maximumContentDim) : Dim
|
|
|
|
|
|
+public class DimAuto (DimAutoStyle style, Dim? minimumContentDim, Dim? maximumContentDim) : Dim
|
|
{
|
|
{
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public override bool Equals (object other)
|
|
|
|
|
|
+ public override bool Equals (object? other)
|
|
{
|
|
{
|
|
return other is DimAuto auto && auto.MinimumContentDim == MinimumContentDim && auto.MaximumContentDim == MaximumContentDim && auto.Style == Style;
|
|
return other is DimAuto auto && auto.MinimumContentDim == MinimumContentDim && auto.MaximumContentDim == MaximumContentDim && auto.Style == Style;
|
|
}
|
|
}
|
|
@@ -409,12 +409,12 @@ public class DimAuto (DimAutoStyle style, Dim minimumContentDim, Dim maximumCont
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED.
|
|
/// Gets the maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED.
|
|
/// </summary>
|
|
/// </summary>
|
|
- public Dim MaximumContentDim { get; } = maximumContentDim;
|
|
|
|
|
|
+ public Dim? MaximumContentDim { get; } = maximumContentDim;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the minimum dimension the View's ContentSize will be constrained to.
|
|
/// Gets the minimum dimension the View's ContentSize will be constrained to.
|
|
/// </summary>
|
|
/// </summary>
|
|
- public Dim MinimumContentDim { get; } = minimumContentDim;
|
|
|
|
|
|
+ public Dim? MinimumContentDim { get; } = minimumContentDim;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the style of the DimAuto.
|
|
/// Gets the style of the DimAuto.
|
|
@@ -571,7 +571,7 @@ public class DimAuto (DimAutoStyle style, Dim minimumContentDim, Dim maximumCont
|
|
/// </remarks>
|
|
/// </remarks>
|
|
/// <param name="left">The left dimension.</param>
|
|
/// <param name="left">The left dimension.</param>
|
|
/// <param name="right">The right dimension.</param>
|
|
/// <param name="right">The right dimension.</param>
|
|
-public class DimCombine (bool add, Dim left, Dim right) : Dim
|
|
|
|
|
|
+public class DimCombine (bool add, Dim? left, Dim? right) : Dim
|
|
{
|
|
{
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets whether the two dimensions are added or subtracted.
|
|
/// Gets whether the two dimensions are added or subtracted.
|
|
@@ -581,20 +581,20 @@ public class DimCombine (bool add, Dim left, Dim right) : Dim
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the left dimension.
|
|
/// Gets the left dimension.
|
|
/// </summary>
|
|
/// </summary>
|
|
- public Dim Left { get; } = left;
|
|
|
|
|
|
+ public Dim? Left { get; } = left;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the right dimension.
|
|
/// Gets the right dimension.
|
|
/// </summary>
|
|
/// </summary>
|
|
- public Dim Right { get; } = right;
|
|
|
|
|
|
+ public Dim? Right { get; } = right;
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override string ToString () { return $"Combine({Left}{(Add ? '+' : '-')}{Right})"; }
|
|
public override string ToString () { return $"Combine({Left}{(Add ? '+' : '-')}{Right})"; }
|
|
|
|
|
|
internal override int Anchor (int size)
|
|
internal override int Anchor (int size)
|
|
{
|
|
{
|
|
- int la = Left.Anchor (size);
|
|
|
|
- int ra = Right.Anchor (size);
|
|
|
|
|
|
+ int la = Left!.Anchor (size);
|
|
|
|
+ int ra = Right!.Anchor (size);
|
|
|
|
|
|
if (Add)
|
|
if (Add)
|
|
{
|
|
{
|
|
@@ -606,8 +606,8 @@ public class DimCombine (bool add, Dim left, Dim right) : Dim
|
|
|
|
|
|
internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
|
|
internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
|
|
{
|
|
{
|
|
- int leftNewDim = Left.Calculate (location, superviewContentSize, us, dimension);
|
|
|
|
- int rightNewDim = Right.Calculate (location, superviewContentSize, us, dimension);
|
|
|
|
|
|
+ int leftNewDim = Left!.Calculate (location, superviewContentSize, us, dimension);
|
|
|
|
+ int rightNewDim = Right!.Calculate (location, superviewContentSize, us, dimension);
|
|
|
|
|
|
int newDimension;
|
|
int newDimension;
|
|
|
|
|
|
@@ -629,12 +629,12 @@ public class DimCombine (bool add, Dim left, Dim right) : Dim
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
internal override bool ReferencesOtherViews ()
|
|
internal override bool ReferencesOtherViews ()
|
|
{
|
|
{
|
|
- if (Left.ReferencesOtherViews ())
|
|
|
|
|
|
+ if (Left!.ReferencesOtherViews ())
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- if (Right.ReferencesOtherViews ())
|
|
|
|
|
|
+ if (Right!.ReferencesOtherViews ())
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -659,7 +659,7 @@ public class DimCombine (bool add, Dim left, Dim right) : Dim
|
|
public class DimPercent (float percent, bool usePosition = false) : Dim
|
|
public class DimPercent (float percent, bool usePosition = false) : Dim
|
|
{
|
|
{
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public override bool Equals (object other) { return other is DimPercent f && f.Percent == Percent && f.UsePosition == UsePosition; }
|
|
|
|
|
|
+ public override bool Equals (object? other) { return other is DimPercent f && f.Percent == Percent && f.UsePosition == UsePosition; }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override int GetHashCode () { return Percent.GetHashCode (); }
|
|
public override int GetHashCode () { return Percent.GetHashCode (); }
|
|
@@ -698,7 +698,7 @@ public class DimPercent (float percent, bool usePosition = false) : Dim
|
|
public class DimFill (int margin) : Dim
|
|
public class DimFill (int margin) : Dim
|
|
{
|
|
{
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public override bool Equals (object other) { return other is DimFill fill && fill.Margin == Margin; }
|
|
|
|
|
|
+ public override bool Equals (object? other) { return other is DimFill fill && fill.Margin == Margin; }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override int GetHashCode () { return Margin.GetHashCode (); }
|
|
public override int GetHashCode () { return Margin.GetHashCode (); }
|
|
@@ -725,7 +725,7 @@ public class DimFill (int margin) : Dim
|
|
public class DimFunc (Func<int> dim) : Dim
|
|
public class DimFunc (Func<int> dim) : Dim
|
|
{
|
|
{
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public override bool Equals (object other) { return other is DimFunc f && f.Func () == Func (); }
|
|
|
|
|
|
+ public override bool Equals (object? other) { return other is DimFunc f && f.Func () == Func (); }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the function that computes the dimension.
|
|
/// Gets the function that computes the dimension.
|
|
@@ -767,7 +767,7 @@ public class DimView : Dim
|
|
public Dimension Dimension { get; }
|
|
public Dimension Dimension { get; }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public override bool Equals (object other) { return other is DimView abs && abs.Target == Target && abs.Dimension == Dimension; }
|
|
|
|
|
|
+ public override bool Equals (object? other) { return other is DimView abs && abs.Target == Target && abs.Dimension == Dimension; }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override int GetHashCode () { return Target.GetHashCode (); }
|
|
public override int GetHashCode () { return Target.GetHashCode (); }
|