]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
removes previous bruteforce method (#14548)
authorFlipp Syder <76629141+vulppine@users.noreply.github.com>
Thu, 9 Mar 2023 16:33:13 +0000 (08:33 -0800)
committerGitHub <noreply@github.com>
Thu, 9 Mar 2023 16:33:13 +0000 (10:33 -0600)
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

Content.Client/UserInterface/Controls/RecordedSplitContainer.cs

index 28021e30e5259fe5f7c9cb2e9ab47c6bcc05280c..21b883dd31d0b5386e25f29f48d9666f06d1b9ad 100644 (file)
@@ -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;
             }