IsEnabled property for drag bar of music controller.

This commit is contained in:
Huo Yaoyuan 2016-12-01 08:20:24 +08:00
parent 19897013a0
commit 3a4fb2ffed
2 changed files with 15 additions and 1 deletions

View File

@ -16,6 +16,18 @@ public class DragBar : Container
public Action<float> SeekRequested;
private bool isDragging;
private bool enabled;
public bool IsEnabled
{
get { return enabled; }
set
{
enabled = value;
if (!enabled)
fill.Width = 0;
}
}
public DragBar()
{
RelativeSizeAxes = Axes.X;
@ -34,13 +46,14 @@ public DragBar()
public void UpdatePosition(float position)
{
if (isDragging) return;
if (isDragging || !IsEnabled) return;
fill.Width = position;
}
private void seek(InputState state)
{
if (!IsEnabled) return;
float seekLocation = state.Mouse.Position.X / DrawWidth;
SeekRequested?.Invoke(seekLocation);
fill.Width = seekLocation;

View File

@ -240,6 +240,7 @@ void preferUnicode_changed(object sender, EventArgs e)
private void workingChanged(object sender = null, EventArgs e = null)
{
progress.IsEnabled = (beatmapSource.Value != null);
if (beatmapSource.Value == current) return;
bool audioEquals = current?.BeatmapInfo.AudioEquals(beatmapSource.Value.BeatmapInfo) ?? false;
current = beatmapSource.Value;