1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 03:57:24 +08:00
osu-lazer/osu.Game/Overlays/Options/OptionDropdown.cs
Dean Herbert 153951d3dd Add OptionItem class
Allow for centalised logic for all option UI controls.
2017-05-04 23:07:48 +09:00

44 lines
1.3 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 System;
using System.Collections.Generic;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options
{
public class OptionDropdown<T> : OptionItem<T>
{
private Dropdown<T> dropdown;
private IEnumerable<KeyValuePair<string, T>> items = new KeyValuePair<string, T>[] { };
public IEnumerable<KeyValuePair<string, T>> Items
{
get
{
return items;
}
set
{
items = value;
if (dropdown != null)
dropdown.Items = value;
}
}
protected override Drawable CreateControl() => dropdown = new OsuDropdown<T>
{
Margin = new MarginPadding { Top = 5 },
RelativeSizeAxes = Axes.X,
Items = Items,
};
}
}