Browse Source

Merge branch 'develop_V4.1.0' of git.kdan.cc:Mac_PDF/PDF_Office into develop_V4.1.0

niehaoyu 7 months ago
parent
commit
fe32c2e775

+ 14 - 6
PDF Office/PDF Master/Class/PDFTools/EditPDF/Controller/KMEditPDFPopToolBarController.swift

@@ -162,11 +162,15 @@ class KMEditPDFPopToolBarController: NSViewController {
             
             let itemView = (self.toolbarView?.itemViews.safe_element(for: idx) as? KMEditPDFToolbarItemView)
             let viewC = (itemView?.obj as? KMDesignButton)
-            let state = viewC?.state ?? .None
-            if state == .Act {
-                viewC?.state = .Norm
+            if key == .fontAdd || key == .fontReduce {
+                
             } else {
-                viewC?.state = .Act
+                let state = viewC?.state ?? .None
+                if state == .Act {
+                    viewC?.state = .Norm
+                } else {
+                    viewC?.state = .Act
+                }
             }
             
             self._trackEvent(key: key, style: self._fetchStyle())
@@ -546,7 +550,9 @@ extension KMEditPDFPopToolBarController: KMEditPDFToolbarViewDelegate {
             viewC.borderWidth = 0
             viewC.borderWidth_hov = 0
             viewC.borderWidth_act = 0
-            viewC.state = model.isSelected ? .Act : .Norm
+            DispatchQueue.main.async {
+                viewC.state = model.isSelected ? .Act : .Norm
+            }
         } else if itemKey == .fontItalic {
             viewC.image = NSImage(named: "KMImageNameEditPDFFontItalic")!
             colorView.popToolTip = NSLocalizedString("Italic font", comment: "")
@@ -555,7 +561,9 @@ extension KMEditPDFPopToolBarController: KMEditPDFToolbarViewDelegate {
             viewC.borderWidth = 0
             viewC.borderWidth_hov = 0
             viewC.borderWidth_act = 0
-            viewC.state = model.isSelected ? .Act : .Norm
+            DispatchQueue.main.async {
+                viewC.state = model.isSelected ? .Act : .Norm
+            }
         } else if itemKey == .textAlignment {
             viewC.image = NSImage(named: "KMImageNameEditPDFAlignCenterSelect")!
             colorView.popToolTip = NSLocalizedString("Center text", comment: "")

+ 5 - 2
PDF Office/PDF Master/Class/PDFTools/EditPDF/Tools/KMEditPDfHanddler.swift

@@ -726,7 +726,9 @@ extension KMEditPDfHanddler {
             if i == 0 {
                 continue
             }
-            if width != rect.size.width {
+            
+            if abs(width-rect.size.width) > 0.01 {
+//            if width != rect.size.width {
                 return false
             }
         }
@@ -746,7 +748,8 @@ extension KMEditPDfHanddler {
             if i == 0 {
                 continue
             }
-            if height != rect.size.height {
+//            if height != rect.size.height {
+            if abs(height-rect.size.height) > 0.01 {
                 return false
             }
         }

+ 26 - 6
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditImagePropertyViewController.swift

@@ -195,16 +195,16 @@ class KMEditImagePropertyViewController: NSViewController {
         self.whVC?.image = NSImage(named: "KMImageNameEditPDFWhExchange")!
         self.whVC?.image_act = NSImage(named: "KMImageNameEditPDFWhExchangeSelected")!
         self.whVC?.pagination()
-        whVC?.borderColor_hov = KMAppearance.Interactive.s0Color()
-        whVC?.borderColor_act = KMAppearance.Interactive.s0Color()
-        whVC?.borderColor_disabled = KMAppearance.Interactive.s0Color()
+//        whVC?.borderColor_hov = KMAppearance.Interactive.s0Color()
+//        whVC?.borderColor_act = KMAppearance.Interactive.s0Color()
+//        whVC?.borderColor_disabled = KMAppearance.Interactive.s0Color()
         whVC?.cornerRadius = 4
         whVC?.cornerRadius_hov = 4
-        whVC?.cornerRadius_act = 4
+//        whVC?.cornerRadius_act = 4
         whVC?.cornerRadius_disabled = 4
         whVC?.background_hov = KMAppearance.view_bg_dis_color()
         whVC?.background_focus = KMAppearance.Layout.l1Color()
-        whVC?.background_act = KMAppearance.buttonSelectedColor()
+//        whVC?.background_act = KMAppearance.buttonSelectedColor()
         whVC?.background_disabled = KMAppearance.buttonDisabledColor()
         self.whVC?.toolTip = NSLocalizedString("Keep Proportions", comment: "")
         self.whVC?.state = self._getKeepProportionsButtonState() ? .Act : .Norm
@@ -513,7 +513,7 @@ class KMEditImagePropertyViewController: NSViewController {
                 self.turnOverBox.isHidden = false
                 self.opacityTitleLabel.isHidden = false
                 
-                self.whVC?.state = .Disabled
+                self._updateWHProportionButtonEnableState()
                 self.cropVC?.state = .Disabled
                 self.replaceVC?.state = .Disabled
                 
@@ -660,6 +660,8 @@ class KMEditImagePropertyViewController: NSViewController {
         }
     }
     
+    // MARK: - Private Methods
+    
     private func changeAreasAlign(areas:[Any],newBounds:[String]) {
         var oldBounds : [String] = []
         for i in 0 ... areas.count-1 {
@@ -682,6 +684,16 @@ class KMEditImagePropertyViewController: NSViewController {
         return state as? Bool ?? defaultV
     }
     
+    private func _updateWHProportionButtonEnableState() {
+        let wEqual = self.handdler?.editAreasBoundsIsEqualForWidth() ?? false
+        let hEqual = self.handdler?.editAreasBoundsIsEqualForHeight() ?? false
+        if (wEqual && hEqual) {
+            self.whVC?.state = self._getKeepProportionsButtonState() ? .Act : .Norm
+        } else {
+            self.whVC?.state = .Disabled
+        }
+    }
+    
     private func _trackEvent() {
         kTrackEventManager.trackEvent(event: "SubTbr_EditPDF", withProperties: ["SubTbr_EditImage":"SubTbr_EditImage_PropertiesPanel_All"])
     }
@@ -968,6 +980,10 @@ extension KMEditImagePropertyViewController: KMTextFieldDelegate {
 
                 self.listView.setBoundsEditArea(area, withBounds: bounds)
             }
+            
+            DispatchQueue.main.async {
+                self._updateWHProportionButtonEnableState()
+            }
         } else if self.hTextFieldItemView.isEqual(to: textField) {
             let number = NSNumber(value: Int(self.hTextFieldItemView.stringValue ?? "") ?? 0)
             let string = self.hTextFieldItemView.textFiled.formatter?.string(for: number)
@@ -1010,6 +1026,10 @@ extension KMEditImagePropertyViewController: KMTextFieldDelegate {
                 
                 self.listView.setBoundsEditArea(area, withBounds: bounds)
             }
+            
+            DispatchQueue.main.async {
+                self._updateWHProportionButtonEnableState()
+            }
         } else if self.rotateTextFieldItemView.isEqual(to: textField) {
 //            let stringValue = self.rotateTextFieldItemView.stringValue
 //            let number = NSNumber(value: Int(stringValue ?? "") ?? 0)

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -1198,7 +1198,7 @@ import Cocoa
                 self.exitDigitalSign()
             }
         }
-        if toolbarItem.itemIdentifier != KMDocumentEditToolbarItemIdentifier {
+        if toolbarItem.itemIdentifier != KMDocumentEditToolbarItemIdentifier && toolbarItem.itemIdentifier != KMRightControlToolbarItemIdentifier && toolbarItem.itemIdentifier != KMLeftControlToolbarItemIdentifier {
             self.editPDFHanddler.clearData()
         }
     }