1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 21:02:54 +08:00
osu-lazer/osu.Game/Overlays/Options/OptionSlider.cs

64 lines
1.8 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-12-15 03:59:23 +08:00
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;
2016-12-08 04:39:21 +08:00
namespace osu.Game.Overlays.Options
{
2017-03-02 02:33:01 +08:00
public class OptionSlider<T> : FillFlowContainer where T : struct
2016-12-08 04:39:21 +08:00
{
private readonly SliderBar<T> slider;
private readonly SpriteText text;
2016-12-08 04:39:21 +08:00
public string LabelText
{
get { return text.Text; }
set
{
text.Text = value;
text.Alpha = string.IsNullOrEmpty(value) ? 0 : 1;
}
}
2017-04-10 15:22:36 +08:00
private Bindable<T> bindable;
public Bindable<T> Bindable
2016-12-08 04:39:21 +08:00
{
set
{
2017-04-10 15:22:36 +08:00
bindable = value;
2017-04-10 16:10:15 +08:00
slider.Current.BindTo(bindable);
if (value?.Disabled ?? true)
Alpha = 0.3f;
}
2016-12-08 04:39:21 +08:00
}
public OptionSlider()
2016-12-08 04:39:21 +08:00
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Right = 5 };
2016-12-08 04:39:21 +08:00
Children = new Drawable[]
{
text = new OsuSpriteText
{
Alpha = 0,
},
2016-12-08 04:39:21 +08:00
slider = new OsuSliderBar<T>
{
Margin = new MarginPadding { Top = 5, Bottom = 5 },
RelativeSizeAxes = Axes.X
2016-12-08 04:39:21 +08:00
}
};
}
}
2016-12-09 21:18:58 +08:00
}