1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:17:51 +08:00

Reduce sample point pieces to pink dot if zoomed out

This commit is contained in:
OliBomby 2024-09-19 16:20:26 +02:00
parent e4cfa7c86f
commit 34087a0f1a
2 changed files with 33 additions and 1 deletions

View File

@ -17,6 +17,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{ {
protected OsuSpriteText Label { get; private set; } protected OsuSpriteText Label { get; private set; }
protected Container LabelContainer { get; private set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
@ -26,7 +28,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new Container LabelContainer = new Container
{ {
AutoSizeAxes = Axes.X, AutoSizeAxes = Axes.X,
Height = 16, Height = 16,

View File

@ -41,6 +41,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
[Resolved] [Resolved]
private Editor? editor { get; set; } private Editor? editor { get; set; }
[Resolved]
private Timeline? timeline { get; set; }
private Bindable<bool> samplesVisible = null!; private Bindable<bool> samplesVisible = null!;
public SamplePointPiece(HitObject hitObject) public SamplePointPiece(HitObject hitObject)
@ -59,6 +62,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private void load(OsuConfigManager config) private void load(OsuConfigManager config)
{ {
HitObject.DefaultsApplied += _ => updateText(); HitObject.DefaultsApplied += _ => updateText();
Label.AllowMultiline = false;
LabelContainer.AutoSizeAxes = Axes.None;
updateText(); updateText();
if (editor != null) if (editor != null)
@ -75,6 +80,30 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
this.FadeTo(samplesVisible.Value ? 1 : 0); this.FadeTo(samplesVisible.Value ? 1 : 0);
} }
private float lastZoom;
private const float zoom_threshold = 40f;
protected override void Update()
{
base.Update();
// Retract visual state if the timeline is zoomed out too far.
if (timeline is null || timeline.Zoom == lastZoom) return;
lastZoom = timeline.Zoom;
if (timeline.Zoom < zoom_threshold)
{
Label.FadeOut(200, Easing.OutQuint);
LabelContainer.ResizeWidthTo(16, 200, Easing.OutQuint);
}
else
{
Label.FadeIn(200, Easing.OutQuint);
LabelContainer.ResizeWidthTo(Label.Width, 200, Easing.OutQuint);
}
}
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
@ -100,6 +129,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private void updateText() private void updateText()
{ {
Label.Text = $"{abbreviateBank(GetBankValue(GetSamples()))} {GetVolumeValue(GetSamples())}"; Label.Text = $"{abbreviateBank(GetBankValue(GetSamples()))} {GetVolumeValue(GetSamples())}";
LabelContainer.ResizeWidthTo(Label.Width, 200, Easing.OutQuint);
} }
private static string? abbreviateBank(string? bank) private static string? abbreviateBank(string? bank)