1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-25 13:33:21 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/TestSceneOsuPopover.cs
2022-06-17 16:37:17 +09:00

106 lines
3.3 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.
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneOsuPopover : OsuGridTestScene
{
public TestSceneOsuPopover()
: base(1, 2)
{
Cell(0, 0).Child = new PopoverContainer
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new OsuSpriteText
{
Text = @"No OverlayColourProvider",
Font = OsuFont.Default.With(size: 40)
},
new TriangleButtonWithPopover()
}
};
Cell(0, 1).Child = new ColourProvidingContainer(OverlayColourScheme.Orange)
{
RelativeSizeAxes = Axes.Both,
Child = new PopoverContainer
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new OsuSpriteText
{
Text = @"With OverlayColourProvider (orange)",
Font = OsuFont.Default.With(size: 40)
},
new TriangleButtonWithPopover()
}
}
};
}
private class TriangleButtonWithPopover : TriangleButton, IHasPopover
{
public TriangleButtonWithPopover()
{
Width = 100;
Height = 30;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Text = @"open";
Action = this.ShowPopover;
}
public Popover GetPopover() => new OsuPopover
{
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(10),
Children = new Drawable[]
{
new OsuSpriteText
{
Text = @"sample text"
},
new OsuTextBox
{
Width = 150,
Height = 30
}
}
}
};
}
private class ColourProvidingContainer : Container
{
[Cached]
private OverlayColourProvider provider { get; }
public ColourProvidingContainer(OverlayColourScheme colourScheme)
{
provider = new OverlayColourProvider(colourScheme);
}
}
}
}