1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:52:56 +08:00

Create IHasOsuContextMenu and update OsuContextMenuContainer in line with framework.

This commit is contained in:
smoogipooo 2017-08-25 15:10:29 +09:00
parent 7467d24d35
commit 4fb9570618
4 changed files with 21 additions and 12 deletions

View File

@ -3,9 +3,8 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
@ -67,9 +66,9 @@ namespace osu.Desktop.Tests.Visual
);
}
private class MyContextMenuContainer : Container, IHasContextMenu
private class MyContextMenuContainer : Container, IHasOsuContextMenu
{
public ContextMenuItem[] ContextMenuItems => new ContextMenuItem[]
public OsuContextMenuItem[] ContextMenuItems => new[]
{
new OsuContextMenuItem(@"Some option"),
new OsuContextMenuItem(@"Highlighted option", MenuItemType.Highlighted),
@ -81,16 +80,16 @@ namespace osu.Desktop.Tests.Visual
};
}
private class AnotherContextMenuContainer : Container, IHasContextMenu
private class AnotherContextMenuContainer : Container, IHasOsuContextMenu
{
public ContextMenuItem[] ContextMenuItems => new ContextMenuItem[]
public OsuContextMenuItem[] ContextMenuItems => new[]
{
new OsuContextMenuItem(@"Simple option"),
new OsuContextMenuItem(@"Simple very very long option"),
new OsuContextMenuItem(@"Change width", MenuItemType.Highlighted) { Action = () => this.ResizeWidthTo(Width * 2, 100, Easing.OutQuint) },
new OsuContextMenuItem(@"Change height", MenuItemType.Highlighted) { Action = () => this.ResizeHeightTo(Height * 2, 100, Easing.OutQuint) },
new OsuContextMenuItem(@"Change width back", MenuItemType.Destructive) { Action = () => this.ResizeWidthTo(Width / 2, 100, Easing.OutQuint) },
new OsuContextMenuItem(@"Change height back", MenuItemType.Destructive) { Action = () => this.ResizeHeightTo(Height / 2, 100, Easing.OutQuint) },
new OsuContextMenuItem(@"Change width", MenuItemType.Highlighted, () => this.ResizeWidthTo(Width * 2, 100, Easing.OutQuint)),
new OsuContextMenuItem(@"Change height", MenuItemType.Highlighted, () => this.ResizeHeightTo(Height * 2, 100, Easing.OutQuint)),
new OsuContextMenuItem(@"Change width back", MenuItemType.Destructive, () => this.ResizeWidthTo(Width / 2, 100, Easing.OutQuint)),
new OsuContextMenuItem(@"Change height back", MenuItemType.Destructive, () => this.ResizeHeightTo(Height / 2, 100, Easing.OutQuint)),
};
}
}

View File

@ -0,0 +1,9 @@
using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Graphics.Cursor
{
public interface IHasOsuContextMenu : IHasContextMenu<OsuContextMenuItem>
{
}
}

View File

@ -7,8 +7,8 @@ using osu.Game.Graphics.UserInterface;
namespace osu.Game.Graphics.Cursor
{
public class OsuContextMenuContainer : ContextMenuContainer
public class OsuContextMenuContainer : ContextMenuContainer<OsuContextMenuItem>
{
protected override ContextMenu<ContextMenuItem> CreateContextMenu() => new OsuContextMenu<ContextMenuItem>();
protected override Menu<OsuContextMenuItem> CreateMenu() => new OsuContextMenu<OsuContextMenuItem>();
}
}

View File

@ -84,6 +84,7 @@
<Compile Include="Graphics\Containers\OsuClickableContainer.cs" />
<Compile Include="Graphics\Containers\OsuFocusedOverlayContainer.cs" />
<Compile Include="Graphics\Containers\OsuScrollContainer.cs" />
<Compile Include="Graphics\Cursor\IHasOsuContextMenu.cs" />
<Compile Include="Graphics\Cursor\OsuContextMenuContainer.cs" />
<Compile Include="Graphics\Containers\OsuTextFlowContainer.cs" />
<Compile Include="Graphics\UserInterface\IconButton.cs" />