From: Flipp Syder <76629141+vulppine@users.noreply.github.com> Date: Thu, 9 Mar 2023 16:33:13 +0000 (-0800) Subject: removes previous bruteforce method (#14548) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=12192ada0bcecae7e3a40f467beba04bf8649832;p=space-station-14.git 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 --- diff --git a/Content.Client/UserInterface/Controls/RecordedSplitContainer.cs b/Content.Client/UserInterface/Controls/RecordedSplitContainer.cs index 28021e30e5..21b883dd31 100644 --- a/Content.Client/UserInterface/Controls/RecordedSplitContainer.cs +++ b/Content.Client/UserInterface/Controls/RecordedSplitContainer.cs @@ -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; }