Inlined code

This commit is contained in:
Tig
2024-05-17 12:45:56 -04:00
parent 7ac767afdb
commit 7ece3bc3c9
2 changed files with 13 additions and 22 deletions

View File

@@ -5,7 +5,7 @@ namespace Terminal.Gui;
/// Represents a dimension that is a combination of two other dimensions.
/// </summary>
/// <param name="add">
/// Indicates whether the two dimensions are added or subtracted.
/// Indicates whether the two dimensions are added or subtracted.
/// </param>
/// <remarks>
/// This is a low-level API that is typically used internally by the layout system. Use the various static
@@ -35,31 +35,28 @@ public class DimCombine (AddOrSubtract add, Dim? left, Dim? right) : Dim
internal override int GetAnchor (int size)
{
int la = Left!.GetAnchor (size);
int ra = Right!.GetAnchor (size);
if (Add == AddOrSubtract.Add)
{
return la + ra;
return Left!.GetAnchor (size) + Right!.GetAnchor (size);
}
return la - ra;
return Left!.GetAnchor (size) - Right!.GetAnchor (size);
}
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 newDimension;
if (Add == AddOrSubtract.Add)
{
newDimension = leftNewDim + rightNewDim;
newDimension = Left!.Calculate (location, superviewContentSize, us, dimension) + Right!.Calculate (location, superviewContentSize, us, dimension);
}
else
{
newDimension = Math.Max (0, leftNewDim - rightNewDim);
newDimension = Math.Max (
0,
Left!.Calculate (location, superviewContentSize, us, dimension)
- Right!.Calculate (location, superviewContentSize, us, dimension));
}
return newDimension;
@@ -83,4 +80,4 @@ public class DimCombine (AddOrSubtract add, Dim? left, Dim? right) : Dim
return false;
}
}
}

View File

@@ -37,28 +37,22 @@ public class PosCombine (AddOrSubtract add, Pos left, Pos right) : Pos
internal override int GetAnchor (int size)
{
int la = Left.GetAnchor (size);
int ra = Right.GetAnchor (size);
if (Add == AddOrSubtract.Add)
{
return la + ra;
return Left.GetAnchor (size) + Right.GetAnchor (size);
}
return la - ra;
return Left.GetAnchor (size) - Right.GetAnchor (size);
}
internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
{
int left = Left.Calculate (superviewDimension, dim, us, dimension);
int right = Right.Calculate (superviewDimension, dim, us, dimension);
if (Add == AddOrSubtract.Add)
{
return left + right;
return Left.Calculate (superviewDimension, dim, us, dimension) + Right.Calculate (superviewDimension, dim, us, dimension);
}
return left - right;
return Left.Calculate (superviewDimension, dim, us, dimension) - Right.Calculate (superviewDimension, dim, us, dimension);
}
internal override bool ReferencesOtherViews ()