|
@@ -1,84 +1,83 @@
|
|
|
|
+using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
using static Terminal.Gui.Dim;
|
|
using static Terminal.Gui.Dim;
|
|
|
|
|
|
namespace Terminal.Gui;
|
|
namespace Terminal.Gui;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
-/// Describes the position of a <see cref="View"/> which can be an absolute value, a percentage, centered, or
|
|
|
|
-/// relative to the ending dimension. Integer values are implicitly convertible to an absolute <see cref="Pos"/>. These
|
|
|
|
-/// objects are created using the static methods Percent, AnchorEnd, and Center. The <see cref="Pos"/> objects can be
|
|
|
|
-/// combined with the addition and subtraction operators.
|
|
|
|
|
|
+/// Describes the horizontal or vertical position of a <see cref="View"/>. The position can be an absolute value,
|
|
|
|
+/// a percentage, centered, a function, relative to the ending dimension, relative to another View, or aligned with a
|
|
|
|
+/// set of views.
|
|
|
|
+/// Integer values are implicitly convertible to an absolute <see cref="Pos"/>. <see cref="Pos"/>
|
|
|
|
+/// objects are created using the static methods provided (e.g. <see cref="Percent"/> and <see cref="Center"/>).
|
|
|
|
+/// The <see cref="Pos"/> objects can be combined with the addition and subtraction operators.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <remarks>
|
|
-/// <para>Use the <see cref="Pos"/> objects on the X or Y properties of a view to control the position.</para>
|
|
|
|
|
|
+/// <para>Use the <see cref="Pos"/> objects on the X or Y properties of a <see cref="View"/> to control the position.</para>
|
|
/// <para>
|
|
/// <para>
|
|
/// These can be used to set the absolute position, when merely assigning an integer value (via the implicit
|
|
/// These can be used to set the absolute position, when merely assigning an integer value (via the implicit
|
|
/// integer to <see cref="Pos"/> conversion), and they can be combined to produce more useful layouts, like:
|
|
/// integer to <see cref="Pos"/> conversion), and they can be combined to produce more useful layouts, like:
|
|
-/// Pos.Center - 3, which would shift the position of the <see cref="View"/> 3 characters to the left after
|
|
|
|
|
|
+/// <c>Pos.Center - 3</c>, which would shift the position of the <see cref="View"/> 3 characters to the left after
|
|
/// centering for example.
|
|
/// centering for example.
|
|
/// </para>
|
|
/// </para>
|
|
/// <para>
|
|
/// <para>
|
|
-/// Reference coordinates of another view by using the methods Left(View), Right(View), Bottom(View), Top(View).
|
|
|
|
-/// The X(View) and Y(View) are aliases to Left(View) and Top(View) respectively.
|
|
|
|
-/// </para>
|
|
|
|
-/// <para>
|
|
|
|
/// <list type="table">
|
|
/// <list type="table">
|
|
/// <listheader>
|
|
/// <listheader>
|
|
/// <term>Pos Object</term> <description>Description</description>
|
|
/// <term>Pos Object</term> <description>Description</description>
|
|
/// </listheader>
|
|
/// </listheader>
|
|
/// <item>
|
|
/// <item>
|
|
/// <term>
|
|
/// <term>
|
|
-/// <see cref="Pos.Function(Func{int})"/>
|
|
|
|
|
|
+/// <see cref="Pos.Align"/>
|
|
/// </term>
|
|
/// </term>
|
|
/// <description>
|
|
/// <description>
|
|
-/// Creates a <see cref="Pos"/> object that computes the position by executing the provided
|
|
|
|
-/// function. The function will be called every time the position is needed.
|
|
|
|
|
|
+/// Creates a <see cref="Pos"/> object that aligns a set of views.
|
|
/// </description>
|
|
/// </description>
|
|
/// </item>
|
|
/// </item>
|
|
/// <item>
|
|
/// <item>
|
|
/// <term>
|
|
/// <term>
|
|
-/// <see cref="Pos.Percent(float)"/>
|
|
|
|
|
|
+/// <see cref="Pos.AnchorEnd()"/>
|
|
/// </term>
|
|
/// </term>
|
|
/// <description>
|
|
/// <description>
|
|
-/// Creates a <see cref="Pos"/> object that is a percentage of the width or height of the
|
|
|
|
-/// SuperView.
|
|
|
|
|
|
+/// Creates a <see cref="Pos"/> object that is anchored to the end (right side or bottom) of
|
|
|
|
+/// the dimension, useful to flush the layout from the right or bottom.
|
|
/// </description>
|
|
/// </description>
|
|
/// </item>
|
|
/// </item>
|
|
/// <item>
|
|
/// <item>
|
|
/// <term>
|
|
/// <term>
|
|
-/// <see cref="Pos.Align()"/>
|
|
|
|
|
|
+/// <see cref="Pos.At(int)"/>
|
|
/// </term>
|
|
/// </term>
|
|
/// <description>
|
|
/// <description>
|
|
-/// Creates a <see cref="Pos"/> object that aligns a set of views.
|
|
|
|
|
|
+/// Creates a <see cref="Pos"/> object that is an absolute position based on the specified
|
|
|
|
+/// integer.
|
|
/// </description>
|
|
/// </description>
|
|
/// </item>
|
|
/// </item>
|
|
/// <item>
|
|
/// <item>
|
|
/// <term>
|
|
/// <term>
|
|
-/// <see cref="Pos.AnchorEnd()"/>
|
|
|
|
|
|
+/// <see cref="Pos.Center"/>
|
|
/// </term>
|
|
/// </term>
|
|
-/// <description>
|
|
|
|
-/// Creates a <see cref="Pos"/> object that is anchored to the end (right side or bottom) of
|
|
|
|
-/// the dimension, useful to flush the layout from the right or bottom.
|
|
|
|
-/// </description>
|
|
|
|
|
|
+/// <description>Creates a <see cref="Pos"/> object that can be used to center the <see cref="View"/>.</description>
|
|
/// </item>
|
|
/// </item>
|
|
/// <item>
|
|
/// <item>
|
|
/// <term>
|
|
/// <term>
|
|
-/// <see cref="Pos.Center"/>
|
|
|
|
|
|
+/// <see cref="Pos.Function(Func{int})"/>
|
|
/// </term>
|
|
/// </term>
|
|
-/// <description>Creates a <see cref="Pos"/> object that can be used to center the <see cref="View"/>.</description>
|
|
|
|
|
|
+/// <description>
|
|
|
|
+/// Creates a <see cref="Pos"/> object that computes the position by executing the provided
|
|
|
|
+/// function. The function will be called every time the position is needed.
|
|
|
|
+/// </description>
|
|
/// </item>
|
|
/// </item>
|
|
/// <item>
|
|
/// <item>
|
|
/// <term>
|
|
/// <term>
|
|
-/// <see cref="Pos.At(int)"/>
|
|
|
|
|
|
+/// <see cref="Pos.Percent(float)"/>
|
|
/// </term>
|
|
/// </term>
|
|
/// <description>
|
|
/// <description>
|
|
-/// Creates a <see cref="Pos"/> object that is an absolute position based on the specified
|
|
|
|
-/// integer value.
|
|
|
|
|
|
+/// Creates a <see cref="Pos"/> object that is a percentage of the width or height of the
|
|
|
|
+/// SuperView.
|
|
/// </description>
|
|
/// </description>
|
|
/// </item>
|
|
/// </item>
|
|
/// <item>
|
|
/// <item>
|
|
/// <term>
|
|
/// <term>
|
|
-/// <see cref="Pos.Left"/>
|
|
|
|
|
|
+/// <see cref="Pos.Left(View)"/>
|
|
/// </term>
|
|
/// </term>
|
|
/// <description>
|
|
/// <description>
|
|
/// Creates a <see cref="Pos"/> object that tracks the Left (X) position of the specified
|
|
/// Creates a <see cref="Pos"/> object that tracks the Left (X) position of the specified
|
|
@@ -135,6 +134,8 @@ namespace Terminal.Gui;
|
|
/// </remarks>
|
|
/// </remarks>
|
|
public class Pos
|
|
public class Pos
|
|
{
|
|
{
|
|
|
|
+ #region Static Methods - Create Pos objects
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Creates a <see cref="Pos"/> object that is anchored to the end (right side or
|
|
/// Creates a <see cref="Pos"/> object that is anchored to the end (right side or
|
|
/// bottom) of the SuperView, minus the respective dimension of the View. This is equivalent to using
|
|
/// bottom) of the SuperView, minus the respective dimension of the View. This is equivalent to using
|
|
@@ -196,14 +197,6 @@ public class Pos
|
|
/// </example>
|
|
/// </example>
|
|
public static Pos Center () { return new PosCenter (); }
|
|
public static Pos Center () { return new PosCenter (); }
|
|
|
|
|
|
- /// <summary>Determines whether the specified object is equal to the current object.</summary>
|
|
|
|
- /// <param name="other">The object to compare with the current object. </param>
|
|
|
|
- /// <returns>
|
|
|
|
- /// <see langword="true"/> if the specified object is equal to the current object; otherwise,
|
|
|
|
- /// <see langword="false"/>.
|
|
|
|
- /// </returns>
|
|
|
|
- public override bool Equals (object other) { return other is Pos abs && abs == this; }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Creates a <see cref="Pos"/> object that computes the position by executing the provided function. The function
|
|
/// Creates a <see cref="Pos"/> object that computes the position by executing the provided function. The function
|
|
/// will be called every time the position is needed.
|
|
/// will be called every time the position is needed.
|
|
@@ -212,69 +205,17 @@ public class Pos
|
|
/// <returns>The <see cref="Pos"/> returned from the function.</returns>
|
|
/// <returns>The <see cref="Pos"/> returned from the function.</returns>
|
|
public static Pos Function (Func<int> function) { return new PosFunc (function); }
|
|
public static Pos Function (Func<int> function) { return new PosFunc (function); }
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Creates a <see cref="Pos"/> object that aligns a set of views according to the specified alignment setting.
|
|
|
|
|
|
+ /// Creates a <see cref="Pos"/> object that aligns a set of views according to the specified alignment setting.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="alignment"></param>
|
|
/// <param name="alignment"></param>
|
|
- /// <param name="groupId">The optional, unique identifier for the set of views to align according to <paramref name="alignment"/>.</param>
|
|
|
|
|
|
+ /// <param name="groupId">
|
|
|
|
+ /// The optional, unique identifier for the set of views to align according to
|
|
|
|
+ /// <paramref name="alignment"/>.
|
|
|
|
+ /// </param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public static Pos Align (Alignment alignment, int groupId = 0) { return new PosAlign (alignment, groupId); }
|
|
public static Pos Align (Alignment alignment, int groupId = 0) { return new PosAlign (alignment, groupId); }
|
|
|
|
|
|
- /// <summary>Serves as the default hash function. </summary>
|
|
|
|
- /// <returns>A hash code for the current object.</returns>
|
|
|
|
- public override int GetHashCode () { return Anchor (0).GetHashCode (); }
|
|
|
|
-
|
|
|
|
- /// <summary>Adds a <see cref="Terminal.Gui.Pos"/> to a <see cref="Terminal.Gui.Pos"/>, yielding a new <see cref="Pos"/>.</summary>
|
|
|
|
- /// <param name="left">The first <see cref="Terminal.Gui.Pos"/> to add.</param>
|
|
|
|
- /// <param name="right">The second <see cref="Terminal.Gui.Pos"/> to add.</param>
|
|
|
|
- /// <returns>The <see cref="Pos"/> that is the sum of the values of <c>left</c> and <c>right</c>.</returns>
|
|
|
|
- public static Pos operator + (Pos left, Pos right)
|
|
|
|
- {
|
|
|
|
- if (left is PosAbsolute && right is PosAbsolute)
|
|
|
|
- {
|
|
|
|
- return new PosAbsolute (left.Anchor (0) + right.Anchor (0));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var newPos = new PosCombine (true, left, right);
|
|
|
|
-
|
|
|
|
- if (left is PosView view)
|
|
|
|
- {
|
|
|
|
- view.Target.SetNeedsLayout ();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return newPos;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>Creates an Absolute <see cref="Pos"/> from the specified integer value.</summary>
|
|
|
|
- /// <returns>The Absolute <see cref="Pos"/>.</returns>
|
|
|
|
- /// <param name="n">The value to convert to the <see cref="Pos"/> .</param>
|
|
|
|
- public static implicit operator Pos (int n) { return new PosAbsolute (n); }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Subtracts a <see cref="Terminal.Gui.Pos"/> from a <see cref="Terminal.Gui.Pos"/>, yielding a new
|
|
|
|
- /// <see cref="Pos"/>.
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="left">The <see cref="Terminal.Gui.Pos"/> to subtract from (the minuend).</param>
|
|
|
|
- /// <param name="right">The <see cref="Terminal.Gui.Pos"/> to subtract (the subtrahend).</param>
|
|
|
|
- /// <returns>The <see cref="Pos"/> that is the <c>left</c> minus <c>right</c>.</returns>
|
|
|
|
- public static Pos operator - (Pos left, Pos right)
|
|
|
|
- {
|
|
|
|
- if (left is PosAbsolute && right is PosAbsolute)
|
|
|
|
- {
|
|
|
|
- return new PosAbsolute (left.Anchor (0) - right.Anchor (0));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var newPos = new PosCombine (false, left, right);
|
|
|
|
-
|
|
|
|
- if (left is PosView view)
|
|
|
|
- {
|
|
|
|
- view.Target.SetNeedsLayout ();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return newPos;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// <summary>Creates a percentage <see cref="Pos"/> object</summary>
|
|
/// <summary>Creates a percentage <see cref="Pos"/> object</summary>
|
|
/// <returns>The percent <see cref="Pos"/> object.</returns>
|
|
/// <returns>The percent <see cref="Pos"/> object.</returns>
|
|
/// <param name="percent">A value between 0 and 100 representing the percentage.</param>
|
|
/// <param name="percent">A value between 0 and 100 representing the percentage.</param>
|
|
@@ -336,8 +277,12 @@ public class Pos
|
|
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
|
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
|
public static Pos Right (View view) { return new PosView (view, Side.Right); }
|
|
public static Pos Right (View view) { return new PosView (view, Side.Right); }
|
|
|
|
|
|
|
|
+ #endregion Static Methods - Create Pos objects
|
|
|
|
+
|
|
|
|
+ #region Methods
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Gets a position that is anchored to a certain point in the layout. This method is typically used
|
|
|
|
|
|
+ /// Gets a position that is anchored to a certain point in the layout. This method is used
|
|
/// internally by the layout system to determine where a View should be positioned.
|
|
/// internally by the layout system to determine where a View should be positioned.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="width">The width of the area where the View is being positioned (Superview.ContentSize).</param>
|
|
/// <param name="width">The width of the area where the View is being positioned (Superview.ContentSize).</param>
|
|
@@ -364,21 +309,88 @@ public class Pos
|
|
/// that
|
|
/// that
|
|
/// is used.
|
|
/// is used.
|
|
/// </returns>
|
|
/// </returns>
|
|
- internal virtual int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension)
|
|
|
|
|
|
+ internal virtual int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension) { return Anchor (superviewDimension); }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Diagnostics API to determine if this Pos object references other views.
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ internal virtual bool ReferencesOtherViews () { return false; }
|
|
|
|
+
|
|
|
|
+ #endregion Methods
|
|
|
|
+
|
|
|
|
+ #region Operators
|
|
|
|
+
|
|
|
|
+ /// <summary>Adds a <see cref="Terminal.Gui.Pos"/> to a <see cref="Terminal.Gui.Pos"/>, yielding a new <see cref="Pos"/>.</summary>
|
|
|
|
+ /// <param name="left">The first <see cref="Terminal.Gui.Pos"/> to add.</param>
|
|
|
|
+ /// <param name="right">The second <see cref="Terminal.Gui.Pos"/> to add.</param>
|
|
|
|
+ /// <returns>The <see cref="Pos"/> that is the sum of the values of <c>left</c> and <c>right</c>.</returns>
|
|
|
|
+ public static Pos operator + (Pos left, Pos right)
|
|
{
|
|
{
|
|
- return Anchor (superviewDimension);
|
|
|
|
|
|
+ if (left is PosAbsolute && right is PosAbsolute)
|
|
|
|
+ {
|
|
|
|
+ return new PosAbsolute (left.Anchor (0) + right.Anchor (0));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var newPos = new PosCombine (true, left, right);
|
|
|
|
+
|
|
|
|
+ if (left is PosView view)
|
|
|
|
+ {
|
|
|
|
+ view.Target.SetNeedsLayout ();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return newPos;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>Creates an Absolute <see cref="Pos"/> from the specified integer value.</summary>
|
|
|
|
+ /// <returns>The Absolute <see cref="Pos"/>.</returns>
|
|
|
|
+ /// <param name="n">The value to convert to the <see cref="Pos"/> .</param>
|
|
|
|
+ public static implicit operator Pos (int n) { return new PosAbsolute (n); }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Diagnostics API to determine if this Pos object references other views.
|
|
|
|
|
|
+ /// Subtracts a <see cref="Terminal.Gui.Pos"/> from a <see cref="Terminal.Gui.Pos"/>, yielding a new
|
|
|
|
+ /// <see cref="Pos"/>.
|
|
/// </summary>
|
|
/// </summary>
|
|
- /// <returns></returns>
|
|
|
|
- internal virtual bool ReferencesOtherViews ()
|
|
|
|
|
|
+ /// <param name="left">The <see cref="Terminal.Gui.Pos"/> to subtract from (the minuend).</param>
|
|
|
|
+ /// <param name="right">The <see cref="Terminal.Gui.Pos"/> to subtract (the subtrahend).</param>
|
|
|
|
+ /// <returns>The <see cref="Pos"/> that is the <c>left</c> minus <c>right</c>.</returns>
|
|
|
|
+ public static Pos operator - (Pos left, Pos right)
|
|
{
|
|
{
|
|
- return false;
|
|
|
|
|
|
+ if (left is PosAbsolute && right is PosAbsolute)
|
|
|
|
+ {
|
|
|
|
+ return new PosAbsolute (left.Anchor (0) - right.Anchor (0));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var newPos = new PosCombine (false, left, right);
|
|
|
|
+
|
|
|
|
+ if (left is PosView view)
|
|
|
|
+ {
|
|
|
|
+ view.Target.SetNeedsLayout ();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return newPos;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region Overrides
|
|
|
|
+
|
|
|
|
+ /// <summary>Determines whether the specified object is equal to the current object.</summary>
|
|
|
|
+ /// <param name="other">The object to compare with the current object. </param>
|
|
|
|
+ /// <returns>
|
|
|
|
+ /// <see langword="true"/> if the specified object is equal to the current object; otherwise,
|
|
|
|
+ /// <see langword="false"/>.
|
|
|
|
+ /// </returns>
|
|
|
|
+ public override bool Equals (object other) { return other is Pos abs && abs == this; }
|
|
|
|
+
|
|
|
|
+ /// <summary>Serves as the default hash function. </summary>
|
|
|
|
+ /// <returns>A hash code for the current object.</returns>
|
|
|
|
+ public override int GetHashCode () { return Anchor (0).GetHashCode (); }
|
|
|
|
+
|
|
|
|
+ #endregion Overrides
|
|
|
|
+
|
|
|
|
+ #region Pos Types
|
|
|
|
+ // TODO: These should not be nested classes - extract them.
|
|
internal class PosAbsolute (int n) : Pos
|
|
internal class PosAbsolute (int n) : Pos
|
|
{
|
|
{
|
|
private readonly int _n = n;
|
|
private readonly int _n = n;
|
|
@@ -413,7 +425,7 @@ public class Pos
|
|
return width - _offset;
|
|
return width - _offset;
|
|
}
|
|
}
|
|
|
|
|
|
- internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension)
|
|
|
|
|
|
+ internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
|
|
{
|
|
{
|
|
int newLocation = Anchor (superviewDimension);
|
|
int newLocation = Anchor (superviewDimension);
|
|
|
|
|
|
@@ -431,7 +443,7 @@ public class Pos
|
|
public override string ToString () { return "Center"; }
|
|
public override string ToString () { return "Center"; }
|
|
internal override int Anchor (int width) { return width / 2; }
|
|
internal override int Anchor (int width) { return width / 2; }
|
|
|
|
|
|
- internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension)
|
|
|
|
|
|
+ internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
|
|
{
|
|
{
|
|
int newDimension = Math.Max (dim.Calculate (0, superviewDimension, us, dimension), 0);
|
|
int newDimension = Math.Max (dim.Calculate (0, superviewDimension, us, dimension), 0);
|
|
|
|
|
|
@@ -459,7 +471,7 @@ public class Pos
|
|
return la - ra;
|
|
return la - ra;
|
|
}
|
|
}
|
|
|
|
|
|
- internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension)
|
|
|
|
|
|
+ internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
|
|
{
|
|
{
|
|
int newDimension = dim.Calculate (0, superviewDimension, us, dimension);
|
|
int newDimension = dim.Calculate (0, superviewDimension, us, dimension);
|
|
int left = _left.Calculate (superviewDimension, dim, us, dimension);
|
|
int left = _left.Calculate (superviewDimension, dim, us, dimension);
|
|
@@ -474,7 +486,7 @@ public class Pos
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Diagnostics API to determine if this Pos object references other views.
|
|
|
|
|
|
+ /// Diagnostics API to determine if this Pos object references other views.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
internal override bool ReferencesOtherViews ()
|
|
internal override bool ReferencesOtherViews ()
|
|
@@ -502,54 +514,55 @@ public class Pos
|
|
internal override int Anchor (int width) { return (int)(width * _factor); }
|
|
internal override int Anchor (int width) { return (int)(width * _factor); }
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Enables alignment of a set of views.
|
|
|
|
|
|
+ /// Enables alignment of a set of views.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <remarks>
|
|
- /// <para>
|
|
|
|
- /// The Group ID is used to identify a set of views that should be alignment together. When only a single
|
|
|
|
- /// set of views is aligned, setting the Group ID is not needed because it defaults to 0.
|
|
|
|
- /// </para>
|
|
|
|
- /// <para>
|
|
|
|
- /// The first view added to the Superview with a given Group ID is used to determine the alignment of the group.
|
|
|
|
- /// The alignment is applied to all views with the same Group ID.
|
|
|
|
- /// </para>
|
|
|
|
|
|
+ /// <para>
|
|
|
|
+ /// The Group ID is used to identify a set of views that should be alignment together. When only a single
|
|
|
|
+ /// set of views is aligned, setting the Group ID is not needed because it defaults to 0.
|
|
|
|
+ /// </para>
|
|
|
|
+ /// <para>
|
|
|
|
+ /// The first view added to the Superview with a given Group ID is used to determine the alignment of the group.
|
|
|
|
+ /// The alignment is applied to all views with the same Group ID.
|
|
|
|
+ /// </para>
|
|
/// </remarks>
|
|
/// </remarks>
|
|
public class PosAlign : Pos
|
|
public class PosAlign : Pos
|
|
{
|
|
{
|
|
|
|
+ // BUGBUG: PosAlign should be internal like all other Pos classes. It is public because the PosAlign Scenario uses it. Refactor that Scenario.
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// The cached location. Used to store the calculated location to avoid recalculating it.
|
|
|
|
|
|
+ /// The cached location. Used to store the calculated location to avoid recalculating it.
|
|
/// </summary>
|
|
/// </summary>
|
|
private int? _location;
|
|
private int? _location;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Gets the identifier of a set of views that should be aligned together. When only a single
|
|
|
|
- /// set of views is aligned, setting the <see cref="_groupId"/> is not needed because it defaults to 0.
|
|
|
|
|
|
+ /// Gets the identifier of a set of views that should be aligned together. When only a single
|
|
|
|
+ /// set of views is aligned, setting the <see cref="_groupId"/> is not needed because it defaults to 0.
|
|
/// </summary>
|
|
/// </summary>
|
|
private readonly int _groupId;
|
|
private readonly int _groupId;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Gets the alignment settings.
|
|
|
|
|
|
+ /// Gets the alignment settings.
|
|
/// </summary>
|
|
/// </summary>
|
|
public Aligner Aligner { get; } = new ();
|
|
public Aligner Aligner { get; } = new ();
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Aligns the views in <paramref name="views"/> that have the same group ID as <paramref name="groupId"/>.
|
|
|
|
|
|
+ /// Aligns the views in <paramref name="views"/> that have the same group ID as <paramref name="groupId"/>.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="groupId"></param>
|
|
/// <param name="groupId"></param>
|
|
/// <param name="views"></param>
|
|
/// <param name="views"></param>
|
|
/// <param name="dimension"></param>
|
|
/// <param name="dimension"></param>
|
|
/// <param name="size"></param>
|
|
/// <param name="size"></param>
|
|
- private static void AlignGroup (int groupId, IList<View> views, Dim.Dimension dimension, int size)
|
|
|
|
|
|
+ private static void AlignGroup (int groupId, IList<View> views, Dimension dimension, int size)
|
|
{
|
|
{
|
|
if (views is null)
|
|
if (views is null)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
Aligner firstInGroup = null;
|
|
Aligner firstInGroup = null;
|
|
List<int> dimensionsList = new ();
|
|
List<int> dimensionsList = new ();
|
|
|
|
+
|
|
List<View> viewsInGroup = views.Where (
|
|
List<View> viewsInGroup = views.Where (
|
|
v =>
|
|
v =>
|
|
{
|
|
{
|
|
@@ -564,15 +577,17 @@ public class Pos
|
|
}
|
|
}
|
|
|
|
|
|
return false;
|
|
return false;
|
|
- }).ToList ();
|
|
|
|
|
|
+ })
|
|
|
|
+ .ToList ();
|
|
|
|
+
|
|
if (viewsInGroup.Count == 0)
|
|
if (viewsInGroup.Count == 0)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- foreach (var view in viewsInGroup)
|
|
|
|
|
|
+ foreach (View view in viewsInGroup)
|
|
{
|
|
{
|
|
- var posAlign = dimension == Dimension.Width ? view.X as PosAlign : view.Y as PosAlign;
|
|
|
|
|
|
+ PosAlign posAlign = dimension == Dimension.Width ? view.X as PosAlign : view.Y as PosAlign;
|
|
|
|
|
|
if (posAlign is { })
|
|
if (posAlign is { })
|
|
{
|
|
{
|
|
@@ -591,7 +606,7 @@ public class Pos
|
|
}
|
|
}
|
|
|
|
|
|
firstInGroup.ContainerSize = size;
|
|
firstInGroup.ContainerSize = size;
|
|
- var locations = firstInGroup.Align (dimensionsList.ToArray ());
|
|
|
|
|
|
+ int [] locations = firstInGroup.Align (dimensionsList.ToArray ());
|
|
|
|
|
|
for (var index = 0; index < viewsInGroup.Count; index++)
|
|
for (var index = 0; index < viewsInGroup.Count; index++)
|
|
{
|
|
{
|
|
@@ -606,47 +621,35 @@ public class Pos
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Enables alignment of a set of views.
|
|
|
|
|
|
+ /// Enables alignment of a set of views.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="alignment"></param>
|
|
/// <param name="alignment"></param>
|
|
/// <param name="groupId">The unique identifier for the set of views to align according to <paramref name="alignment"/>.</param>
|
|
/// <param name="groupId">The unique identifier for the set of views to align according to <paramref name="alignment"/>.</param>
|
|
public PosAlign (Alignment alignment, int groupId = 0)
|
|
public PosAlign (Alignment alignment, int groupId = 0)
|
|
{
|
|
{
|
|
- Aligner.PutSpaceBetweenItems = true;
|
|
|
|
|
|
+ Aligner.SpaceBetweenItems = true;
|
|
Aligner.Alignment = alignment;
|
|
Aligner.Alignment = alignment;
|
|
_groupId = groupId;
|
|
_groupId = groupId;
|
|
Aligner.PropertyChanged += Aligner_PropertyChanged;
|
|
Aligner.PropertyChanged += Aligner_PropertyChanged;
|
|
}
|
|
}
|
|
|
|
|
|
- private void Aligner_PropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
|
|
|
- {
|
|
|
|
- _location = null;
|
|
|
|
- }
|
|
|
|
|
|
+ private void Aligner_PropertyChanged (object sender, PropertyChangedEventArgs e) { _location = null; }
|
|
|
|
|
|
- /// <inheritdoc />
|
|
|
|
|
|
+ /// <inheritdoc/>
|
|
public override bool Equals (object other)
|
|
public override bool Equals (object other)
|
|
{
|
|
{
|
|
return other is PosAlign align && _groupId == align._groupId && _location == align._location && align.Aligner.Alignment == Aligner.Alignment;
|
|
return other is PosAlign align && _groupId == align._groupId && _location == align._location && align.Aligner.Alignment == Aligner.Alignment;
|
|
}
|
|
}
|
|
|
|
|
|
- /// <inheritdoc />
|
|
|
|
- public override int GetHashCode ()
|
|
|
|
- {
|
|
|
|
- return Aligner.GetHashCode () ^ _groupId.GetHashCode ();
|
|
|
|
- }
|
|
|
|
|
|
+ /// <inheritdoc/>
|
|
|
|
+ public override int GetHashCode () { return Aligner.GetHashCode () ^ _groupId.GetHashCode (); }
|
|
|
|
|
|
- /// <inheritdoc />
|
|
|
|
- public override string ToString ()
|
|
|
|
- {
|
|
|
|
- return $"Align(groupId={_groupId}, alignment={Aligner.Alignment})";
|
|
|
|
- }
|
|
|
|
|
|
+ /// <inheritdoc/>
|
|
|
|
+ public override string ToString () { return $"Align(groupId={_groupId}, alignment={Aligner.Alignment})"; }
|
|
|
|
|
|
- internal override int Anchor (int width)
|
|
|
|
- {
|
|
|
|
- return _location ?? 0 - width;
|
|
|
|
- }
|
|
|
|
|
|
+ internal override int Anchor (int width) { return _location ?? 0 - width; }
|
|
|
|
|
|
- internal override int Calculate (int superviewDimension, Dim dim, View us, Dim.Dimension dimension)
|
|
|
|
|
|
+ internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
|
|
{
|
|
{
|
|
if (_location.HasValue && Aligner.ContainerSize == superviewDimension)
|
|
if (_location.HasValue && Aligner.ContainerSize == superviewDimension)
|
|
{
|
|
{
|
|
@@ -667,8 +670,8 @@ public class Pos
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
// Helper class to provide dynamic value by the execution of a function that returns an integer.
|
|
// Helper class to provide dynamic value by the execution of a function that returns an integer.
|
|
internal class PosFunc (Func<int> n) : Pos
|
|
internal class PosFunc (Func<int> n) : Pos
|
|
{
|
|
{
|
|
@@ -679,28 +682,29 @@ public class Pos
|
|
internal override int Anchor (int width) { return _function (); }
|
|
internal override int Anchor (int width) { return _function (); }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // TODO: This should not be a nested enum. Extract it.
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Describes which side of the view to use for the position.
|
|
|
|
|
|
+ /// Describes which side of the view to use for the position.
|
|
/// </summary>
|
|
/// </summary>
|
|
public enum Side
|
|
public enum Side
|
|
{
|
|
{
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// The left (X) side of the view.
|
|
|
|
|
|
+ /// The left (X) side of the view.
|
|
/// </summary>
|
|
/// </summary>
|
|
Left = 0,
|
|
Left = 0,
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// The top (Y) side of the view.
|
|
|
|
|
|
+ /// The top (Y) side of the view.
|
|
/// </summary>
|
|
/// </summary>
|
|
Top = 1,
|
|
Top = 1,
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// The right (X + Width) side of the view.
|
|
|
|
|
|
+ /// The right (X + Width) side of the view.
|
|
/// </summary>
|
|
/// </summary>
|
|
Right = 2,
|
|
Right = 2,
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// The bottom (Y + Height) side of the view.
|
|
|
|
|
|
+ /// The bottom (Y + Height) side of the view.
|
|
/// </summary>
|
|
/// </summary>
|
|
Bottom = 3
|
|
Bottom = 3
|
|
}
|
|
}
|
|
@@ -744,14 +748,12 @@ public class Pos
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Diagnostics API to determine if this Pos object references other views.
|
|
|
|
|
|
+ /// Diagnostics API to determine if this Pos object references other views.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- internal override bool ReferencesOtherViews ()
|
|
|
|
- {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
|
|
+ internal override bool ReferencesOtherViews () { return true; }
|
|
}
|
|
}
|
|
|
|
+ #endregion Pos Types
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -846,56 +848,54 @@ public class Dim
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// The dimensions will be computed based on the View's non-Text content.
|
|
/// The dimensions will be computed based on the View's non-Text content.
|
|
- /// <para>
|
|
|
|
- /// If <see cref="View.ContentSize"/> is explicitly set (is not <see langword="null"/>) then <see cref="View.ContentSize"/>
|
|
|
|
- /// will be used to determine the dimension.
|
|
|
|
- /// </para>
|
|
|
|
- /// <para>
|
|
|
|
- /// Otherwise, the Subview in <see cref="View.Subviews"/> with the largest corresponding position plus dimension
|
|
|
|
- /// will determine the dimension.
|
|
|
|
- /// </para>
|
|
|
|
- /// <para>
|
|
|
|
- /// The corresponding dimension of the view's <see cref="View.Text"/> will be ignored.
|
|
|
|
- /// </para>
|
|
|
|
|
|
+ /// <para>
|
|
|
|
+ /// If <see cref="View.ContentSize"/> is explicitly set (is not <see langword="null"/>) then
|
|
|
|
+ /// <see cref="View.ContentSize"/>
|
|
|
|
+ /// will be used to determine the dimension.
|
|
|
|
+ /// </para>
|
|
|
|
+ /// <para>
|
|
|
|
+ /// Otherwise, the Subview in <see cref="View.Subviews"/> with the largest corresponding position plus dimension
|
|
|
|
+ /// will determine the dimension.
|
|
|
|
+ /// </para>
|
|
|
|
+ /// <para>
|
|
|
|
+ /// The corresponding dimension of the view's <see cref="View.Text"/> will be ignored.
|
|
|
|
+ /// </para>
|
|
/// </summary>
|
|
/// </summary>
|
|
Content = 1,
|
|
Content = 1,
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// <para>
|
|
|
|
- /// The corresponding dimension of the view's <see cref="View.Text"/>, formatted using the
|
|
|
|
- /// <see cref="View.TextFormatter"/> settings,
|
|
|
|
- /// will be used to determine the dimension.
|
|
|
|
- /// </para>
|
|
|
|
- /// <para>
|
|
|
|
- /// The corresponding dimensions of the <see cref="View.Subviews"/> will be ignored.
|
|
|
|
- /// </para>
|
|
|
|
|
|
+ /// <para>
|
|
|
|
+ /// The corresponding dimension of the view's <see cref="View.Text"/>, formatted using the
|
|
|
|
+ /// <see cref="View.TextFormatter"/> settings,
|
|
|
|
+ /// will be used to determine the dimension.
|
|
|
|
+ /// </para>
|
|
|
|
+ /// <para>
|
|
|
|
+ /// The corresponding dimensions of the <see cref="View.Subviews"/> will be ignored.
|
|
|
|
+ /// </para>
|
|
/// </summary>
|
|
/// </summary>
|
|
Text = 2
|
|
Text = 2
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- ///
|
|
|
|
/// </summary>
|
|
/// </summary>
|
|
public enum Dimension
|
|
public enum Dimension
|
|
{
|
|
{
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// No dimension specified.
|
|
|
|
|
|
+ /// No dimension specified.
|
|
/// </summary>
|
|
/// </summary>
|
|
None = 0,
|
|
None = 0,
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// The height dimension.
|
|
|
|
|
|
+ /// The height dimension.
|
|
/// </summary>
|
|
/// </summary>
|
|
Height = 1,
|
|
Height = 1,
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// The width dimension.
|
|
|
|
|
|
+ /// The width dimension.
|
|
/// </summary>
|
|
/// </summary>
|
|
Width = 2
|
|
Width = 2
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Creates a <see cref="Dim"/> object that automatically sizes the view to fit all the view's SubViews and/or Text.
|
|
/// Creates a <see cref="Dim"/> object that automatically sizes the view to fit all the view's SubViews and/or Text.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -907,7 +907,7 @@ public class Dim
|
|
/// <example>
|
|
/// <example>
|
|
/// This initializes a <see cref="View"/> with two SubViews. The view will be automatically sized to fit the two
|
|
/// This initializes a <see cref="View"/> with two SubViews. The view will be automatically sized to fit the two
|
|
/// SubViews.
|
|
/// SubViews.
|
|
- /// <code>
|
|
|
|
|
|
+ /// <code>
|
|
/// var button = new Button () { Text = "Click Me!", X = 1, Y = 1, Width = 10, Height = 1 };
|
|
/// var button = new Button () { Text = "Click Me!", X = 1, Y = 1, Width = 10, Height = 1 };
|
|
/// var textField = new TextField { Text = "Type here", X = 1, Y = 2, Width = 20, Height = 1 };
|
|
/// var textField = new TextField { Text = "Type here", X = 1, Y = 2, Width = 20, Height = 1 };
|
|
/// var view = new Window () { Title = "MyWindow", X = 0, Y = 0, Width = Dim.Auto (), Height = Dim.Auto () };
|
|
/// var view = new Window () { Title = "MyWindow", X = 0, Y = 0, Width = Dim.Auto (), Height = Dim.Auto () };
|
|
@@ -1060,7 +1060,8 @@ public class Dim
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Calculates and returns the dimension of a <see cref="View"/> object. It takes into account the location of the
|
|
/// Calculates and returns the dimension of a <see cref="View"/> object. It takes into account the location of the
|
|
- /// <see cref="View"/>, it's SuperView's ContentSize, and whether it should automatically adjust its size based on its content.
|
|
|
|
|
|
+ /// <see cref="View"/>, it's SuperView's ContentSize, and whether it should automatically adjust its size based on its
|
|
|
|
+ /// content.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="location">
|
|
/// <param name="location">
|
|
/// The starting point from where the size calculation begins. It could be the left edge for width calculation or the
|
|
/// The starting point from where the size calculation begins. It could be the left edge for width calculation or the
|
|
@@ -1079,13 +1080,10 @@ public class Dim
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Diagnostics API to determine if this Dim object references other views.
|
|
|
|
|
|
+ /// Diagnostics API to determine if this Dim object references other views.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- internal virtual bool ReferencesOtherViews ()
|
|
|
|
- {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
|
|
+ internal virtual bool ReferencesOtherViews () { return false; }
|
|
|
|
|
|
internal class DimAbsolute (int n) : Dim
|
|
internal class DimAbsolute (int n) : Dim
|
|
{
|
|
{
|
|
@@ -1111,7 +1109,8 @@ public class Dim
|
|
/// </para>
|
|
/// </para>
|
|
/// </remarks>
|
|
/// </remarks>
|
|
/// <param name="style">
|
|
/// <param name="style">
|
|
- /// Specifies how <see cref="Dim.DimAuto"/> will compute the dimension. The default is <see cref="Dim.DimAutoStyle.Auto"/>.
|
|
|
|
|
|
+ /// Specifies how <see cref="Dim.DimAuto"/> will compute the dimension. The default is
|
|
|
|
+ /// <see cref="Dim.DimAutoStyle.Auto"/>.
|
|
/// </param>
|
|
/// </param>
|
|
/// <param name="min">Specifies the minimum dimension that view will be automatically sized to.</param>
|
|
/// <param name="min">Specifies the minimum dimension that view will be automatically sized to.</param>
|
|
/// <param name="max">Specifies the maximum dimension that view will be automatically sized to. NOT CURRENTLY SUPPORTED.</param>
|
|
/// <param name="max">Specifies the maximum dimension that view will be automatically sized to. NOT CURRENTLY SUPPORTED.</param>
|
|
@@ -1122,11 +1121,13 @@ public class Dim
|
|
internal readonly DimAutoStyle _style = style;
|
|
internal readonly DimAutoStyle _style = style;
|
|
internal int _size;
|
|
internal int _size;
|
|
|
|
|
|
- /// <inheritdoc />
|
|
|
|
|
|
+ /// <inheritdoc/>
|
|
public override bool Equals (object other) { return other is DimAuto auto && auto._min == _min && auto._max == _max && auto._style == _style; }
|
|
public override bool Equals (object other) { return other is DimAuto auto && auto._min == _min && auto._max == _max && auto._style == _style; }
|
|
- /// <inheritdoc />
|
|
|
|
|
|
+
|
|
|
|
+ /// <inheritdoc/>
|
|
public override int GetHashCode () { return HashCode.Combine (base.GetHashCode (), _min, _max, _style); }
|
|
public override int GetHashCode () { return HashCode.Combine (base.GetHashCode (), _min, _max, _style); }
|
|
- /// <inheritdoc />
|
|
|
|
|
|
+
|
|
|
|
+ /// <inheritdoc/>
|
|
public override string ToString () { return $"Auto({_style},{_min},{_max})"; }
|
|
public override string ToString () { return $"Auto({_style},{_min},{_max})"; }
|
|
|
|
|
|
internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
|
|
internal override int Calculate (int location, int superviewContentSize, View us, Dimension dimension)
|
|
@@ -1148,7 +1149,7 @@ public class Dim
|
|
return superviewContentSize;
|
|
return superviewContentSize;
|
|
}
|
|
}
|
|
|
|
|
|
- if (_style.HasFlag (Dim.DimAutoStyle.Text))
|
|
|
|
|
|
+ if (_style.HasFlag (DimAutoStyle.Text))
|
|
{
|
|
{
|
|
textSize = int.Max (autoMin, dimension == Dimension.Width ? us.TextFormatter.Size.Width : us.TextFormatter.Size.Height);
|
|
textSize = int.Max (autoMin, dimension == Dimension.Width ? us.TextFormatter.Size.Width : us.TextFormatter.Size.Height);
|
|
}
|
|
}
|
|
@@ -1164,12 +1165,13 @@ public class Dim
|
|
// TODO: AnchorEnd needs work
|
|
// TODO: AnchorEnd needs work
|
|
// TODO: If _min > 0 we can SetRelativeLayout for the subviews?
|
|
// TODO: If _min > 0 we can SetRelativeLayout for the subviews?
|
|
subviewsSize = 0;
|
|
subviewsSize = 0;
|
|
|
|
+
|
|
if (us.Subviews.Count > 0)
|
|
if (us.Subviews.Count > 0)
|
|
{
|
|
{
|
|
- for (int i = 0; i < us.Subviews.Count; i++)
|
|
|
|
|
|
+ for (var i = 0; i < us.Subviews.Count; i++)
|
|
{
|
|
{
|
|
- var v = us.Subviews [i];
|
|
|
|
- bool isNotPosAnchorEnd = dimension == Dim.Dimension.Width ? v.X is not Pos.PosAnchorEnd : v.Y is not Pos.PosAnchorEnd;
|
|
|
|
|
|
+ View v = us.Subviews [i];
|
|
|
|
+ bool isNotPosAnchorEnd = dimension == Dimension.Width ? v.X is not Pos.PosAnchorEnd : v.Y is not Pos.PosAnchorEnd;
|
|
|
|
|
|
//if (!isNotPosAnchorEnd)
|
|
//if (!isNotPosAnchorEnd)
|
|
//{
|
|
//{
|
|
@@ -1178,7 +1180,8 @@ public class Dim
|
|
|
|
|
|
if (isNotPosAnchorEnd)
|
|
if (isNotPosAnchorEnd)
|
|
{
|
|
{
|
|
- int size = dimension == Dim.Dimension.Width ? v.Frame.X + v.Frame.Width : v.Frame.Y + v.Frame.Height;
|
|
|
|
|
|
+ int size = dimension == Dimension.Width ? v.Frame.X + v.Frame.Width : v.Frame.Y + v.Frame.Height;
|
|
|
|
+
|
|
if (size > subviewsSize)
|
|
if (size > subviewsSize)
|
|
{
|
|
{
|
|
subviewsSize = size;
|
|
subviewsSize = size;
|
|
@@ -1186,7 +1189,6 @@ public class Dim
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1204,20 +1206,21 @@ public class Dim
|
|
}
|
|
}
|
|
|
|
|
|
max = int.Max (max, autoMin);
|
|
max = int.Max (max, autoMin);
|
|
|
|
+
|
|
return int.Min (max, _max?.Anchor (superviewContentSize) ?? superviewContentSize);
|
|
return int.Min (max, _max?.Anchor (superviewContentSize) ?? superviewContentSize);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Diagnostics API to determine if this Dim object references other views.
|
|
|
|
|
|
+ /// Diagnostics API to determine if this Dim object references other views.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
internal override bool ReferencesOtherViews ()
|
|
internal override bool ReferencesOtherViews ()
|
|
{
|
|
{
|
|
// BUGBUG: This is not correct. _contentSize may be null.
|
|
// BUGBUG: This is not correct. _contentSize may be null.
|
|
- return _style.HasFlag (Dim.DimAutoStyle.Content);
|
|
|
|
|
|
+ return _style.HasFlag (DimAutoStyle.Content);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
internal class DimCombine (bool add, Dim left, Dim right) : Dim
|
|
internal class DimCombine (bool add, Dim left, Dim right) : Dim
|
|
{
|
|
{
|
|
internal bool _add = add;
|
|
internal bool _add = add;
|
|
@@ -1257,9 +1260,8 @@ public class Dim
|
|
return newDimension;
|
|
return newDimension;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Diagnostics API to determine if this Dim object references other views.
|
|
|
|
|
|
+ /// Diagnostics API to determine if this Dim object references other views.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
internal override bool ReferencesOtherViews ()
|
|
internal override bool ReferencesOtherViews ()
|
|
@@ -1355,9 +1357,6 @@ public class Dim
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
- internal override bool ReferencesOtherViews ()
|
|
|
|
- {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
|
|
+ internal override bool ReferencesOtherViews () { return true; }
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|