1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Give DrawableBeatDivisor a ctor

This commit is contained in:
smoogipoo 2018-03-20 13:57:25 +09:00
parent fa5fd46f85
commit 50192b21e3
3 changed files with 19 additions and 26 deletions

View File

@ -10,17 +10,10 @@ namespace osu.Game.Tests.Visual
{
public class TestCaseDrawableBeatDivisor : OsuTestCase
{
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(parent);
[BackgroundDependencyLoader]
private void load()
{
dependencies.Cache(new BindableBeatDivisor());
Child = new DrawableBeatDivisor
Child = new DrawableBeatDivisor(new BindableBeatDivisor())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -70,7 +70,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose
Padding = new MarginPadding { Right = 5 },
Child = timeline = new ScrollableTimeline { RelativeSizeAxes = Axes.Both }
},
new DrawableBeatDivisor { RelativeSizeAxes = Axes.Both }
new DrawableBeatDivisor(beatDivisor) { RelativeSizeAxes = Axes.Both }
},
},
ColumnDimensions = new[]

View File

@ -19,14 +19,17 @@ namespace osu.Game.Screens.Edit.Screens.Compose
{
private static readonly int[] available_divisors = { 1, 2, 3, 4, 6, 8, 12, 16 };
private readonly Bindable<int> beatDivisor = new Bindable<int>(1);
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
private int currentDivisorIndex;
[BackgroundDependencyLoader]
private void load(OsuColour colours, BindableBeatDivisor beatDivisor)
public DrawableBeatDivisor(BindableBeatDivisor beatDivisor)
{
this.beatDivisor.BindTo(beatDivisor);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Masking = true;
CornerRadius = 5;
@ -45,7 +48,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose
{
new Drawable[]
{
new TickContainer(1, 2, 3, 4, 6, 8, 12, 16)
new TickContainer(beatDivisor, 1, 2, 3, 4, 6, 8, 12, 16)
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Horizontal = 5 }
@ -79,7 +82,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose
Icon = FontAwesome.fa_chevron_left,
Action = selectPrevious
},
new DivisorText(),
new DivisorText(beatDivisor),
new DivisorButton
{
Icon = FontAwesome.fa_chevron_right,
@ -135,17 +138,17 @@ namespace osu.Game.Screens.Edit.Screens.Compose
{
private readonly Bindable<int> beatDivisor = new Bindable<int>();
public DivisorText()
public DivisorText(BindableBeatDivisor beatDivisor)
{
this.beatDivisor.BindTo(beatDivisor);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, BindableBeatDivisor beatDivisor)
private void load(OsuColour colours)
{
this.beatDivisor.BindTo(beatDivisor);
Colour = colours.BlueLighter;
}
@ -187,27 +190,24 @@ namespace osu.Game.Screens.Edit.Screens.Compose
{
private readonly Bindable<int> beatDivisor = new Bindable<int>();
public new MarginPadding Padding
{
set => base.Padding = value;
}
public new MarginPadding Padding { set => base.Padding = value; }
private EquilateralTriangle marker;
private readonly int[] availableDivisors;
private readonly float tickSpacing;
public TickContainer(params int[] divisors)
public TickContainer(BindableBeatDivisor beatDivisor, params int[] divisors)
{
this.beatDivisor.BindTo(beatDivisor);
availableDivisors = divisors;
tickSpacing = 1f / (availableDivisors.Length + 1);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, BindableBeatDivisor beatDivisor)
private void load(OsuColour colours)
{
this.beatDivisor.BindTo(beatDivisor);
InternalChild = marker = new EquilateralTriangle
{
Anchor = Anchor.BottomLeft,