Jelajahi Sumber

【页面编辑】补充缩放视图

tangchao 1 tahun lalu
induk
melakukan
4d245af6f6

+ 41 - 11
PDF Office/PDF Master/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift

@@ -12,6 +12,10 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
     @IBOutlet weak var topBarBox: NSBox!
     @IBOutlet weak var contentBox: NSBox!
     
+    @IBOutlet weak var thumbnailSizeView: NSView!
+    @IBOutlet weak var lineBoxView: NSView!
+    
+    
     var toolBar = KMPDFEditToolbar(frame: NSZeroRect)
     override var thumbnailView: KMPDFThumbnailView {
         get {
@@ -46,8 +50,8 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
     var pageIsUpdate: Bool = true
     var selectedPages: [Int] = []
     
-    private let defaultItemSize = NSMakeSize(200, 200)
-    var itemSize: NSSize = NSMakeSize(200, 200)
+    private let defaultItemSize = NSMakeSize(215, 250)
+    var itemSize: NSSize = NSMakeSize(215, 250)
     
     // index=1 双击退出;index=2 打印
     var itemClick: KMCommonClickBlock?
@@ -125,6 +129,12 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
         self.thumbnailView.collectionView.wantsLayer = true
         self.thumbnailView.collectionView.layer?.backgroundColor = KMAppearance.PDFViewBackgroundColor().cgColor
         
+        self.thumbnailSizeView.wantsLayer = true
+        self.thumbnailSizeView.layer?.backgroundColor = KMAppearance.Layout.b80Color().cgColor
+        self.lineBoxView.wantsLayer = true
+        self.lineBoxView.layer?.backgroundColor = KMAppearance.Layout.h2Color().cgColor
+        
+        
         var allowedFileTypes: [String] = []
 //        if let _types = KMConvertPDFManager.supportFileType()  {
         allowedFileTypes = KMTools.pdfExtensions + KMConvertPDFManager.supportFileType()
@@ -677,13 +687,13 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
         if (self.itemSize.width < self.defaultItemSize.width) {
             self.itemSize = self.defaultItemSize
         } else if (self.itemSize.width == self.defaultItemSize.width) {
-            self.itemSize = NSSize(width: self.defaultItemSize.width*1.5, height: self.defaultItemSize.height*1.5)
+            self.itemSize = NSSize(width: self.defaultItemSize.width*2, height: self.defaultItemSize.height*2)
         }
 
-        self.toolBar.zoomInButton?.isEnabled = true
-        if (self.itemSize.width > self.defaultItemSize.width) {
-            sender?.isEnabled = false
-        }
+//        self.toolBar.zoomInButton?.isEnabled = true
+//        if (self.itemSize.width > self.defaultItemSize.width) {
+//            sender?.isEnabled = false
+//        }
         self.pageEditThumbnailView.zoomOut()
     }
     
@@ -705,10 +715,10 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
             self.itemSize = NSSize(width: self.defaultItemSize.width*0.5, height: self.defaultItemSize.height*0.5)
         }
 
-        self.toolBar.zoomOutButton?.isEnabled = true
-        if (self.itemSize.width < self.defaultItemSize.width) {
-            sender?.isEnabled = false
-        }
+//        self.toolBar.zoomOutButton?.isEnabled = true
+//        if (self.itemSize.width < self.defaultItemSize.width) {
+//            sender?.isEnabled = false
+//        }
         self.pageEditThumbnailView.zoomIn()
     }
     
@@ -835,6 +845,26 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
         }
         return item_
     }
