1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-22 10:53:21 +08:00

Add border showing selected blueprints in timeline

This commit is contained in:
Dean Herbert 2021-04-16 18:16:22 +09:00
parent 0030b2dde6
commit d9d50f0e88

View File

@ -40,7 +40,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private Bindable<int> indexInCurrentComboBindable; private Bindable<int> indexInCurrentComboBindable;
private Bindable<int> comboIndexBindable; private Bindable<int> comboIndexBindable;
private readonly Drawable circle; private readonly ExtendableCircle circle;
private readonly Border border;
private readonly Container colouredComponents; private readonly Container colouredComponents;
private readonly OsuSpriteText comboIndexText; private readonly OsuSpriteText comboIndexText;
@ -62,7 +63,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Height = circle_size; Height = circle_size;
AddRangeInternal(new[] AddRangeInternal(new Drawable[]
{ {
circle = new ExtendableCircle circle = new ExtendableCircle
{ {
@ -70,6 +71,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
}, },
border = new Border
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
colouredComponents = new Container colouredComponents = new Container
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
@ -116,11 +123,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
protected override void OnSelected() protected override void OnSelected()
{ {
// base logic hides selected blueprints when not selected, but timeline doesn't do that. // base logic hides selected blueprints when not selected, but timeline doesn't do that.
updateComboColour();
} }
protected override void OnDeselected() protected override void OnDeselected()
{ {
// base logic hides selected blueprints when not selected, but timeline doesn't do that. // base logic hides selected blueprints when not selected, but timeline doesn't do that.
updateComboColour();
} }
private void updateComboIndex() => comboIndexText.Text = (indexInCurrentComboBindable.Value + 1).ToString(); private void updateComboIndex() => comboIndexText.Text = (indexInCurrentComboBindable.Value + 1).ToString();
@ -133,6 +142,16 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
var comboColours = skin.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value ?? Array.Empty<Color4>(); var comboColours = skin.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value ?? Array.Empty<Color4>();
var comboColour = combo.GetComboColour(comboColours); var comboColour = combo.GetComboColour(comboColours);
if (IsSelected)
{
border.Show();
comboColour = comboColour.Lighten(0.3f);
}
else
{
border.Hide();
}
if (HitObject is IHasDuration duration && duration.Duration > 0) if (HitObject is IHasDuration duration && duration.Duration > 0)
circle.Colour = ColourInfo.GradientHorizontal(comboColour, comboColour.Lighten(0.4f)); circle.Colour = ColourInfo.GradientHorizontal(comboColour, comboColour.Lighten(0.4f));
else else
@ -340,22 +359,38 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
} }
} }
public class Border : ExtendableCircle
{
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Content.Child.Alpha = 0;
Content.Child.AlwaysPresent = true;
Content.BorderColour = colours.Yellow;
Content.EdgeEffect = new EdgeEffectParameters();
}
}
/// <summary> /// <summary>
/// A circle with externalised end caps so it can take up the full width of a relative width area. /// A circle with externalised end caps so it can take up the full width of a relative width area.
/// </summary> /// </summary>
public class ExtendableCircle : CompositeDrawable public class ExtendableCircle : CompositeDrawable
{ {
private readonly Circle content; protected readonly Circle Content;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => content.ReceivePositionalInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Content.ReceivePositionalInputAt(screenSpacePos);
public override Quad ScreenSpaceDrawQuad => content.ScreenSpaceDrawQuad; public override Quad ScreenSpaceDrawQuad => Content.ScreenSpaceDrawQuad;
public ExtendableCircle() public ExtendableCircle()
{ {
Padding = new MarginPadding { Horizontal = -circle_size / 2f }; Padding = new MarginPadding { Horizontal = -circle_size / 2f };
InternalChild = content = new Circle InternalChild = Content = new Circle
{ {
BorderColour = OsuColour.Gray(0.75f),
BorderThickness = 4,
Masking = true,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
{ {