Browse Source

【2025】【PDFView】修改选中注释效果

dinglingui 3 months ago
parent
commit
51d5f4b129
16 changed files with 88 additions and 19 deletions
  1. 3 0
      PDF Office/PDF Master/Class/Common/Category/NSObject+KMExtension.swift
  2. 1 1
      PDF Office/PDF Master/Class/DigtalSignature/CPDFDigtalView/Event/CPDFListViewConfig.m
  3. 47 6
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/PDFListView+KMExtensions.swift
  4. 4 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotation+PDFListView.swift
  5. 4 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFButtonWidgetAnnotation+PDFListView.swift
  6. 4 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFFreeTextAnnotation+PDFListView.swift
  7. 4 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFLinkAnnotation+PDFListView.swift
  8. 4 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFRedactAnnotation+PDFListView.swift
  9. 4 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFTextAnnotation+PDFListView.swift
  10. 4 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFWidgetAnnotation+PDFListView.swift
  11. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.m
  12. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewConfig.swift
  13. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/ComPDFUIConfig.swift
  14. 3 1
      PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopContentEditWindowController.swift
  15. 1 1
      PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopContentEditWindowController.xib
  16. 2 0
      PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopOperationWindowController.swift

+ 3 - 0
PDF Office/PDF Master/Class/Common/Category/NSObject+KMExtension.swift

@@ -399,6 +399,9 @@ func KMContextFillEllipseInRect(_ ctx: CGContext?, _ rect: CGRect) {
     ctx?.fillEllipse(in: rect)
 }
 
+func KMContextRectangleInRect(_ ctx: CGContext?, _ rect: CGRect) {
+    ctx?.addRect(rect)
+}
 
 func KMContextStrokeEllipseInRect(_ ctx: CGContext?, _ rect: CGRect) {
     ctx?.strokeEllipse(in: rect)

+ 1 - 1
PDF Office/PDF Master/Class/DigtalSignature/CPDFDigtalView/Event/CPDFListViewConfig.m

@@ -34,7 +34,7 @@
     if(_annotationBorderColor) {
         return _annotationBorderColor;
     }
-    return [NSColor colorWithRed:82.0/255.0 green:102.0/255.0 blue:204.0/255.0 alpha:1];
+    return [NSColor colorWithRed:45.0/255.0 green:145.0/255.0 blue:255.0/255.0 alpha:1];
 }
 
 - (NSColor *)dragHoverColor {

+ 47 - 6
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/PDFListView+KMExtensions.swift

@@ -157,13 +157,12 @@ 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 = active ? NSColor(red: 82.0/255.0, green: 102.0/255.0, blue: 204.0/255.0, alpha: 1) : NSColor.secondarySelectedControlColor.usingColorSpaceName(.calibratedRGB)?.withAlphaComponent(1)
+    let color = NSColor(red: 48.0/255.0, green: 145.0/255.0, blue: 255.0/255.0, alpha: 1)
     
-    KMContextSetFillColorWithColor(context, color?.cgColor)
-    KMContextSetStrokeColorWithColor(context, NSColor.white.cgColor)
-    KMContextSetLineWidth(context, 0.25 * radius)
-    KMContextFillEllipseInRect(context, rect)
-    KMContextStrokeEllipseInRect(context, KMRectInset(rect, -0.25*radius, -0.25*radius))
+    KMContextSetStrokeColorWithColor(context, color.cgColor)
+    KMContextSetLineWidth(context, 0.5 * radius)
+    KMContextRectangleInRect(context, rect)
+    context.strokePath()
 }
 
 func CPDFListViewDrawResizeHandles(_ context: CGContext, _ rect: NSRect, _ radius: CGFloat, _ active: Bool) {
@@ -177,6 +176,48 @@ func CPDFListViewDrawResizeHandles(_ context: CGContext, _ rect: NSRect, _ radiu
     CPDFListViewDrawResizeHandle(context, NSMakePoint(NSMaxX(rect), NSMinY(rect)), radius, active)
 }
 
+func CPDFListViewDrawLineHandles(_ context: CGContext, _ rect: NSRect, _ radius:CGFloat) {
+    let startPoint0 = CGPoint(x: rect.minX + radius, y: rect.minY)
+    let endPoint0 = CGPoint(x: rect.midX - radius, y: rect.minY)
+    context.move(to: startPoint0)
+    context.addLine(to: endPoint0)
+
+    let startPoint1 = CGPoint(x: rect.midX + radius, y: rect.minY)
+    let endPoint1 = CGPoint(x: rect.maxX - radius, y: rect.minY)
+    context.move(to: startPoint1)
+    context.addLine(to: endPoint1)
+
+    let startPoint2 = CGPoint(x: rect.maxX, y: rect.minY + radius)
+    let endPoint2 = CGPoint(x: rect.maxX, y: rect.midY - radius)
+    context.move(to: startPoint2)
+    context.addLine(to: endPoint2)
+
+    let startPoint3 = CGPoint(x: rect.maxX, y: rect.midY + radius)
+    let endPoint3 = CGPoint(x: rect.maxX, y: rect.maxY - radius)
+    context.move(to: startPoint3)
+    context.addLine(to: endPoint3)
+    
+    let startPoint4 = CGPoint(x: rect.maxX - radius, y: rect.maxY)
+    let endPoint4 = CGPoint(x: rect.midX + radius, y: rect.maxY)
+    context.move(to: startPoint4)
+    context.addLine(to: endPoint4)
+    
+    let startPoint5 = CGPoint(x: rect.midX - radius, y: rect.maxY)
+    let endPoint5 = CGPoint(x: rect.minX + radius, y: rect.maxY)
+    context.move(to: startPoint5)
+    context.addLine(to: endPoint5)
+    
+    let startPoint6 = CGPoint(x: rect.minX, y: rect.maxY - radius)
+    let endPoint6 = CGPoint(x: rect.minX, y: rect.midY + radius)
+    context.move(to: startPoint6)
+    context.addLine(to: endPoint6)
+
+    let startPoint7 = CGPoint(x: rect.minX, y: rect.midY - radius)
+    let endPoint7 = CGPoint(x: rect.minX, y: rect.minY + radius)
+    context.move(to: startPoint7)
+    context.addLine(to: endPoint7)
+}
+
 func CPDFListViewDrawFreeTextResizeHandle(_ context: CGContext, _ rect: NSRect, _ radius: CGFloat, _ active: Bool) {
     CPDFListViewDrawResizeHandle(context, NSMakePoint(NSMaxX(rect), NSMidY(rect)), radius, active)
     CPDFListViewDrawResizeHandle(context, NSMakePoint(NSMinX(rect), NSMidY(rect)), radius, active)

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

@@ -51,7 +51,10 @@ import Foundation
                 context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
             }
         } else {
-            context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            context.setLineWidth(lineWidth)
+            CPDFListViewDrawLineHandles(context, rect, 4.0/2)
+            // 绘制路径
+            context.strokePath()
         }
         context.restoreGState()
         context.saveGState()

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

