Update BeatDivisorControl to better match new designs and metrics

This commit is contained in:
Dean Herbert
2022-05-24 16:50:16 +09:00
parent 4a88affd03
commit 3c2e57bf00
2 changed files with 28 additions and 55 deletions

View File

@ -5,11 +5,13 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Overlays;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components; using osu.Game.Screens.Edit.Compose.Components;
using osuTK; using osuTK;
@ -25,6 +27,9 @@ namespace osu.Game.Tests.Visual.Editing
private SliderBar<int> tickSliderBar => beatDivisorControl.ChildrenOfType<SliderBar<int>>().Single(); private SliderBar<int> tickSliderBar => beatDivisorControl.ChildrenOfType<SliderBar<int>>().Single();
private EquilateralTriangle tickMarkerHead => tickSliderBar.ChildrenOfType<EquilateralTriangle>().Single(); private EquilateralTriangle tickMarkerHead => tickSliderBar.ChildrenOfType<EquilateralTriangle>().Single();
[Cached]
private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Green);
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {

View File

@ -8,9 +8,7 @@ using Humanizer;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -22,6 +20,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Overlays;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using osuTK.Input; using osuTK.Input;
@ -38,18 +37,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
Masking = true; Masking = true;
CornerRadius = 5;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new Box new Box
{ {
Name = "Gray Background", Name = "Main background",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = colours.Gray4 Colour = colourProvider.Background3,
}, },
new GridContainer new GridContainer
{ {
@ -65,9 +63,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
{ {
new Box new Box
{ {
Name = "Black Background", Name = "Tick area background",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.Black Colour = colourProvider.Background5,
}, },
new TickSliderBar(beatDivisor) new TickSliderBar(beatDivisor)
{ {
@ -86,7 +84,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = colours.Gray4 Colour = colourProvider.Background3
}, },
new Container new Container
{ {
@ -139,11 +137,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.Gray4
},
new Container new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -402,15 +395,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
ClearInternal(); ClearInternal();
CurrentNumber.ValueChanged -= moveMarker; CurrentNumber.ValueChanged -= moveMarker;
foreach (int t in beatDivisor.ValidDivisors.Value.Presets) foreach (int divisor in beatDivisor.ValidDivisors.Value.Presets)
{ {
AddInternal(new Tick AddInternal(new Tick(divisor)
{ {
Anchor = Anchor.TopLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre, Origin = Anchor.Centre,
RelativePositionAxes = Axes.X, RelativePositionAxes = Axes.Both,
Colour = BindableBeatDivisor.GetColourFor(t, colours), Colour = BindableBeatDivisor.GetColourFor(divisor, colours),
X = getMappedPosition(t) X = getMappedPosition(divisor),
}); });
} }
@ -422,7 +415,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void moveMarker(ValueChangedEvent<int> divisor) private void moveMarker(ValueChangedEvent<int> divisor)
{ {
marker.MoveToX(getMappedPosition(divisor.NewValue), 100, Easing.OutQuint); marker.MoveToX(getMappedPosition(divisor.NewValue), 100, Easing.OutQuint);
marker.Flash();
} }
protected override void UpdateValue(float value) protected override void UpdateValue(float value)
@ -489,29 +481,26 @@ namespace osu.Game.Screens.Edit.Compose.Components
private float getMappedPosition(float divisor) => MathF.Pow((divisor - 1) / (beatDivisor.ValidDivisors.Value.Presets.Last() - 1), 0.90f); private float getMappedPosition(float divisor) => MathF.Pow((divisor - 1) / (beatDivisor.ValidDivisors.Value.Presets.Last() - 1), 0.90f);
private class Tick : CompositeDrawable private class Tick : Circle
{ {
public Tick() public Tick(int divisor)
{ {
Size = new Vector2(2.5f, 10); Size = new Vector2(6f, 12) * BindableBeatDivisor.GetSize(divisor);
InternalChild = new Box { RelativeSizeAxes = Axes.Both }; InternalChild = new Box { RelativeSizeAxes = Axes.Both };
CornerRadius = 0.5f;
Masking = true;
} }
} }
private class Marker : CompositeDrawable private class Marker : CompositeDrawable
{ {
private Color4 defaultColour; [Resolved]
private OverlayColourProvider colourProvider { get; set; }
private const float size = 7; private const float size = 10;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load()
{ {
Colour = defaultColour = colours.Gray4; Colour = colourProvider.Background3;
Anchor = Anchor.TopLeft; Anchor = Anchor.TopLeft;
Origin = Anchor.TopCentre; Origin = Anchor.TopCentre;
@ -521,15 +510,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new Box
{
Width = 2,
RelativeSizeAxes = Axes.Y,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0.2f), Color4.White),
Blending = BlendingParameters.Additive,
},
new EquilateralTriangle new EquilateralTriangle
{ {
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
@ -548,22 +528,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
get => active; get => active;
set set
{ {
this.FadeColour(value ? Color4.White : defaultColour, 500, Easing.OutQuint); this.FadeColour(value ? colourProvider.Background1 : colourProvider.Background3, 500, Easing.OutQuint);
active = value; active = value;
} }
} }
public void Flash()
{
bool wasActive = active;
Active = true;
if (wasActive) return;
using (BeginDelayedSequence(50))
Active = false;
}
} }
} }
} }