Skip to content

Commit

Permalink
Fix quick-deleting unselected slider path control point also deleting…
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Dec 30, 2024
1 parent aa67f87 commit 182f998
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,34 @@ public void SetSelectionTo(PathControlPoint pathControlPoint)
/// <summary>
/// Delete all visually selected <see cref="PathControlPoint"/>s.
/// </summary>
/// <returns></returns>
/// <returns>Whether any change actually took place.</returns>
public bool DeleteSelected()
{
List<PathControlPoint> toRemove = Pieces.Where(p => p.IsSelected.Value).Select(p => p.ControlPoint).ToList();

if (!Delete(toRemove))
return false;

// 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;
}

/// <summary>
/// Delete the specified <see cref="PathControlPoint"/>s.
/// </summary>
/// <returns>Whether any change actually took place.</returns>
public bool Delete(List<PathControlPoint> toRemove)
{
// 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ public override bool HandleQuickDeletion()
if (hoveredControlPoint == null)
return false;

hoveredControlPoint.IsSelected.Value = true;
ControlPointVisualiser?.DeleteSelected();
if (hoveredControlPoint.IsSelected.Value)
ControlPointVisualiser?.DeleteSelected();
else
ControlPointVisualiser?.Delete([hoveredControlPoint.ControlPoint]);

return true;
}

Expand Down

0 comments on commit 182f998

Please sign in to comment.