@@ -64,7 +64,10 @@ import Foundation
                 context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
             }
         } else {
-            context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            context.setLineWidth(lineWidth)
+            CPDFListViewDrawLineHandles(context, rect, 4.0/2)
+            // 绘制路径
+            context.strokePath()
         }
         context.restoreGState()
         context.saveGState()

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

@@ -39,7 +39,10 @@ import Foundation
                 context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
             }
         } else {
-            context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            context.setLineWidth(lineWidth)
+            CPDFListViewDrawLineHandles(context, rect, 4.0/2)
+            // 绘制路径
+            context.strokePath()
         }
         context.restoreGState()
         context.saveGState()

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

@@ -57,7 +57,10 @@ import Foundation
             }
             
         } else {
-            context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            context.setLineWidth(lineWidth)
+            CPDFListViewDrawLineHandles(context, rect, 4.0/2)
+            // 绘制路径
+            context.strokePath()
         }
         context.restoreGState()
         context.saveGState()

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

@@ -62,7 +62,10 @@ import Foundation
                 context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
             }
         } else {
-            context.stroke(KMRectInset(NSRectToCGRect(rect), 0,0), width: lineWidth)
+            context.setLineWidth(lineWidth)
+            CPDFListViewDrawLineHandles(context, rect, 4.0/2)
+            // 绘制路径
+            context.strokePath()
         }
         context.restoreGState()
     }

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

@@ -144,7 +144,10 @@ extension CPDFTextAnnotation {
             KMContextSetLineDash(context, 0, length, 2)
             KMContextStrokeRectWithWidth(context, KMRectInset(NSRectToCGRect(rect), 0,0), lineWidth)
         } else {
-            KMContextStrokeRectWithWidth(context, KMRectInset(NSRectToCGRect(rect), 0, 0), lineWidth)
+            context.setLineWidth(lineWidth)
+            CPDFListViewDrawLineHandles(context, rect, 4.0/2)
+            // 绘制路径
+            context.strokePath()
         }
         KMContextSetStrokeColorWithColor(context, color)
         KMContextRestoreGState(context)

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

