Browse Source

【fix】 【注释】修改注释toolbar效果

dinglingui 4 months ago
parent
commit
d222ae73ea

+ 12 - 0
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameUnderLineDrakIcon.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "content.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 88 - 0
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameUnderLineDrakIcon.imageset/content.pdf

@@ -0,0 +1,88 @@
+%PDF-1.7
+
+1 0 obj
+  << >>
+endobj
+
+2 0 obj
+  << /Length 3 0 R >>
+stream
+/DeviceRGB CS
+/DeviceRGB cs
+q
+1.000000 0.000000 -0.000000 1.000000 3.000000 5.000000 cm
+1.000000 1.000000 1.000000 scn
+10.000000 1.000021 m
+10.992238 1.000021 l
+9.892282 3.750021 l
+4.107718 3.750021 l
+3.007762 1.000021 l
+4.000000 1.000021 l
+4.000000 0.000021 l
+0.000000 0.000021 l
+0.000000 1.000021 l
+1.392225 1.000021 l
+6.303642 13.278564 l
+7.696358 13.278564 l
+12.607775 1.000021 l
+14.000000 1.000021 l
+14.000000 0.000021 l
+10.000000 0.000021 l
+10.000000 1.000021 l
+h
+4.507701 4.750021 m
+9.492299 4.750021 l
+7.000000 10.981022 l
+4.507701 4.750021 l
+h
+f*
+n
+Q
+
+endstream
+endobj
+
+3 0 obj
+  560
+endobj
+
+4 0 obj
+  << /Annots []
+     /Type /Page
+     /MediaBox [ 0.000000 0.000000 20.000000 20.000000 ]
+     /Resources 1 0 R
+     /Contents 2 0 R
+     /Parent 5 0 R
+  >>
+endobj
+
+5 0 obj
+  << /Kids [ 4 0 R ]
+     /Count 1
+     /Type /Pages
+  >>
+endobj
+
+6 0 obj
+  << /Pages 5 0 R
+     /Type /Catalog
+  >>
+endobj
+
+xref
+0 7
+0000000000 65535 f
+0000000010 00000 n
+0000000034 00000 n
+0000000650 00000 n
+0000000672 00000 n
+0000000845 00000 n
+0000000919 00000 n
+trailer
+<< /ID [ (some) (id) ]
+   /Root 6 0 R
+   /Size 7
+>>
+startxref
+978
+%%EOF

+ 2 - 11
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/Sidetabbar/KMImageNameAnnotationUnderline.imageset/Contents.json

