mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 16:03:01 +08:00
Add mouse down repeat support to timeline zoom buttons
This commit is contained in:
parent
c080ebcc50
commit
487dd47c9e
@ -6,10 +6,13 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||||
{
|
{
|
||||||
@ -52,6 +55,45 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
HoverColour = OsuColour.Gray(0.25f);
|
HoverColour = OsuColour.Gray(0.25f);
|
||||||
FlashColour = OsuColour.Gray(0.5f);
|
FlashColour = OsuColour.Gray(0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ScheduledDelegate repeatSchedule;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The initial delay before mouse down repeat begins.
|
||||||
|
/// </summary>
|
||||||
|
private const int repeat_initial_delay = 250;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The delay between mouse down repeats after the initial repeat.
|
||||||
|
/// </summary>
|
||||||
|
private const int repeat_tick_rate = 70;
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
// don't actuate a click since we are manually handling repeats.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
|
{
|
||||||
|
if (e.Button == MouseButton.Left)
|
||||||
|
{
|
||||||
|
Action clickAction = () => base.OnClick(new ClickEvent(e.CurrentState, e.Button));
|
||||||
|
|
||||||
|
// run once for initial down
|
||||||
|
clickAction();
|
||||||
|
|
||||||
|
Scheduler.Add(repeatSchedule = new ScheduledDelegate(clickAction, Clock.CurrentTime + repeat_initial_delay, repeat_tick_rate));
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnMouseDown(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnMouseUp(MouseUpEvent e)
|
||||||
|
{
|
||||||
|
repeatSchedule?.Cancel();
|
||||||
|
base.OnMouseUp(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user