A game framework written with osu! in mind.
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
4using osu.Framework.Graphics;
5using osu.Framework.Graphics.Containers;
6using osu.Framework.Graphics.Shapes;
7using osu.Framework.Utils;
8using osuTK;
9
10namespace osu.Framework.Tests.Visual.Containers
11{
12 [System.ComponentModel.Description(@"Checking for bugged corner radius")]
13 public class TestSceneCircularContainer : FrameworkTestScene
14 {
15 private SingleUpdateCircularContainer container;
16
17 public TestSceneCircularContainer()
18 {
19 AddStep("128x128 box", () => addContainer(new Vector2(128)));
20 AddAssert("Expect CornerRadius = 64", () => Precision.AlmostEquals(container.CornerRadius, 64));
21 AddStep("128x64 box", () => addContainer(new Vector2(128, 64)));
22 AddAssert("Expect CornerRadius = 32", () => Precision.AlmostEquals(container.CornerRadius, 32));
23 AddStep("64x128 box", () => addContainer(new Vector2(64, 128)));
24 AddAssert("Expect CornerRadius = 32", () => Precision.AlmostEquals(container.CornerRadius, 32));
25 }
26
27 private void addContainer(Vector2 size)
28 {
29 Clear();
30 Add(container = new SingleUpdateCircularContainer
31 {
32 Masking = true,
33 AutoSizeAxes = Axes.Both,
34 Child = new Box { Size = size }
35 });
36 }
37
38 private class SingleUpdateCircularContainer : CircularContainer
39 {
40 private bool firstUpdate = true;
41
42 public override bool UpdateSubTree()
43 {
44 if (!firstUpdate)
45 return true;
46
47 firstUpdate = false;
48
49 return base.UpdateSubTree();
50 }
51 }
52 }
53}