浏览代码

【fix】【工具栏】AI 工具 icon 未上下居中

tangchao 9 月之前
父节点
当前提交
e236f8acfd

+ 12 - 20
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/Controller/KMToolbarConfigViewController.swift

@@ -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 []
     }

+ 0 - 4
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/Model/KMToolbarConfigModel.swift

@@ -427,10 +427,6 @@ extension KMToolbarConfigModel {
             searchView.sendsWholeSearchString = true
             searchView.sendsSearchStringImmediately = true
             searchView.drawsBackground = false
-//            searchView.delegate = self
-//            self.searchField = searchView
-
-//            self.refreshSearchBarMenu()
 
             boxView.addSubview(searchView)
             let titleLabel = NSTextField(labelWithString: NSLocalizedString("Search", comment: ""))