Merge branch 'music-controller-improvements' into song-progress-graph

# Conflicts:
#	osu.Game/Overlays/DragBar.cs
This commit is contained in:
Dean Herbert
2017-04-07 15:49:14 +09:00
2 changed files with 49 additions and 37 deletions

View File

@ -17,7 +17,8 @@ namespace osu.Game.Overlays
protected readonly Box Fill; protected readonly Box Fill;
public Action<float> SeekRequested; public Action<float> SeekRequested;
private bool isDragging;
public bool IsSeeking { get; private set; }
private bool enabled = true; private bool enabled = true;
public bool IsEnabled public bool IsEnabled
@ -56,7 +57,7 @@ namespace osu.Game.Overlays
public void UpdatePosition(float position) public void UpdatePosition(float position)
{ {
if (isDragging || !IsEnabled) return; if (IsSeeking || !IsEnabled) return;
updatePosition(position); updatePosition(position);
} }
@ -72,7 +73,7 @@ namespace osu.Game.Overlays
private void updatePosition(float position) private void updatePosition(float position)
{ {
position = MathHelper.Clamp(position, 0, 1); position = MathHelper.Clamp(position, 0, 1);
FillContainer.TransformTo(FillContainer.Width, position, 100, EasingTypes.OutQuint, new TransformWidth()); fill.TransformTo(fill.Width, position, 200, EasingTypes.OutQuint, new TransformSeek());
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
@ -87,15 +88,15 @@ namespace osu.Game.Overlays
return true; return true;
} }
protected override bool OnDragStart(InputState state) => isDragging = true; protected override bool OnDragStart(InputState state) => IsSeeking = true;
protected override bool OnDragEnd(InputState state) protected override bool OnDragEnd(InputState state)
{ {
isDragging = false; IsSeeking = false;
return true; return true;
} }
private class TransformWidth : TransformFloat private class TransformSeek : TransformFloat
{ {
public override void Apply(Drawable d) public override void Apply(Drawable d)
{ {

View File

@ -46,6 +46,8 @@ namespace osu.Game.Overlays
private Container dragContainer; private Container dragContainer;
private const float progress_height = 10;
private const float bottom_black_area_height = 50; private const float bottom_black_area_height = 50;
public MusicController() public MusicController()
@ -117,53 +119,62 @@ namespace osu.Game.Overlays
Text = @"Nothing to play", Text = @"Nothing to play",
Font = @"Exo2.0-BoldItalic" Font = @"Exo2.0-BoldItalic"
}, },
new FillFlowContainer<Button> new Container {
{ Padding = new MarginPadding { Bottom = progress_height },
AutoSizeAxes = Axes.X,
Height = bottom_black_area_height, Height = bottom_black_area_height,
Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.X,
Spacing = new Vector2(5),
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Children = new[] Children = new Drawable[]
{ {
new Button new FillFlowContainer<Button>
{ {
Action = prev, AutoSizeAxes = Axes.Both,
Icon = FontAwesome.fa_step_backward, Direction = FillDirection.Horizontal,
}, Spacing = new Vector2(5),
playButton = new Button Origin = Anchor.Centre,
{ Anchor = Anchor.Centre,
//Scale = new Vector2(1.4f), Children = new[]
Action = () =>
{ {
if (current?.Track == null) return; new Button
if (current.Track.IsRunning) {
current.Track.Stop(); Action = prev,
else Icon = FontAwesome.fa_step_backward,
current.Track.Start(); },
}, playButton = new Button
Icon = FontAwesome.fa_play_circle_o, {
//Scale = new Vector2(1.3f),
Action = () =>
{
if (current?.Track == null) return;
if (current.Track.IsRunning)
current.Track.Stop();
else
current.Track.Start();
},
Icon = FontAwesome.fa_play_circle_o,
},
new Button
{
Action = next,
Icon = FontAwesome.fa_step_forward,
},
}
}, },
new Button new Button
{ {
Action = next, Origin = Anchor.Centre,
Icon = FontAwesome.fa_step_forward, Anchor = Anchor.CentreRight,
Position = new Vector2(-bottom_black_area_height / 2, 0),
Icon = FontAwesome.fa_bars,
}, },
} }
}, },
new Button
{
Origin = Anchor.Centre,
Anchor = Anchor.BottomRight,
Position = new Vector2(-bottom_black_area_height / 2),
Icon = FontAwesome.fa_bars,
},
progress = new DragBar progress = new DragBar
{ {
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Height = 10, Height = progress_height,
Colour = colours.Yellow, Colour = colours.Yellow,
SeekRequested = seek SeekRequested = seek
} }