diff --git a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs
index 905e433731..b176ecb148 100644
--- a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs
+++ b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs
@@ -8,13 +8,12 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
-using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
namespace osu.Game.Rulesets.Edit
{
///
- /// A blueprint placed above a adding editing functionality.
+ /// A blueprint placed above a displaying item adding editing functionality.
///
public abstract class SelectionBlueprint : CompositeDrawable, IStateful
{
@@ -86,7 +85,7 @@ namespace osu.Game.Rulesets.Edit
protected virtual void OnDeselected()
{
- // selection blueprints are AlwaysPresent while the related DrawableHitObject is visible
+ // selection blueprints are AlwaysPresent while the related item is visible
// set the body piece's alpha directly to avoid arbitrarily rendering frame buffers etc. of children.
foreach (var d in InternalChildren)
d.Hide();
diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
index 7f81629f80..c2ba627df4 100644
--- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
@@ -14,15 +14,13 @@ using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Edit;
-using osu.Game.Rulesets.Objects;
-using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Edit.Compose.Components
{
///
- /// A container which provides a "blueprint" display of hitobjects.
+ /// A container which provides a "blueprint" display of items.
/// Includes selection and manipulation support via a .
///
public abstract class BlueprintContainer : CompositeDrawable, IKeyBindingHandler
@@ -65,15 +63,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected virtual Container> CreateSelectionBlueprintContainer() => new Container> { RelativeSizeAxes = Axes.Both };
///
- /// Creates a which outlines s and handles movement of selections.
+ /// Creates a which outlines items and handles movement of selections.
///
protected abstract SelectionHandler CreateSelectionHandler();
///
- /// Creates a for a specific .
+ /// Creates a for a specific item.
///
- /// The to create the overlay for.
- protected virtual SelectionBlueprint CreateBlueprintFor(T hitObject) => null;
+ /// The item to create the overlay for.
+ protected virtual SelectionBlueprint CreateBlueprintFor(T item) => null;
protected virtual DragBox CreateDragBox(Action performSelect) => new DragBox(performSelect);
@@ -103,7 +101,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
ClickedBlueprint = SelectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered);
// Deselection should only occur if no selected blueprints are hovered
- // A special case for when a blueprint was selected via this click is added since OnClick() may occur outside the hitobject and should not trigger deselection
+ // A special case for when a blueprint was selected via this click is added since OnClick() may occur outside the item and should not trigger deselection
if (endClickSelection(e) || ClickedBlueprint != null)
return true;
@@ -237,7 +235,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
SelectionBlueprints.Add(blueprint);
- OnBlueprintAdded(blueprint);
+ if (SelectionHandler.SelectedItems.Contains(item))
+ blueprint.Select();
+
+ OnBlueprintAdded(blueprint.Item);
}
protected void RemoveBlueprintFor(T item)
@@ -254,22 +255,24 @@ namespace osu.Game.Screens.Edit.Compose.Components
if (movementBlueprints?.Contains(blueprint) == true)
finishSelectionMovement();
- OnBlueprintRemoved(blueprint);
+ OnBlueprintRemoved(blueprint.Item);
}
///
- /// Called after a blueprint has been added.
+ /// Called after an item's blueprint has been added.
///
- /// The for which the blueprint has been added.
- protected virtual void OnBlueprintAdded(SelectionBlueprint blueprint)
+ /// The item for which the blueprint has been added.
+ protected virtual void OnBlueprintAdded(T item)
{
+ if (SelectionHandler.SelectedItems.Contains(item))
+ blueprintMap[item].Select();
}
///
- /// Called after a blueprint has been removed.
+ /// Called after an item's blueprint has been removed.
///
- /// The for which the blueprint has been removed.
- protected virtual void OnBlueprintRemoved(SelectionBlueprint item)
+ /// The item for which the blueprint has been removed.
+ protected virtual void OnBlueprintRemoved(T item)
{
}
@@ -398,16 +401,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
if (!SelectionHandler.SelectedBlueprints.Any())
return;
- // Any selected blueprint that is hovered can begin the movement of the group, however only the earliest hitobject is used for movement
+ // Any selected blueprint that is hovered can begin the movement of the group, however only the first item (according to SortForMovement) is used for movement.
// A special case is added for when a click selection occurred before the drag
if (!clickSelectionBegan && !SelectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
return;
- // Movement is tracked from the blueprint of the earliest hitobject, since it only makes sense to distance snap from that hitobject
+ // Movement is tracked from the blueprint of the earliest item, since it only makes sense to distance snap from that item
movementBlueprints = SortForMovement(SelectionHandler.SelectedBlueprints).ToArray();
movementBlueprintOriginalPositions = movementBlueprints.Select(m => m.ScreenSpaceSelectionPoint).ToArray();
}
+ ///
+ /// Apply sorting of selected blueprints before performing movement. Generally used to surface the "main" item to the beginning of the collection.
+ ///
+ /// The blueprints to be moved.
+ /// Sorted blueprints.
protected virtual IEnumerable> SortForMovement(IReadOnlyList> blueprints) => blueprints;
///
@@ -442,7 +450,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
}
// if no positional snapping could be performed, try unrestricted snapping from the earliest
- // hitobject in the selection.
+ // item in the selection.
// The final movement position, relative to movementBlueprintOriginalPosition.
Vector2 movePosition = movementBlueprintOriginalPositions.First() + distanceTravelled;
diff --git a/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs
index f22404e77d..f8ac0552ae 100644
--- a/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs
@@ -239,9 +239,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
updatePlacementPosition();
}
- protected sealed override SelectionBlueprint CreateBlueprintFor(HitObject hitObject)
+ protected sealed override SelectionBlueprint CreateBlueprintFor(HitObject item)
{
- var drawable = Composer.HitObjects.FirstOrDefault(d => d.HitObject == hitObject);
+ var drawable = Composer.HitObjects.FirstOrDefault(d => d.HitObject == item);
if (drawable == null)
return null;
diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
index 52c148f852..8f2f1d65b8 100644
--- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
@@ -15,26 +15,27 @@ using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Edit;
-using osu.Game.Rulesets.Objects;
-using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Edit.Compose.Components
{
///
- /// A component which outlines s and handles movement of selections.
+ /// A component which outlines items and handles movement of selections.
///
public abstract class SelectionHandler : CompositeDrawable, IKeyBindingHandler
{
///
/// The currently selected blueprints.
/// Should be used when operations are dealing directly with the visible blueprints.
- /// For more general selection operations, use instead.
+ /// For more general selection operations, use instead.
///
public IReadOnlyList> SelectedBlueprints => selectedBlueprints;
- public BindableList SelectedItems = new BindableList();
+ ///
+ /// The currently selected items.
+ ///
+ public readonly BindableList SelectedItems = new BindableList();
private readonly List> selectedBlueprints;
@@ -124,45 +125,45 @@ namespace osu.Game.Screens.Edit.Compose.Components
#region User Input Handling
///
- /// Handles the selected s being moved.
+ /// Handles the selected items being moved.
///
///
- /// Just returning true is enough to allow updates to take place.
+ /// Just returning true is enough to allow default movement to take place.
/// Custom implementation is only required if other attributes are to be considered, like changing columns.
///
/// The move event.
///
- /// Whether any s could be moved.
+ /// Whether any items could be moved.
/// Returning true will also propagate StartTime changes provided by the closest .
///
public virtual bool HandleMovement(MoveSelectionEvent moveEvent) => false;
///
- /// Handles the selected s being rotated.
+ /// Handles the selected items being rotated.
///
/// The delta angle to apply to the selection.
- /// Whether any s could be rotated.
+ /// Whether any items could be rotated.
public virtual bool HandleRotation(float angle) => false;
///
- /// Handles the selected s being scaled.
+ /// Handles the selected items being scaled.
///
/// The delta scale to apply, in playfield local coordinates.
/// The point of reference where the scale is originating from.
- /// Whether any s could be scaled.
+ /// Whether any items could be scaled.
public virtual bool HandleScale(Vector2 scale, Anchor anchor) => false;
///
- /// Handles the selected s being flipped.
+ /// Handles the selected items being flipped.
///
/// The direction to flip
- /// Whether any s could be flipped.
+ /// Whether any items could be flipped.
public virtual bool HandleFlip(Direction direction) => false;
///
- /// Handles the selected s being reversed pattern-wise.
+ /// Handles the selected items being reversed pattern-wise.
///
- /// Whether any s could be reversed.
+ /// Whether any items could be reversed.
public virtual bool HandleReverse() => false;
public bool OnPressed(PlatformAction action)
@@ -196,7 +197,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// The blueprint.
internal virtual void HandleSelected(SelectionBlueprint blueprint)
{
- // there are potentially multiple SelectionHandlers active, but we only want to add hitobjects to the selected list once.
+ // there are potentially multiple SelectionHandlers active, but we only want to add items to the selected list once.
if (!SelectedItems.Contains(blueprint.Item))
SelectedItems.Add(blueprint.Item);
@@ -323,7 +324,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
if (selectedBlueprints.Count == 0)
return;
- // Move the rectangle to cover the hitobjects
+ // Move the rectangle to cover the items
var topLeft = new Vector2(float.MaxValue, float.MaxValue);
var bottomRight = new Vector2(float.MinValue, float.MinValue);
diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs
index 2bb80bc27b..7c1bbd65f9 100644
--- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs
@@ -179,9 +179,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
protected override SelectionHandler CreateSelectionHandler() => new TimelineSelectionHandler();
- protected override SelectionBlueprint CreateBlueprintFor(HitObject hitObject)
+ protected override SelectionBlueprint CreateBlueprintFor(HitObject item)
{
- return new TimelineHitObjectBlueprint(hitObject)
+ return new TimelineHitObjectBlueprint(item)
{
OnDragHandled = handleScrollViaDrag
};