1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 17:33:03 +08:00
osu-lazer/osu.Desktop.Tests/Visual/TestCaseContextMenu.cs

98 lines
3.6 KiB
C#
Raw Normal View History

2017-06-12 17:56:07 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2017-08-28 13:42:52 +08:00
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
2017-08-28 13:42:52 +08:00
using osu.Framework.Graphics.UserInterface;
2017-06-12 17:56:07 +08:00
using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
2017-06-12 17:56:07 +08:00
namespace osu.Desktop.Tests.Visual
2017-06-12 17:56:07 +08:00
{
internal class TestCaseContextMenu : OsuTestCase
2017-06-12 17:56:07 +08:00
{
public override string Description => @"Menu visible on right click";
private const int start_time = 0;
private const int duration = 1000;
2017-07-10 02:37:51 +08:00
private readonly Container container;
public TestCaseContextMenu()
2017-06-12 17:56:07 +08:00
{
Add(container = new MyContextMenuContainer
{
Size = new Vector2(200),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
2017-06-12 18:37:13 +08:00
new Box
2017-06-12 17:56:07 +08:00
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Green,
}
}
});
Add(new AnotherContextMenuContainer
{
Size = new Vector2(200),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Red,
}
}
});
}
2017-06-12 17:56:07 +08:00
protected override void LoadComplete()
{
base.LoadComplete();
// Move box along a square trajectory
2017-07-16 23:28:20 +08:00
container.Loop(c => c
.MoveTo(new Vector2(0, 100), duration).Then()
.MoveTo(new Vector2(100, 100), duration).Then()
.MoveTo(new Vector2(100, 0), duration).Then()
.MoveTo(Vector2.Zero, duration)
);
2017-06-12 17:56:07 +08:00
}
2017-08-28 13:42:52 +08:00
private class MyContextMenuContainer : Container, IHasContextMenu
2017-06-12 17:56:07 +08:00
{
2017-08-28 13:42:52 +08:00
public MenuItem[] ContextMenuItems => new MenuItem[]
2017-06-12 17:56:07 +08:00
{
2017-08-28 13:42:52 +08:00
new OsuMenuItem(@"Some option"),
new OsuMenuItem(@"Highlighted option", MenuItemType.Highlighted),
new OsuMenuItem(@"Another option"),
new OsuMenuItem(@"Choose me please"),
new OsuMenuItem(@"And me too"),
new OsuMenuItem(@"Trying to fill"),
new OsuMenuItem(@"Destructive option", MenuItemType.Destructive),
2017-06-12 17:56:07 +08:00
};
}
2017-08-28 13:42:52 +08:00
private class AnotherContextMenuContainer : Container, IHasContextMenu
2017-06-12 17:56:07 +08:00
{
2017-08-28 13:42:52 +08:00
public MenuItem[] ContextMenuItems => new MenuItem[]
2017-06-12 17:56:07 +08:00
{
2017-08-28 13:42:52 +08:00
new OsuMenuItem(@"Simple option"),
new OsuMenuItem(@"Simple very very long option"),
new OsuMenuItem(@"Change width", MenuItemType.Highlighted, () => this.ResizeWidthTo(Width * 2, 100, Easing.OutQuint)),
new OsuMenuItem(@"Change height", MenuItemType.Highlighted, () => this.ResizeHeightTo(Height * 2, 100, Easing.OutQuint)),
new OsuMenuItem(@"Change width back", MenuItemType.Destructive, () => this.ResizeWidthTo(Width / 2, 100, Easing.OutQuint)),
new OsuMenuItem(@"Change height back", MenuItemType.Destructive, () => this.ResizeHeightTo(Height / 2, 100, Easing.OutQuint)),
2017-06-12 17:56:07 +08:00
};
}
}
}