removes previous bruteforce method (#14548)
instead checks if the final size of the container is supposed to be bigger than zero: if it is, then it will continue to attempt to set the split fraction until the size is no longer zero, then it will do it once last time before stopping
This commit is contained in:
parent
5e88334bca
commit
12192ada0b
1 changed files with 4 additions and 28 deletions
|
|
@ -16,36 +16,12 @@ public sealed class RecordedSplitContainer : SplitContainer
|
|||
protected override Vector2 ArrangeOverride(Vector2 finalSize)
|
||||
{
|
||||
if (ResizeMode == SplitResizeMode.RespectChildrenMinSize
|
||||
&& DesiredSplitCenter != null)
|
||||
&& DesiredSplitCenter != null
|
||||
&& !finalSize.Equals(Vector2.Zero))
|
||||
{
|
||||
var secondMin = GetChild(1).DesiredSize;
|
||||
double minSize = Orientation == SplitOrientation.Vertical
|
||||
? secondMin.Y
|
||||
: secondMin.X;
|
||||
double finalSizeComponent = Orientation == SplitOrientation.Vertical
|
||||
? finalSize.Y
|
||||
: finalSize.X;
|
||||
SplitFraction = (float) DesiredSplitCenter.Value;
|
||||
|
||||
var firstTotalFractional = (finalSizeComponent - minSize - SplitWidth - SplitEdgeSeparation) / finalSizeComponent;
|
||||
DesiredSplitCenter = Math.Round(DesiredSplitCenter.Value, 2, MidpointRounding.ToZero);
|
||||
|
||||
// total space the split center takes up must fit the available space percentage given to the first child
|
||||
var canFirstFit = DesiredSplitCenter <= firstTotalFractional;
|
||||
|
||||
if (DesiredSplitCenter > 1 || DesiredSplitCenter < 0 || !canFirstFit)
|
||||
{
|
||||
DesiredSplitCenter = Math.Round(firstTotalFractional, 2, MidpointRounding.ToZero);
|
||||
}
|
||||
|
||||
// don't need anything more than two digits of precision for this
|
||||
var currentSplitFraction = Math.Round(SplitFraction, 2, MidpointRounding.ToZero);
|
||||
|
||||
// brute force it
|
||||
if (currentSplitFraction != DesiredSplitCenter.Value)
|
||||
{
|
||||
SplitFraction = (float) DesiredSplitCenter.Value;
|
||||
}
|
||||
else
|
||||
if (!Size.Equals(Vector2.Zero))
|
||||
{
|
||||
DesiredSplitCenter = null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue