Add back artworks copy & paste
This commit is contained in:
2 files changed
+17
-27
No files matched your search
@@ -1000,9 +1000,6 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dragging Source Support - Required for multi-image drag and drop.
|
|
||||||
Return a custom object that implements NSPasteboardWriting (or simply use NSPasteboardItem), or nil to prevent dragging for the item.
|
|
||||||
*/
|
|
||||||
func collectionView(_ collectionView: NSCollectionView,
|
func collectionView(_ collectionView: NSCollectionView,
|
||||||
pasteboardWriterForItemAt indexPath: IndexPath) -> NSPasteboardWriting? {
|
pasteboardWriterForItemAt indexPath: IndexPath) -> NSPasteboardWriting? {
|
||||||
var provider: NSFilePromiseProvider?
|
var provider: NSFilePromiseProvider?
|
||||||
@@ -1091,7 +1088,6 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
|||||||
// Look only for image urls.
|
// Look only for image urls.
|
||||||
if let urls = pasteboard.readObjects(forClasses: [NSURL.self], options: options), !urls.isEmpty {
|
if let urls = pasteboard.readObjects(forClasses: [NSURL.self], options: options), !urls.isEmpty {
|
||||||
// One or more of the URLs in this drag is image file.
|
// One or more of the URLs in this drag is image file.
|
||||||
// The sample allows for this; a user may be able to drag in a mix of files, any one of them being an image file.
|
|
||||||
dragOperation = [.copy]
|
dragOperation = [.copy]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1256,31 +1252,25 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
func collectionViewCopy(in collectionView: NSCollectionView) {
|
func collectionViewCopy(in collectionView: NSCollectionView) {
|
||||||
// pasteboard.declareTypes([artworksPBoardType, .tiff], owner: nil)
|
let indexes = artworksView.selectionIndexes
|
||||||
//
|
if indexes.isEmpty { return }
|
||||||
// for image in itemIndexes.map({ artworks[$0] }).compactMap({ $0.imageValue }) {
|
|
||||||
// if let representations = image.image?.representations {
|
let pasteboard = NSPasteboard.general
|
||||||
// let bitmapData = NSBitmapImageRep.representationOfImageReps(in: representations, using: .tiff, properties: [:])
|
pasteboard.clearContents()
|
||||||
// pasteboard.setData(bitmapData, forType: .tiff)
|
|
||||||
// }
|
let items = indexes.compactMap { artworks[$0].imageValue }
|
||||||
// pasteboard.setData(NSKeyedArchiver.archivedData(withRootObject: image), forType: artworksPBoardType)
|
pasteboard.writeObjects(items)
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return itemIndexes.count
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectionViewPaste(to collectionView: NSCollectionView) {
|
func collectionViewPaste(to collectionView: NSCollectionView) {
|
||||||
// let pb = NSPasteboard.general
|
let pasteboard = NSPasteboard.general
|
||||||
//
|
|
||||||
// if let archivedImageData = pb.data(forType: artworksPBoardType), let image = NSKeyedUnarchiver.unarchiveObject(with: archivedImageData) as? MP42Image {
|
let classes = [MP42Image.classForCoder(), NSURL.classForCoder(), NSImage.classForCoder()]
|
||||||
// _ = add(artworks: [image])
|
let options = [NSPasteboard.ReadingOptionKey.urlReadingContentsConformToTypes: NSImage.imageTypes]
|
||||||
// } else {
|
|
||||||
// let classes = [NSURL.classForCoder(), NSImage.classForCoder()]
|
if let items = pasteboard.readObjects(forClasses: classes, options: options) as [AnyObject]? {
|
||||||
// let options = [NSPasteboard.ReadingOptionKey.urlReadingContentsConformToTypes: NSImage.imageTypes]
|
_ = add(artworks: items, toIndexPath:IndexPath(index: 0))
|
||||||
// if let items = pb.readObjects(forClasses: classes, options: options) as [AnyObject]? {
|
}
|
||||||
// _ = add(artworks: items)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
Submodule MP42Foundation updated: 23ac1a3256...5555a95ee6.
Reference in new issue
Block a user