Browse Source

【2025】【PDFView】Pop线段宽度框限制最小值或者最大值时按钮置灰

dinglingui 3 weeks ago
parent
commit
ad8eb1cd6f

+ 2 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFListViewExtension/CPDFListView+UndoManager.m

@@ -65,6 +65,8 @@ static NSString *CPDFListViewAnnotationPropertiesObservationContext = @"CPDFList
         CPDFPage *page = note.page;
         if(([note isKindOfClass:[CPDFTextAnnotation class]] || [note isKindOfClass:[CPDFFreeTextAnnotation class]]) && note.contents.length < 1)
             [self removeAnnotation:note];
+        else if ([note isKindOfClass:[CPDFMarkupAnnotation class]])
+            [self updateHighLightAnnotationViewForPage:note.page];
          else
             [self setNeedsDisplayAnnotationViewForPage:note.page];
     }

+ 42 - 0
PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopAnnotationViewController.swift

@@ -72,6 +72,8 @@ class KMNPopAnnotationViewController: KMNBaseViewController {
                 operationBox.contentView = shapeView
                 
                 congfigShapePopUI()
+                
+                updateShapeWidthButtonState()
                 break
             case .linkAnnotation:
                 if let newLinkAnnotation = annotationPopMode.annotation as? CPDFLinkAnnotation {
@@ -638,6 +640,44 @@ class KMNPopAnnotationViewController: KMNBaseViewController {
         generaColorGroup.delegate = self
     }
     
+    private func updateShapeWidthButtonState() {
+        let annotations = annotationPopMode.annotations
+        var isNoHaveZoomOut = true
+        var isNoHaveZoomIn = true
+
+        for i in 0 ..< annotations.count {
+            let annotation = annotations[i]
+            var shapeWidth = annotation.borderWidth
+            if annotation.isKind(of: CSelfSignAnnotation.self) == true {
+                if let signAnnotation:CSelfSignAnnotation = annotation as? CSelfSignAnnotation {
+                    shapeWidth = signAnnotation.lineAnnotationWidth
+                }
+            }
+            
+            if shapeWidth < minLineValue {
+                isNoHaveZoomOut = false
+            }
+            
+            if shapeWidth > maxLineValue {
+                isNoHaveZoomIn = false
+            }
+        }
+        
+        if isNoHaveZoomOut == false {
+            widthZoomOutButton.properties.state = .pressed
+        } else {
+            widthZoomOutButton.properties.state = .normal
+        }
+        widthZoomOutButton.reloadData()
+        
+        if isNoHaveZoomIn == false {
+            widthZoomInButton.properties.state = .pressed
+        } else {
+            widthZoomInButton.properties.state = .normal
+        }
+        widthZoomOutButton.reloadData()
+    }
+    
     private func congfigFontPopUI() {
         fontNameSelect.properties = ComponentSelectProperties(size: .s,
                                                               state: .normal,
@@ -831,12 +871,14 @@ class KMNPopAnnotationViewController: KMNBaseViewController {
         if annotationPopMode.zoomOutShapeWidth() {
             updatePDFViewCallback?()
         }
+        updateShapeWidthButtonState()
     }
     
     @objc func widthZoomInButtonClicked(_ sender: NSView) {
         if annotationPopMode.zoomInShapeWidth() {
             updatePDFViewCallback?()
         }
+        updateShapeWidthButtonState()
     }
     
     @objc func pageLinkButtonClicked(_ sender: NSView) {