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 OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-06-12 17:56:07 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
|
|
namespace osu.Desktop.VisualTests.Tests
|
|
|
|
|
{
|
|
|
|
|
internal class TestCaseContextMenu : TestCase
|
|
|
|
|
{
|
|
|
|
|
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;
|
2017-07-09 17:23:34 +08:00
|
|
|
|
|
2017-07-07 20:05:55 +08:00
|
|
|
|
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-07-09 17:23:34 +08:00
|
|
|
|
}
|
2017-06-12 17:56:07 +08:00
|
|
|
|
|
2017-07-09 17:23:34 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2017-07-15 00:18:12 +08:00
|
|
|
|
// Move box along a square trajectory
|
2017-07-16 22:37:59 +08:00
|
|
|
|
container
|
2017-07-15 00:18:12 +08:00
|
|
|
|
.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-07-16 22:37:59 +08:00
|
|
|
|
.Loop();
|
2017-06-12 17:56:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class MyContextMenuContainer : Container, IHasContextMenu
|
|
|
|
|
{
|
2017-06-12 18:37:13 +08:00
|
|
|
|
public ContextMenuItem[] ContextMenuItems => new ContextMenuItem[]
|
2017-06-12 17:56:07 +08:00
|
|
|
|
{
|
|
|
|
|
new OsuContextMenuItem(@"Some option"),
|
2017-06-13 14:20:21 +08:00
|
|
|
|
new OsuContextMenuItem(@"Highlighted option", MenuItemType.Highlighted),
|
2017-06-12 17:56:07 +08:00
|
|
|
|
new OsuContextMenuItem(@"Another option"),
|
|
|
|
|
new OsuContextMenuItem(@"Choose me please"),
|
|
|
|
|
new OsuContextMenuItem(@"And me too"),
|
|
|
|
|
new OsuContextMenuItem(@"Trying to fill"),
|
2017-06-13 14:20:21 +08:00
|
|
|
|
new OsuContextMenuItem(@"Destructive option", MenuItemType.Destructive),
|
2017-06-12 17:56:07 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class AnotherContextMenuContainer : Container, IHasContextMenu
|
|
|
|
|
{
|
2017-06-12 18:37:13 +08:00
|
|
|
|
public ContextMenuItem[] ContextMenuItems => new ContextMenuItem[]
|
2017-06-12 17:56:07 +08:00
|
|
|
|
{
|
|
|
|
|
new OsuContextMenuItem(@"Simple option"),
|
|
|
|
|
new OsuContextMenuItem(@"Simple very very long option"),
|
2017-07-15 00:18:12 +08:00
|
|
|
|
new OsuContextMenuItem(@"Change width", MenuItemType.Highlighted) { Action = () => this.ResizeWidthTo(Width * 2, 100, EasingTypes.OutQuint) },
|
|
|
|
|
new OsuContextMenuItem(@"Change height", MenuItemType.Highlighted) { Action = () => this.ResizeHeightTo(Height * 2, 100, EasingTypes.OutQuint) },
|
|
|
|
|
new OsuContextMenuItem(@"Change width back", MenuItemType.Destructive) { Action = () => this.ResizeWidthTo(Width / 2, 100, EasingTypes.OutQuint) },
|
|
|
|
|
new OsuContextMenuItem(@"Change height back", MenuItemType.Destructive) { Action = () => this.ResizeHeightTo(Height / 2, 100, EasingTypes.OutQuint) },
|
2017-06-12 17:56:07 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|