// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; using System.Linq; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Settings { public class SettingsDropdown : SettingsItem { protected new OsuDropdown Control => (OsuDropdown)base.Control; private IEnumerable items = Enumerable.Empty(); public IEnumerable Items { get => items; set { items = value; if (Control != null) Control.Items = value; } } private IBindableList itemSource; public IBindableList ItemSource { get => itemSource; set { itemSource = value; if (Control != null) Control.ItemSource = value; } } public override IEnumerable FilterTerms => base.FilterTerms.Concat(Control.Items.Select(i => i.ToString())); protected sealed override Drawable CreateControl() => CreateDropdown(); protected virtual OsuDropdown CreateDropdown() => new DropdownControl { Items = Items, ItemSource = ItemSource }; protected class DropdownControl : OsuDropdown { public DropdownControl() { Margin = new MarginPadding { Top = 5 }; RelativeSizeAxes = Axes.X; } } } }