|
@@ -14,15 +14,18 @@ internal class PreviewShiftLayers_UpdateableChange : InterruptableUpdateableChan
|
|
private List<Guid> layerGuids;
|
|
private List<Guid> layerGuids;
|
|
private VecD delta;
|
|
private VecD delta;
|
|
private Dictionary<Guid, ShapeVectorData> originalShapes;
|
|
private Dictionary<Guid, ShapeVectorData> originalShapes;
|
|
|
|
+ private RectD? clipRect;
|
|
|
|
+ private VectorPath? clipPath;
|
|
|
|
|
|
private int frame;
|
|
private int frame;
|
|
|
|
|
|
[GenerateUpdateableChangeActions]
|
|
[GenerateUpdateableChangeActions]
|
|
- public PreviewShiftLayers_UpdateableChange(List<Guid> layerGuids, VecD delta, int frame)
|
|
|
|
|
|
+ public PreviewShiftLayers_UpdateableChange(List<Guid> layerGuids, RectD clipRect, VecD delta, int frame)
|
|
{
|
|
{
|
|
this.delta = delta;
|
|
this.delta = delta;
|
|
this.layerGuids = layerGuids;
|
|
this.layerGuids = layerGuids;
|
|
this.frame = frame;
|
|
this.frame = frame;
|
|
|
|
+ this.clipRect = clipRect.IsZeroOrNegativeArea ? null : clipRect;
|
|
}
|
|
}
|
|
|
|
|
|
public override bool InitializeAndValidate(Document target)
|
|
public override bool InitializeAndValidate(Document target)
|
|
@@ -50,6 +53,14 @@ internal class PreviewShiftLayers_UpdateableChange : InterruptableUpdateableChan
|
|
originalShapes[layerGuid] = transformableObject.EmbeddedShapeData;
|
|
originalShapes[layerGuid] = transformableObject.EmbeddedShapeData;
|
|
transformableObject.EmbeddedShapeData = null;
|
|
transformableObject.EmbeddedShapeData = null;
|
|
}
|
|
}
|
|
|
|
+ else if (layer is ImageLayerNode imgLayer)
|
|
|
|
+ {
|
|
|
|
+ var image = imgLayer.GetLayerImageAtFrame(frame);
|
|
|
|
+ if (image is null)
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return true;
|
|
return true;
|
|
@@ -68,16 +79,25 @@ internal class PreviewShiftLayers_UpdateableChange : InterruptableUpdateableChan
|
|
{
|
|
{
|
|
var layer = target.FindMemberOrThrow<LayerNode>(layerGuid);
|
|
var layer = target.FindMemberOrThrow<LayerNode>(layerGuid);
|
|
|
|
|
|
- if (layer is ImageLayerNode)
|
|
|
|
|
|
+ if (layer is ImageLayerNode imgNode)
|
|
{
|
|
{
|
|
- var area = ShiftLayerHelper.DrawShiftedLayer(target, layerGuid, true, (VecI)delta, frame);
|
|
|
|
|
|
+ if (clipRect.HasValue)
|
|
|
|
+ {
|
|
|
|
+ clipPath?.Dispose();
|
|
|
|
+ clipPath = new VectorPath();
|
|
|
|
+ clipPath.AddRect(clipRect.Value);
|
|
|
|
+ clipPath.Offset((VecI)delta);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var area = ShiftLayerHelper.DrawShiftedLayer(target, layerGuid, true, (VecI)delta, frame, clipPath);
|
|
|
|
+
|
|
changes.Add(new LayerImageArea_ChangeInfo(layerGuid, area));
|
|
changes.Add(new LayerImageArea_ChangeInfo(layerGuid, area));
|
|
}
|
|
}
|
|
else if (layer is VectorLayerNode vectorLayer)
|
|
else if (layer is VectorLayerNode vectorLayer)
|
|
{
|
|
{
|
|
StrokeJoin join = StrokeJoin.Miter;
|
|
StrokeJoin join = StrokeJoin.Miter;
|
|
StrokeCap cap = StrokeCap.Butt;
|
|
StrokeCap cap = StrokeCap.Butt;
|
|
-
|
|
|
|
|
|
+
|
|
(vectorLayer.EmbeddedShapeData as PathVectorData)?.Path.Dispose();
|
|
(vectorLayer.EmbeddedShapeData as PathVectorData)?.Path.Dispose();
|
|
|
|
|
|
var originalShape = originalShapes[layerGuid];
|
|
var originalShape = originalShapes[layerGuid];
|
|
@@ -90,8 +110,9 @@ internal class PreviewShiftLayers_UpdateableChange : InterruptableUpdateableChan
|
|
cap = shape.StrokeLineCap;
|
|
cap = shape.StrokeLineCap;
|
|
}
|
|
}
|
|
|
|
|
|
- VecD mappedDelta = originalShape.TransformationMatrix.Invert().MapVector((float)delta.X, (float)delta.Y);
|
|
|
|
-
|
|
|
|
|
|
+ VecD mappedDelta = originalShape.TransformationMatrix.Invert()
|
|
|
|
+ .MapVector((float)delta.X, (float)delta.Y);
|
|
|
|
+
|
|
var finalMatrix = Matrix3X3.CreateTranslation((float)mappedDelta.X, (float)mappedDelta.Y);
|
|
var finalMatrix = Matrix3X3.CreateTranslation((float)mappedDelta.X, (float)mappedDelta.Y);
|
|
|
|
|
|
path.AddPath(path, finalMatrix, AddPathMode.Append);
|
|
path.AddPath(path, finalMatrix, AddPathMode.Append);
|
|
@@ -106,9 +127,10 @@ internal class PreviewShiftLayers_UpdateableChange : InterruptableUpdateableChan
|
|
StrokeLineJoin = join,
|
|
StrokeLineJoin = join,
|
|
StrokeLineCap = cap
|
|
StrokeLineCap = cap
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
vectorLayer.EmbeddedShapeData = newShapeData;
|
|
vectorLayer.EmbeddedShapeData = newShapeData;
|
|
- changes.Add(new VectorShape_ChangeInfo(layerGuid, ShiftLayer_UpdateableChange.AffectedAreaFromBounds(target, layerGuid, frame)));
|
|
|
|
|
|
+ changes.Add(new VectorShape_ChangeInfo(layerGuid,
|
|
|
|
+ ShiftLayer_UpdateableChange.AffectedAreaFromBounds(target, layerGuid, frame)));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -139,6 +161,7 @@ internal class PreviewShiftLayers_UpdateableChange : InterruptableUpdateableChan
|
|
var image = imgLayer.GetLayerImageAtFrame(frame);
|
|
var image = imgLayer.GetLayerImageAtFrame(frame);
|
|
var affected = image.FindAffectedArea();
|
|
var affected = image.FindAffectedArea();
|
|
image.CancelChanges();
|
|
image.CancelChanges();
|
|
|
|
+ image.SetClippingPath(null);
|
|
changes.Add(new LayerImageArea_ChangeInfo(layerGuid, affected));
|
|
changes.Add(new LayerImageArea_ChangeInfo(layerGuid, affected));
|
|
}
|
|
}
|
|
else if (layer is VectorLayerNode transformableObject)
|
|
else if (layer is VectorLayerNode transformableObject)
|
|
@@ -150,4 +173,10 @@ internal class PreviewShiftLayers_UpdateableChange : InterruptableUpdateableChan
|
|
|
|
|
|
return changes;
|
|
return changes;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public override void Dispose()
|
|
|
|
+ {
|
|
|
|
+ base.Dispose();
|
|
|
|
+ clipPath?.Dispose();
|
|
|
|
+ }
|
|
}
|
|
}
|