From c4395b1cea45b242e2f19816a92b9aa4df2c727a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 Jan 2020 15:42:49 +0900 Subject: [PATCH] Clean up nested class implementations --- .../Timeline/TimelineHitObjectDisplay.cs | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectDisplay.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectDisplay.cs index b09c1a5597..397c74b193 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectDisplay.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectDisplay.cs @@ -36,33 +36,32 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline protected override SelectionBlueprintContainer CreateSelectionBlueprintContainer() => new TimelineSelectionBlueprintContainer { RelativeSizeAxes = Axes.Both }; - protected class TimelineSelectionBlueprintContainer : SelectionBlueprintContainer - { - protected override Container Content { get; } - - public TimelineSelectionBlueprintContainer() - { - AddInternal(new TimelinePart(Content = new Container { RelativeSizeAxes = Axes.Both }) { RelativeSizeAxes = Axes.Both }); - } - } - protected override void LoadComplete() { base.LoadComplete(); DragBox.Alpha = 0; } - protected override SelectionBlueprint CreateBlueprintFor(HitObject hitObject) + protected override bool OnDrag(DragEvent e) { - //var yOffset = content.Count(d => d.X == h.StartTime); - //var yOffset = 0; - - return new TimelineHitObjectRepresentation(hitObject); + lastDragEvent = e; + return base.OnDrag(e); } + protected override void Update() + { + if (IsDragged && lastDragEvent != null) + // trigger every frame so drags continue to update selection while playback is scrolling the timeline. + DragBox.UpdateDrag(lastDragEvent); + + base.Update(); + } + + protected override SelectionBlueprint CreateBlueprintFor(HitObject hitObject) => new TimelineHitObjectRepresentation(hitObject); + protected override DragBox CreateDragBox(Action performSelect) => new CustomDragBox(performSelect); - internal class CustomDragBox : DragBox + private class CustomDragBox : DragBox { public CustomDragBox(Action performSelect) : base(performSelect) @@ -88,11 +87,21 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline } } + protected class TimelineSelectionBlueprintContainer : SelectionBlueprintContainer + { + protected override Container Content { get; } + + public TimelineSelectionBlueprintContainer() + { + AddInternal(new TimelinePart(Content = new Container { RelativeSizeAxes = Axes.Both }) { RelativeSizeAxes = Axes.Both }); + } + } + private class TimelineHitObjectRepresentation : SelectionBlueprint { private readonly Circle circle; - private Container extensionBar; + private readonly Container extensionBar; public const float THICKNESS = 3;