@@ -33,7 +33,10 @@ import Foundation
             KMContextSetLineDash(context, 0, length, 2)
             KMContextStrokeRectWithWidth(context, KMRectInset(NSRectToCGRect(rect), 0,0), lineWidth)
         } else {
-            KMContextStrokeRectWithWidth(context, KMRectInset(NSRectToCGRect(rect), 0,0), lineWidth)
+            context.setLineWidth(lineWidth)
+            CPDFListViewDrawLineHandles(context, rect, 4.0/2)
+            // 绘制路径
+            context.strokePath()
         }
         KMContextRestoreGState(context)
         KMContextSaveGState(context)

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.m

@@ -964,7 +964,7 @@ NSNotificationName const CPDFListViewDisplayModeChangeNotification = @"CPDFListV
         drawRect.size.width = size.width;
         
         CGContextSaveGState(context);
-        CGContextSetFillColorWithColor(context, [NSColor colorWithRed:23.0/255.0 green:112.0/255.0 blue:244.0/255.0 alpha:0.5].CGColor);
+        CGContextSetFillColorWithColor(context, [NSColor colorWithRed:48.0/255.0 green:145.0/255.0 blue:255.0/255.0 alpha:0.14].CGColor);
         CGContextFillRect(context,annotation.bounds);
         CGContextRestoreGState(context);
         

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewConfig.swift

@@ -10,7 +10,7 @@ import Cocoa
 @objcMembers
 class CPDFListViewConfig: NSObject {
     var _annotationBorderOffset: NSNumber = 5
-    var _annotationBorderColor: NSColor = NSColor(red: 82.0/255.0, green: 102.0/255.0, blue: 204.0/255.0, alpha: 1)
+    var _annotationBorderColor: NSColor = NSColor(red: 48.0/255.0, green: 145.0/255.0, blue: 255.0/255.0, alpha: 1)
     var _dragHoverColor: NSColor = NSColor(red: 23/255.0, green: 112/255.0, blue: 244/255.0, alpha: 1.0)
     var isSaveDefault: Bool = false
     var _isSquareFromPolygon: Bool = false

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/ComPDFUIConfig.swift

@@ -21,7 +21,7 @@ class ComPDFUIConfig: NSObject {
             NSImage.makePDFListViewCursorImages()
             
             CPDFListViewConfig.defaultManager.annotationBorderOffset = 2
-            CPDFListViewConfig.defaultManager.annotationBorderColor = NSColor(red: 23.0/255.0, green: 112.0/255.0, blue: 244.0/255.0, alpha: 1.0)
+            CPDFListViewConfig.defaultManager.annotationBorderColor = NSColor(red: 48.0/255.0, green: 145.0/255.0, blue: 255.0/255.0, alpha: 1.0)
             
             CPDFKitConfig.sharedInstance().isShowFormRequiredFlagColor = false
             

+ 3 - 1
PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopContentEditWindowController.swift

@@ -12,7 +12,7 @@ import KMComponentLibrary
 class KMNPopContentEditWindowController: KMNBaseWindowController {
     public var editType:EditContentPopType = .editNone {
         didSet {
-            rightOffsetConstraint.constant = 41.0
+            rightOffsetConstraint.constant = 45.0
             paneBox.isHidden = false
             
             switch editType {
@@ -674,6 +674,8 @@ class KMNPopContentEditWindowController: KMNBaseWindowController {
             positionRect.origin.y = positionNew.y + popOffSet + CGFloat(truncating: listView.editingConfig().editAreaMargin)
             
             self.window?.setFrame(positionRect, display: true)
+            
+            updateUILanguage()
         }
     }
     

+ 1 - 1
PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopContentEditWindowController.xib

@@ -48,7 +48,7 @@
             <windowStyleMask key="styleMask" fullSizeContentView="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="240" width="480" height="270"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
             <view key="contentView" id="se5-gp-TjO">
                 <rect key="frame" x="0.0" y="0.0" width="522" height="42"/>
                 <autoresizingMask key="autoresizingMask"/>

+ 2 - 0
PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopOperationWindowController.swift

@@ -743,6 +743,8 @@ class KMNPopOperationWindowController: KMNBaseWindowController {
                 positionRect.origin.y = positionNew.y + popOffSet
                 
                 self.window?.setFrame(positionRect, display: true)
+                
+                updateUILanguage()
             } else {
                 
             }