// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Game.Rulesets.Edit; using osuTK; namespace osu.Game.Screens.Edit.Compose.Components { /// /// An event which occurs when a is dragged. /// public class SelectionDragEvent { /// /// The dragged . /// public readonly SelectionBlueprint DraggedBlueprint; /// /// The screen-space position of the hitobject at the start of the drag. /// public readonly Vector2 ScreenSpaceDragStartPosition; /// /// The new screen-space position of the hitobject at the current drag point. /// public readonly Vector2 ScreenSpaceDragPosition; /// /// The distance between and the hitobject's current position, in the coordinate-space of the hitobject's parent. /// /// /// This does not use and does not represent the cumulative drag distance. /// public readonly Vector2 InstantDragDelta; public SelectionDragEvent(SelectionBlueprint blueprint, Vector2 screenSpaceDragStartPosition, Vector2 screenSpaceDragPosition) { DraggedBlueprint = blueprint; ScreenSpaceDragStartPosition = screenSpaceDragStartPosition; ScreenSpaceDragPosition = screenSpaceDragPosition; InstantDragDelta = toLocalSpace(ScreenSpaceDragPosition) - DraggedBlueprint.HitObject.Position; } /// /// Converts a screen-space position into the coordinate space of the hitobject's parents. /// /// The screen-space position. /// The position in the coordinate space of the hitobject's parent. private Vector2 toLocalSpace(Vector2 screenSpacePosition) => DraggedBlueprint.HitObject.Parent.ToLocalSpace(screenSpacePosition); } }