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
|
|
|
|
|
|
2017-06-12 18:39:45 +08:00
|
|
|
|
using OpenTK;
|
2017-06-12 17:56:07 +08:00
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
|
{
|
|
|
|
|
public class OsuContextMenu<TItem> : ContextMenu<TItem>
|
|
|
|
|
where TItem : ContextMenuItem
|
|
|
|
|
{
|
|
|
|
|
protected override Menu<TItem> CreateMenu() => new CustomMenu();
|
|
|
|
|
|
|
|
|
|
public class CustomMenu : Menu<TItem>
|
|
|
|
|
{
|
|
|
|
|
private const int fade_duration = 250;
|
|
|
|
|
|
|
|
|
|
public CustomMenu()
|
|
|
|
|
{
|
|
|
|
|
CornerRadius = 5;
|
|
|
|
|
ItemsContainer.Padding = new MarginPadding { Vertical = OsuContextMenuItem.MARGIN_VERTICAL };
|
|
|
|
|
Masking = true;
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
2017-06-13 14:27:47 +08:00
|
|
|
|
Colour = Color4.Black.Opacity(0.1f),
|
2017-06-12 17:56:07 +08:00
|
|
|
|
Radius = 4,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
Background.Colour = colours.ContextMenuGray;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-23 02:50:25 +08:00
|
|
|
|
protected override void AnimateOpen() => this.FadeIn(fade_duration, Easing.OutQuint);
|
|
|
|
|
protected override void AnimateClose() => this.FadeOut(fade_duration, Easing.OutQuint);
|
2017-06-12 18:39:45 +08:00
|
|
|
|
|
|
|
|
|
protected override void UpdateContentHeight()
|
|
|
|
|
{
|
|
|
|
|
var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight;
|
2017-07-23 02:50:25 +08:00
|
|
|
|
this.ResizeTo(new Vector2(1, State == MenuState.Opened ? actualHeight : 0), 300, Easing.OutQuint);
|
2017-06-12 18:39:45 +08:00
|
|
|
|
}
|
2017-06-12 17:56:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|