From b0df787b1addc5b36f616e2ee19bb1fbb538ce04 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Dec 2021 14:13:36 +0900 Subject: [PATCH] Move public method up and add xmldoc to second public method --- .../Components/PathControlPointVisualiser.cs | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs index b72e2d786b..065d4737a5 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs @@ -69,6 +69,39 @@ protected override void LoadComplete() controlPoints.BindTo(slider.Path.ControlPoints); } + /// + /// Selects the corresponding to the given , + /// and deselects all other s. + /// + public void SetSelectionTo(PathControlPoint pathControlPoint) + { + foreach (var p in Pieces) + p.IsSelected.Value = p.ControlPoint == pathControlPoint; + } + + /// + /// Delete all visually selected s. + /// + /// + public bool DeleteSelected() + { + List toRemove = Pieces.Where(p => p.IsSelected.Value).Select(p => p.ControlPoint).ToList(); + + // Ensure that there are any points to be deleted + if (toRemove.Count == 0) + return false; + + changeHandler?.BeginChange(); + RemoveControlPointsRequested?.Invoke(toRemove); + changeHandler?.EndChange(); + + // Since pieces are re-used, they will not point to the deleted control points while remaining selected + foreach (var piece in Pieces) + piece.IsSelected.Value = false; + + return true; + } + private void onControlPointsChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) @@ -162,16 +195,6 @@ private void selectionRequested(PathControlPointPiece piece, MouseButtonEvent e) SetSelectionTo(piece.ControlPoint); } - /// - /// Selects the corresponding to the given , - /// and deselects all other s. - /// - public void SetSelectionTo(PathControlPoint pathControlPoint) - { - foreach (var p in Pieces) - p.IsSelected.Value = p.ControlPoint == pathControlPoint; - } - /// /// Attempts to set the given control point piece to the given path type. /// If that would fail, try to change the path such that it instead succeeds @@ -203,25 +226,6 @@ private void updatePathType(PathControlPointPiece piece, PathType? type) [Resolved(CanBeNull = true)] private IEditorChangeHandler changeHandler { get; set; } - public bool DeleteSelected() - { - List toRemove = Pieces.Where(p => p.IsSelected.Value).Select(p => p.ControlPoint).ToList(); - - // Ensure that there are any points to be deleted - if (toRemove.Count == 0) - return false; - - changeHandler?.BeginChange(); - RemoveControlPointsRequested?.Invoke(toRemove); - changeHandler?.EndChange(); - - // Since pieces are re-used, they will not point to the deleted control points while remaining selected - foreach (var piece in Pieces) - piece.IsSelected.Value = false; - - return true; - } - #region Drag handling private Vector2[] dragStartPositions;