mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 18:42:56 +08:00
Removed gradient from test case, modified DragBar to allow access to what's needed in the progress bar, styled the progress bar
This commit is contained in:
parent
50f93bc215
commit
7fea233181
@ -22,11 +22,6 @@ namespace osu.Desktop.VisualTests
|
|||||||
{
|
{
|
||||||
base.Reset();
|
base.Reset();
|
||||||
|
|
||||||
Add(new Box
|
|
||||||
{
|
|
||||||
ColourInfo = ColourInfo.GradientVertical(Color4.WhiteSmoke, Color4.Gray),
|
|
||||||
RelativeSizeAxes = Framework.Graphics.Axes.Both,
|
|
||||||
});
|
|
||||||
Add(new SongProgress
|
Add(new SongProgress
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
|
@ -11,7 +11,8 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
public class DragBar : Container
|
public class DragBar : Container
|
||||||
{
|
{
|
||||||
private Box fill;
|
protected Container fillContainer;
|
||||||
|
protected Box fill;
|
||||||
|
|
||||||
public Action<float> SeekRequested;
|
public Action<float> SeekRequested;
|
||||||
private bool isDragging;
|
private bool isDragging;
|
||||||
@ -24,7 +25,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
enabled = value;
|
enabled = value;
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
fill.Width = 0;
|
fillContainer.Width = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,12 +35,19 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
fill = new Box()
|
fillContainer = new Container
|
||||||
{
|
{
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Width = 0
|
Width = 0,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
fill = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -48,7 +56,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
if (isDragging || !IsEnabled) return;
|
if (isDragging || !IsEnabled) return;
|
||||||
|
|
||||||
fill.Width = position;
|
fillContainer.Width = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seek(InputState state)
|
private void seek(InputState state)
|
||||||
@ -56,7 +64,7 @@ namespace osu.Game.Overlays
|
|||||||
if (!IsEnabled) return;
|
if (!IsEnabled) return;
|
||||||
float seekLocation = state.Mouse.Position.X / DrawWidth;
|
float seekLocation = state.Mouse.Position.X / DrawWidth;
|
||||||
SeekRequested?.Invoke(seekLocation);
|
SeekRequested?.Invoke(seekLocation);
|
||||||
fill.Width = seekLocation;
|
fillContainer.Width = seekLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
|
@ -16,9 +16,8 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
public class SongProgress : Container
|
public class SongProgress : Container
|
||||||
{
|
{
|
||||||
private const int graph_height = 34;
|
public static readonly int BAR_HEIGHT = 5;
|
||||||
private const int handle_height = 25;
|
public static readonly int GRAPH_HEIGHT = 34;
|
||||||
private const int handle_width = 14;
|
|
||||||
public static readonly Color4 FILL_COLOUR = new Color4(221, 255, 255, 255);
|
public static readonly Color4 FILL_COLOUR = new Color4(221, 255, 255, 255);
|
||||||
public static readonly Color4 GLOW_COLOUR = new Color4(221, 255, 255, 150);
|
public static readonly Color4 GLOW_COLOUR = new Color4(221, 255, 255, 150);
|
||||||
|
|
||||||
@ -40,15 +39,20 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
float currentProgress = (float)(current.Track.CurrentTime / current.Track.Length);
|
float currentProgress = (float)(current.Track.CurrentTime / current.Track.Length);
|
||||||
|
|
||||||
|
progress.IsEnabled = true;
|
||||||
progress.UpdatePosition(currentProgress);
|
progress.UpdatePosition(currentProgress);
|
||||||
graph.Progress = (int)(graph.ColumnCount * currentProgress);
|
graph.Progress = (int)(graph.ColumnCount * currentProgress);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
progress.IsEnabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SongProgress()
|
public SongProgress()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = SongProgressBar.BAR_HEIGHT + graph_height + handle_height;
|
Height = BAR_HEIGHT + GRAPH_HEIGHT + SongProgressBar.HANDLE_SIZE.Y;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -57,56 +61,22 @@ namespace osu.Game.Screens.Play
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Height = graph_height,
|
Height = GRAPH_HEIGHT,
|
||||||
Margin = new MarginPadding
|
Margin = new MarginPadding
|
||||||
{
|
{
|
||||||
Bottom = SongProgressBar.BAR_HEIGHT
|
Bottom = BAR_HEIGHT
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
progress = new SongProgressBar
|
progress = new SongProgressBar
|
||||||
{
|
{
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
IsEnabled = true,
|
|
||||||
SeekRequested = delegate (float position)
|
SeekRequested = delegate (float position)
|
||||||
{
|
{
|
||||||
Framework.Logging.Logger.Log($@"Seeked to {position}");
|
current?.Track?.Seek(current.Track.Length * position);
|
||||||
|
current?.Track?.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle = new Container
|
|
||||||
// {
|
|
||||||
// Origin = Anchor.BottomLeft,
|
|
||||||
// Anchor = Anchor.BottomLeft,
|
|
||||||
// Width = 2,
|
|
||||||
// Height = bar_height + graph_height,
|
|
||||||
// Position = new Vector2(2, 0),
|
|
||||||
// Children = new Drawable[]
|
|
||||||
// {
|
|
||||||
// new Box
|
|
||||||
// {
|
|
||||||
// RelativeSizeAxes = Axes.Both,
|
|
||||||
// Colour = Color4.White
|
|
||||||
// },
|
|
||||||
// new Container
|
|
||||||
// {
|
|
||||||
// Origin = Anchor.BottomCentre,
|
|
||||||
// Anchor = Anchor.TopCentre,
|
|
||||||
// Width = handle_width,
|
|
||||||
// Height = handle_height,
|
|
||||||
// CornerRadius = 5,
|
|
||||||
// Masking = true,
|
|
||||||
// Children = new Drawable[]
|
|
||||||
// {
|
|
||||||
// new Box
|
|
||||||
// {
|
|
||||||
// RelativeSizeAxes = Axes.Both,
|
|
||||||
// Colour = Color4.White
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,66 @@
|
|||||||
using System;
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
using osu.Game.Overlays;
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public class SongProgressBar : DragBar
|
public class SongProgressBar : DragBar
|
||||||
{
|
{
|
||||||
public static readonly int BAR_HEIGHT = 5;
|
public static readonly Vector2 HANDLE_SIZE = new Vector2(14, 25);
|
||||||
|
|
||||||
|
private Container handle;
|
||||||
|
|
||||||
public SongProgressBar()
|
public SongProgressBar()
|
||||||
{
|
{
|
||||||
Colour = SongProgress.FILL_COLOUR;
|
fill.Colour = SongProgress.FILL_COLOUR;
|
||||||
Height = BAR_HEIGHT;
|
Height = SongProgress.BAR_HEIGHT;
|
||||||
|
|
||||||
|
Add(new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.Black,
|
||||||
|
Alpha = 0.5f,
|
||||||
|
Depth = 1
|
||||||
|
});
|
||||||
|
fillContainer.Add(handle = new Container
|
||||||
|
{
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Width = 2,
|
||||||
|
Height = SongProgress.BAR_HEIGHT + SongProgress.GRAPH_HEIGHT,
|
||||||
|
Colour = Color4.White,
|
||||||
|
Position = new Vector2(2, 0),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Size = HANDLE_SIZE,
|
||||||
|
CornerRadius = 5,
|
||||||
|
Masking = true,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.White
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ namespace osu.Game.Screens.Play
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (DrawWidth == lastDrawWidth) return;
|
if (DrawWidth == lastDrawWidth) return;
|
||||||
//recreateGraph();
|
recreateGraph();
|
||||||
lastDrawWidth = DrawWidth;
|
lastDrawWidth = DrawWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ using osu.Game.Graphics;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user