1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 09:22:54 +08:00

Make DragBar animate seeks.

This commit is contained in:
Dean Herbert 2017-04-07 09:57:34 +09:00
parent a56643aa61
commit bc4e0bfa8b
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Input;
namespace osu.Game.Overlays
@ -48,7 +49,7 @@ namespace osu.Game.Overlays
{
if (isDragging || !IsEnabled) return;
fill.Width = position;
updatePosition(position);
}
private void seek(InputState state)
@ -56,7 +57,12 @@ namespace osu.Game.Overlays
if (!IsEnabled) return;
float seekLocation = state.Mouse.Position.X / DrawWidth;
SeekRequested?.Invoke(seekLocation);
fill.Width = seekLocation;
updatePosition(seekLocation);
}
private void updatePosition(float position)
{
fill.TransformTo(fill.Width, position, 100, EasingTypes.OutQuint, new TransformWidth());
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
@ -78,5 +84,14 @@ namespace osu.Game.Overlays
isDragging = false;
return true;
}
private class TransformWidth : TransformFloat
{
public override void Apply(Drawable d)
{
base.Apply(d);
d.Width = CurrentValue;
}
}
}
}