Ver código fonte

【PDFView】注释很大绘制出现卡顿(注释超出画布时,hover效果不绘制)

dinglingui 3 meses atrás
pai
commit
540156d8b6

+ 4 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFButtonWidgetAnnotation+PDFListView.swift

@@ -59,7 +59,10 @@ import Foundation
         if (isHover) {
             let lengths: [CGFloat] = [5.0, 5.0]
             context.setLineDash(phase: 0.0, lengths: lengths)
-            context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            let clipRect = context.boundingBoxOfClipPath // 获取剪辑边界矩形
+            if(clipRect.width >= rect.width || clipRect.height >= rect.height ) {
+                context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            }
         } else {
             context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
         }

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

@@ -54,7 +54,10 @@ import Foundation
         if (isHover) {
             let lengths: [CGFloat] = [5.0, 5.0]
             context.setLineDash(phase: 0.0, lengths: lengths)
-            context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            let clipRect = context.boundingBoxOfClipPath // 获取剪辑边界矩形
+            if(clipRect.width >= rect.width || clipRect.height >= rect.height ) {
+                context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            }
         } else {
             context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
         }

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

@@ -42,7 +42,11 @@ import Foundation
         if (isHover) {
             let lengths: [CGFloat] = [5.0, 2.0]
             context.setLineDash(phase: 0.0, lengths: lengths)
-            context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            let clipRect = context.boundingBoxOfClipPath // 获取剪辑边界矩形
+            if(clipRect.width >= rect.width || clipRect.height >= rect.height ) {
+                context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            }
+            
         } else {
             context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
         }

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

@@ -57,7 +57,10 @@ import Foundation
         if (isHover) {
             let lengths: [CGFloat] = [5.0, 5.0]
             context.setLineDash(phase: 0.0, lengths: lengths)
-            context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            let clipRect = context.boundingBoxOfClipPath // 获取剪辑边界矩形
+            if(clipRect.width >= rect.width || clipRect.height >= rect.height ) {
+                context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            }
         } else {
             context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
         }