|
|
@@ -6,7 +6,7 @@ using Drawie.Numerics;
|
|
|
|
|
|
namespace PixiEditor.ChangeableDocument.Changes.Selection.MagicWand;
|
|
|
|
|
|
-internal class MagicWand_Change : Change
|
|
|
+internal class MagicWand_UpdateableChange : UpdateableChange
|
|
|
{
|
|
|
private VectorPath? originalPath;
|
|
|
private VectorPath path = new() { FillType = PathFillType.EvenOdd };
|
|
|
@@ -16,8 +16,8 @@ internal class MagicWand_Change : Change
|
|
|
private int frame;
|
|
|
private double tolerance;
|
|
|
|
|
|
- [GenerateMakeChangeAction]
|
|
|
- public MagicWand_Change(List<Guid> memberGuids, VecI point, SelectionMode mode, double tolerance, int frame)
|
|
|
+ [GenerateUpdateableChangeActions]
|
|
|
+ public MagicWand_UpdateableChange(List<Guid> memberGuids, VecI point, SelectionMode mode, double tolerance, int frame)
|
|
|
{
|
|
|
path.MoveTo(point);
|
|
|
this.mode = mode;
|
|
|
@@ -33,7 +33,24 @@ internal class MagicWand_Change : Change
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ [UpdateChangeMethod]
|
|
|
+ public void Update(VecI point)
|
|
|
+ {
|
|
|
+ this.point = point;
|
|
|
+ }
|
|
|
+
|
|
|
public override OneOf<None, IChangeInfo, List<IChangeInfo>> Apply(Document target, bool firstApply, out bool ignoreInUndo)
|
|
|
+ {
|
|
|
+ ignoreInUndo = false;
|
|
|
+ return CommonApply(target);
|
|
|
+ }
|
|
|
+
|
|
|
+ public override OneOf<None, IChangeInfo, List<IChangeInfo>> ApplyTemporarily(Document target)
|
|
|
+ {
|
|
|
+ return CommonApply(target);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Selection_ChangeInfo CommonApply(Document target)
|
|
|
{
|
|
|
HashSet<Guid> membersToReference = new();
|
|
|
|
|
|
@@ -45,19 +62,6 @@ internal class MagicWand_Change : Change
|
|
|
|
|
|
path = MagicWandHelper.DoMagicWandFloodFill(point, membersToReference, tolerance, target, frame);
|
|
|
|
|
|
- ignoreInUndo = false;
|
|
|
- return CommonApply(target);
|
|
|
- }
|
|
|
-
|
|
|
- public override OneOf<None, IChangeInfo, List<IChangeInfo>> Revert(Document target)
|
|
|
- {
|
|
|
- (var toDispose, target.Selection.SelectionPath) = (target.Selection.SelectionPath, new VectorPath(originalPath!));
|
|
|
- toDispose.Dispose();
|
|
|
- return new Selection_ChangeInfo(new VectorPath(target.Selection.SelectionPath));
|
|
|
- }
|
|
|
-
|
|
|
- private Selection_ChangeInfo CommonApply(Document target)
|
|
|
- {
|
|
|
var toDispose = target.Selection.SelectionPath;
|
|
|
if (mode == SelectionMode.New)
|
|
|
{
|
|
|
@@ -67,13 +71,21 @@ internal class MagicWand_Change : Change
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- target.Selection.SelectionPath = originalPath!.Op(path, mode.ToVectorPathOp());
|
|
|
+ target.Selection.SelectionPath = target.Selection.SelectionPath!.Op(path, mode.ToVectorPathOp());
|
|
|
}
|
|
|
toDispose.Dispose();
|
|
|
|
|
|
return new Selection_ChangeInfo(new VectorPath(target.Selection.SelectionPath));
|
|
|
}
|
|
|
|
|
|
+ public override OneOf<None, IChangeInfo, List<IChangeInfo>> Revert(Document target)
|
|
|
+ {
|
|
|
+ var toDispose = target.Selection.SelectionPath;
|
|
|
+ target.Selection.SelectionPath = new VectorPath(originalPath!);
|
|
|
+ toDispose.Dispose();
|
|
|
+ return new Selection_ChangeInfo(new VectorPath(target.Selection.SelectionPath));
|
|
|
+ }
|
|
|
+
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
path.Dispose();
|