2020-10-06 15:40:47 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-10-15 10:48:08 +08:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
2020-10-06 15:40:47 +08:00
|
|
|
using NUnit.Framework;
|
2021-10-15 10:48:08 +08:00
|
|
|
using osu.Framework.Allocation;
|
2020-10-06 15:40:47 +08:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2021-10-15 10:48:08 +08:00
|
|
|
using osu.Game.Overlays;
|
2020-10-06 15:40:47 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
{
|
|
|
|
public class TestSceneLabelledSliderBar : OsuTestScene
|
|
|
|
{
|
|
|
|
[TestCase(false)]
|
|
|
|
[TestCase(true)]
|
|
|
|
public void TestSliderBar(bool hasDescription) => createSliderBar(hasDescription);
|
|
|
|
|
|
|
|
private void createSliderBar(bool hasDescription = false)
|
|
|
|
{
|
|
|
|
AddStep("create component", () =>
|
|
|
|
{
|
2021-10-15 10:48:08 +08:00
|
|
|
FillFlowContainer flow;
|
2020-10-06 15:40:47 +08:00
|
|
|
|
2021-10-15 10:48:08 +08:00
|
|
|
Child = flow = new FillFlowContainer
|
2020-10-06 15:40:47 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Width = 500,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2021-10-15 10:48:08 +08:00
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
2020-10-06 15:40:47 +08:00
|
|
|
{
|
2021-10-15 10:48:08 +08:00
|
|
|
new LabelledSliderBar<double>
|
2020-10-06 15:40:47 +08:00
|
|
|
{
|
2021-10-15 10:48:08 +08:00
|
|
|
Current = new BindableDouble(5)
|
|
|
|
{
|
|
|
|
MinValue = 0,
|
|
|
|
MaxValue = 10,
|
|
|
|
Precision = 1,
|
|
|
|
},
|
|
|
|
Label = "a sample component",
|
|
|
|
Description = hasDescription ? "this text describes the component" : string.Empty,
|
|
|
|
},
|
|
|
|
},
|
2020-10-06 15:40:47 +08:00
|
|
|
};
|
|
|
|
|
2021-10-15 10:48:08 +08:00
|
|
|
foreach (var colour in Enum.GetValues(typeof(OverlayColourScheme)).OfType<OverlayColourScheme>())
|
|
|
|
{
|
|
|
|
flow.Add(new OverlayColourContainer(colour)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Child = new LabelledSliderBar<double>
|
|
|
|
{
|
|
|
|
Current = new BindableDouble(5)
|
|
|
|
{
|
|
|
|
MinValue = 0,
|
|
|
|
MaxValue = 10,
|
|
|
|
Precision = 1,
|
|
|
|
},
|
|
|
|
Label = "a sample component",
|
|
|
|
Description = hasDescription ? "this text describes the component" : string.Empty,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-10-06 15:40:47 +08:00
|
|
|
});
|
|
|
|
}
|
2021-10-15 10:48:08 +08:00
|
|
|
|
|
|
|
private class OverlayColourContainer : Container
|
|
|
|
{
|
|
|
|
[Cached]
|
|
|
|
private OverlayColourProvider colourProvider;
|
|
|
|
|
|
|
|
public OverlayColourContainer(OverlayColourScheme scheme)
|
|
|
|
{
|
|
|
|
colourProvider = new OverlayColourProvider(scheme);
|
|
|
|
}
|
|
|
|
}
|
2020-10-06 15:40:47 +08:00
|
|
|
}
|
|
|
|
}
|