osu/osu.Game/Graphics/UserInterface/OsuMenu.cs

44 lines
1.3 KiB
C#
Raw Normal View History

2017-03-21 22:51:26 +00: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.Extensions.Color4Extensions;
using osu.Framework.Graphics;
2017-08-25 06:09:07 +00:00
using osu.Framework.Graphics.Containers;
2017-03-21 22:51:26 +00:00
using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterface
{
2017-08-25 06:09:07 +00:00
public class OsuMenu<TItem> : Menu<TItem>
where TItem : MenuItem
2017-03-21 22:51:26 +00:00
{
public OsuMenu()
{
CornerRadius = 4;
2017-08-25 06:09:07 +00:00
BackgroundColour = Color4.Black.Opacity(0.5f);
2017-03-21 22:51:26 +00:00
}
2017-07-22 18:50:25 +00:00
protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint);
protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint);
2017-03-21 22:51:26 +00:00
2017-08-25 06:09:07 +00:00
protected override void UpdateMenuHeight()
2017-03-21 22:51:26 +00:00
{
var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight;
2017-08-25 07:27:01 +00:00
this.ResizeHeightTo(State == MenuState.Opened ? actualHeight : 0, 300, Easing.OutQuint);
2017-03-21 22:51:26 +00:00
}
2017-08-25 06:09:07 +00:00
protected override FlowContainer<MenuItemRepresentation> CreateItemsFlow()
{
var flow = base.CreateItemsFlow();
flow.Padding = new MarginPadding(5);
return flow;
}
}
public class OsuMenu : OsuMenu<MenuItem>
{
2017-03-21 22:51:26 +00:00
}
}