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 osu.Framework.Allocation;
|
2017-03-05 02:42:37 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-02-03 18:13:10 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
{
|
|
|
|
public class OsuDropDownMenuItem<U> : DropDownMenuItem<U>
|
|
|
|
{
|
|
|
|
public OsuDropDownMenuItem(string text, U value) : base(text, value)
|
|
|
|
{
|
|
|
|
Foreground.Padding = new MarginPadding(2);
|
|
|
|
|
2017-03-16 20:17:14 +08:00
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 6;
|
|
|
|
|
2017-02-03 18:13:10 +08:00
|
|
|
Children = new[]
|
|
|
|
{
|
2017-03-02 02:33:01 +08:00
|
|
|
new FillFlowContainer
|
2017-02-03 18:13:10 +08:00
|
|
|
{
|
2017-03-04 18:00:17 +08:00
|
|
|
Direction = FillDirection.Horizontal,
|
2017-02-03 18:13:10 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2017-03-16 20:17:14 +08:00
|
|
|
chevron = new TextAwesome
|
2017-02-03 18:13:10 +08:00
|
|
|
{
|
2017-03-16 20:17:14 +08:00
|
|
|
AlwaysPresent = true,
|
2017-02-03 18:13:10 +08:00
|
|
|
Icon = FontAwesome.fa_chevron_right,
|
2017-03-16 20:17:14 +08:00
|
|
|
UseFullGlyphHeight = false,
|
2017-02-03 18:13:10 +08:00
|
|
|
Colour = Color4.Black,
|
2017-03-16 20:17:14 +08:00
|
|
|
Alpha = 0.5f,
|
|
|
|
TextSize = 8,
|
|
|
|
Margin = new MarginPadding { Left = 3, Right = 3 },
|
2017-02-03 18:13:10 +08:00
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
},
|
|
|
|
new OsuSpriteText {
|
|
|
|
Text = text,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-03-16 20:17:14 +08:00
|
|
|
private Color4? accentColour;
|
|
|
|
|
|
|
|
private TextAwesome chevron;
|
|
|
|
|
|
|
|
protected override void FormatForeground(bool hover = false)
|
|
|
|
{
|
|
|
|
base.FormatForeground(hover);
|
|
|
|
chevron.Alpha = hover ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Color4 AccentColour
|
|
|
|
{
|
|
|
|
get { return accentColour.GetValueOrDefault(); }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
accentColour = value;
|
|
|
|
BackgroundColourHover = BackgroundColourSelected = value;
|
|
|
|
FormatBackground();
|
|
|
|
FormatForeground();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-03 18:13:10 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
2017-03-16 20:17:14 +08:00
|
|
|
BackgroundColour = Color4.Transparent;
|
|
|
|
BackgroundColourHover = accentColour ?? colours.PinkDarker;
|
2017-02-03 18:13:10 +08:00
|
|
|
BackgroundColourSelected = Color4.Black.Opacity(0.5f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|