Browse Source

【文字图片编辑】多选属性面板变化调整

lizhe 1 year ago
parent
commit
6ff6d024f5

+ 32 - 13
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditImagePropertyViewController.swift

@@ -27,6 +27,7 @@ class KMEditImagePropertyViewController: NSViewController {
     @IBOutlet weak var opacitySlider: NSSlider!
     @IBOutlet weak var opacityBox: NSBox!
     @IBOutlet weak var opacityBoxBottomMaginConstraint: NSLayoutConstraint!
+    @IBOutlet weak var opacityBoxTopConstraint: NSLayoutConstraint!
     
     @IBOutlet weak var cropBox: NSBox!
     @IBOutlet weak var confirmBox: NSBox!
@@ -44,6 +45,9 @@ class KMEditImagePropertyViewController: NSViewController {
     @IBOutlet weak var flipHorizontalBox: NSBox!
     @IBOutlet weak var flipVerticalBox: NSBox!
     
+    @IBOutlet weak var alignmentView: KMEditPropertyAlignmentView!
+    @IBOutlet weak var alignmentViewTopConstraint: NSLayoutConstraint!
+    
     var rotateLeftVC: KMDesignPropertySelector?
     var rotateRightVC: KMDesignPropertySelector?
     var flipHorizontalVC: KMDesignPropertySelector?
@@ -56,7 +60,6 @@ class KMEditImagePropertyViewController: NSViewController {
     var replaceVC: KMDesignButton?
     var exportVC: KMDesignButton?
     
-    @IBOutlet weak var alignmentView: KMEditPropertyAlignmentView!
     var imagesAreas : [CPDFEditImageArea] = []
     var listView : CPDFListView!
     
@@ -193,8 +196,14 @@ class KMEditImagePropertyViewController: NSViewController {
         exportVC?.updateUI()
     }
     
-    func updateLanguage(){
-        self.titleLabel.stringValue = NSLocalizedString("Image", comment: "")
+    func updateLanguage() {
+        let areas = self.editingAreas
+        if imagesAreas.count > 0 && imagesAreas.count != areas.count { //多选图片跟文字
+            self.titleLabel.stringValue = NSLocalizedString("General Properties", comment: "")
+        } else {
+            self.titleLabel.stringValue = NSLocalizedString("Image", comment: "")
+        }
+        
         self.opacityTitleLabel.stringValue = NSLocalizedString("Opacity", comment: "")
         self.cropVC?.stringValue = NSLocalizedString("Crop", comment: "")
         self.confirmVC?.stringValue = NSLocalizedString("Confirm Cut", comment: "")
@@ -224,12 +233,14 @@ class KMEditImagePropertyViewController: NSViewController {
                 self.opacityBox.isHidden = false
                 self.opacityBoxHeight.constant = 56
                 self.opacityBoxBottomMaginConstraint.constant = 16
+                self.opacityBoxTopConstraint.constant = 16
                 self.buttonBox.isHidden = false
                 self.cropBox.isHidden = false
                 self.cancelBox.isHidden = false
                 self.replaceBox.isHidden = false
                 self.buttonBoxHeight.constant = 112
                 self.editImageView.image = self.listView.selectImageAreas.thumbnailImage
+                self.alignmentViewTopConstraint.constant = 16
 
                 let opacity: CGFloat = self.listView.opacity(for: imagesAreas.first)
                 self.updateImageAreasOpacity(opacity: opacity, state: .ended, needListView: false)
@@ -242,11 +253,13 @@ class KMEditImagePropertyViewController: NSViewController {
                 self.opacityBox.isHidden = false
                 self.opacityBoxHeight.constant = 56
                 self.opacityBoxBottomMaginConstraint.constant = 0
+                self.opacityBoxTopConstraint.constant = 0
                 self.buttonBox.isHidden = false
                 self.cropBox.isHidden = true
                 self.cancelBox.isHidden = true
                 self.replaceBox.isHidden = true
                 self.buttonBoxHeight.constant = 0
+                self.alignmentViewTopConstraint.constant = 16
                 var opacity = self.listView.opacity(for: imagesAreas.first)
                 for area in imagesAreas {
                     let newOpacity = self.listView.opacity(for: area)
@@ -256,8 +269,12 @@ class KMEditImagePropertyViewController: NSViewController {
                 }
                 self.updateImageAreasOpacity(opacity: opacity, state: .ended, needListView: false)
             } else if imagesAreas.count > 0 && imagesAreas.count != areas.count { //多选图片跟文字
-                self.headerBox.isHidden = true
-                self.headerBoxHeight.constant = 0
+                self.opacityBoxBottomMaginConstraint.constant = 0
+                self.headerBoxMaginWidthConstraint.constant = 0
+                self.alignmentViewTopConstraint.constant = 0
+                self.opacityBoxTopConstraint.constant = 0
+//                self.headerBox.isHidden = true
+                self.headerBoxHeight.constant = 48
                 self.imageBox.isHidden = true
                 self.imageBoxHeight.constant = 0
                 self.opacityBox.isHidden = true
@@ -265,6 +282,7 @@ class KMEditImagePropertyViewController: NSViewController {
                 self.buttonBox.isHidden = true
                 self.buttonBoxHeight.constant = 0
             }
+            self.updateLanguage()
         }
     }
     
@@ -496,20 +514,21 @@ extension KMEditImagePropertyViewController {
         if imagesAreas.count == 1 {
             let panel = NSSavePanel()
             panel.nameFieldStringValue = "\(NSLocalizedString("Untitled", comment: "")).png"
-            let button = NSButton.init(checkboxWithTitle: NSLocalizedString("Open the document after saving", comment: ""), target: nil, action: nil)
-            button.state = .on
-            panel.accessoryView = button
+//            let button = NSButton.init(checkboxWithTitle: NSLocalizedString("Open the document after saving", comment: ""), target: nil, action: nil)
+//            button.state = .on
+//            panel.accessoryView = button
             panel.isExtensionHidden = true
             let response = panel.runModal()
             if response == .OK {
                 let url = panel.url
                 let result = self.listView.extractImage(with: self.listView.selectImageAreas, toImagePath: url!.path)
                 if result {
-                    if button.state == .on { /// 开启文档
-                        NSWorkspace.shared.openFile(url!.path)
-                    } else {
-                        
-                    }
+//                    if button.state == .on { /// 开启文档
+//                        NSWorkspace.shared.openFile(url!.path)
+                    NSWorkspace.shared.activateFileViewerSelecting([url!])
+//                    } else {
+//
+//                    }
                 }
             }
         } else if imagesAreas.count > 1 {

+ 2 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditImagePropertyViewController.xib

@@ -8,6 +8,7 @@
         <customObject id="-2" userLabel="File's Owner" customClass="KMEditImagePropertyViewController" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="alignmentView" destination="3AP-7h-Nfc" id="loc-yn-FkQ"/>
+                <outlet property="alignmentViewTopConstraint" destination="Vog-68-6WN" id="Qqk-9Z-zrD"/>
                 <outlet property="buttonBox" destination="9za-vG-ihA" id="m1z-pN-ORp"/>
                 <outlet property="buttonBoxHeight" destination="q4K-hM-hqe" id="4Tg-z0-d6c"/>
                 <outlet property="cancelBox" destination="vr8-ml-OC0" id="kUB-8H-yo0"/>
@@ -25,6 +26,7 @@
                 <outlet property="opacityBox" destination="9ig-7b-xDq" id="Nlc-yf-4BI"/>
                 <outlet property="opacityBoxBottomMaginConstraint" destination="agw-2V-YyY" id="rjO-EG-goy"/>
                 <outlet property="opacityBoxHeight" destination="pQN-DI-xiY" id="xvF-Br-Df7"/>
+                <outlet property="opacityBoxTopConstraint" destination="pMH-jX-v3E" id="0oh-Dc-ukD"/>
                 <outlet property="opacitySlider" destination="Z0O-zt-cBQ" id="lW1-SW-S3f"/>
                 <outlet property="opacityTitleLabel" destination="XPI-yz-g9u" id="NH7-jW-9Vn"/>
                 <outlet property="replaceBox" destination="dSf-T8-3R3" id="WIv-EB-D9V"/>

+ 40 - 8
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditPDFTextPropertyViewController.swift

@@ -35,13 +35,17 @@ class KMEditPDFTextPropertyViewController: NSViewController {
     @IBOutlet weak var propertyTitle: NSTextField!
     @IBOutlet weak var preImageView: NSImageView!
     
+    @IBOutlet weak var textPresuppositionContentView: NSView!
     @IBOutlet weak var textPresuppositionBox: NSBox!
     @IBOutlet weak var resetTextPresuppositionBox: NSBox!
     @IBOutlet weak var textPresuppositionTopContstraint: NSLayoutConstraint!
+    @IBOutlet weak var textPresuppositionHeightContstraint: NSLayoutConstraint!
     
     @IBOutlet weak var fontContentView: NSView!
     @IBOutlet weak var fontTitleLabel: NSTextField!
     @IBOutlet weak var fontImageView: NSButton!
+    @IBOutlet weak var fontContentViewHeightConstraint: NSLayoutConstraint!
+    @IBOutlet weak var fontContentViewTopConstraint: NSLayoutConstraint!
     
     @IBOutlet weak var fontNameBox: NSBox!
     @IBOutlet weak var fontStyleBox: NSBox!
@@ -55,6 +59,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
     @IBOutlet weak var fontColorButton: NSButton!
     @IBOutlet weak var fontCustomColorButton: NSButton!
     
+    @IBOutlet weak var alignmentTopConstraint: NSLayoutConstraint!
     @IBOutlet weak var alignmentView: KMEditPropertyAlignmentView!
     
     var textPresuppositionVC: KMDesignSelect?
@@ -105,6 +110,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
         self.setup()
         self.initData()
         self.reloadData()
+        self.updateLanguage()
     }
     
     func setup() {
@@ -228,7 +234,14 @@ class KMEditPDFTextPropertyViewController: NSViewController {
     }
     
     func updateLanguage() {
+        let areas = self.listView.editingAreas() ?? []
+        if textsAreas.count > 0 && textsAreas.count != areas.count { //多选图片跟文字
+            self.propertyTitle.stringValue = NSLocalizedString("General Properties", comment: "")
+        } else {
+            self.propertyTitle.stringValue = NSLocalizedString("Text", comment: "")
+        }
         
+        self.fontTitleLabel.stringValue = NSLocalizedString("Font", comment: "")
     }
     
     func reloadData() {
@@ -236,25 +249,44 @@ class KMEditPDFTextPropertyViewController: NSViewController {
             self.listView.editingAreas().count > 0 {
             textsAreas = []
             
-            let areas = self.listView.editingAreas()
-            self.alignmentView.editingAreas = areas ?? []
-            
-            for i in 0 ... areas!.count-1 {
-                if areas![i] is CPDFEditTextArea {
-                    textsAreas.append(areas![i] as! CPDFEditTextArea)
+            let areas = self.listView.editingAreas() ?? []
+            self.alignmentView.editingAreas = areas
+            for i in 0 ... areas.count-1 {
+                if areas[i] is CPDFEditTextArea {
+                    textsAreas.append(areas[i] as! CPDFEditTextArea)
                 }
             }
-            if textsAreas.count == 1 {
+            if textsAreas.count == 1 && textsAreas.count == areas.count {
                 self.headerBox.isHidden = false
+                self.fontContentView.isHidden = false
+                self.textPresuppositionContentView.isHidden = false
                 self.imageViewHeightConstraint.constant = 88
                 self.textPresuppositionTopContstraint.constant = 152
-            } else if textsAreas.count > 1 {
+                self.fontContentViewHeightConstraint.constant = 153
+                self.alignmentTopConstraint.constant = 16
+                self.fontContentViewTopConstraint.constant = 8
+            } else if textsAreas.count > 1 && textsAreas.count == areas.count {
                 self.headerBox.isHidden = true
+                self.fontContentView.isHidden = false
+                self.textPresuppositionContentView.isHidden = false
                 self.imageViewHeightConstraint.constant = 0
                 self.textPresuppositionTopContstraint.constant = 50
+                self.fontContentViewHeightConstraint.constant = 153
+                self.alignmentTopConstraint.constant = 16
+                self.fontContentViewTopConstraint.constant = 8
+            } else if textsAreas.count > 0 && textsAreas.count != areas.count { //多选图片跟文字
+                self.headerBox.isHidden = true
+                self.fontContentView.isHidden = true
+                self.textPresuppositionContentView.isHidden = true
+                self.fontContentViewHeightConstraint.constant = 0
+                self.textPresuppositionTopContstraint.constant = 16
+                self.imageViewHeightConstraint.constant = 0
+                self.alignmentTopConstraint.constant = 0
+                self.fontContentViewTopConstraint.constant = 0
             }
             
             self.refreshSelectAreaProperty()
+            self.updateLanguage()
         }
     }
     

+ 6 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditPDFTextPropertyViewController.xib

@@ -8,12 +8,15 @@
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="KMEditPDFTextPropertyViewController" customModule="PDF_Master" customModuleProvider="target">
             <connections>
+                <outlet property="alignmentTopConstraint" destination="UEJ-wK-qqM" id="L36-e1-XfJ"/>
                 <outlet property="alignmentView" destination="Oi3-L1-ffT" id="rBC-Tk-pG6"/>
                 <outlet property="centerAlignmentBox" destination="rXF-2b-cRj" id="fi9-sF-XfO"/>
                 <outlet property="colorBox" destination="Dcy-0U-AoP" id="ADd-OX-dJd"/>
                 <outlet property="contentView" destination="dAY-3A-lfL" id="mu3-cD-1Tc"/>
                 <outlet property="fontColorButton" destination="KRu-kj-Nkf" id="Jpy-RT-33W"/>
                 <outlet property="fontContentView" destination="LHG-XG-Y6G" id="Jjo-I3-Qjb"/>
+                <outlet property="fontContentViewHeightConstraint" destination="C7Q-H9-QI3" id="WlD-J7-HJN"/>
+                <outlet property="fontContentViewTopConstraint" destination="hQa-vT-vVO" id="DCi-0F-9gd"/>
                 <outlet property="fontCustomColorButton" destination="Rrw-k0-Lul" id="GpU-DA-0uw"/>
                 <outlet property="fontImageView" destination="Ae7-Z5-hap" id="7eg-xn-7T2"/>
                 <outlet property="fontNameBox" destination="UTw-eO-Jvo" id="Azp-fI-lGq"/>
@@ -29,6 +32,8 @@
                 <outlet property="resetTextPresuppositionBox" destination="cZ0-Lb-7rt" id="NTl-SG-HeT"/>
                 <outlet property="rightAlignmentBox" destination="LB3-jb-9Hl" id="fLg-Cb-V6u"/>
                 <outlet property="textPresuppositionBox" destination="Pd8-gf-nbc" id="sMR-ru-581"/>
+                <outlet property="textPresuppositionContentView" destination="c0i-e8-xpM" id="Ki0-0n-7IM"/>
+                <outlet property="textPresuppositionHeightContstraint" destination="4Db-zz-MLg" id="93s-uo-67s"/>
                 <outlet property="textPresuppositionTopContstraint" destination="eXm-YW-Pwj" id="pUO-ce-FC5"/>
                 <outlet property="view" destination="4mG-P9-QH2" id="rSY-kX-3d6"/>
             </connections>
@@ -222,6 +227,7 @@
                                     <constraint firstItem="2gN-hL-7Ez" firstAttribute="leading" secondItem="LHG-XG-Y6G" secondAttribute="leading" id="9RC-zj-BJv"/>
                                     <constraint firstItem="2gN-hL-7Ez" firstAttribute="top" secondItem="LHG-XG-Y6G" secondAttribute="top" constant="8" id="9fv-Yt-Hkh"/>
                                     <constraint firstItem="Ae7-Z5-hap" firstAttribute="centerY" secondItem="2gN-hL-7Ez" secondAttribute="centerY" id="BTJ-rI-dsN"/>
+                                    <constraint firstAttribute="height" constant="153" id="C7Q-H9-QI3"/>
                                     <constraint firstAttribute="bottom" secondItem="LB3-jb-9Hl" secondAttribute="bottom" constant="5" id="Cn1-DH-y8f"/>
                                     <constraint firstItem="1Xr-1z-9Ud" firstAttribute="width" secondItem="AHN-i5-WYB" secondAttribute="width" id="FpD-Fa-wDR"/>
                                     <constraint firstItem="LB3-jb-9Hl" firstAttribute="leading" secondItem="rXF-2b-cRj" secondAttribute="trailing" constant="8" id="Hf9-Ha-1nV"/>