mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 13:02:54 +08:00
Add support for dragging outside visible extents
This commit is contained in:
parent
477e1b7d27
commit
cb09c2e144
@ -18,6 +18,7 @@ using osuTK;
|
|||||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||||
{
|
{
|
||||||
[Cached(typeof(IDistanceSnapProvider))]
|
[Cached(typeof(IDistanceSnapProvider))]
|
||||||
|
[Cached]
|
||||||
public class Timeline : ZoomableScrollContainer, IDistanceSnapProvider
|
public class Timeline : ZoomableScrollContainer, IDistanceSnapProvider
|
||||||
{
|
{
|
||||||
public readonly Bindable<bool> WaveformVisible = new Bindable<bool>();
|
public readonly Bindable<bool> WaveformVisible = new Bindable<bool>();
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -20,6 +21,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
{
|
{
|
||||||
internal class TimelineBlueprintContainer : BlueprintContainer
|
internal class TimelineBlueprintContainer : BlueprintContainer
|
||||||
{
|
{
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private Timeline timeline { get; set; }
|
||||||
|
|
||||||
private DragEvent lastDragEvent;
|
private DragEvent lastDragEvent;
|
||||||
|
|
||||||
public TimelineBlueprintContainer(EditorBeatmap beatmap)
|
public TimelineBlueprintContainer(EditorBeatmap beatmap)
|
||||||
@ -48,6 +52,18 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
protected override bool OnDrag(DragEvent e)
|
protected override bool OnDrag(DragEvent e)
|
||||||
{
|
{
|
||||||
|
if (timeline != null)
|
||||||
|
{
|
||||||
|
var timelineQuad = timeline.ScreenSpaceDrawQuad;
|
||||||
|
var mouseX = e.ScreenSpaceMousePosition.X;
|
||||||
|
|
||||||
|
// scroll if in a drag and dragging outside visible extents
|
||||||
|
if (mouseX > timelineQuad.TopRight.X)
|
||||||
|
timeline.ScrollBy((float)((mouseX - timelineQuad.TopRight.X) / 10 * Clock.ElapsedFrameTime));
|
||||||
|
else if (mouseX < timelineQuad.TopLeft.X)
|
||||||
|
timeline.ScrollBy((float)((mouseX - timelineQuad.TopLeft.X) / 10 * Clock.ElapsedFrameTime));
|
||||||
|
}
|
||||||
|
|
||||||
lastDragEvent = e;
|
lastDragEvent = e;
|
||||||
return base.OnDrag(e);
|
return base.OnDrag(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user