2020-01-03 20:54:56 +00: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 osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
{
|
2020-01-20 09:21:21 +00:00
|
|
|
|
public partial class TestSceneOverlayHeader : OsuTestScene
|
2020-01-03 20:54:56 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly FillFlowContainer flow;
|
|
|
|
|
|
2020-01-20 09:21:21 +00:00
|
|
|
|
public TestSceneOverlayHeader()
|
2020-01-03 20:54:56 +00:00
|
|
|
|
{
|
|
|
|
|
AddRange(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
},
|
|
|
|
|
new BasicScrollContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = flow = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Vertical
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-07-21 17:02:22 +00:00
|
|
|
|
addHeader("Orange OverlayHeader (no background, 100 padding)", new TestNoBackgroundHeader(), OverlayColourScheme.Orange);
|
2020-07-21 19:56:44 +00:00
|
|
|
|
addHeader("Blue OverlayHeader (default 50 padding)", new TestNoControlHeader(), OverlayColourScheme.Blue);
|
2020-02-03 08:09:46 +00:00
|
|
|
|
addHeader("Green TabControlOverlayHeader (string) with ruleset selector", new TestStringTabControlHeader(), OverlayColourScheme.Green);
|
2020-07-21 17:02:22 +00:00
|
|
|
|
addHeader("Pink TabControlOverlayHeader (enum, 30 padding)", new TestEnumTabControlHeader(), OverlayColourScheme.Pink);
|
|
|
|
|
addHeader("Red BreadcrumbControlOverlayHeader (no background, 10 padding)", new TestBreadcrumbControlHeader(), OverlayColourScheme.Red);
|
2020-01-03 20:54:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 13:35:07 +00:00
|
|
|
|
private void addHeader(string name, OverlayHeader header, OverlayColourScheme colourScheme)
|
2020-01-03 20:54:56 +00:00
|
|
|
|
{
|
|
|
|
|
flow.Add(new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2020-01-07 21:41:52 +00:00
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2020-01-03 20:54:56 +00:00
|
|
|
|
Margin = new MarginPadding(20),
|
|
|
|
|
Text = name,
|
|
|
|
|
},
|
2020-01-26 13:35:07 +00:00
|
|
|
|
new ColourProvidedContainer(colourScheme, header)
|
2020-01-07 21:41:52 +00:00
|
|
|
|
{
|
2020-01-26 13:35:07 +00:00
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
}
|
2020-01-03 20:54:56 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 13:35:07 +00:00
|
|
|
|
private partial class ColourProvidedContainer : Container
|
|
|
|
|
{
|
|
|
|
|
[Cached]
|
|
|
|
|
private readonly OverlayColourProvider colourProvider;
|
|
|
|
|
|
|
|
|
|
public ColourProvidedContainer(OverlayColourScheme colourScheme, OverlayHeader header)
|
|
|
|
|
{
|
|
|
|
|
colourProvider = new OverlayColourProvider(colourScheme);
|
|
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Add(header);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-27 12:36:19 +00:00
|
|
|
|
private partial class TestNoBackgroundHeader : OverlayHeader
|
|
|
|
|
{
|
2020-03-24 21:08:20 +00:00
|
|
|
|
protected override OverlayTitle CreateTitle() => new TestTitle();
|
2020-07-21 17:02:22 +00:00
|
|
|
|
|
|
|
|
|
public TestNoBackgroundHeader()
|
|
|
|
|
{
|
|
|
|
|
ContentSidePadding = 100;
|
|
|
|
|
}
|
2020-01-27 12:36:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-03 20:54:56 +00:00
|
|
|
|
private partial class TestNoControlHeader : OverlayHeader
|
|
|
|
|
{
|
2020-01-27 12:36:19 +00:00
|
|
|
|
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/changelog");
|
2020-01-03 20:54:56 +00:00
|
|
|
|
|
2020-03-24 21:08:20 +00:00
|
|
|
|
protected override OverlayTitle CreateTitle() => new TestTitle();
|
2020-01-03 20:54:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 21:41:52 +00:00
|
|
|
|
private partial class TestStringTabControlHeader : TabControlOverlayHeader<string>
|
2020-01-03 20:54:56 +00:00
|
|
|
|
{
|
2020-01-27 12:36:19 +00:00
|
|
|
|
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/news");
|
2020-01-03 20:54:56 +00:00
|
|
|
|
|
2020-03-24 21:08:20 +00:00
|
|
|
|
protected override OverlayTitle CreateTitle() => new TestTitle();
|
2020-01-03 20:54:56 +00:00
|
|
|
|
|
2023-01-13 20:50:12 +00:00
|
|
|
|
protected override Drawable CreateTabControlContent() => new OverlayRulesetSelector();
|
2020-02-03 08:09:46 +00:00
|
|
|
|
|
2020-01-26 13:35:07 +00:00
|
|
|
|
public TestStringTabControlHeader()
|
2020-01-03 20:54:56 +00:00
|
|
|
|
{
|
|
|
|
|
TabControl.AddItem("tab1");
|
|
|
|
|
TabControl.AddItem("tab2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 21:41:52 +00:00
|
|
|
|
private partial class TestEnumTabControlHeader : TabControlOverlayHeader<TestEnum>
|
|
|
|
|
{
|
2020-07-21 17:02:22 +00:00
|
|
|
|
public TestEnumTabControlHeader()
|
|
|
|
|
{
|
|
|
|
|
ContentSidePadding = 30;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-27 12:36:19 +00:00
|
|
|
|
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/rankings");
|
2020-01-07 21:41:52 +00:00
|
|
|
|
|
2020-03-24 21:08:20 +00:00
|
|
|
|
protected override OverlayTitle CreateTitle() => new TestTitle();
|
2020-01-07 21:41:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private enum TestEnum
|
|
|
|
|
{
|
|
|
|
|
Some,
|
|
|
|
|
Cool,
|
|
|
|
|
Tabs
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-03 20:54:56 +00:00
|
|
|
|
private partial class TestBreadcrumbControlHeader : BreadcrumbControlOverlayHeader
|
|
|
|
|
{
|
2020-03-24 21:08:20 +00:00
|
|
|
|
protected override OverlayTitle CreateTitle() => new TestTitle();
|
2020-01-03 20:54:56 +00:00
|
|
|
|
|
2020-01-26 13:35:07 +00:00
|
|
|
|
public TestBreadcrumbControlHeader()
|
2020-01-03 20:54:56 +00:00
|
|
|
|
{
|
2020-07-21 17:02:22 +00:00
|
|
|
|
ContentSidePadding = 10;
|
|
|
|
|
|
2020-01-21 03:00:12 +00:00
|
|
|
|
TabControl.AddItem("tab1");
|
|
|
|
|
TabControl.AddItem("tab2");
|
|
|
|
|
TabControl.Current.Value = "tab2";
|
2020-01-03 20:54:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-24 21:08:20 +00:00
|
|
|
|
private partial class TestTitle : OverlayTitle
|
2020-01-03 20:54:56 +00:00
|
|
|
|
{
|
|
|
|
|
public TestTitle()
|
|
|
|
|
{
|
|
|
|
|
Title = "title";
|
2020-03-24 21:08:20 +00:00
|
|
|
|
IconTexture = "Icons/changelog";
|
2020-01-03 20:54:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|