Browse Source

【fix】【内容编辑】选中文本框后,对其方式下拉框,需要选中一个默认选中状态

TangChao 7 months ago
parent
commit
3cb8e8c45b

+ 11 - 0
PDF Office/PDF Master/Class/PDFTools/EditPDF/Controller/KMEditPDFPopToolBarController.swift

@@ -236,6 +236,9 @@ class KMEditPDFPopToolBarController: NSViewController {
         createFilePopover.setValue(true, forKey: "shouldHideAnchor")
         createFilePopover.show(relativeTo: CGRect(x: sender.bounds.origin.x, y: 20, width: sender.bounds.size.width, height: sender.bounds.size.height), of: sender, preferredEdge: .maxY)
         
+        let model = self.datas.safe_element(for: sender.tag) as? KMEditPDFToolbarModel
+        vc.align = model?.textAlign ?? .center
+        
         self.popover_ = createFilePopover
         
         vc.itemAction = { [weak self] idx, _ in
@@ -458,6 +461,14 @@ extension KMEditPDFPopToolBarController: KMEditPDFToolbarViewDelegate {
             viewC.borderWidth = 0
             viewC.borderWidth_hov = 0
             viewC.borderWidth_act = 0
+            if KMAppearance.isDarkMode() {
+                viewC.background = NSColor.clear
+                viewC.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
+                viewC.background_act = KMAppearance.Interactive.m1Color()
+            } else {
+                
+            }
+            
             DispatchQueue.main.async {
                 viewC.state = model.isSelected ? .Act : .Norm
             }

+ 46 - 0
PDF Office/PDF Master/Class/PDFTools/EditPDF/Controller/KMTextAlignmentController.swift

@@ -18,6 +18,25 @@ class KMTextAlignmentController: NSViewController {
     
     var itemAction: KMCommonClickBlock?
     
+    var align: NSTextAlignment = .center {
+        didSet {
+            let data = self.align
+            if data == .left {
+                self.leftVc_?.state = .Act
+                self.centerVc_?.state = .Norm
+                self.rightVc_?.state = .Norm
+            } else if data == .center {
+                self.leftVc_?.state = .Norm
+                self.centerVc_?.state = .Act
+                self.rightVc_?.state = .Norm
+            } else if data == .right {
+                self.leftVc_?.state = .Norm
+                self.centerVc_?.state = .Norm
+                self.rightVc_?.state = .Act
+            }
+        }
+    }
+    
     override func viewDidLoad() {
         super.viewDidLoad()
         
@@ -32,6 +51,11 @@ class KMTextAlignmentController: NSViewController {
         self.leftVc_?.image = NSImage(named: "KMImageNameEditPDFAlignLeftSelect")!
         self.leftVc_?.tag = 0
         
+        self.leftVc_?.initDefaultValue()
+        self.leftVc_?.borderWidth = 0
+        self.leftVc_?.borderWidth_hov = 0
+        self.leftVc_?.borderWidth_act = 0
+        
         self.centerVc_ = KMDesignButton(withType: .Image)
         self.centerBox.contentView = self.centerVc_!.view
         self.centerBox.borderWidth = 0
@@ -41,6 +65,11 @@ class KMTextAlignmentController: NSViewController {
         self.centerVc_?.image = NSImage(named: "KMImageNameEditPDFAlignCenterSelect")!
         self.centerVc_?.tag = 1
         
+        self.centerVc_?.initDefaultValue()
+        self.centerVc_?.borderWidth = 0
+        self.centerVc_?.borderWidth_hov = 0
+        self.centerVc_?.borderWidth_act = 0
+        
         self.rightVc_ = KMDesignButton(withType: .Image)
         self.rightBox.contentView = self.rightVc_!.view
         self.rightBox.borderWidth = 0
@@ -50,6 +79,11 @@ class KMTextAlignmentController: NSViewController {
         self.rightVc_?.image = NSImage(named: "KMImageNameEditPDFAlignRightSelect")!
         self.rightVc_?.tag = 2
         
+        self.rightVc_?.initDefaultValue()
+        self.rightVc_?.borderWidth = 0
+        self.rightVc_?.borderWidth_hov = 0
+        self.rightVc_?.borderWidth_act = 0
+        
         self.reloadData()
     }
     
@@ -63,6 +97,18 @@ class KMTextAlignmentController: NSViewController {
             self.leftVc_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
             self.centerVc_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
             self.rightVc_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
+            
+            leftVc_?.background = NSColor.clear
+            leftVc_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
+            leftVc_?.background_act = KMAppearance.Interactive.m1Color()
+            
+            centerVc_?.background = NSColor.clear
+            centerVc_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
+            centerVc_?.background_act = KMAppearance.Interactive.m1Color()
+            
+            rightVc_?.background = NSColor.clear
+            rightVc_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
+            rightVc_?.background_act = KMAppearance.Interactive.m1Color()
         } else {
             self.view.layer?.backgroundColor = .white
             self.leftVc_?.background_hov = NSColor(red: 237/255, green: 238/255, blue: 240/255, alpha: 1)

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

@@ -1166,7 +1166,7 @@ extension KMEditImagePropertyViewController: KMTextFieldDelegate {
 //            let stringValue = self.rotateTextFieldItemView.stringValue
 //            let number = NSNumber(value: Int(stringValue ?? "") ?? 0)
 //            let formatter = NumberFormatter()
-//            let string = formatter.string(for: stringValue)
+//            let string = formatter.string(for: number)
 //            let string = self.rotateTextFieldItemView.kFormatter?.string(for: number)
 //            self.rotateTextFieldItemView.stringValue = string
         }