1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 01:32:54 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/TestSceneIconButton.cs

114 lines
4.0 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
2018-04-13 17:19:50 +08:00
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
2019-03-25 00:02:36 +08:00
using osuTK;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
2019-03-25 00:02:36 +08:00
namespace osu.Game.Tests.Visual.UserInterface
2018-04-13 17:19:50 +08:00
{
[TestFixture]
2022-11-24 13:32:20 +08:00
public partial class TestSceneIconButton : OsuTestScene
2018-04-13 17:19:50 +08:00
{
public TestSceneIconButton()
2018-04-13 17:19:50 +08:00
{
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Spacing = new Vector2(10, 10),
Children = new[]
{
new NamedIconButton("No change", new IconButton()),
2018-07-13 15:28:18 +08:00
new NamedIconButton("Background colours", new ColouredIconButton()),
new NamedIconButton("Full-width", new IconButton { Size = new Vector2(200, 30) }),
2018-04-13 17:19:50 +08:00
new NamedIconButton("Icon colours", new IconButton
{
IconColour = Color4.Green,
IconHoverColour = Color4.Red
})
}
};
}
2022-11-24 13:32:20 +08:00
private partial class ColouredIconButton : IconButton
2018-07-13 15:28:18 +08:00
{
public ColouredIconButton()
{
FlashColour = Color4.DarkGreen;
HoverColour = Color4.Green;
}
}
2022-11-24 13:32:20 +08:00
private partial class NamedIconButton : Container
2018-04-13 17:19:50 +08:00
{
public NamedIconButton(string name, IconButton button)
2018-04-13 17:19:50 +08:00
{
AutoSizeAxes = Axes.Y;
Width = 200;
Container iconContainer;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.5f,
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 10),
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = name
},
new Container
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.1f,
},
iconContainer = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = button
}
}
}
}
}
};
iconContainer.AutoSizeAxes = Axes.Both;
2018-04-13 17:19:50 +08:00
button.Anchor = Anchor.Centre;
button.Origin = Anchor.Centre;
button.Icon = OsuIcon.RulesetOsu;
2018-04-13 17:19:50 +08:00
}
}
}
}