Bläddra i källkod

Fixed copy pasting multiple layers

Krzysztof Krysiński 5 månader sedan
förälder
incheckning
af92d81972
1 ändrade filer med 13 tillägg och 3 borttagningar
  1. 13 3
      src/PixiEditor/Models/Controllers/ClipboardController.cs

+ 13 - 3
src/PixiEditor/Models/Controllers/ClipboardController.cs

@@ -262,16 +262,26 @@ internal static class ClipboardController
             pos = dataObjectWithPos.GetVecD(ClipboardDataFormats.PositionFormat);
         }
 
+        RectD? tightBounds = null;
         for (var i = 0; i < layerIds.Length; i++)
         {
             var layerId = layerIds[i];
 
             var layer = doc.StructureHelper.Find(layerId);
-            if (layer is not { TightBounds: not null } || !layer.TightBounds.Value.Pos.AlmostEquals(pos))
-                return false;
+
+            if(layer == null) return false;
+
+            if(tightBounds == null)
+            {
+                tightBounds = layer.TightBounds;
+            }
+            else if(layer.TightBounds.HasValue)
+            {
+                tightBounds = tightBounds.Value.Union(layer.TightBounds.Value);
+            }
         }
 
-        return true;
+        return tightBounds.HasValue && tightBounds.Value.Pos.AlmostEquals(pos);
     }
 
     private static Guid[] GetLayerIds(IEnumerable<IDataObject> data)