Browse Source

【注释】调整高亮或划线注释的不透明度,预览和工具栏上的颜色不会同步刷新 -- 透明度兼容

lizhe 9 months ago
parent
commit
abfa681e64

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

@@ -119,7 +119,7 @@ class KMNoteTypeImageView: NSImageView {
                 image?.lockFocus()
                 if let context = NSGraphicsContext.current?.cgContext {
                     let newColor = color.usingColorSpaceName(NSColorSpaceName.calibratedRGB)
-                    let newUnderlineColor = NSColor(red: newColor!.redComponent, green: newColor!.greenComponent, blue: newColor!.blueComponent, alpha: 0.7)
+                    let newUnderlineColor = NSColor(red: newColor!.redComponent, green: newColor!.greenComponent, blue: newColor!.blueComponent, alpha: newColor?.alphaComponent ?? 0.7)
                     newUnderlineColor.setFill()
                     context.setStrokeColor(NSColor.clear.cgColor)
                     let fw = image!.size.width

+ 35 - 5
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift

@@ -1008,6 +1008,7 @@ let KMColorPickerViewHeight: CGFloat = 64
             textAnnotationImageView.image = annotationModel?.annotationImage
         } else {
             generalImageView.image = annotationModel?.annotationImage
+            generalImageView.alphaValue = (annotationModel?.opacity())!
         }
     }
     
@@ -1668,20 +1669,21 @@ let KMColorPickerViewHeight: CGFloat = 64
                     annotationModel?.setOpacity(opacity)
                     annotationModel?.setColor(textColor)
                 } else {
-                    annotationModel?.setOpacity(opacity)
+                    opacity = annotationModel?.opacity() ?? 1
+//                    annotationModel?.setOpacity(opacity)
                     annotationModel?.setColor(textColor)
                     if let model = self.annotationModel {
                         if (model.annotation == nil || CPDFListViewConfig.defaultManager.isSaveDefault) && self.isannotationMode {
                             if self.annotationType.isMarkup() {
                                 let type = self.annotationType
                                 if type == .highlight {
-                                    KMPreferenceManager.shared.markupHighlightColor = textColor
+                                    KMPreferenceManager.shared.markupHighlightColor = textColor.withAlphaComponent(opacity)
                                 } else if type == .underline {
-                                    KMPreferenceManager.shared.markupUnderlineColor = textColor
+                                    KMPreferenceManager.shared.markupUnderlineColor = textColor.withAlphaComponent(opacity)
                                 } else if type == .strikeOut {
-                                    KMPreferenceManager.shared.markupStrikthroughColor = textColor
+                                    KMPreferenceManager.shared.markupStrikthroughColor = textColor.withAlphaComponent(opacity)
                                 } else if type == .ink {
-                                    KMPreferenceManager.shared.markupPenColor = textColor
+                                    KMPreferenceManager.shared.markupPenColor = textColor.withAlphaComponent(opacity)
                                 }
                             }
                         }
@@ -1802,6 +1804,34 @@ let KMColorPickerViewHeight: CGFloat = 64
         }
         opacityComboBox.stringValue = "\(Int(opcity * 100))%"
         updateAnnotation(.opacity)
+        
+        if annotationType == .square || annotationType == .circle || annotationType == .line || annotationType == .arrow {
+
+        } else if annotationType == .freeText {
+
+        } else if annotationType == .signDate || annotationType == .signText {
+
+        } else {
+            var opacity = annotationModel?.opacity() ?? 1
+            var textColor = annotationModel?.color() ?? NSColor.clear
+            annotationModel?.setColor(textColor)
+            if let model = self.annotationModel {
+                if (model.annotation == nil || CPDFListViewConfig.defaultManager.isSaveDefault) && self.isannotationMode {
+                    if self.annotationType.isMarkup() {
+                        let type = self.annotationType
+                        if type == .highlight {
+                            KMPreferenceManager.shared.markupHighlightColor = textColor.withAlphaComponent(opacity)
+                        } else if type == .underline {
+                            KMPreferenceManager.shared.markupUnderlineColor = textColor.withAlphaComponent(opacity)
+                        } else if type == .strikeOut {
+                            KMPreferenceManager.shared.markupStrikthroughColor = textColor.withAlphaComponent(opacity)
+                        } else if type == .ink {
+                            KMPreferenceManager.shared.markupPenColor = textColor.withAlphaComponent(opacity)
+                        }
+                    }
+                }
+            }
+        }
     }
     
     @IBAction func opacityComboBoxAction(_ sender: Any) {