mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 22:06:08 +08:00
Allow scrolling via drag while dragging a hold note handle
This commit is contained in:
parent
cef45afbc8
commit
3d42973764
@ -49,20 +49,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
protected override void OnDrag(DragEvent e)
|
protected override void OnDrag(DragEvent e)
|
||||||
{
|
{
|
||||||
if (timeline != null)
|
handleScrollViaDrag(e);
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnDrag(e);
|
base.OnDrag(e);
|
||||||
lastDragEvent = e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDragEnd(DragEndEvent e)
|
protected override void OnDragEnd(DragEndEvent e)
|
||||||
@ -74,7 +63,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
// trigger every frame so drags continue to update selection while playback is scrolling the timeline.
|
// trigger every frame so drags continue to update selection while playback is scrolling the timeline.
|
||||||
if (IsDragged)
|
if (lastDragEvent != null)
|
||||||
OnDrag(lastDragEvent);
|
OnDrag(lastDragEvent);
|
||||||
|
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -82,10 +71,33 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
protected override SelectionHandler CreateSelectionHandler() => new TimelineSelectionHandler();
|
protected override SelectionHandler CreateSelectionHandler() => new TimelineSelectionHandler();
|
||||||
|
|
||||||
protected override SelectionBlueprint CreateBlueprintFor(HitObject hitObject) => new TimelineHitObjectBlueprint(hitObject);
|
protected override SelectionBlueprint CreateBlueprintFor(HitObject hitObject) => new TimelineHitObjectBlueprint(hitObject)
|
||||||
|
{
|
||||||
|
OnDragHandled = handleScrollViaDrag
|
||||||
|
};
|
||||||
|
|
||||||
protected override DragBox CreateDragBox(Action<RectangleF> performSelect) => new TimelineDragBox(performSelect);
|
protected override DragBox CreateDragBox(Action<RectangleF> performSelect) => new TimelineDragBox(performSelect);
|
||||||
|
|
||||||
|
private void handleScrollViaDrag(DragEvent e)
|
||||||
|
{
|
||||||
|
lastDragEvent = e;
|
||||||
|
|
||||||
|
if (lastDragEvent == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal class TimelineSelectionHandler : SelectionHandler
|
internal class TimelineSelectionHandler : SelectionHandler
|
||||||
{
|
{
|
||||||
// for now we always allow movement. snapping is provided by the Timeline's "distance" snap implementation
|
// for now we always allow movement. snapping is provided by the Timeline's "distance" snap implementation
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -28,6 +29,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
private readonly Bindable<double> startTime;
|
private readonly Bindable<double> startTime;
|
||||||
|
|
||||||
|
public Action<DragEvent> OnDragHandled;
|
||||||
|
|
||||||
public const float THICKNESS = 5;
|
public const float THICKNESS = 5;
|
||||||
|
|
||||||
private const float circle_size = 16;
|
private const float circle_size = 16;
|
||||||
@ -78,7 +81,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new DragBar(hitObject),
|
new DragBar(hitObject) { OnDragHandled = e => OnDragHandled?.Invoke(e) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,6 +93,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private Timeline timeline { get; set; }
|
private Timeline timeline { get; set; }
|
||||||
|
|
||||||
|
public Action<DragEvent> OnDragHandled;
|
||||||
|
|
||||||
public DragBar(HitObject hitObject)
|
public DragBar(HitObject hitObject)
|
||||||
{
|
{
|
||||||
this.hitObject = hitObject;
|
this.hitObject = hitObject;
|
||||||
@ -155,6 +160,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
{
|
{
|
||||||
base.OnDrag(e);
|
base.OnDrag(e);
|
||||||
|
|
||||||
|
OnDragHandled?.Invoke(e);
|
||||||
|
|
||||||
var time = timeline.GetTimeFromScreenSpacePosition(e.ScreenSpaceMousePosition);
|
var time = timeline.GetTimeFromScreenSpacePosition(e.ScreenSpaceMousePosition);
|
||||||
|
|
||||||
switch (hitObject)
|
switch (hitObject)
|
||||||
@ -177,6 +184,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
beatmap.UpdateHitObject(hitObject);
|
beatmap.UpdateHitObject(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnDragEnd(DragEndEvent e)
|
||||||
|
{
|
||||||
|
base.OnDragEnd(e);
|
||||||
|
|
||||||
|
OnDragHandled?.Invoke(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
Loading…
Reference in New Issue
Block a user