mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-31 02:08:03 +01:00
DimCombine -> public
This commit is contained in:
@@ -493,19 +493,38 @@ public class DimAuto (DimAutoStyle style, Dim minimumContentDim, Dim maximumCont
|
||||
public override string ToString () { return $"Auto({Style},{MinimumContentDim},{MaximumContentDim})"; }
|
||||
}
|
||||
|
||||
internal class DimCombine (bool add, Dim left, Dim right) : Dim
|
||||
/// <summary>
|
||||
/// Represents a dimension that is a combination of two other dimensions.
|
||||
/// </summary>
|
||||
/// <param name="add">Indicates whether the two dimensions are added or subtracted. If <see langword="true"/>, the dimensions are added, otherwise they are subtracted. </param>
|
||||
/// <param name="left">The left dimension.</param>
|
||||
/// <param name="right">The right dimension.</param>
|
||||
public class DimCombine (bool add, Dim left, Dim right) : Dim
|
||||
{
|
||||
internal bool _add = add;
|
||||
internal Dim _left = left, _right = right;
|
||||
/// <summary>
|
||||
/// Gets whether the two dimensions are added or subtracted.
|
||||
/// </summary>
|
||||
public bool Add { get; } = add;
|
||||
|
||||
public override string ToString () { return $"Combine({_left}{(_add ? '+' : '-')}{_right})"; }
|
||||
/// <summary>
|
||||
/// Gets the left dimension.
|
||||
/// </summary>
|
||||
public Dim Left { get; } = left;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the right dimension.
|
||||
/// </summary>
|
||||
public Dim Right { get; } = right;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString () { return $"Combine({Left}{(Add ? '+' : '-')}{Right})"; }
|
||||
|
||||
internal override int Anchor (int width)
|
||||
{
|
||||
int la = _left.Anchor (width);
|
||||
int ra = _right.Anchor (width);
|
||||
int la = Left.Anchor (width);
|
||||
int ra = Right.Anchor (width);
|
||||
|
||||
if (_add)
|
||||
if (Add)
|
||||
{
|
||||
return la + ra;
|
||||
}
|
||||
@@ -515,12 +534,12 @@ internal class DimCombine (bool add, Dim left, Dim right) : Dim
|
||||
|
||||
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;
|
||||
|
||||
if (_add)
|
||||
if (Add)
|
||||
{
|
||||
newDimension = leftNewDim + rightNewDim;
|
||||
}
|
||||
@@ -538,12 +557,12 @@ internal class DimCombine (bool add, Dim left, Dim right) : Dim
|
||||
/// <returns></returns>
|
||||
internal override bool ReferencesOtherViews ()
|
||||
{
|
||||
if (_left.ReferencesOtherViews ())
|
||||
if (Left.ReferencesOtherViews ())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_right.ReferencesOtherViews ())
|
||||
if (Right.ReferencesOtherViews ())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -483,9 +483,9 @@ public class PosCenter : Pos
|
||||
/// <summary>
|
||||
/// Represents a position that is a combination of two other positions.
|
||||
/// </summary>
|
||||
/// <param name="add"></param>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <param name="add">Indicates whether the two positions are added or subtracted. If <see langword="true"/>, the positions are added, otherwise they are subtracted.</param>
|
||||
/// <param name="left">The left position.</param>
|
||||
/// <param name="right">The right position.</param>
|
||||
public class PosCombine (bool add, Pos left, Pos right) : Pos
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -901,8 +901,8 @@ public partial class View
|
||||
|
||||
return;
|
||||
case DimCombine dc:
|
||||
CollectDim (dc._left, from, ref nNodes, ref nEdges);
|
||||
CollectDim (dc._right, from, ref nNodes, ref nEdges);
|
||||
CollectDim (dc.Left, from, ref nNodes, ref nEdges);
|
||||
CollectDim (dc.Right, from, ref nNodes, ref nEdges);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1123,8 +1123,8 @@ public partial class View
|
||||
|
||||
case Dim dim and DimCombine:
|
||||
// Recursively check for not Absolute or not View
|
||||
ThrowInvalid (view, (dim as DimCombine)._left, name);
|
||||
ThrowInvalid (view, (dim as DimCombine)._right, name);
|
||||
ThrowInvalid (view, (dim as DimCombine).Left, name);
|
||||
ThrowInvalid (view, (dim as DimCombine).Right, name);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -355,8 +355,8 @@ public class DimTests
|
||||
Assert.Equal (99, dimFill.Anchor (100));
|
||||
|
||||
var dimCombine = new DimCombine (true, dimFactor, dimAbsolute);
|
||||
Assert.Equal (dimCombine._left, dimFactor);
|
||||
Assert.Equal (dimCombine._right, dimAbsolute);
|
||||
Assert.Equal (dimCombine.Left, dimFactor);
|
||||
Assert.Equal (dimCombine.Right, dimAbsolute);
|
||||
Assert.Equal (20, dimCombine.Anchor (100));
|
||||
|
||||
var view = new View { Frame = new Rectangle (20, 10, 20, 1) };
|
||||
|
||||
Reference in New Issue
Block a user