Jelajahi Sumber

【文字图片编辑】token组件完善

lizhe 1 tahun lalu
induk
melakukan
57ca21bd9a

+ 7 - 8
PDF Office/PDF Master/Class/Home/ViewController/customViewController/KMDesignButton.xib

@@ -1,12 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21701"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMDesignButton" customModule="PDF_Office" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMDesignButton" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="button" destination="Zns-K7-6eD" id="VMf-U0-mvN"/>
                 <outlet property="imageButtonBox" destination="cvM-Bd-5JV" id="jfg-8m-FSC"/>
@@ -85,7 +84,7 @@
             </constraints>
             <point key="canvasLocation" x="68" y="67.5"/>
         </customView>
-        <box boxType="custom" borderWidth="0.0" title="Box" id="Y8j-9c-Qz0" customClass="KMMoveBox" customModule="PDF_Office" customModuleProvider="target">
+        <box boxType="custom" borderWidth="0.0" title="Box" id="Y8j-9c-Qz0" customClass="KMMoveBox" customModule="PDF_Master" customModuleProvider="target">
             <rect key="frame" x="0.0" y="0.0" width="80" height="32"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <view key="contentView" id="V2P-Be-4EP">
@@ -108,7 +107,7 @@
             </constraints>
             <point key="canvasLocation" x="-114" y="158"/>
         </box>
-        <box boxType="custom" borderWidth="0.0" title="Box" id="cvM-Bd-5JV" customClass="KMMoveBox" customModule="PDF_Office" customModuleProvider="target">
+        <box boxType="custom" borderWidth="0.0" title="Box" id="cvM-Bd-5JV" customClass="KMMoveBox" customModule="PDF_Master" customModuleProvider="target">
             <rect key="frame" x="0.0" y="0.0" width="32" height="32"/>
             <autoresizingMask key="autoresizingMask"/>
             <view key="contentView" id="MNI-fR-ZxO">
@@ -129,7 +128,7 @@
             </view>
             <point key="canvasLocation" x="-114" y="264"/>
         </box>
-        <box boxType="custom" cornerRadius="4" title="Box" id="Xrh-vh-9yg" customClass="KMMoveBox" customModule="PDF_Office" customModuleProvider="target">
+        <box boxType="custom" cornerRadius="4" title="Box" id="Xrh-vh-9yg" customClass="KMMoveBox" customModule="PDF_Master" customModuleProvider="target">
             <rect key="frame" x="0.0" y="0.0" width="412" height="2"/>
             <autoresizingMask key="autoresizingMask"/>
             <view key="contentView" id="JIa-kj-5wJ">
@@ -255,7 +254,7 @@
             </constraints>
             <point key="canvasLocation" x="554" y="439"/>
         </customView>
-        <box boxType="custom" borderWidth="0.0" title="Box" id="Dan-L1-vKC" customClass="KMMoveBox" customModule="PDF_Office" customModuleProvider="target">
+        <box boxType="custom" borderWidth="0.0" title="Box" id="Dan-L1-vKC" customClass="KMMoveBox" customModule="PDF_Master" customModuleProvider="target">
             <rect key="frame" x="0.0" y="0.0" width="65" height="22"/>
             <autoresizingMask key="autoresizingMask"/>
             <view key="contentView" id="tPq-1S-9CW">

+ 57 - 6
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditPDFTextPropertyViewController.swift

