tangled
alpha
login
or
join now
keii.dev
/
osu-framework
0
fork
atom
A game framework written with osu! in mind.
0
fork
atom
overview
issues
pulls
pipelines
Fix DSPFC not considerng parent padding correctly
smoogipoo
5 years ago
bdef0e7f
6083659a
+48
-1
2 changed files
expand all
collapse all
unified
split
osu.Framework
Graphics
Containers
DrawSizePreservingFillContainer.cs
osu.Framework.Tests
Visual
Containers
TestSceneDrawSizePreservingFillContainer.cs
+47
osu.Framework.Tests/Visual/Containers/TestSceneDrawSizePreservingFillContainer.cs
···
1
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2
// See the LICENCE file in the repository root for full licence text.
3
0
4
using osu.Framework.Graphics;
5
using osu.Framework.Graphics.Containers;
6
using osu.Framework.Graphics.Shapes;
0
7
using osuTK;
8
using osuTK.Graphics;
9
···
14
public TestSceneDrawSizePreservingFillContainer()
15
{
16
DrawSizePreservingFillContainer fillContainer;
0
17
Child = new Container
18
{
19
Anchor = Anchor.Centre,
···
55
AddSliderStep("Height", 50, 650, 500, v => Child.Height = v);
56
57
AddStep("Override Size to 1x1", () => Child.Size = Vector2.One);
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
58
}
59
}
60
}
···
1
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2
// See the LICENCE file in the repository root for full licence text.
3
4
+
using NUnit.Framework;
5
using osu.Framework.Graphics;
6
using osu.Framework.Graphics.Containers;
7
using osu.Framework.Graphics.Shapes;
8
+
using osu.Framework.Utils;
9
using osuTK;
10
using osuTK.Graphics;
11
···
16
public TestSceneDrawSizePreservingFillContainer()
17
{
18
DrawSizePreservingFillContainer fillContainer;
19
+
20
Child = new Container
21
{
22
Anchor = Anchor.Centre,
···
58
AddSliderStep("Height", 50, 650, 500, v => Child.Height = v);
59
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));
105
}
106
}
107
}
+1
-1
osu.Framework/Graphics/Containers/DrawSizePreservingFillContainer.cs
···
44
{
45
base.Update();
46
47
-
Vector2 drawSizeRatio = Vector2.Divide(Parent.DrawSize, TargetDrawSize);
48
49
switch (Strategy)
50
{
···
44
{
45
base.Update();
46
47
+
Vector2 drawSizeRatio = Vector2.Divide(Parent.ChildSize, TargetDrawSize);
48
49
switch (Strategy)
50
{