|
@@ -64,7 +64,8 @@ internal static class ClipboardController
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
public static async Task CopyToClipboard(DocumentViewModel document, RectD? lastTransform)
|
|
public static async Task CopyToClipboard(DocumentViewModel document, RectD? lastTransform)
|
|
|
{
|
|
{
|
|
|
- await Clipboard.ClearAsync();
|
|
|
|
|
|
|
+ // This breaks often on X11 and macos
|
|
|
|
|
+ //await Clipboard.ClearAsync();
|
|
|
|
|
|
|
|
DataTransfer transfer = new DataTransfer();
|
|
DataTransfer transfer = new DataTransfer();
|
|
|
|
|
|
|
@@ -145,7 +146,8 @@ internal static class ClipboardController
|
|
|
|
|
|
|
|
public static async Task CopyVisibleToClipboard(DocumentViewModel document, string? output = null)
|
|
public static async Task CopyVisibleToClipboard(DocumentViewModel document, string? output = null)
|
|
|
{
|
|
{
|
|
|
- await Clipboard.ClearAsync();
|
|
|
|
|
|
|
+ // This breaks often on X11 and macos
|
|
|
|
|
+ //await Clipboard.ClearAsync();
|
|
|
|
|
|
|
|
DataTransfer data = new DataTransfer();
|
|
DataTransfer data = new DataTransfer();
|
|
|
|
|
|
|
@@ -255,6 +257,7 @@ internal static class ClipboardController
|
|
|
List<Guid> adjustedLayerIds = AdjustIdsForImport(layerIds, targetDoc);
|
|
List<Guid> adjustedLayerIds = AdjustIdsForImport(layerIds, targetDoc);
|
|
|
List<Guid?> newIds = new();
|
|
List<Guid?> newIds = new();
|
|
|
using var block = document.Operations.StartChangeBlock();
|
|
using var block = document.Operations.StartChangeBlock();
|
|
|
|
|
+ manager.Owner.ToolsSubViewModel.SetActiveTool<MoveToolViewModel>(false);
|
|
|
foreach (var layerId in adjustedLayerIds)
|
|
foreach (var layerId in adjustedLayerIds)
|
|
|
{
|
|
{
|
|
|
if (targetDoc.StructureHelper.Find(layerId) == null)
|
|
if (targetDoc.StructureHelper.Find(layerId) == null)
|
|
@@ -270,7 +273,6 @@ internal static class ClipboardController
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- manager.Owner.ToolsSubViewModel.SetActiveTool<MoveToolViewModel>(false);
|
|
|
|
|
Guid? mainGuid = newIds.FirstOrDefault(x => x != null);
|
|
Guid? mainGuid = newIds.FirstOrDefault(x => x != null);
|
|
|
if (mainGuid != null)
|
|
if (mainGuid != null)
|
|
|
{
|
|
{
|
|
@@ -293,29 +295,37 @@ internal static class ClipboardController
|
|
|
List<DataImage> images = await GetImage(data);
|
|
List<DataImage> images = await GetImage(data);
|
|
|
if (images.Count == 0 || pasteAsNew)
|
|
if (images.Count == 0 || pasteAsNew)
|
|
|
{
|
|
{
|
|
|
- return await TryPasteNestedDocument(document, manager, data);
|
|
|
|
|
|
|
+ if (await TryPasteNestedDocument(document, manager, data))
|
|
|
|
|
+ {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (images.Count == 1 || (images.Count > 1 && !pasteAsNew))
|
|
|
|
|
|
|
+ if (images.Count > 0)
|
|
|
{
|
|
{
|
|
|
- var dataImage = images[0];
|
|
|
|
|
- var position = dataImage.Position;
|
|
|
|
|
-
|
|
|
|
|
- if (document.SizeBindable.X < position.X || document.SizeBindable.Y < position.Y || !hasPos)
|
|
|
|
|
|
|
+ if (!pasteAsNew)
|
|
|
{
|
|
{
|
|
|
- position = VecI.Zero;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ var dataImage = images[0];
|
|
|
|
|
+ var position = dataImage.Position;
|
|
|
|
|
|
|
|
- manager.Owner.ToolsSubViewModel.SetActiveTool<MoveToolViewModel>(false);
|
|
|
|
|
- document.Operations.InvokeCustomAction(() =>
|
|
|
|
|
- {
|
|
|
|
|
- document.Operations.PasteImageWithTransform(dataImage.Image, position);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (document.SizeBindable.X < position.X || document.SizeBindable.Y < position.Y || !hasPos)
|
|
|
|
|
+ {
|
|
|
|
|
+ position = VecI.Zero;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+ manager.Owner.ToolsSubViewModel.SetActiveTool<MoveToolViewModel>(false);
|
|
|
|
|
+ document.Operations.InvokeCustomAction(() =>
|
|
|
|
|
+ {
|
|
|
|
|
+ document.Operations.PasteImageWithTransform(dataImage.Image, position);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ manager.Owner.ToolsSubViewModel.SetActiveTool<MoveToolViewModel>(false);
|
|
|
|
|
+ document.Operations.PasteImagesAsLayers(images, document.AnimationDataViewModel.ActiveFrameBindable, images.Count > 1);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- document.Operations.PasteImagesAsLayers(images, document.AnimationDataViewModel.ActiveFrameBindable);
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -346,7 +356,7 @@ internal static class ClipboardController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool imported = TryPlaceNestedDocument(document, manager, path, out _);
|
|
bool imported = TryPlaceNestedDocument(document, manager, path, out _);
|
|
|
- if(!imported)
|
|
|
|
|
|
|
+ if (!imported)
|
|
|
{
|
|
{
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -360,7 +370,8 @@ internal static class ClipboardController
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static bool TryPlaceNestedDocument(DocumentViewModel document, DocumentManagerViewModel manager, string path, out string? error)
|
|
|
|
|
|
|
+ public static bool TryPlaceNestedDocument(DocumentViewModel document, DocumentManagerViewModel manager, string path,
|
|
|
|
|
+ out string? error)
|
|
|
{
|
|
{
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
@@ -980,7 +991,8 @@ internal static class ClipboardController
|
|
|
|
|
|
|
|
public static async Task CopyIds(Guid[] ids, DataFormat<byte[]> format, Guid docId)
|
|
public static async Task CopyIds(Guid[] ids, DataFormat<byte[]> format, Guid docId)
|
|
|
{
|
|
{
|
|
|
- await Clipboard.ClearAsync();
|
|
|
|
|
|
|
+ // This breaks often on X11 and macos
|
|
|
|
|
+ //await Clipboard.ClearAsync();
|
|
|
|
|
|
|
|
DataTransfer data = new DataTransfer();
|
|
DataTransfer data = new DataTransfer();
|
|
|
|
|
|