Skip to content

Commit

Permalink
Update ProportionalStackPanel.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Sep 23, 2024
1 parent a6d9f10 commit 4007ce3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Dock.Avalonia/Controls/ProportionalStackPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ protected override Size ArrangeOverride(Size arrangeSize)
else
{
Debug.Assert(!double.IsNaN(proportion));
var width = CalculateDimension(arrangeSize.Width - splitterThickness, proportion, ref sumOfFractions);
var width = CalculateDimension(arrangeSize.Width - splitterThickness, proportion,
ref sumOfFractions);
remainingRect = remainingRect.WithWidth(width);
left += width;
}
Expand All @@ -421,7 +422,8 @@ protected override Size ArrangeOverride(Size arrangeSize)
else
{
Debug.Assert(!double.IsNaN(proportion));
var height = CalculateDimension(arrangeSize.Height - splitterThickness, proportion, ref sumOfFractions);
var height = CalculateDimension(arrangeSize.Height - splitterThickness, proportion,
ref sumOfFractions);
remainingRect = remainingRect.WithHeight(height);
top += height;
}
Expand All @@ -439,13 +441,13 @@ protected override Size ArrangeOverride(Size arrangeSize)
}

private double CalculateDimension(
double dimension,
double proportion,
double dimension,
double proportion,
ref double sumOfFractions)
{
var childDimension = dimension * proportion;
var flooredChildDimension = Math.Floor(childDimension);

// sums fractions from the division
sumOfFractions += childDimension - flooredChildDimension;

Expand All @@ -455,7 +457,7 @@ private double CalculateDimension(
sumOfFractions -= Math.Round(sumOfFractions);
return Math.Max(0, flooredChildDimension + 1);
}

return Math.Max(0, flooredChildDimension);
}

Expand Down

0 comments on commit 4007ce3

Please sign in to comment.