@@ -59,8 +59,9 @@ class KMEditPDFTextPropertyViewController: NSViewController {
     @IBOutlet weak var areasTopButton: NSButton!
     @IBOutlet weak var areasRightButton: NSButton!
     
-    var textPresuppositionVC: KMDesignPropertySelector?
-    var textPresuppositionResetVC: KMDesignSelect?
+    var textPresuppositionVC: KMDesignSelect?
+    var textPresuppositionResetVC: KMDesignPropertySelector?
+    var textPresuppositionResetString: String = ""
     
     var leftAlignmentVC: KMDesignPropertySelector?
     var centerAlignmentVC: KMDesignPropertySelector?
@@ -103,9 +104,13 @@ class KMEditPDFTextPropertyViewController: NSViewController {
     }
     
     func setup() {
+        
+        //
+        self.fontColorButton.border(NSColor.clear, 0, 10)
         //alignment
         leftAlignmentVC = KMDesignPropertySelector.init(withType: .Icon_Btn)
         leftAlignmentBox.contentView = leftAlignmentVC?.view
+        leftAlignmentBox.fillColor = NSColor.clear
         leftAlignmentVC?.target = self
         leftAlignmentVC?.action = #selector(leftAlignmentAction)
         leftAlignmentVC?.image = NSImage(named: "KMImageNameEditPDFAlignLeft")!
@@ -113,6 +118,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
         
         centerAlignmentVC = KMDesignPropertySelector.init(withType: .Icon_Btn)
         centerAlignmentBox.contentView = centerAlignmentVC?.view
+        centerAlignmentBox.fillColor = NSColor.clear
         centerAlignmentVC?.target = self
         centerAlignmentVC?.action = #selector(centerAlignmentAction)
         centerAlignmentVC?.image = NSImage(named: "KMImageNameEditPDFAlignCenter")!
@@ -120,6 +126,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
         
         rightAlignmentVC = KMDesignPropertySelector.init(withType: .Icon_Btn)
         rightAlignmentBox.contentView = rightAlignmentVC?.view
+        rightAlignmentBox.fillColor = NSColor.clear
         rightAlignmentVC?.target = self
         rightAlignmentVC?.action = #selector(rightAlignmentAction)
         rightAlignmentVC?.image = NSImage(named: "KMImageNameEditPDFAlignRight")!
@@ -143,7 +150,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
         if fontNames.last == "Regular" {
             font = NSFont.init(name: fontNames.first!, size: currentFont.pointSize)!
         } else {
-            font = NSFont.init(name: currentFont.fontName, size: currentFont.pointSize)!
+            font = NSFont.init(name: "Helvetica-Bold", size: currentFont.pointSize)!
         }
         
         var styleArray: [String] = []
@@ -165,6 +172,21 @@ class KMEditPDFTextPropertyViewController: NSViewController {
         fontSizeVC?.addItems(withObjectValues: self.supportFontSize())
         fontSizeVC?.selectItem(at: 0)
         fontSizeVC?.delete = self
+        
+        //textPresupposition
+        let textPresuppositionArray = ["Customize", "H1 Headline", "H2 Title", "H3 Subtitle", "B1 Text", "B2 Small Text", "B3 Describtion"]
+        textPresuppositionVC = KMDesignSelect.init(withType: .PopButton)
+        textPresuppositionBox.contentView = textPresuppositionVC?.view
+        textPresuppositionVC?.addItems(withObjectValues: textPresuppositionArray)
+        textPresuppositionVC?.selectItem(at: 0)
+        textPresuppositionVC?.delete = self
+        
+        textPresuppositionResetVC = KMDesignPropertySelector.init(withType: .Icon_Btn)
+        resetTextPresuppositionBox.contentView = textPresuppositionResetVC?.view
+        resetTextPresuppositionBox.fillColor = NSColor.clear
+        textPresuppositionResetVC?.target = self
+        textPresuppositionResetVC?.action = #selector(resetTextPresuppositionButtonAction)
+        textPresuppositionResetVC?.image = NSImage(named: "KMImagePropertPanelTextDefaultMore")!
     }
     
     func initData() {
@@ -175,13 +197,13 @@ class KMEditPDFTextPropertyViewController: NSViewController {
         let fontAlign : String = UserDefaults.standard.object(forKey: CEditPDFTextDefaultFontAlign) as? String ?? "2"
         self.fontNameVC!.stringValue = fontName
         self.fontStyleVC!.stringValue = fontStyle
-        self.fontSizeVC!.stringValue = fontSize
+        self.fontSizeVC!.stringValue = fontSize + "pt"
         self.alignment = NSTextAlignment.init(rawValue: Int(fontAlign)!)!
         self.currentColor = fontColor
         DispatchQueue.main.async {
             NSColorPanel.shared.color = self.currentColor
         }
-        self.fontColorButton.image = self.swatchWithColor(color: self.currentColor, size: NSSize(width: 18, height: 18))
+        self.fontColorButton.image = self.swatchWithColor(color: self.currentColor, size: NSSize(width: 20, height: 20))
     }
     
     func updateUI() {
@@ -606,11 +628,40 @@ extension KMEditPDFTextPropertyViewController {
         }
         self.updataPreviewImage()
     }
+    
+    @objc func resetTextPresuppositionButtonAction(sender: NSButton) {
+        var popViewDataArr: [String] = []
+        for string in ["Redefine", "Reset"] {
+            popViewDataArr.append(NSLocalizedString(string, comment: ""))
+        }
+        
+        let vc: KMHomePopViewController = KMHomePopViewController().initWithPopViewDataArr(popViewDataArr)
+        let createFilePopover: NSPopover = NSPopover.init()
+        createFilePopover.contentViewController = vc
+        createFilePopover.animates = true
+        createFilePopover.behavior = .semitransient
+        createFilePopover.setValue(true, forKey: "shouldHideAnchor")
+        createFilePopover.show(relativeTo: CGRect(x: sender.bounds.origin.x, y: -10, width: sender.bounds.size.width, height: sender.bounds.size.height), of: sender, preferredEdge: .maxY)
+        
+//        vc.customBoxWidthLayoutConstraint.constant = self.popWidth ?? sender.frame.width
+        vc.downCallback = { [weak self](downEntered: Bool, count: String) -> Void in
+            if downEntered {
+//                if self != nil {
+//                    if self!.mouseDownAction != nil {
+//                        self!.mouseDownAction!(sender, count)
+//                    }
+//                }
+                createFilePopover.close()
+            }
+        }
+    }
 }
 
 extension KMEditPDFTextPropertyViewController: KMSelectPopButtonDelegate {
     func km_comboBoxSelectionDidChange(_ obj: KMDesignSelect) {
-        
+        if obj == textPresuppositionVC {
+            print("textPresuppositionVC")
+        }
     }
 }
 

+ 4 - 5
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarController.swift

@@ -45,6 +45,7 @@ class KMToolbarController: NSViewController {
     var toolbarItems : [NSToolbarItem.Identifier : Any] = [:]
     var listView : CPDFListView?
     var lastItemBox : KMToolBoxItem = KMToolBoxItem()
+    var lastChildItemBox : KMToolBoxItem = KMToolBoxItem()
     
     var popover: NSPopover?
     
@@ -477,15 +478,13 @@ extension KMToolbarController: KMToolbarViewControllerDelegate {
             if type == .addText || type == .addImage {
                 let boxItem = item.clickObject as? KMToolBoxItem
                 if boxItem != nil {
-                    if self.lastItemBox != boxItem {
-                        if self.lastItemBox.itemIdentifier != "KMDocumentPageEditToolbarItemIdentifier" {
-                            self.lastItemBox.isSelected = false
-                        }
+                    if self.lastChildItemBox != boxItem {
+                        self.lastChildItemBox.isSelected = false
                         boxItem!.isSelected = true
                     } else {
                         boxItem!.isSelected = !boxItem!.isSelected
                     }
-                    self.lastItemBox = boxItem!
+                    self.lastChildItemBox = boxItem!
                 }
             }