|
@@ -35,9 +35,6 @@ class KMToolbarConfigViewController: NSViewController {
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
-// self.view.wantsLayer = true
|
|
|
-// self.view.layer?.backgroundColor = NSColor.red.cgColor
|
|
|
-
|
|
|
self.initDefalutValue()
|
|
|
}
|
|
|
|
|
@@ -48,18 +45,10 @@ class KMToolbarConfigViewController: NSViewController {
|
|
|
|
|
|
self.collectionView.register(KMToolbarConfigViewItem.self, forItemWithIdentifier: self.cellIdentifier_)
|
|
|
(self.collectionView.collectionViewLayout as? NSCollectionViewFlowLayout)?.scrollDirection = .horizontal
|
|
|
-// self.collectionView.registerForDraggedTypes([kKMLocalForDraggedTypes, .fileURL, .string])
|
|
|
- collectionView.registerForDraggedTypes([NSPasteboard.PasteboardType.string])
|
|
|
- collectionView.setDraggingSourceOperationMask(.every, forLocal: false)
|
|
|
- collectionView.setDraggingSourceOperationMask(.every, forLocal: true)
|
|
|
+ self.collectionView.registerForDraggedTypes([NSPasteboard.PasteboardType.string])
|
|
|
|
|
|
self.collectionView.allowsMultipleSelection = false
|
|
|
-// self.collectionView.enclosingScrollView?.drawsBackground = false
|
|
|
self.collectionView.enclosingScrollView?.backgroundColor = .gridColor
|
|
|
- self.collectionView.enclosingScrollView?.wantsLayer = true
|
|
|
- self.collectionView.enclosingScrollView?.layer?.backgroundColor = NSColor.red.cgColor
|
|
|
-// self.collectionView.wantsLayer = true
|
|
|
-// self.collectionView.layer?.backgroundColor = NSColor.red.cgColor
|
|
|
|
|
|
self.removedLabel.stringValue = NSLocalizedString("Hide", comment: "")
|
|
|
self.removedCollectionView.delegate = self
|
|
@@ -68,9 +57,7 @@ class KMToolbarConfigViewController: NSViewController {
|
|
|
self.removedCollectionView.register(KMToolbarConfigViewItem.self, forItemWithIdentifier: self.cellIdentifier_)
|
|
|
(self.removedCollectionView.collectionViewLayout as? NSCollectionViewFlowLayout)?.scrollDirection = .horizontal
|
|
|
|
|
|
- removedCollectionView.registerForDraggedTypes([NSPasteboard.PasteboardType.string])
|
|
|
- removedCollectionView.setDraggingSourceOperationMask(.every, forLocal: false)
|
|
|
- removedCollectionView.setDraggingSourceOperationMask(.every, forLocal: true)
|
|
|
+ self.removedCollectionView.registerForDraggedTypes([NSPasteboard.PasteboardType.string])
|
|
|
self.removedCollectionView.isSelectable = true
|
|
|
|
|
|
self.tipLabel.stringValue = NSLocalizedString("Drag and drop to add, remove and reorder the tools.", comment: "")
|
|
@@ -213,16 +200,21 @@ extension KMToolbarConfigViewController: NSCollectionViewDelegate, NSCollectionV
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: NSCollectionView, validateDrop draggingInfo: NSDraggingInfo, proposedIndexPath proposedDropIndexPath: AutoreleasingUnsafeMutablePointer<NSIndexPath>, dropOperation proposedDropOperation: UnsafeMutablePointer<NSCollectionView.DropOperation>) -> NSDragOperation {
|
|
|
+ let draggingSource = draggingInfo.draggingSource as? NSCollectionView
|
|
|
if collectionView.isEqual(self.removedCollectionView) {
|
|
|
- return .move
|
|
|
+ if self.collectionView.isEqual(to: draggingSource) {
|
|
|
+ return .copy
|
|
|
+ } else {
|
|
|
+ return .move
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if collectionView.isEqual(self.collectionView) {
|
|
|
-// if indexPathsOfItemsBeingShowItemDragged.count != 0 {
|
|
|
+ if self.removedCollectionView.isEqual(to: draggingSource) {
|
|
|
+ return .copy
|
|
|
+ } else {
|
|
|
return .move
|
|
|
-// } else {
|
|
|
-// return .copy
|
|
|
-// }
|
|
|
+ }
|
|
|
}
|
|
|
return []
|
|
|
}
|