2019-09-20 17:35:15 +08:00
|
|
|
// 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 NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-09-24 18:00:26 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2019-09-20 17:35:15 +08:00
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
{
|
|
|
|
public class TestSceneLabelledComponent : OsuTestScene
|
|
|
|
{
|
|
|
|
[TestCase(false)]
|
|
|
|
[TestCase(true)]
|
|
|
|
public void TestPadded(bool hasDescription) => createPaddedComponent(hasDescription);
|
|
|
|
|
|
|
|
[TestCase(false)]
|
|
|
|
[TestCase(true)]
|
|
|
|
public void TestNonPadded(bool hasDescription) => createPaddedComponent(hasDescription, false);
|
|
|
|
|
|
|
|
private void createPaddedComponent(bool hasDescription = false, bool padded = true)
|
|
|
|
{
|
|
|
|
AddStep("create component", () =>
|
|
|
|
{
|
2019-09-24 17:22:02 +08:00
|
|
|
LabelledComponent<Drawable> component;
|
2019-09-20 17:35:15 +08:00
|
|
|
|
|
|
|
Child = new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Width = 500,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2019-09-24 17:22:02 +08:00
|
|
|
Child = component = padded ? (LabelledComponent<Drawable>)new PaddedLabelledComponent() : new NonPaddedLabelledComponent(),
|
2019-09-20 17:35:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
component.Label = "a sample component";
|
|
|
|
component.Description = hasDescription ? "this text describes the component" : string.Empty;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-09-24 17:22:02 +08:00
|
|
|
private class PaddedLabelledComponent : LabelledComponent<Drawable>
|
2019-09-20 17:35:15 +08:00
|
|
|
{
|
|
|
|
public PaddedLabelledComponent()
|
|
|
|
: base(true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Drawable CreateComponent() => new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Colour = Color4.Red,
|
|
|
|
Text = @"(( Component ))"
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-09-24 17:22:02 +08:00
|
|
|
private class NonPaddedLabelledComponent : LabelledComponent<Drawable>
|
2019-09-20 17:35:15 +08:00
|
|
|
{
|
|
|
|
public NonPaddedLabelledComponent()
|
|
|
|
: base(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Drawable CreateComponent() => new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 40,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.SlateGray
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Colour = Color4.Red,
|
|
|
|
Text = @"(( Component ))"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|