瀏覽代碼

【2025】【Page】注释选中效果UI变化(线段注释待确认)

dinglingui 3 月之前
父節點
當前提交
54aa7d77f8
共有 13 個文件被更改,包括 26 次插入104 次删除
  1. 2 4
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/PDFListView+KMExtensions.swift
  2. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotation+PDFListView.swift
  3. 2 7
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFButtonWidgetAnnotation+PDFListView.swift
  4. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFFreeTextAnnotation+PDFListView.swift
  5. 1 51
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFInkAnnotation+PDFListView.swift
  6. 4 9
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFLineAnnotation+PDFListView.swift
  7. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFLinkAnnotation+PDFListView.swift
  8. 3 8
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFPolygonAnnotation+PDFListView.swift
  9. 3 3
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFPolylineAnnotation+PDFListView.swift
  10. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFRedactAnnotation+PDFListView.swift
  11. 0 6
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFStampAnnotation+PDFListView.swift
  12. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFTextAnnotation+PDFListView.swift
  13. 1 6
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFWidgetAnnotation+PDFListView.swift

+ 2 - 4
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/PDFListView+KMExtensions.swift

@@ -158,10 +158,8 @@ import Foundation
 func CPDFListViewDrawResizeHandle(_ context: CGContext, _ point: NSPoint, _ radius: CGFloat, _ active: Bool) {
     let rect = NSMakeRect(point.x - radius, point.y - radius, 2 * radius, 2 * radius)
     let color = NSColor(red: 48.0/255.0, green: 145.0/255.0, blue: 255.0/255.0, alpha: 1)
-    
-    KMContextSetStrokeColorWithColor(context, color.cgColor)
-    KMContextSetLineWidth(context, 0.5 * radius)
-    KMContextRectangleInRect(context, rect)
+    context.setFillColor(color.cgColor)
+    context.fill(rect)
     context.strokePath()
 }
 

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotation+PDFListView.swift

@@ -43,8 +43,8 @@ import Foundation
         context.saveGState()
         let color = CPDFListViewConfig.defaultManager.annotationBorderColor.cgColor
         context.setStrokeColor(color)
