Merge pull request #18687 from peppy/editor-repeat-behaviour-change-collapsing

Fix timing adjustment repeat buttons firing one change per repeat invocation
This commit is contained in:
Dan Balasescu 2022-06-14 20:24:13 +09:00 committed by GitHub
commit cc7943dfb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -23,6 +23,9 @@ public class RepeatingButtonBehaviour : Component
private Sample sample;
public Action RepeatBegan;
public Action RepeatEnded;
/// <summary>
/// An additive modifier for the frequency of the sample played on next actuation.
/// This can be adjusted during the button's <see cref="Drawable.OnClick"/> event to affect the repeat sample playback of that click.
@ -44,6 +47,7 @@ private void load(AudioManager audio)
protected override bool OnMouseDown(MouseDownEvent e)
{
RepeatBegan?.Invoke();
beginRepeat();
return true;
}
@ -51,6 +55,7 @@ protected override bool OnMouseDown(MouseDownEvent e)
protected override void OnMouseUp(MouseUpEvent e)
{
adjustDelegate?.Cancel();
RepeatEnded?.Invoke();
base.OnMouseUp(e);
}

View File

@ -44,6 +44,9 @@ public LocalisableString Text
[Resolved]
private OverlayColourProvider colourProvider { get; set; }
[Resolved]
private EditorBeatmap editorBeatmap { get; set; }
public TimingAdjustButton(double adjustAmount)
{
this.adjustAmount = adjustAmount;
@ -72,7 +75,11 @@ public TimingAdjustButton(double adjustAmount)
}
});
AddInternal(repeatBehaviour = new RepeatingButtonBehaviour(this));
AddInternal(repeatBehaviour = new RepeatingButtonBehaviour(this)
{
RepeatBegan = () => editorBeatmap.BeginChange(),
RepeatEnded = () => editorBeatmap.EndChange()
});
}
[BackgroundDependencyLoader]