A game framework written with osu! in mind.

Fix DSPFC not considerng parent padding correctly

+48 -1
+47
osu.Framework.Tests/Visual/Containers/TestSceneDrawSizePreservingFillContainer.cs
··· 1 1 // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2 2 // See the LICENCE file in the repository root for full licence text. 3 3 4 + using NUnit.Framework; 4 5 using osu.Framework.Graphics; 5 6 using osu.Framework.Graphics.Containers; 6 7 using osu.Framework.Graphics.Shapes; 8 + using osu.Framework.Utils; 7 9 using osuTK; 8 10 using osuTK.Graphics; 9 11 ··· 14 16 public TestSceneDrawSizePreservingFillContainer() 15 17 { 16 18 DrawSizePreservingFillContainer fillContainer; 19 + 17 20 Child = new Container 18 21 { 19 22 Anchor = Anchor.Centre, ··· 55 58 AddSliderStep("Height", 50, 650, 500, v => Child.Height = v); 56 59 57 60 AddStep("Override Size to 1x1", () => Child.Size = Vector2.One); 61 + } 62 + 63 + [Test] 64 + public void TestParentPadding() 65 + { 66 + Box fullBox = null; 67 + Box innerBox = null; 68 + 69 + AddStep("create container", () => 70 + { 71 + Child = new Container 72 + { 73 + Anchor = Anchor.Centre, 74 + Origin = Anchor.Centre, 75 + Size = new Vector2(512, 384), 76 + Children = new Drawable[] 77 + { 78 + fullBox = new Box 79 + { 80 + RelativeSizeAxes = Axes.Both, 81 + Colour = Color4.Red, 82 + }, 83 + new Container 84 + { 85 + RelativeSizeAxes = Axes.Both, 86 + Padding = new MarginPadding { Left = 100 }, 87 + Children = new Drawable[] 88 + { 89 + new DrawSizePreservingFillContainer 90 + { 91 + Child = innerBox = new Box 92 + { 93 + Size = new Vector2(1024, 768), 94 + Colour = Color4.Pink, 95 + Alpha = 0.3f 96 + } 97 + }, 98 + } 99 + }, 100 + } 101 + }; 102 + }); 103 + 104 + AddAssert("inner box stops at edge of right box", () => Precision.AlmostEquals(fullBox.ScreenSpaceDrawQuad.TopRight, innerBox.ScreenSpaceDrawQuad.TopRight)); 58 105 } 59 106 } 60 107 }
+1 -1
osu.Framework/Graphics/Containers/DrawSizePreservingFillContainer.cs
··· 44 44 { 45 45 base.Update(); 46 46 47 - Vector2 drawSizeRatio = Vector2.Divide(Parent.DrawSize, TargetDrawSize); 47 + Vector2 drawSizeRatio = Vector2.Divide(Parent.ChildSize, TargetDrawSize); 48 48 49 49 switch (Strategy) 50 50 {