-        if (isHover) {
-            let lengths: [CGFloat] = [5.0, 5.0]
+        if (isHover || pdfView.activeAnnotations.count > 1) {
+            let lengths: [CGFloat] = [2.0, 2.0]
             context.setLineDash(phase: 0.0, lengths: lengths)
             let clipRect = context.boundingBoxOfClipPath // 获取剪辑边界矩形
             if(clipRect.width >= rect.width || clipRect.height >= rect.height ) {

+ 2 - 7
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFButtonWidgetAnnotation+PDFListView.swift

@@ -56,8 +56,8 @@ import Foundation
         context.saveGState()
         let color = CPDFListViewConfig.defaultManager.annotationBorderColor.cgColor
         context.setStrokeColor(color)
-        if (isHover) {
-            let lengths: [CGFloat] = [5.0, 5.0]
+        if (isHover || pdfView.activeAnnotations.count > 1) {
+            let lengths: [CGFloat] = [2.0, 2.0]
             context.setLineDash(phase: 0.0, lengths: lengths)
             let clipRect = context.boundingBoxOfClipPath // 获取剪辑边界矩形
             if(clipRect.width >= rect.width || clipRect.height >= rect.height ) {
@@ -77,11 +77,6 @@ import Foundation
         context.restoreGState()
     }
     
-    override func borderRecct(for pdfView: CPDFListView) -> CGRect {
-        let rect = pdfView.integralRect(self.bounds, on: self.page)
-        return rect
-    }
-    
     override func resizeHandleForPoint(_ point: NSPoint, scaleFactor: CGFloat) -> CRectEdges {
         let rect = NSRectFromCGRect(KMRectInset(NSRectToCGRect(self.bounds), 0.0, 0.0))
         return self.isResizable() ? CPDFListViewResizeHandleForPointFromRect(point, rect, 8.0 / scaleFactor) : CRectEdges(rawValue: 0)

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFFreeTextAnnotation+PDFListView.swift

@@ -55,8 +55,8 @@ import Foundation
         context.saveGState()
         let color = CPDFListViewConfig.defaultManager.annotationBorderColor.cgColor
         context.setStrokeColor(color)
-        if (isHover) {
-            let lengths: [CGFloat] = [5.0, 5.0]
+        if (isHover || pdfView.activeAnnotations.count > 1) {
+            let lengths: [CGFloat] = [2.0, 2.0]
             context.setLineDash(phase: 0.0, lengths: lengths)
             let clipRect = context.boundingBoxOfClipPath // 获取剪辑边界矩形
             if(clipRect.width >= rect.width || clipRect.height >= rect.height ) {

+ 1 - 51
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFInkAnnotation+PDFListView.swift

@@ -209,7 +209,7 @@ import Foundation
         }
         
         if (isDashed) {
-            let pattern: [CGFloat] = [5.0, 5.0]
+            let pattern: [CGFloat] = [2.0, 2.0]
             path.setLineDash(pattern, count: 2, phase: 0.0)
         }
         color?.setStroke()
@@ -339,56 +339,6 @@ import Foundation
         
         return NSUnionRect(super.displayRectForBounds(bounds, lineWidth: _lineWidth), NSIntegralRect(rect));
     }
-    
-    override func drawSelectionHighlightForView(_ pdfView: CPDFListView, inContext context: CGContext, isHover: Bool) {
-        super.drawSelectionHighlightForView(pdfView, inContext: context, isHover: isHover)
-        
-        if !self.isKind(of: KMTableAnnotation.self) {
-            if NSIsEmptyRect(self.bounds) == false {
-                let scale = ceil(1.0 / pdfView.unitWidth(on: self.page))
-                var b = self.bounds
-                var bounds = NSIntegralRect(b)
-                var rect = NSMakeRect(0.0, 0.0, scale * NSWidth(bounds), scale * NSHeight(bounds))
-                var image = NSImage(size: rect.size)
-                image.lockFocus()
-                let transform = NSAffineTransform()
-                transform.scale(by: scale)
-                transform.translateX(by: NSMinX(b) - NSMinX(bounds), yBy: NSMinY(b) - NSMinY(bounds))
-                transform.concat()
-                var path = NSBezierPath()
-                for aPath in self.paths {
-                    guard let _path = aPath as? NSBezierPath else {
-                        continue
-                    }
-                    path.append(_path)
-                }
-                let lineWidth = self.lineWidth()
-                path.lineWidth = fmax(1.0, lineWidth)
-                path.lineJoinStyle = .round
-                if self.borderStyle() == .dashed {
-                    path.setDashPattern(self.dashPattern() as? NSArray ?? NSArray())
-                    path.lineCapStyle = .butt
-                } else {
-                    path.lineCapStyle = .round
-                }
-                NSGraphicsContext.saveGraphicsState()
-                
-                NSShadow.setShadowWithColor(NSColor(white: 0, alpha: 0.33333), blurRadius: 2.0, yOffset: -2.0)
-                let color = self.color ?? .black
-                NSColor(calibratedWhite: 0, alpha: color.alphaComponent).setStroke()
-                path.stroke()
-                NSGraphicsContext.restoreGraphicsState()
-                NSGraphicsContext.current?.compositingOperation = .clear
-                NSColor.black.setStroke()
-                path.stroke()
-                image.unlockFocus()
-                
-                let cgImage = image.cgImage(forProposedRect: &rect, context: NSGraphicsContext(cgContext: context, flipped: false), hints: nil)
-                KMContextDrawImage(context, NSRectToCGRect(bounds), cgImage)
-            }
-        }
-        
-    }
      
     override func isConvertibleAnnotation() -> Bool {
         return true

+ 4 - 9
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFLineAnnotation+PDFListView.swift

@@ -59,13 +59,13 @@ import Foundation
                     CPDFListViewDrawResizeHandle(context, point, delta, true)
                 }
             } else {
-                let rect = self.bounds
+                let rect = self.borderRecct(for: pdfView)
                 let lineWidth = pdfView.unitWidth(on: self.page)
                 context.saveGState()
                 let color = CPDFListViewConfig.defaultManager.annotationBorderColor.cgColor
                 context.setStrokeColor(color)
-                if(isHover) {
-                    let length: [CGFloat] = [5.0, 5.0]
+                if(isHover || pdfView.activeAnnotations.count > 1) {
+                    let length: [CGFloat] = [2.0, 2.0]
                     context.setLineDash(phase: 0, lengths: length)
                     context.stroke(rect, width: lineWidth)
                 } else {
@@ -75,12 +75,7 @@ import Foundation
             }
         }
     }
-    
-    override func borderRecct(for pdfView: CPDFListView) -> CGRect {
-        let rect = pdfView.integralRect(self.bounds, on: self.page)
-        return rect
-    }
-    
+        
     override func isMovable() -> Bool {
         return true
     }

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFLinkAnnotation+PDFListView.swift

@@ -69,8 +69,8 @@ import Foundation
         context.saveGState()
         let color = CPDFListViewConfig.defaultManager.annotationBorderColor.cgColor
         context.setStrokeColor(color)
-        if (isHover) {
-            let lengths: [CGFloat] = [5.0, 2.0]
+        if (isHover || pdfView.activeAnnotations.count > 1) {
+            let lengths: [CGFloat] = [2.0, 2.0]
             context.setLineDash(phase: 0.0, lengths: lengths)
             let clipRect = context.boundingBoxOfClipPath // 获取剪辑边界矩形
             if(clipRect.width >= rect.width || clipRect.height >= rect.height ) {

+ 3 - 8
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFPolygonAnnotation+PDFListView.swift

@@ -39,13 +39,13 @@ import Foundation
                     CPDFListViewDrawResizeHandle(context, savePoint, delta, true)
                 }
             } else {
-                let rect = self.bounds
+                var rect = self.borderRecct(for: pdfView)
                 let lineWidth = pdfView.unitWidth(on: self.page)
                 context.saveGState()
                 let color = CPDFListViewConfig.defaultManager.annotationBorderColor.cgColor
                 context.setStrokeColor(color)
-                if isHover {
-                    let lengths: [CGFloat] = [5, 5]
+                if(isHover || pdfView.activeAnnotations.count > 1) {
+                    let lengths: [CGFloat] = [2, 2]
                     context.setLineDash(phase: 0, lengths: lengths)
                     context.stroke(rect.insetBy(dx: 0, dy: 0), width: lineWidth)
                 } else {
@@ -57,11 +57,6 @@ import Foundation
         self.drawPolygonStart(in: context)
     }
     
-    override func borderRecct(for pdfView: CPDFListView) -> CGRect {
-        let rect = pdfView.integralRect(bounds, on: page)
-        return rect
-    }
-
     override func resizeHandleForPoint(_ point: NSPoint, scaleFactor: CGFloat) -> CRectEdges {
         guard self.isResizable() else { return CRectEdges(rawValue: 0) }
 

+ 3 - 3
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFPolylineAnnotation+PDFListView.swift

@@ -33,13 +33,13 @@ import Foundation
                     CPDFListViewDrawResizeHandle(context, savePoint, delta, true)
                 }
             } else {
-                let rect = self.bounds
+                var rect = self.borderRecct(for: pdfView)
                 let lineWidth = pdfView.unitWidth(on: self.page)
                 context.saveGState()
                 let color = CPDFListViewConfig.defaultManager.annotationBorderColor.cgColor
                 context.setStrokeColor(color)
-                if isHover {
-                    let lengths: [CGFloat] = [5, 5]
+                if(isHover || pdfView.activeAnnotations.count > 1) {
+                    let lengths: [CGFloat] = [2, 2]
                     context.setLineDash(phase: 0, lengths: lengths)
                     context.stroke(rect, width: lineWidth)
                 } else {

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFRedactAnnotation+PDFListView.swift

@@ -54,8 +54,8 @@ import Foundation
         context.saveGState()
         let color = CPDFListViewConfig.defaultManager.annotationBorderColor.cgColor
         context.setStrokeColor(color)
-        if (isHover) {
-            let lengths: [CGFloat] = [5.0, 5.0]
+        if (isHover || pdfView.activeAnnotations.count > 1) {
+            let lengths: [CGFloat] = [2.0, 2.0]
             context.setLineDash(phase: 0.0, lengths: lengths)
             let clipRect = context.boundingBoxOfClipPath // 获取剪辑边界矩形
             if(clipRect.width >= rect.width || clipRect.height >= rect.height ) {

+ 0 - 6
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFStampAnnotation+PDFListView.swift

@@ -80,13 +80,7 @@ import Foundation
         return true
     }
     
-    override func borderRecct(for pdfView: CPDFListView) -> CGRect {
-        var rect = pdfView.integralRect(self.bounds, on: self.page)
-        //        let offsetNum = 0
-        rect = NSRectFromCGRect(KMRectInset(NSRectToCGRect(rect), 0, 0))
-        return rect
     }
-}
 
 //MARK: - Update
 extension CPDFStampAnnotation {

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFTextAnnotation+PDFListView.swift

@@ -139,8 +139,8 @@ extension CPDFTextAnnotation {
         let lineWidth = pdfView.unitWidth(on: self.page)
         KMContextSaveGState(context);
         let color = NSColor(red: 82.0/255.0, green: 102.0/255.0, blue: 204.0/255.0, alpha: 1.0).cgColor
-        if(isHover) {
-            var length: [CGFloat] = [5.0, 5.0]
+        if(isHover || pdfView.activeAnnotations.count > 1) {
+            let length: [CGFloat] = [2.0, 2.0]
             KMContextSetLineDash(context, 0, length, 2)
             KMContextStrokeRectWithWidth(context, KMRectInset(NSRectToCGRect(rect), 0,0), lineWidth)
         } else {

+ 1 - 6
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFWidgetAnnotation+PDFListView.swift

@@ -26,7 +26,7 @@ import Foundation
         KMContextSaveGState(context);
         let color = CPDFListViewConfig.defaultManager.annotationBorderColor.cgColor
         KMContextSetStrokeColorWithColor(context, color)
-        if(isHover) {
+        if(isHover || pdfView.activeAnnotations.count > 1) {
             let offsetNum = CPDFListViewConfig.defaultManager.annotationBorderOffset
             rect = NSRectFromCGRect(KMRectInset(NSRectToCGRect(rect), -(offsetNum.floatValue).cgFloat, -(offsetNum.floatValue).cgFloat))
             let length: [CGFloat] = [5,5]
@@ -46,11 +46,6 @@ import Foundation
         KMContextRestoreGState(context);
     }
     
-    override func borderRecct(for pdfView: CPDFListView) -> CGRect {
-        let rect = pdfView.integralRect(self.bounds, on: self.page)
-        return rect
-    }
-    
     override func isResizable() -> Bool {
         return true
     }