Sfoglia il codice sorgente

【页面编辑】列表视图调整UI

tangchao 1 anno fa
parent
commit
b389143225

+ 1 - 5
PDF Office/PDF Master/Class/Common/Base/KMBaseWindowController.swift

@@ -7,13 +7,9 @@
 
 import Cocoa
 
-typealias KMBaseWindowControllerBatchAction = (_ controller: NSWindowController, _ files: [KMFileAttribute]) -> Void
-typealias KMBaseWindowControllerCancelAction = (_ controller: NSWindowController) -> Void
-
 class KMBaseWindowController: NSWindowController {
     
-    var batchAction: KMBaseWindowControllerBatchAction?
-    var cancelAction: KMBaseWindowControllerCancelAction?
+    var cancelAction: KMCommonBlock?
     
     deinit {
         Swift.debugPrint(self.className + "已释放")

+ 4 - 0
PDF Office/PDF Master/Class/Common/KMCommonDefine.swift

@@ -43,3 +43,7 @@ let kKMLocalForDraggedTypes = NSPasteboard.PasteboardType(rawValue: "KMLocalForD
 
 let kKMMainMenuAccountRefreshItemTag = 16
 
+// MARK: - 特定的Block
+
+typealias KMBatchActionBlock = (_ controller: NSWindowController, _ files: [KMFileAttribute]) -> Void
+

+ 2 - 0
PDF Office/PDF Master/Class/PDFTools/AddPassword/New/KMSecurityWindowController.swift

@@ -10,6 +10,8 @@ import Cocoa
 class KMSecurityWindowController: KMBaseWindowController {
     @IBOutlet weak var securityView: KMSecurityView!
     
+    var batchAction: KMBatchActionBlock?
+    
     override func windowDidLoad() {
         super.windowDidLoad()
 

+ 6 - 4
PDF Office/PDF Master/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift

@@ -46,8 +46,8 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
     var pageIsUpdate: Bool = true
     var selectedPages: [Int] = []
     
-    private let defaultItemSize = NSMakeSize(218 + 12 * 2, 292 + 24)
-    var itemSize: NSSize = NSMakeSize(218 + 12 * 2, 292 + 24)
+    private let defaultItemSize = NSMakeSize(200, 200)
+    var itemSize: NSSize = NSMakeSize(200, 200)
     
     // index=1 双击退出;index=2 打印
     var itemClick: KMCommonClickBlock?
@@ -121,7 +121,9 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
         
         // 显示拖放移动动效
 //        self.thumbnailView.dragMoveEffectAnimated = true
-        self.thumbnailView.collectionView.backgroundColor(NSColor.km_init(hex: "#CED0D4"))
+//        self.thumbnailView.collectionView.backgroundColor(NSColor.km_init(hex: "#CED0D4"))
+        self.thumbnailView.collectionView.wantsLayer = true
+        self.thumbnailView.collectionView.layer?.backgroundColor = KMAppearance.PDFViewBackgroundColor().cgColor
         
         var allowedFileTypes: [String] = []
 //        if let _types = KMConvertPDFManager.supportFileType()  {
@@ -1073,7 +1075,7 @@ extension KMPDFEditViewController: KMThumbnailViewDelegate {
     }
     
     func thumbnailView(thumbanView: KMThumbnailView, insetForSectionAt section: Int) -> NSEdgeInsets {
-        return NSEdgeInsets(top: 16, left: 16, bottom: 0, right: 32)
+        return NSEdgeInsets(top: 6, left: 6, bottom: 0, right: 6)
     }
     
     func thumbnailView(thumbanView: KMThumbnailView, sizeForItemAt indexpath: IndexPath) -> NSSize {

+ 19 - 13
PDF Office/PDF Master/Class/PDFTools/PageEdit/View/KMPageEditThumbnailItem.swift

@@ -70,10 +70,14 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
         self.textBox.addSubview(self.pageTextLabel)
         self.textBox.addSubview(self.pageSizeTextLabel)
         
-        self.backgroundView.wantsLayer = true
-        self.backgroundView.layer?.cornerRadius = 8.0
-        self.backgroundView.layer?.masksToBounds = true
-        self.backgroundView.layer?.borderWidth = 1.0
+        self.pageBox.wantsLayer = true
+        self.pageBox.layer?.backgroundColor = NSColor(white: 192.0/255.0, alpha: 1.0).cgColor
+        self.pageBox.layer?.cornerRadius = 6
+        self.pageBox.layer?.masksToBounds = true
+//        self.backgroundView.wantsLayer = true
+//        self.backgroundView.layer?.cornerRadius = 8.0
+//        self.backgroundView.layer?.masksToBounds = true
+//        self.backgroundView.layer?.borderWidth = 1.0
         self.isSelected = false
         
         self.pageView.wantsLayer = true
@@ -134,11 +138,13 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
              super.isSelected = newValue
              
              if (newValue) {
-                 self.backgroundView.layer?.backgroundColor = NSColor.km_init(hex: "#1770F41A").cgColor
-                 self.backgroundView.layer?.borderColor = NSColor.km_init(hex: "#1770F4").cgColor
+//                 self.backgroundView.layer?.backgroundColor = NSColor.km_init(hex: "#1770F41A").cgColor
+//                 self.backgroundView.layer?.borderColor = NSColor.km_init(hex: "#1770F4").cgColor
+                 self.pageBox.layer?.backgroundColor = NSColor(white: 192.0/255.0, alpha: 1.0).cgColor
              } else {
-                 self.backgroundView.layer?.backgroundColor = NSColor.clear.cgColor
-                 self.backgroundView.layer?.borderColor = NSColor.clear.cgColor
+//                 self.backgroundView.layer?.backgroundColor = NSColor.clear.cgColor
+//                 self.backgroundView.layer?.borderColor = NSColor.clear.cgColor
+                 self.pageBox.layer?.backgroundColor = .clear
              }
          }
      }
@@ -166,19 +172,19 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
          let viewWidth: CGFloat = NSWidth(self.view.bounds)
          let viewHeight: CGFloat = NSHeight(self.view.bounds)
          
-         let backgroundViewX: CGFloat = 12;
+         let backgroundViewX: CGFloat = 0;
          let backgroundViewY: CGFloat = 24;
          let backgroundViewW: CGFloat = viewWidth - backgroundViewX * 2;
          let backgroundViewH: CGFloat = viewHeight - 24;
-         self.backgroundView.frame = NSMakeRect(backgroundViewX, backgroundViewY, backgroundViewW, backgroundViewH)
+//         self.backgroundView.frame = NSMakeRect(backgroundViewX, backgroundViewY, backgroundViewW, backgroundViewH)
          
          var bounds = page.bounds
          let transform = page.transform()
          bounds = bounds.applying(transform)
          
-         var size = NSMakeSize(backgroundViewW-32, backgroundViewH-46)
+         var size = NSMakeSize(backgroundViewW, backgroundViewH-26)
          if (self.isShowPageSize == false) {
-            size = NSMakeSize(backgroundViewW-32, backgroundViewH-72)
+            size = NSMakeSize(backgroundViewW, backgroundViewH-52)
          }
 
          if (page.rotation == -90 || page.rotation == -270) {
@@ -228,7 +234,7 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
              self.pageTextLabel.frame = NSMakeRect((textWidth-textSize.width)*0.5, 4, textSize.width, height);
          }
          
-         let margin: CGFloat = 16 + NSMinX(self.backgroundView.frame)
+         let margin: CGFloat =  NSMinX(self.backgroundView.frame)
          let pageBoxY: CGFloat = self.textBox.frame.maxY+8
          let pageBoxW: CGFloat = viewWidth-margin*2
          let pageBoxH: CGFloat = viewHeight-pageBoxY-8

+ 3 - 1
PDF Office/PDF Master/Class/PDFTools/RemovePassword/New/KMRemovePasswordWindowController.swift

@@ -8,8 +8,10 @@
 import Cocoa
 
 class KMRemovePasswordWindowController: KMBaseWindowController {
-
     @IBOutlet weak var removePasswordView: KMRemovePasswordView!
+    
+    var batchAction: KMBatchActionBlock?
+    
     override func windowDidLoad() {
         super.windowDidLoad()