+    
+    // MARK: - Zoom Methods
+    
+    @IBAction func buttonClicked_Bigger(_ sender: AnyObject?) {
+//        if (self.thumbnailView.thumbnailSize.width == 100.) {
+//            self.thumbnailView.thumbnailSize = CGSizeMake(200, 200);
+//        } else if (self.thumbnailView.thumbnailSize.width == 200.) {
+//            self.thumbnailView.thumbnailSize = CGSizeMake(400, 400);
+//        }
+        self.zoomOutButtonAction(sender: sender as? NSButton)
+    }
+    
+    @IBAction func buttonClicked_Smaller(_ sender: AnyObject?) {
+//        if (self.thumbnailView.thumbnailSize.width == 400.) {
+//            self.thumbnailView.thumbnailSize = CGSizeMake(200, 200);
+//        } else if (self.thumbnailView.thumbnailSize.width == 200.) {
+//            self.thumbnailView.thumbnailSize = CGSizeMake(100, 100);
+//        }
+        self.zoomInButtonAction(sender: sender as? NSButton)
+    }
 }
 
 extension KMPDFEditViewController {

+ 52 - 2
PDF Office/PDF Master/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.xib

@@ -1,14 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21701"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="KMPDFEditViewController" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="contentBox" destination="H78-7z-jdm" id="fst-f6-ba8"/>
+                <outlet property="lineBoxView" destination="9X3-1V-DZ8" id="gB1-mA-E7R"/>
+                <outlet property="thumbnailSizeView" destination="Jf5-OZ-sXa" id="Pib-0f-y8b"/>
                 <outlet property="topBarBox" destination="9MH-c6-Ein" id="4yW-J4-TfZ"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
             </connections>
@@ -36,9 +38,53 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                     </view>
                 </box>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="Jf5-OZ-sXa">
+                    <rect key="frame" x="372" y="16" width="88" height="32"/>
+                    <subviews>
+                        <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nbB-12-iF1">
+                            <rect key="frame" x="14" y="8" width="16" height="16"/>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameZoomout" imagePosition="overlaps" alignment="center" imageScaling="proportionallyDown" inset="2" id="wp2-ja-C64">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="buttonClicked_Smaller:" target="-2" id="cJY-xV-90Q"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="AzX-4N-uaa">
+                            <rect key="frame" x="58" y="8" width="16" height="16"/>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameZoomoin" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="W58-xr-jlL">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="buttonClicked_Bigger:" target="-2" id="qkv-Xf-5ha"/>
+                            </connections>
+                        </button>
+                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="9X3-1V-DZ8">
+                            <rect key="frame" x="44" y="8" width="1" height="16"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="16" id="WhF-bC-cri"/>
+                                <constraint firstAttribute="width" constant="1" id="z0i-An-EC4"/>
+                            </constraints>
+                        </customView>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="AzX-4N-uaa" firstAttribute="centerY" secondItem="Jf5-OZ-sXa" secondAttribute="centerY" id="FLY-cM-pLp"/>
+                        <constraint firstAttribute="trailing" secondItem="AzX-4N-uaa" secondAttribute="trailing" constant="14" id="XeC-NF-W4Q"/>
+                        <constraint firstItem="9X3-1V-DZ8" firstAttribute="centerY" secondItem="Jf5-OZ-sXa" secondAttribute="centerY" id="Zbf-w9-sgQ"/>
+                        <constraint firstAttribute="height" constant="32" id="cG1-JH-RdK"/>
+                        <constraint firstAttribute="width" constant="88" id="hE0-8E-4z4"/>
+                        <constraint firstItem="9X3-1V-DZ8" firstAttribute="centerX" secondItem="Jf5-OZ-sXa" secondAttribute="centerX" id="mpO-ur-VNN"/>
+                        <constraint firstItem="nbB-12-iF1" firstAttribute="leading" secondItem="Jf5-OZ-sXa" secondAttribute="leading" constant="14" id="nao-Eg-9su"/>
+                        <constraint firstItem="nbB-12-iF1" firstAttribute="centerY" secondItem="Jf5-OZ-sXa" secondAttribute="centerY" id="upj-OE-YGg"/>
+                    </constraints>
+                </customView>
             </subviews>
             <constraints>
                 <constraint firstAttribute="trailing" secondItem="9MH-c6-Ein" secondAttribute="trailing" id="3XF-0A-rcC"/>
+                <constraint firstAttribute="bottom" secondItem="Jf5-OZ-sXa" secondAttribute="bottom" constant="16" id="7tR-XL-PEB"/>
+                <constraint firstAttribute="trailing" secondItem="Jf5-OZ-sXa" secondAttribute="trailing" constant="20" id="LTk-QE-7uv"/>
                 <constraint firstItem="H78-7z-jdm" firstAttribute="top" secondItem="9MH-c6-Ein" secondAttribute="bottom" id="Nhk-9Y-2aa"/>
                 <constraint firstItem="9MH-c6-Ein" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="Q7l-UX-efw"/>
                 <constraint firstAttribute="bottom" secondItem="H78-7z-jdm" secondAttribute="bottom" id="QBN-Il-nSW"/>
@@ -49,4 +95,8 @@
             <point key="canvasLocation" x="235" y="121"/>
         </customView>
     </objects>
+    <resources>
+        <image name="KMImageNameZoomoin" width="16" height="16"/>
+        <image name="KMImageNameZoomout" width="16" height="16"/>
+    </resources>
 </document>

+ 9 - 1
PDF Office/PDF Master/Class/PDFTools/PageEdit/View/KMPageEditThumbnailItem.swift

@@ -31,6 +31,7 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
         label.isBordered = false
         label.isSelectable = false
         label.drawsBackground = false
+        label.font = .SFProTextRegularFont(11)
         return label
     }()
     
@@ -70,6 +71,9 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
         self.textBox.addSubview(self.pageTextLabel)
         self.textBox.addSubview(self.pageSizeTextLabel)
         
+        self.pageTextLabel.wantsLayer = true
+        self.pageTextLabel.layer?.cornerRadius = 2
+        self.pageTextLabel.layer?.masksToBounds = true
         self.pageBox.wantsLayer = true
         self.pageBox.layer?.backgroundColor = NSColor(white: 192.0/255.0, alpha: 1.0).cgColor
         self.pageBox.layer?.cornerRadius = 6
@@ -140,11 +144,15 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
              if (newValue) {
 //                 self.backgroundView.layer?.backgroundColor = NSColor.km_init(hex: "#1770F41A").cgColor
 //                 self.backgroundView.layer?.borderColor = NSColor.km_init(hex: "#1770F4").cgColor
+                 self.pageTextLabel.textColor = .white
+                 self.pageTextLabel.layer?.backgroundColor = NSColor.systemBlue.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.pageBox.layer?.backgroundColor = .clear
+                 self.pageTextLabel.textColor = .labelColor
+                 self.pageTextLabel.layer?.backgroundColor = .clear
              }
          }
      }
@@ -237,7 +245,7 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
          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
+         let pageBoxH: CGFloat = viewHeight-pageBoxY
          self.pageBox.frame = NSMakeRect(margin, pageBoxY, pageBoxW, pageBoxH)
          
          var pageX: CGFloat = (NSWidth(self.pageBox.frame)-size.width)*0.5

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/PageEdit/View/KMPageEditThumbnailItem.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>