osu/osu.Game/Graphics/UserInterface/OsuDropdown.cs

40 lines
1.4 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 System.Linq;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterface
{
2017-03-22 14:32:32 +00:00
public class OsuDropdown<T> : Dropdown<T>
2017-03-21 22:51:26 +00:00
{
2017-03-22 14:32:32 +00:00
protected override DropdownHeader CreateHeader() => new OsuDropdownHeader { AccentColour = AccentColour };
2017-03-21 22:51:26 +00:00
protected override Menu CreateMenu() => new OsuMenu();
private Color4? accentColour;
public virtual Color4 AccentColour
{
get { return accentColour.GetValueOrDefault(); }
set
{
accentColour = value;
if (Header != null)
2017-03-22 14:32:32 +00:00
((OsuDropdownHeader)Header).AccentColour = value;
foreach (var item in MenuItems.OfType<OsuDropdownMenuItem<T>>())
2017-03-21 22:51:26 +00:00
item.AccentColour = value;
}
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
if (accentColour == null)
AccentColour = colours.PinkDarker;
}
2017-03-22 14:32:32 +00:00
protected override DropdownMenuItem<T> CreateMenuItem(string text, T value) => new OsuDropdownMenuItem<T>(text, value) { AccentColour = AccentColour };
2017-03-21 22:51:26 +00:00
}
}