2017-02-07 12:59:30 +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-02-03 18:13:10 +08:00
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2017-02-25 20:12:39 +08:00
|
|
|
using osu.Framework.Graphics.Transforms;
|
2017-02-03 18:13:10 +08:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using OpenTK;
|
2017-02-03 18:23:14 +08:00
|
|
|
using OpenTK.Graphics;
|
2017-03-05 02:42:37 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-02-03 18:13:10 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
{
|
|
|
|
public class OsuDropDownMenu<U> : DropDownMenu<U>
|
|
|
|
{
|
|
|
|
protected override DropDownHeader CreateHeader() => new OsuDropDownHeader();
|
|
|
|
|
2017-02-06 08:17:50 +08:00
|
|
|
protected override IEnumerable<DropDownMenuItem<U>> GetDropDownItems(IEnumerable<KeyValuePair<string, U>> values)
|
|
|
|
=> values.Select(v => new OsuDropDownMenuItem<U>(v.Key, v.Value));
|
2017-02-03 18:13:10 +08:00
|
|
|
|
|
|
|
public OsuDropDownMenu()
|
|
|
|
{
|
2017-02-04 15:05:24 +08:00
|
|
|
ContentContainer.CornerRadius = 4;
|
2017-02-03 18:23:14 +08:00
|
|
|
ContentBackground.Colour = Color4.Black.Opacity(0.5f);
|
2017-02-03 18:13:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void AnimateOpen()
|
|
|
|
{
|
|
|
|
ContentContainer.FadeIn(300, EasingTypes.OutQuint);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void AnimateClose()
|
|
|
|
{
|
|
|
|
ContentContainer.FadeOut(300, EasingTypes.OutQuint);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void UpdateContentHeight()
|
|
|
|
{
|
|
|
|
if (State == DropDownMenuState.Opened)
|
|
|
|
ContentContainer.ResizeTo(new Vector2(1, ContentHeight), 300, EasingTypes.OutQuint);
|
|
|
|
else
|
|
|
|
ContentContainer.ResizeTo(new Vector2(1, 0), 300, EasingTypes.OutQuint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|