Browse Source

Fixed pasting vectors and transform corners wip

Krzysztof Krysiński 1 month ago
parent
commit
a709779b69

+ 2 - 2
src/PixiEditor/Models/Controllers/ClipboardController.cs

@@ -331,11 +331,11 @@ internal static class ClipboardController
 
 
             if (tightBounds == null)
             if (tightBounds == null)
             {
             {
-                tightBounds = layer.TightBounds;
+                tightBounds = layer.TransformationCorners.AABBBounds;
             }
             }
             else if (layer.TightBounds.HasValue)
             else if (layer.TightBounds.HasValue)
             {
             {
-                tightBounds = tightBounds.Value.Union(layer.TightBounds.Value);
+                tightBounds = tightBounds.Value.Union(layer.TransformationCorners.AABBBounds);
             }
             }
         }
         }
 
 

+ 15 - 17
src/PixiEditor/ViewModels/SubViewModels/ClipboardViewModel.cs

@@ -99,26 +99,23 @@ internal class ClipboardViewModel : SubViewModel<ViewModelMain>
             Guid[] guids = doc.StructureHelper.GetAllLayers().Select(x => x.Id).ToArray();
             Guid[] guids = doc.StructureHelper.GetAllLayers().Select(x => x.Id).ToArray();
             await ClipboardController.TryPasteFromClipboard(doc, Owner.DocumentManagerSubViewModel, pasteAsNewLayer);
             await ClipboardController.TryPasteFromClipboard(doc, Owner.DocumentManagerSubViewModel, pasteAsNewLayer);
 
 
-            // Leaving the code below commented out in case something breaks.
-            // It instantly ended paste image operation after I made it interruptable,
-            // I did test it, and it seems everything works fine without it.
-            /*doc.Operations.InvokeCustomAction(
+            doc.Operations.InvokeCustomAction(
                 () =>
                 () =>
-            {
-                Guid[] newGuids = doc.StructureHelper.GetAllLayers().Select(x => x.Id).ToArray();
-
-                var diff = newGuids.Except(guids).ToArray();
-                if (diff.Length > 0)
                 {
                 {
-                    doc.Operations.ClearSoftSelectedMembers();
-                    doc.Operations.SetSelectedMember(diff[0]);
+                    Guid[] newGuids = doc.StructureHelper.GetAllLayers().Select(x => x.Id).ToArray();
 
 
-                    for (int i = 1; i < diff.Length; i++)
+                    var diff = newGuids.Except(guids).ToArray();
+                    if (diff.Length > 0)
                     {
                     {
-                        doc.Operations.AddSoftSelectedMember(diff[i]);
+                        doc.Operations.ClearSoftSelectedMembers();
+                        doc.Operations.SetSelectedMember(diff[0]);
+
+                        for (int i = 1; i < diff.Length; i++)
+                        {
+                            doc.Operations.AddSoftSelectedMember(diff[i]);
+                        }
                     }
                     }
-                }
-            }, false);*/
+                }, false);
         });
         });
     }
     }
 
 
@@ -398,7 +395,7 @@ internal class ClipboardViewModel : SubViewModel<ViewModelMain>
         var selectedNodes = doc.NodeGraph.AllNodes.Where(x => x.IsNodeSelected).Select(x => x.Id).ToArray();
         var selectedNodes = doc.NodeGraph.AllNodes.Where(x => x.IsNodeSelected).Select(x => x.Id).ToArray();
         if (selectedNodes.Length == 0)
         if (selectedNodes.Length == 0)
             return;
             return;
-        
+
         await ClipboardController.CopyNodes(selectedNodes, doc.Id);
         await ClipboardController.CopyNodes(selectedNodes, doc.Id);
 
 
         areNodesInClipboard = true;
         areNodesInClipboard = true;
@@ -583,7 +580,8 @@ internal class ClipboardViewModel : SubViewModel<ViewModelMain>
         return ColorSearchResult.GetIcon(targetColor.ToOpaqueMediaColor().ToOpaqueColor());
         return ColorSearchResult.GetIcon(targetColor.ToOpaqueMediaColor().ToOpaqueColor());
     }
     }
 
 
-    private void ConnectRelatedNodes(IDocument sourceDoc, DocumentViewModel targetDoc, Dictionary<Guid, Guid> nodeMapping)
+    private void ConnectRelatedNodes(IDocument sourceDoc, DocumentViewModel targetDoc,
+        Dictionary<Guid, Guid> nodeMapping)
     {
     {
         foreach (var connection in sourceDoc.NodeGraphHandler.Connections)
         foreach (var connection in sourceDoc.NodeGraphHandler.Connections)
         {
         {