1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 00:47:26 +08:00
osu-lazer/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineDragBox.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.3 KiB
C#
Raw Normal View History

// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{
public partial class TimelineDragBox : DragBox
{
2022-10-05 21:04:43 +08:00
public double MinTime { get; private set; }
2022-10-05 21:04:43 +08:00
public double MaxTime { get; private set; }
private double? startTime;
[Resolved]
private Timeline timeline { get; set; }
protected override Drawable CreateBox() => new Box
{
RelativeSizeAxes = Axes.Y,
Alpha = 0.3f
};
public override void HandleDrag(MouseButtonEvent e)
{
startTime ??= timeline.TimeAtPosition(e.MouseDownPosition.X);
2022-10-05 21:04:43 +08:00
double endTime = timeline.TimeAtPosition(e.MousePosition.X);
MinTime = Math.Min(startTime.Value, endTime);
MaxTime = Math.Max(startTime.Value, endTime);
Box.X = timeline.PositionAtTime(MinTime);
Box.Width = timeline.PositionAtTime(MaxTime) - Box.X;
}
public override void Hide()
{
base.Hide();
startTime = null;
}
}
}