|
@@ -145,6 +145,11 @@ public class Dim
|
|
{
|
|
{
|
|
#region static Dim creation methods
|
|
#region static Dim creation methods
|
|
|
|
|
|
|
|
+ /// <summary>Creates an Absolute <see cref="Dim"/> from the specified integer value.</summary>
|
|
|
|
+ /// <returns>The Absolute <see cref="Dim"/>.</returns>
|
|
|
|
+ /// <param name="size">The value to convert to the <see cref="Dim"/>.</param>
|
|
|
|
+ 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.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -180,8 +185,7 @@ public class Dim
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Creates a <see cref="Dim"/> object that fills the dimension, leaving the specified number of columns for a
|
|
|
|
- /// margin.
|
|
|
|
|
|
+ /// Creates a <see cref="Dim"/> object that fills the dimension, leaving the specified margin.
|
|
/// </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>
|
|
@@ -231,11 +235,6 @@ public class Dim
|
|
return new DimPercent (percent / 100, usePosition);
|
|
return new DimPercent (percent / 100, usePosition);
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>Creates an Absolute <see cref="Dim"/> from the specified integer value.</summary>
|
|
|
|
- /// <returns>The Absolute <see cref="Dim"/>.</returns>
|
|
|
|
- /// <param name="size">The value to convert to the <see cref="Dim"/>.</param>
|
|
|
|
- public static Dim Absolute (int size) { return new DimAbsolute (size); }
|
|
|
|
-
|
|
|
|
/// <summary>Creates a <see cref="Dim"/> object that tracks the Width of the specified <see cref="View"/>.</summary>
|
|
/// <summary>Creates a <see cref="Dim"/> object that tracks the Width of the specified <see cref="View"/>.</summary>
|
|
/// <returns>The width <see cref="Dim"/> of the other <see cref="View"/>.</returns>
|
|
/// <returns>The width <see cref="Dim"/> of the other <see cref="View"/>.</returns>
|
|
/// <param name="view">The view that will be tracked.</param>
|
|
/// <param name="view">The view that will be tracked.</param>
|
|
@@ -355,17 +354,17 @@ public class Dim
|
|
/// <param name="size"></param>
|
|
/// <param name="size"></param>
|
|
public class DimAbsolute (int size) : Dim
|
|
public class DimAbsolute (int size) : Dim
|
|
{
|
|
{
|
|
- /// <summary>
|
|
|
|
- /// Gets the size of the dimension.
|
|
|
|
- /// </summary>
|
|
|
|
- public int Size { get; } = size;
|
|
|
|
-
|
|
|
|
/// <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 (); }
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Gets the size of the dimension.
|
|
|
|
+ /// </summary>
|
|
|
|
+ public int Size { get; } = size;
|
|
|
|
+
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override string ToString () { return $"Absolute({Size})"; }
|
|
public override string ToString () { return $"Absolute({Size})"; }
|
|
|
|
|
|
@@ -397,21 +396,33 @@ public class DimAbsolute (int size) : Dim
|
|
/// <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
|
|
{
|
|
{
|
|
- /// <summary>
|
|
|
|
- /// Gets the minimum dimension the View's ContentSize will be constrained to.
|
|
|
|
- /// </summary>
|
|
|
|
- public Dim MinimumContentDim { get; } = minimumContentDim;
|
|
|
|
|
|
+ /// <inheritdoc/>
|
|
|
|
+ public override bool Equals (object other)
|
|
|
|
+ {
|
|
|
|
+ return other is DimAuto auto && auto.MinimumContentDim == MinimumContentDim && auto.MaximumContentDim == MaximumContentDim && auto.Style == Style;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <inheritdoc/>
|
|
|
|
+ public override int GetHashCode () { return HashCode.Combine (base.GetHashCode (), MinimumContentDim, MaximumContentDim, Style); }
|
|
|
|
|
|
/// <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>
|
|
|
|
+ /// Gets the minimum dimension the View's ContentSize will be constrained to.
|
|
|
|
+ /// </summary>
|
|
|
|
+ public Dim MinimumContentDim { get; } = minimumContentDim;
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the style of the DimAuto.
|
|
/// Gets the style of the DimAuto.
|
|
/// </summary>
|
|
/// </summary>
|
|
public DimAutoStyle Style { get; } = style;
|
|
public DimAutoStyle Style { get; } = style;
|
|
|
|
|
|
|
|
+ /// <inheritdoc/>
|
|
|
|
+ public override string ToString () { return $"Auto({Style},{MinimumContentDim},{MaximumContentDim})"; }
|
|
|
|
+
|
|
internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
|
|
internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
|
|
{
|
|
{
|
|
if (us == null)
|
|
if (us == null)
|
|
@@ -502,18 +513,6 @@ public class DimAuto (DimAutoStyle style, Dim minimumContentDim, Dim maximumCont
|
|
// BUGBUG: This is not correct. _contentSize may be null.
|
|
// BUGBUG: This is not correct. _contentSize may be null.
|
|
return false; //_style.HasFlag (DimAutoStyle.Content);
|
|
return false; //_style.HasFlag (DimAutoStyle.Content);
|
|
}
|
|
}
|
|
-
|
|
|
|
- /// <inheritdoc/>
|
|
|
|
- public override bool Equals (object other)
|
|
|
|
- {
|
|
|
|
- return other is DimAuto auto && auto.MinimumContentDim == MinimumContentDim && auto.MaximumContentDim == MaximumContentDim && auto.Style == Style;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <inheritdoc/>
|
|
|
|
- public override int GetHashCode () { return HashCode.Combine (base.GetHashCode (), MinimumContentDim, MaximumContentDim, Style); }
|
|
|
|
-
|
|
|
|
- /// <inheritdoc/>
|
|
|
|
- public override string ToString () { return $"Auto({Style},{MinimumContentDim},{MaximumContentDim})"; }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -616,27 +615,27 @@ public class DimCombine (bool add, Dim left, Dim right) : Dim
|
|
/// </param>
|
|
/// </param>
|
|
public class DimPercent (float percent, bool usePosition = false) : Dim
|
|
public class DimPercent (float percent, bool usePosition = false) : Dim
|
|
{
|
|
{
|
|
- /// <summary>
|
|
|
|
- /// Gets the percentage.
|
|
|
|
- /// </summary>
|
|
|
|
- public new float Percent { get; } = percent;
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Gets whether the dimension is computed using the View's position or ContentSize.
|
|
|
|
- /// </summary>
|
|
|
|
- public bool UsePosition { get; } = usePosition;
|
|
|
|
-
|
|
|
|
/// <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 (); }
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Gets the percentage.
|
|
|
|
+ /// </summary>
|
|
|
|
+ public new float Percent { get; } = percent;
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public override string ToString () { return $"Percent({Percent},{UsePosition})"; }
|
|
public override string ToString () { return $"Percent({Percent},{UsePosition})"; }
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Gets whether the dimension is computed using the View's position or ContentSize.
|
|
|
|
+ /// </summary>
|
|
|
|
+ public bool UsePosition { get; } = usePosition;
|
|
|
|
+
|
|
internal override int Anchor (int size) { return (int)(size * Percent); }
|
|
internal override int Anchor (int size) { return (int)(size * Percent); }
|
|
|
|
|
|
internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
|
|
internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
|
|
@@ -655,17 +654,17 @@ public class DimPercent (float percent, bool usePosition = false) : Dim
|
|
/// <param name="margin">The margin to not fill.</param>
|
|
/// <param name="margin">The margin to not fill.</param>
|
|
public class DimFill (int margin) : Dim
|
|
public class DimFill (int margin) : Dim
|
|
{
|
|
{
|
|
- /// <summary>
|
|
|
|
- /// Gets the margin to not fill.
|
|
|
|
- /// </summary>
|
|
|
|
- public int Margin { get; } = margin;
|
|
|
|
-
|
|
|
|
/// <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 (); }
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Gets the margin to not fill.
|
|
|
|
+ /// </summary>
|
|
|
|
+ public int Margin { get; } = margin;
|
|
|
|
+
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override string ToString () { return $"Fill({Margin})"; }
|
|
public override string ToString () { return $"Fill({Margin})"; }
|
|
|
|
|
|
@@ -682,14 +681,14 @@ public class DimFill (int margin) : Dim
|
|
/// <param name="dim"></param>
|
|
/// <param name="dim"></param>
|
|
public class DimFunc (Func<int> dim) : Dim
|
|
public class DimFunc (Func<int> dim) : Dim
|
|
{
|
|
{
|
|
|
|
+ /// <inheritdoc/>
|
|
|
|
+ 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.
|
|
/// </summary>
|
|
/// </summary>
|
|
public Func<int> Func { get; } = dim;
|
|
public Func<int> Func { get; } = dim;
|
|
|
|
|
|
- /// <inheritdoc/>
|
|
|
|
- public override bool Equals (object other) { return other is DimFunc f && f.Func () == Func (); }
|
|
|
|
-
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override int GetHashCode () { return Func.GetHashCode (); }
|
|
public override int GetHashCode () { return Func.GetHashCode (); }
|
|
|
|
|
|
@@ -708,11 +707,6 @@ public class DimFunc (Func<int> dim) : Dim
|
|
/// </remarks>
|
|
/// </remarks>
|
|
public class DimView : Dim
|
|
public class DimView : Dim
|
|
{
|
|
{
|
|
- /// <summary>
|
|
|
|
- /// Gets the indicated dimension of the View.
|
|
|
|
- /// </summary>
|
|
|
|
- public Dimension Dimension { get; }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="DimView"/> class.
|
|
/// Initializes a new instance of the <see cref="DimView"/> class.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -725,9 +719,9 @@ public class DimView : Dim
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Gets the View the dimension is anchored to.
|
|
|
|
|
|
+ /// Gets the indicated dimension of the View.
|
|
/// </summary>
|
|
/// </summary>
|
|
- public View Target { get; init; }
|
|
|
|
|
|
+ public Dimension Dimension { get; }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override bool Equals (object other) { return other is DimView abs && abs.Target == Target; }
|
|
public override bool Equals (object other) { return other is DimView abs && abs.Target == Target; }
|
|
@@ -735,6 +729,11 @@ public class DimView : Dim
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override int GetHashCode () { return Target.GetHashCode (); }
|
|
public override int GetHashCode () { return Target.GetHashCode (); }
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Gets the View the dimension is anchored to.
|
|
|
|
+ /// </summary>
|
|
|
|
+ public View Target { get; init; }
|
|
|
|
+
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
public override string ToString ()
|
|
public override string ToString ()
|
|
{
|
|
{
|