Improve Drag & Drop
This commit is contained in:
8 files changed
+207
-62
No files matched your search
@@ -103,7 +103,7 @@ protocol ArtworkSelectorControllerDelegate: AnyObject {
|
||||
func didAddArtworks(metadata: MetadataResult)
|
||||
}
|
||||
|
||||
class CollectionView : NSCollectionView {
|
||||
class ArtworkCollectionView : NSCollectionView {
|
||||
override func keyDown(with event: NSEvent) {
|
||||
guard let key = event.charactersIgnoringModifiers?.utf16.first else { super.keyDown(with: event); return }
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -307,7 +307,7 @@
|
||||
<rect key="frame" x="1" y="1" width="96" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sbg-eG-N9u">
|
||||
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sbg-eG-N9u">
|
||||
<rect key="frame" x="0.0" y="3" width="96" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" alignment="right" title="Table View Cell" id="fIl-II-Tfv">
|
||||
@@ -342,7 +342,7 @@
|
||||
<rect key="frame" x="100" y="1" width="615" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KkS-kR-z72">
|
||||
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KkS-kR-z72">
|
||||
<rect key="frame" x="0.0" y="3" width="615" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" title="Table View Cell" id="Ktq-AC-XnR">
|
||||
@@ -436,8 +436,8 @@
|
||||
</customView>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSActionTemplate" width="15" height="15"/>
|
||||
<image name="NSAddTemplate" width="14" height="13"/>
|
||||
<image name="NSRemoveTemplate" width="14" height="4"/>
|
||||
<image name="NSActionTemplate" width="20" height="20"/>
|
||||
<image name="NSAddTemplate" width="18" height="17"/>
|
||||
<image name="NSRemoveTemplate" width="18" height="5"/>
|
||||
</resources>
|
||||
</document>
|
||||
@@ -24,16 +24,16 @@
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView misplaced="YES" id="1">
|
||||
<customView id="1">
|
||||
<rect key="frame" x="0.0" y="0.0" width="769" height="306"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<tabView controlSize="small" translatesAutoresizingMaskIntoConstraints="NO" id="10">
|
||||
<rect key="frame" x="-11" y="-12" width="791" height="170"/>
|
||||
<rect key="frame" x="-11" y="-12" width="791" height="313"/>
|
||||
<tabViewItems>
|
||||
<tabViewItem label="Metadata" identifier="1" id="11">
|
||||
<view key="view" id="12">
|
||||
<rect key="frame" x="10" y="25" width="771" height="132"/>
|
||||
<rect key="frame" x="10" y="25" width="771" height="86"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<popUpButton toolTip="Add a new metadata item" translatesAutoresizingMaskIntoConstraints="NO" id="30">
|
||||
@@ -90,9 +90,9 @@
|
||||
<accessibility description="Sets"/>
|
||||
</popUpButton>
|
||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="16" horizontalPageScroll="10" verticalLineScroll="16" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="r4i-wT-qDC">
|
||||
<rect key="frame" x="17" y="36" width="737" height="90"/>
|
||||
<rect key="frame" x="17" y="36" width="737" height="44"/>
|
||||
<clipView key="contentView" id="cQT-bX-0YB">
|
||||
<rect key="frame" x="1" y="1" width="735" height="88"/>
|
||||
<rect key="frame" x="1" y="1" width="735" height="42"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="plain" columnReordering="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="14" rowSizeStyle="automatic" headerView="qXU-xB-xRF" viewBased="YES" floatsGroupRows="NO" id="qg5-r0-E4V" customClass="ExpandedTableView" customModule="Subler" customModuleProvider="target">
|
||||
@@ -325,7 +325,7 @@
|
||||
</tabViewItem>
|
||||
<tabViewItem label="Artwork" identifier="Item 1" id="15">
|
||||
<view key="view" id="16">
|
||||
<rect key="frame" x="10" y="25" width="771" height="286"/>
|
||||
<rect key="frame" x="10" y="25" width="771" height="275"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="223">
|
||||
@@ -366,13 +366,13 @@
|
||||
</connections>
|
||||
</slider>
|
||||
<scrollView wantsLayer="YES" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WUe-C3-hRA">
|
||||
<rect key="frame" x="17" y="36" width="737" height="256"/>
|
||||
<rect key="frame" x="17" y="36" width="737" height="233"/>
|
||||
<clipView key="contentView" id="jau-dn-6LI">
|
||||
<rect key="frame" x="1" y="1" width="735" height="254"/>
|
||||
<rect key="frame" x="1" y="1" width="735" height="231"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<collectionView selectable="YES" allowsMultipleSelection="YES" id="HHe-zs-flI" customClass="CollectionView" customModule="Subler" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="735" height="254"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="735" height="231"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<collectionViewFlowLayout key="collectionViewLayout" minimumInteritemSpacing="10" minimumLineSpacing="10" id="ofy-8i-tTx">
|
||||
<size key="itemSize" width="280" height="260"/>
|
||||
@@ -391,7 +391,7 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="bD2-5M-Iiz">
|
||||
<rect key="frame" x="720" y="1" width="16" height="172"/>
|
||||
<rect key="frame" x="720" y="1" width="16" height="231"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
|
||||
@@ -14,7 +14,7 @@ extension NSPasteboard.PasteboardType {
|
||||
static let artworkDragType = NSPasteboard.PasteboardType("org.subler.artworkdragdrop")
|
||||
}
|
||||
|
||||
class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableViewDelegate, NSCollectionViewDataSource, NSCollectionViewDelegate, NSDraggingDestination, NSFilePromiseProviderDelegate {
|
||||
class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableViewDelegate, NSCollectionViewDataSource, CollectionViewDelegate, NSDraggingDestination, NSFilePromiseProviderDelegate {
|
||||
|
||||
var metadata: MP42Metadata {
|
||||
didSet {
|
||||
@@ -976,9 +976,9 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
||||
|
||||
func filePromiseProvider(_ filePromiseProvider: NSFilePromiseProvider, fileNameForType fileType: String) -> String {
|
||||
if let userInfo = filePromiseProvider.userInfo as? [String: AnyObject] {
|
||||
return "Untitled." + (userInfo[FilePromiseProvider.UserInfoKeys.extensionKey] as! String)
|
||||
return "Artwork." + (userInfo[FilePromiseProvider.UserInfoKeys.extensionKey] as! String)
|
||||
} else {
|
||||
return "Untitled.tiff"
|
||||
return "Artwork.tiff"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1249,38 +1249,38 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
||||
}
|
||||
}
|
||||
|
||||
func collectionViewDelete(in collectionView: NSCollectionView) {
|
||||
let itemIndexes = collectionView.selectionIndexPaths.compactMap { $0.last }
|
||||
let items = itemIndexes.map { artworks[$0] }
|
||||
remove(metadataArtworks: items)
|
||||
}
|
||||
|
||||
// override func imageBrowser(_ aBrowser: IKImageBrowserView!, writeItemsAt itemIndexes: IndexSet!, to pasteboard: NSPasteboard!) -> Int {
|
||||
// pasteboard.declareTypes([artworksPBoardType, .tiff], owner: nil)
|
||||
//
|
||||
// for image in itemIndexes.map({ artworks[$0] }).compactMap({ $0.imageValue }) {
|
||||
// if let representations = image.image?.representations {
|
||||
// let bitmapData = NSBitmapImageRep.representationOfImageReps(in: representations, using: .tiff, properties: [:])
|
||||
// pasteboard.setData(bitmapData, forType: .tiff)
|
||||
// }
|
||||
// pasteboard.setData(NSKeyedArchiver.archivedData(withRootObject: image), forType: artworksPBoardType)
|
||||
// }
|
||||
//
|
||||
// return itemIndexes.count
|
||||
// }
|
||||
//
|
||||
// func paste(to imagebrowserview: ImageBrowserView) {
|
||||
// let pb = NSPasteboard.general
|
||||
//
|
||||
// if let archivedImageData = pb.data(forType: artworksPBoardType), let image = NSKeyedUnarchiver.unarchiveObject(with: archivedImageData) as? MP42Image {
|
||||
// _ = add(artworks: [image])
|
||||
// } else {
|
||||
// let classes = [NSURL.classForCoder(), NSImage.classForCoder()]
|
||||
// let options = [NSPasteboard.ReadingOptionKey.urlReadingContentsConformToTypes: NSImage.imageTypes]
|
||||
// if let items = pb.readObjects(forClasses: classes, options: options) as [AnyObject]? {
|
||||
// _ = add(artworks: items)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override func imageBrowser(_ aBrowser: IKImageBrowserView!, removeItemsAt indexes: IndexSet!) {
|
||||
// let items = indexes.map { artworks[$0] }
|
||||
// remove(metadataArtworks: items)
|
||||
// }
|
||||
func collectionViewCopy(in collectionView: NSCollectionView) {
|
||||
// pasteboard.declareTypes([artworksPBoardType, .tiff], owner: nil)
|
||||
//
|
||||
// for image in itemIndexes.map({ artworks[$0] }).compactMap({ $0.imageValue }) {
|
||||
// if let representations = image.image?.representations {
|
||||
// let bitmapData = NSBitmapImageRep.representationOfImageReps(in: representations, using: .tiff, properties: [:])
|
||||
// pasteboard.setData(bitmapData, forType: .tiff)
|
||||
// }
|
||||
// pasteboard.setData(NSKeyedArchiver.archivedData(withRootObject: image), forType: artworksPBoardType)
|
||||
// }
|
||||
//
|
||||
// return itemIndexes.count
|
||||
}
|
||||
|
||||
func collectionViewPaste(to collectionView: NSCollectionView) {
|
||||
// let pb = NSPasteboard.general
|
||||
//
|
||||
// if let archivedImageData = pb.data(forType: artworksPBoardType), let image = NSKeyedUnarchiver.unarchiveObject(with: archivedImageData) as? MP42Image {
|
||||
// _ = add(artworks: [image])
|
||||
// } else {
|
||||
// let classes = [NSURL.classForCoder(), NSImage.classForCoder()]
|
||||
// let options = [NSPasteboard.ReadingOptionKey.urlReadingContentsConformToTypes: NSImage.imageTypes]
|
||||
// if let items = pb.readObjects(forClasses: classes, options: options) as [AnyObject]? {
|
||||
// _ = add(artworks: items)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user