2020-10-01 17:07:39 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|
|
|
{
|
|
|
|
public class TimingPointPiece : CompositeDrawable
|
|
|
|
{
|
2020-10-01 18:29:34 +08:00
|
|
|
private readonly TimingControlPoint point;
|
|
|
|
|
2020-10-01 17:07:39 +08:00
|
|
|
private readonly BindableNumber<double> beatLength;
|
|
|
|
private OsuSpriteText bpmText;
|
|
|
|
|
|
|
|
public TimingPointPiece(TimingControlPoint point)
|
|
|
|
{
|
2020-10-01 18:29:34 +08:00
|
|
|
this.point = point;
|
2020-10-01 17:07:39 +08:00
|
|
|
beatLength = point.BeatLengthBindable.GetBoundCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
2021-04-14 18:39:27 +08:00
|
|
|
Margin = new MarginPadding { Vertical = 10 };
|
2020-10-01 17:07:39 +08:00
|
|
|
|
2021-04-14 18:39:27 +08:00
|
|
|
const float corner_radius = 5;
|
2020-10-01 17:07:39 +08:00
|
|
|
|
2021-04-14 18:39:27 +08:00
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
Masking = true;
|
|
|
|
CornerRadius = corner_radius;
|
2020-10-01 18:29:34 +08:00
|
|
|
|
2020-10-01 17:07:39 +08:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
2021-04-14 18:39:27 +08:00
|
|
|
Colour = point.GetRepresentingColour(colours),
|
2020-10-01 17:07:39 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
bpmText = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Alpha = 0.9f,
|
2021-04-14 18:39:27 +08:00
|
|
|
Padding = new MarginPadding { Vertical = 3, Horizontal = 6 },
|
|
|
|
Font = OsuFont.Default.With(size: 20, weight: FontWeight.SemiBold),
|
|
|
|
Colour = colours.B5,
|
2020-10-01 17:07:39 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
beatLength.BindValueChanged(beatLength =>
|
|
|
|
{
|
|
|
|
bpmText.Text = $"{60000 / beatLength.NewValue:n1} BPM";
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|