1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 14:07:25 +08:00
osu-lazer/osu.Game/Graphics/UserInterface/OsuMenu.cs
2017-08-25 15:09:07 +09:00

44 lines
1.4 KiB
C#

// 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.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterface
{
public class OsuMenu<TItem> : Menu<TItem>
where TItem : MenuItem
{
public OsuMenu()
{
CornerRadius = 4;
BackgroundColour = Color4.Black.Opacity(0.5f);
}
protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint);
protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint);
protected override void UpdateMenuHeight()
{
var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight;
this.ResizeTo(new Vector2(1, State == MenuState.Opened ? actualHeight : 0), 300, Easing.OutQuint);
}
protected override FlowContainer<MenuItemRepresentation> CreateItemsFlow()
{
var flow = base.CreateItemsFlow();
flow.Padding = new MarginPadding(5);
return flow;
}
}
public class OsuMenu : OsuMenu<MenuItem>
{
}
}