mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using osu.Framework.Graphics;
|
|
using osuTK;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Framework.MathUtils;
|
|
using osu.Framework.Testing;
|
|
|
|
namespace osu.Framework.Tests.Visual
|
|
{
|
|
[System.ComponentModel.Description(@"Checking for bugged corner radius")]
|
|
public class TestCaseCircularContainer : TestCase
|
|
{
|
|
private SingleUpdateCircularContainer container;
|
|
|
|
public TestCaseCircularContainer()
|
|
{
|
|
AddStep("128x128 box", () => addContainer(new Vector2(128)));
|
|
AddAssert("Expect CornerRadius = 64", () => Precision.AlmostEquals(container.CornerRadius, 64));
|
|
AddStep("128x64 box", () => addContainer(new Vector2(128, 64)));
|
|
AddAssert("Expect CornerRadius = 32", () => Precision.AlmostEquals(container.CornerRadius, 32));
|
|
AddStep("64x128 box", () => addContainer(new Vector2(64, 128)));
|
|
AddAssert("Expect CornerRadius = 32", () => Precision.AlmostEquals(container.CornerRadius, 32));
|
|
}
|
|
|
|
private void addContainer(Vector2 size)
|
|
{
|
|
Clear();
|
|
Add(container = new SingleUpdateCircularContainer
|
|
{
|
|
Masking = true,
|
|
AutoSizeAxes = Axes.Both,
|
|
Child = new Box { Size = size }
|
|
});
|
|
}
|
|
|
|
private class SingleUpdateCircularContainer : CircularContainer
|
|
{
|
|
private bool firstUpdate = true;
|
|
|
|
public override bool UpdateSubTree()
|
|
{
|
|
if (!firstUpdate)
|
|
return true;
|
|
firstUpdate = false;
|
|
|
|
return base.UpdateSubTree();
|
|
}
|
|
}
|
|
}
|
|
}
|