@@ -1,17 +1,8 @@
 {
   "images" : [
     {
-      "filename" : "underline.pdf",
-      "idiom" : "universal",
-      "scale" : "1x"
-    },
-    {
-      "idiom" : "universal",
-      "scale" : "2x"
-    },
-    {
-      "idiom" : "universal",
-      "scale" : "3x"
+      "filename" : "wavyline.pdf",
+      "idiom" : "universal"
     }
   ],
   "info" : {

+ 0 - 81
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/Sidetabbar/KMImageNameAnnotationUnderline.imageset/underline.pdf

@@ -1,81 +0,0 @@
-%PDF-1.7
-
-1 0 obj
-  << >>
-endobj
-
-2 0 obj
-  << /Length 3 0 R >>
-stream
-/DeviceRGB CS
-/DeviceRGB cs
-q
-1.000000 0.000000 -0.000000 1.000000 3.416992 4.000000 cm
-0.152941 0.235294 0.384314 scn
-0.000000 0.000000 m
-2.409668 0.000000 l
-3.752930 3.999023 l
-9.413086 3.999023 l
-10.746094 0.000000 l
-13.166016 0.000000 l
-7.823730 14.796387 l
-5.342285 14.796387 l
-0.000000 0.000000 l
-h
-6.490723 12.202148 m
-6.665039 12.202148 l
-8.797852 5.844727 l
-4.368164 5.844727 l
-6.490723 12.202148 l
-h
-f
-n
-Q
-
-endstream
-endobj
-
-3 0 obj
-  416
-endobj
-
-4 0 obj
-  << /Annots []
-     /Type /Page
-     /MediaBox [ 0.000000 0.000000 20.000000 20.000000 ]
-     /Resources 1 0 R
-     /Contents 2 0 R
-     /Parent 5 0 R
-  >>
-endobj
-
-5 0 obj
-  << /Kids [ 4 0 R ]
-     /Count 1
-     /Type /Pages
-  >>
-endobj
-
-6 0 obj
-  << /Pages 5 0 R
-     /Type /Catalog
-  >>
-endobj
-
-xref
-0 7
-0000000000 65535 f
-0000000010 00000 n
-0000000034 00000 n
-0000000506 00000 n
-0000000528 00000 n
-0000000701 00000 n
-0000000775 00000 n
-trailer
-<< /ID [ (some) (id) ]
-   /Root 6 0 R
-   /Size 7
->>
-startxref
-834
-%%EOF

+ 88 - 0
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/Sidetabbar/KMImageNameAnnotationUnderline.imageset/wavyline.pdf

@@ -0,0 +1,88 @@
+%PDF-1.7
+
+1 0 obj
+  << >>
+endobj
+
+2 0 obj
+  << /Length 3 0 R >>
+stream
+/DeviceRGB CS
+/DeviceRGB cs
+q
+1.000000 0.000000 -0.000000 1.000000 3.000000 5.000000 cm
+0.152276 0.234759 0.385445 scn
+10.000000 1.000021 m
+10.992238 1.000021 l
+9.892282 3.750021 l
+4.107718 3.750021 l
+3.007762 1.000021 l
+4.000000 1.000021 l
+4.000000 0.000021 l
+0.000000 0.000021 l
+0.000000 1.000021 l
+1.392225 1.000021 l
+6.303642 13.278564 l
+7.696358 13.278564 l
+12.607775 1.000021 l
+14.000000 1.000021 l
+14.000000 0.000021 l
+10.000000 0.000021 l
+10.000000 1.000021 l
+h
+4.507701 4.750021 m
+9.492299 4.750021 l
+7.000000 10.981022 l
+4.507701 4.750021 l
+h
+f*
+n
+Q
+
+endstream
+endobj
+
+3 0 obj
+  560
+endobj
+
+4 0 obj
+  << /Annots []
+     /Type /Page
+     /MediaBox [ 0.000000 0.000000 20.000000 20.000000 ]
+     /Resources 1 0 R
+     /Contents 2 0 R
+     /Parent 5 0 R
+  >>
+endobj
+
+5 0 obj
+  << /Kids [ 4 0 R ]
+     /Count 1
+     /Type /Pages
+  >>
+endobj
+
+6 0 obj
+  << /Pages 5 0 R
+     /Type /Catalog
+  >>
+endobj
+
+xref
+0 7
+0000000000 65535 f
+0000000010 00000 n
+0000000034 00000 n
+0000000650 00000 n
+0000000672 00000 n
+0000000845 00000 n
+0000000919 00000 n
+trailer
+<< /ID [ (some) (id) ]
+   /Root 6 0 R
+   /Size 7
+>>
+startxref
+978
+%%EOF

+ 26 - 6
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Annotation/View/KMNoteTypeImageView.swift

@@ -78,7 +78,7 @@ class KMNoteTypeImageView: NSImageView {
             if appearanceName == .darkAqua {
                 strikePath = "KMImageNameAnnotationStrikeout"
                 highlight = "KMImageNameStikeoutDrakIcon"
-                underline = "KMImageNameAnnotationUnderline"
+                underline = "KMImageNameUnderLineDrakIcon"
                 inkImagePath = "KMImageNameAnnotationFreehandDrak"
                 inkIcon = "KMImageNameInkDrakIcon"
             }
@@ -142,7 +142,7 @@ class KMNoteTypeImageView: NSImageView {
                 image?.unlockFocus()
             }
         } else if type == SKNUnderlineString {
-            if let baseImage = NSImage(named: highlight) {
+            if let baseImage = NSImage(named: underline) {
                 var size = NSMakeSize(20, 20)
                 image = NSImage(size: size)
                 image?.lockFocus()
@@ -261,7 +261,7 @@ class KMNoteTypeImageView: NSImageView {
         } else if type == SKMeasureRectangleString {
             image = NSImage(named: "KMImageNameListMeasureSquare")?.copy() as? NSImage
         } else if type == "Squiggly" {
-            if let baseImage = NSImage(named: highlight)?.copy() as? NSImage {
+            if let baseImage = NSImage(named: underline)?.copy() as? NSImage {
                 // baseImage.size.offset(x: 1.5, y: 1.5)
                 var size = NSMakeSize(20, 20)
                 image = NSImage(size: size)
@@ -269,13 +269,33 @@ class KMNoteTypeImageView: NSImageView {
                 let ref3 = NSGraphicsContext.current?.cgContext
                 KMContextSaveGState(ref3)
                 KMContextBeginPath(ref3)
-                KMContextMoveToPoint(ref3, 2, 3)
-                KMContextAddCurveToPoint(ref3, image!.size.width/2, -4,  2 * image!.size.width/4, 2 * image!.size.width/4, image!.size.width, 4)
-                KMContextSetLineWidth(ref3, 1);
+                
+                let length = 24.0
+                let stepLength = 6.0
+                var count = Int(round(length / CGFloat(stepLength)))
+
+                if count == 0 {
+                    count = 1
+                }
+                KMContextSetLineWidth(ref3, 2);
                 if let newColor = color.usingColorSpaceName(.calibratedRGB) {
                     let newInkColor = NSColor(red: newColor.redComponent, green: newColor.greenComponent, blue: newColor.blueComponent, alpha: 1)
                     newInkColor.set()
                 }
+                var initX = 0.0
+                for i in 0..<count {
+                    let s = CGPoint(x: initX, y: 2)
+                    let e = CGPoint(x: initX + stepLength, y: 2)
+                    let cp1 = CGPoint(x: initX + CGFloat(stepLength) / 2, y: 2 + 4)
+                    let cp2 = CGPoint(x: initX + CGFloat(stepLength) - CGFloat(stepLength) / 2, y: 0)
+                    
+                    ref3?.move(to: s)
+                    ref3?.addCurve(to: e, control1: cp1, control2: cp2)
+                    ref3?.strokePath()
+                    
+                    initX += CGFloat(stepLength)
+                }
+
                 KMContextStrokePath(ref3);
                 KMContextRestoreGState(ref3);
                 baseImage.draw(in: CGRect(x: 0, y: 0, width: image!.size.width, height: image!.size.height))