Преглед изворни кода

【文字图片编辑】图片编辑多选操作优化

lizhe пре 1 година
родитељ
комит
90ab02b04b

+ 50 - 20
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditImagePropertyViewController.swift

@@ -21,10 +21,12 @@ class KMEditImagePropertyViewController: NSViewController {
     
     @IBOutlet weak var headerBox: NSBox!
     @IBOutlet weak var headerBoxHeight: NSLayoutConstraint!
+    @IBOutlet weak var headerBoxMaginWidthConstraint: NSLayoutConstraint!
     
     @IBOutlet weak var opacityTitleLabel: NSTextField!
     @IBOutlet weak var opacitySlider: NSSlider!
     @IBOutlet weak var opacityBox: NSBox!
+    @IBOutlet weak var opacityBoxBottomMaginConstraint: NSLayoutConstraint!
     
     @IBOutlet weak var cropBox: NSBox!
     @IBOutlet weak var cancelBox: NSBox!
@@ -113,6 +115,7 @@ class KMEditImagePropertyViewController: NSViewController {
         rotateLeftVC?.target = self
         rotateLeftVC?.action = #selector(leftRotationImageAction)
         rotateLeftVC?.image = NSImage(named: "KMImageNameEditPDFRotationLeft")!
+        rotateLeftVC?._image_disabled = NSImage(named: "KMImageNameEditPDFRotationLeft")!
         rotateLeftVC?.updateUI()
         
         rotateRightVC = KMDesignPropertySelector.init(withType: .Icon_Btn)
@@ -210,10 +213,12 @@ class KMEditImagePropertyViewController: NSViewController {
                 self.listView.selectImageAreas = imagesAreas.first
                 self.headerBox.isHidden = false
                 self.headerBoxHeight.constant = 176
+                self.headerBoxMaginWidthConstraint.constant = 8
                 self.imageBox.isHidden = false
                 self.imageBoxHeight.constant = 88
                 self.opacityBox.isHidden = false
-                self.opacityBoxHeight.constant = 68
+                self.opacityBoxHeight.constant = 56
+                self.opacityBoxBottomMaginConstraint.constant = 16
                 self.buttonBox.isHidden = false
                 self.cropBox.isHidden = false
                 self.cancelBox.isHidden = false
@@ -225,11 +230,13 @@ class KMEditImagePropertyViewController: NSViewController {
                 self.updateImageAreasOpacity(opacity: opacity, state: .ended, needListView: false)
             } else if imagesAreas.count > 1 && imagesAreas.count == areas.count { //多选图片
                 self.headerBox.isHidden = false
-                self.headerBoxHeight.constant = 80
+                self.headerBoxHeight.constant = 82
+                self.headerBoxMaginWidthConstraint.constant = 0
                 self.imageBox.isHidden = true
                 self.imageBoxHeight.constant = 0
                 self.opacityBox.isHidden = false
-                self.opacityBoxHeight.constant = 68
+                self.opacityBoxHeight.constant = 56
+                self.opacityBoxBottomMaginConstraint.constant = 0
                 self.buttonBox.isHidden = false
                 self.cropBox.isHidden = true
                 self.cancelBox.isHidden = true
@@ -261,14 +268,26 @@ class KMEditImagePropertyViewController: NSViewController {
             self.cancelBox.isHidden = true
             self.cropBoxWidthConstraint.constant = 0
             self.cropBox.title = NSLocalizedString("Crop", comment: "")
-//            self.replaceVC?.state = .Norm
-//            self.exportVC?.state = .Norm
+            self.replaceVC?.state = .Norm
+            self.exportVC?.state = .Norm
+            self.opacitySlider.isEnabled = true
+            self.opacityVC?.state = .Norm
+            self.rotateLeftVC?.state = .Norm
+            self.rotateRightVC?.state = .Norm
+            self.flipVerticalVC?.state = .Norm
+            self.flipHorizontalVC?.state = .Norm
         } else {
             self.cancelBox.isHidden = false
             self.cropBoxWidthConstraint.constant = 120
             self.cropBox.title = NSLocalizedString("Confirm Cut", comment: "")
-//            self.replaceVC?.state = .Disabled
-//            self.exportVC?.state = .Disabled
+            self.replaceVC?.state = .Disabled
+            self.exportVC?.state = .Disabled
+            self.opacitySlider.isEnabled = false
+            self.opacityVC?.state = .Disabled
+            self.rotateLeftVC?.state = .Disabled
+            self.rotateRightVC?.state = .Disabled
+            self.flipVerticalVC?.state = .Disabled
+            self.flipHorizontalVC?.state = .Disabled
         }
     }
     
@@ -280,7 +299,8 @@ class KMEditImagePropertyViewController: NSViewController {
                 }
             }
             
-            if self.listView.editingAreas()!.count == 1 && (self.listView.editingAreas()!.first is CPDFEditImageArea) {
+//            self.listView.editingAreas()!.count == 1 &&
+            if (self.listView.editingAreas()?.first is CPDFEditImageArea) {
                 self.listView.selectImageAreas = self.listView.editingAreas()!.first as? CPDFEditImageArea
                 self.editImageView.image = self.listView.selectImageAreas.thumbnailImage
                 self.opacitySlider.objectValue = self.listView.opacity(for: self.listView.selectImageAreas)
@@ -373,12 +393,18 @@ extension KMEditImagePropertyViewController {
             return
         }
         let areas = self.listView.editingAreas()
-        if areas!.count == 1 && (areas!.first is CPDFEditImageArea) {
-            self.listView.horizontalMirror(with: self.listView.selectImageAreas)
-            self.editImageView.image = self.listView.selectImageAreas.thumbnailImage
-        } else {
-            for imagesArea in imagesAreas {
-                self.listView.horizontalMirror(with: self.listView.selectImageAreas)
+        if areas != nil {
+            for item in areas! {
+                if item is CPDFEditImageArea {
+                    self.listView.horizontalMirror(with: item as? CPDFEditImageArea)
+                    if areas?.count == 1 {
+                        self.editImageView.image = (item as AnyObject).thumbnailImage
+                    }
+                } else {
+                    for imagesArea in imagesAreas {
+                        self.listView.horizontalMirror(with: imagesArea)
+                    }
+                }
             }
         }
     }
@@ -388,12 +414,16 @@ extension KMEditImagePropertyViewController {
             return
         }
         let areas = self.listView.editingAreas()
-        if areas!.count == 1 && (areas!.first is CPDFEditImageArea) {
-            self.listView.verticalMirror(with: self.listView.selectImageAreas)
-            self.editImageView.image = self.listView.selectImageAreas.thumbnailImage
-        } else {
-            for imagesArea in imagesAreas {
-                self.listView.verticalMirror(with: self.listView.selectImageAreas)
+        if areas != nil {
+            for item in areas! {
+                if item is CPDFEditImageArea {
+                    self.listView.verticalMirror(with: item as? CPDFEditImageArea)
+                    self.editImageView.image = self.listView.selectImageAreas.thumbnailImage
+                } else {
+                    for imagesArea in imagesAreas {
+                        self.listView.verticalMirror(with: imagesArea)
+                    }
+                }
             }
         }
     }

+ 21 - 19
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditImagePropertyViewController.xib

@@ -19,9 +19,11 @@
                 <outlet property="flipVerticalBox" destination="qRi-Cl-0oE" id="ice-B3-agn"/>
                 <outlet property="headerBox" destination="6yW-By-Sg9" id="7g9-Ja-zZN"/>
                 <outlet property="headerBoxHeight" destination="2Nc-Uj-EEg" id="g90-0Y-Ajz"/>
+                <outlet property="headerBoxMaginWidthConstraint" destination="qGk-qT-mBb" id="2qA-NH-y7u"/>
                 <outlet property="imageBox" destination="5y4-Y4-XuO" id="29i-qF-x7l"/>
                 <outlet property="imageBoxHeight" destination="lWK-rG-QR4" id="Gqy-86-ey9"/>
                 <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="opacitySlider" destination="Z0O-zt-cBQ" id="lW1-SW-S3f"/>
                 <outlet property="opacityTitleLabel" destination="XPI-yz-g9u" id="NH7-jW-9Vn"/>
@@ -46,13 +48,13 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <box borderType="none" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="qjn-Az-nK1">
-                                <rect key="frame" x="10" y="240" width="240" height="68"/>
+                                <rect key="frame" x="10" y="252" width="240" height="56"/>
                                 <view key="contentView" id="vpF-9O-Amq">
-                                    <rect key="frame" x="0.0" y="0.0" width="240" height="68"/>
+                                    <rect key="frame" x="0.0" y="0.0" width="240" height="56"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <subviews>
                                         <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XPI-yz-g9u">
-                                            <rect key="frame" x="-2" y="52" width="49" height="16"/>
+                                            <rect key="frame" x="-2" y="40" width="49" height="16"/>
                                             <textFieldCell key="cell" lineBreakMode="clipping" title="opacity" id="LXH-cy-YvE">
                                                 <font key="font" usesAppearanceFont="YES"/>
                                                 <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -60,7 +62,7 @@
                                             </textFieldCell>
                                         </textField>
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="GOt-dw-CGs">
-                                            <rect key="frame" x="0.0" y="12" width="240" height="32"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="240" height="32"/>
                                             <subviews>
                                                 <slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Z0O-zt-cBQ">
                                                     <rect key="frame" x="-2" y="0.0" width="144" height="28"/>
@@ -100,7 +102,7 @@
                                     </constraints>
                                 </view>
                                 <constraints>
-                                    <constraint firstAttribute="height" constant="68" id="pQN-DI-xiY"/>
+                                    <constraint firstAttribute="height" constant="56" id="pQN-DI-xiY"/>
                                 </constraints>
                             </box>
                             <box borderType="none" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="6yW-By-Sg9">
@@ -220,11 +222,23 @@
                                 </constraints>
                             </box>
                             <box boxType="custom" borderType="none" borderWidth="0.0" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="9za-vG-ihA">
-                                <rect key="frame" x="16" y="112" width="228" height="112"/>
+                                <rect key="frame" x="16" y="124" width="228" height="112"/>
                                 <view key="contentView" id="ZP8-0e-bWE">
                                     <rect key="frame" x="0.0" y="0.0" width="228" height="112"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <subviews>
+                                        <box boxType="custom" borderWidth="0.0" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="vr8-ml-OC0">
+                                            <rect key="frame" x="118" y="80" width="110" height="32"/>
+                                            <view key="contentView" id="5bE-LY-pCd">
+                                                <rect key="frame" x="0.0" y="0.0" width="110" height="32"/>
+                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                            </view>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="32" id="10w-cb-xaQ"/>
+                                                <constraint firstAttribute="width" constant="110" id="pkB-tF-Moj"/>
+                                            </constraints>
+                                            <color key="fillColor" red="0.92156862750000001" green="0.92156862750000001" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                        </box>
                                         <box boxType="custom" borderWidth="0.0" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="AAt-gQ-hOo">
                                             <rect key="frame" x="0.0" y="80" width="228" height="32"/>
                                             <view key="contentView" id="d4R-c0-wzQ">
@@ -247,18 +261,6 @@
                                             </constraints>
                                             <color key="fillColor" red="0.92156862750000001" green="0.92156862750000001" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                         </box>
-                                        <box boxType="custom" borderWidth="0.0" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="vr8-ml-OC0">
-                                            <rect key="frame" x="118" y="80" width="110" height="32"/>
-                                            <view key="contentView" id="5bE-LY-pCd">
-                                                <rect key="frame" x="0.0" y="0.0" width="110" height="32"/>
-                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                            </view>
-                                            <constraints>
-                                                <constraint firstAttribute="height" constant="32" id="10w-cb-xaQ"/>
-                                                <constraint firstAttribute="width" constant="110" id="pkB-tF-Moj"/>
-                                            </constraints>
-                                            <color key="fillColor" red="0.92156862750000001" green="0.92156862750000001" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                                        </box>
                                         <box boxType="custom" borderWidth="0.0" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="8lZ-Kd-hWi">
                                             <rect key="frame" x="0.0" y="0.0" width="228" height="32"/>
                                             <view key="contentView" id="dx8-kP-W3q">
@@ -290,7 +292,7 @@
                                 </constraints>
                             </box>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="3AP-7h-Nfc" customClass="KMEditPropertyAlignmentView" customModule="PDF_Master" customModuleProvider="target">
-                                <rect key="frame" x="16" y="-4" width="228" height="100"/>
+                                <rect key="frame" x="16" y="8" width="228" height="100"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="100" id="fcW-mh-2WD"/>
                                 </constraints>