Browse Source

Fixed LayerStructure cloning

flabbet 4 years ago
parent
commit
a9d8cc953b

+ 4 - 3
PixiEditor/Models/Layers/GuidStructureItem.cs

@@ -109,9 +109,9 @@ namespace PixiEditor.Models.Layers
 
         public GuidStructureItem CloneGroup()
         {
-            GuidStructureItem item = new(Name, StartLayerGuid, EndLayerGuid, Array.Empty<GuidStructureItem>(), Parent?.CloneGroup())
+            GuidStructureItem item = new(Name, StartLayerGuid, EndLayerGuid, Array.Empty<GuidStructureItem>(), null)
             {
-                GroupGuid = GroupGuid,
+                GroupGuid = this.GroupGuid,
                 IsExpanded = isExpanded,
                 IsRenaming = isRenaming
             };
@@ -121,7 +121,8 @@ namespace PixiEditor.Models.Layers
                 item.Subgroups = new ObservableCollection<GuidStructureItem>();
                 for (int i = 0; i < Subgroups.Count; i++)
                 {
-                    item.Subgroups.Add(item.CloneGroup());
+                    item.Subgroups.Add(Subgroups[i].CloneGroup());
+                    item.Subgroups[^1].Parent = item;
                 }
             }
 

+ 3 - 3
PixiEditor/Models/Layers/LayerStructure.cs

@@ -377,11 +377,11 @@ namespace PixiEditor.Models.Layers
             LayerStructureChanged?.Invoke(this, EventArgs.Empty);
         }
 
-        public List<Guid> GetLayersInOrder(GroupData folder)
+        public List<Guid> GetLayersInOrder(GroupData group)
         {
             List<Guid> layerGuids = new();
-            int minIndex = folder.BottomIndex;
-            int maxIndex = folder.TopIndex;
+            int minIndex = group.BottomIndex;
+            int maxIndex = group.TopIndex;
 
             for (int i = minIndex; i <= maxIndex; i++)
             {