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
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
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
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
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
61
+
}
62
62
+
63
63
+
[Test]
64
64
+
public void TestParentPadding()
65
65
+
{
66
66
+
Box fullBox = null;
67
67
+
Box innerBox = null;
68
68
+
69
69
+
AddStep("create container", () =>
70
70
+
{
71
71
+
Child = new Container
72
72
+
{
73
73
+
Anchor = Anchor.Centre,
74
74
+
Origin = Anchor.Centre,
75
75
+
Size = new Vector2(512, 384),
76
76
+
Children = new Drawable[]
77
77
+
{
78
78
+
fullBox = new Box
79
79
+
{
80
80
+
RelativeSizeAxes = Axes.Both,
81
81
+
Colour = Color4.Red,
82
82
+
},
83
83
+
new Container
84
84
+
{
85
85
+
RelativeSizeAxes = Axes.Both,
86
86
+
Padding = new MarginPadding { Left = 100 },
87
87
+
Children = new Drawable[]
88
88
+
{
89
89
+
new DrawSizePreservingFillContainer
90
90
+
{
91
91
+
Child = innerBox = new Box
92
92
+
{
93
93
+
Size = new Vector2(1024, 768),
94
94
+
Colour = Color4.Pink,
95
95
+
Alpha = 0.3f
96
96
+
}
97
97
+
},
98
98
+
}
99
99
+
},
100
100
+
}
101
101
+
};
102
102
+
});
103
103
+
104
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
47
-
Vector2 drawSizeRatio = Vector2.Divide(Parent.DrawSize, TargetDrawSize);
47
47
+
Vector2 drawSizeRatio = Vector2.Divide(Parent.ChildSize, TargetDrawSize);
48
48
49
49
switch (Strategy)
50
50
{