|
@@ -45,6 +45,11 @@ class KMHighlightController: NSViewController {
|
|
|
return annotations
|
|
|
}
|
|
|
|
|
|
+ func getValidAnnotationType() -> CAnnotationType {
|
|
|
+
|
|
|
+ return .highlight
|
|
|
+ }
|
|
|
+
|
|
|
func setupProperty() {
|
|
|
|
|
|
colorLabel.stringValue = KMLocalizedString("Color")
|
|
@@ -195,46 +200,6 @@ class KMHighlightController: NSViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- func updateDefaultInfo(_ color: NSColor?, _ opacity: CGFloat?) {
|
|
|
- if let resultColor = color {
|
|
|
- if annotations.count == 0 {
|
|
|
- if viewManager?.subToolMode == .Highlight {
|
|
|
- CPDFAnnotationConfig.standard.setColor(resultColor, toType: .highlight)
|
|
|
- } else if viewManager?.subToolMode == .Underline {
|
|
|
- CPDFAnnotationConfig.standard.setColor(resultColor, toType: .underline)
|
|
|
- } else if viewManager?.subToolMode == .Strikethrough {
|
|
|
- CPDFAnnotationConfig.standard.setColor(resultColor, toType: .strikeOut)
|
|
|
- } else if viewManager?.subToolMode == .Waveline {
|
|
|
- CPDFAnnotationConfig.standard.setColor(resultColor, toType: .squiggly)
|
|
|
- }
|
|
|
- } else {
|
|
|
- for annotation in annotations {
|
|
|
- CPDFAnnotationConfig.standard.setColor(resultColor, toType: annotation.exchangeToAnnotationType(annotation.markupType()))
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- NotificationCenter.default.post(name: toolbarImageColorChangedNotificationName, object: nil)
|
|
|
- }
|
|
|
-
|
|
|
- if let resultOpacity = opacity {
|
|
|
- if annotations.count == 0 {
|
|
|
- if viewManager?.subToolMode == .Highlight {
|
|
|
- CPDFAnnotationConfig.standard.setOpacity(resultOpacity, toType: .highlight)
|
|
|
- } else if viewManager?.subToolMode == .Underline {
|
|
|
- CPDFAnnotationConfig.standard.setOpacity(resultOpacity, toType: .underline)
|
|
|
- } else if viewManager?.subToolMode == .Strikethrough {
|
|
|
- CPDFAnnotationConfig.standard.setOpacity(resultOpacity, toType: .strikeOut)
|
|
|
- } else if viewManager?.subToolMode == .Waveline {
|
|
|
- CPDFAnnotationConfig.standard.setOpacity(resultOpacity, toType: .squiggly)
|
|
|
- }
|
|
|
- } else {
|
|
|
- for annotation in annotations {
|
|
|
- CPDFAnnotationConfig.standard.setOpacity(resultOpacity, toType: annotation.exchangeToAnnotationType(annotation.markupType()))
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
//MARK: - Mouse
|
|
|
override func mouseDown(with event: NSEvent) {
|
|
|
super.mouseDown(with: event)
|
|
@@ -248,12 +213,20 @@ class KMHighlightController: NSViewController {
|
|
|
//MARK: - ComponentCColorDelegate
|
|
|
extension KMHighlightController: ComponentCColorDelegate {
|
|
|
func componentCColorDidChooseColor(_ view: NSView, _ color: NSColor?) {
|
|
|
-
|
|
|
CPDFAnnotation.updateAnnotations(annotations, newColor: color, withPDFView: pdfView)
|
|
|
|
|
|
- updateDefaultInfo(color, nil)
|
|
|
+ if annotations.count == 0 {
|
|
|
+ CPDFMarkupAnnotation.updateMarkupAnnotationDefaultColor(KMPDFViewManager.getValidPDFAnnotationType(viewManager?.subToolMode), color)
|
|
|
+ } else {
|
|
|
+ for annotation in annotations {
|
|
|
+ CPDFMarkupAnnotation.updateMarkupAnnotationDefaultColor(annotation.exchangeToAnnotationType(annotation.markupType()), color)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ NotificationCenter.default.post(name: toolbarImageColorChangedNotificationName, object: nil)
|
|
|
|
|
|
reloadData()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// func componentCColorDidRightMouseUpWithItems(_ view: NSView) -> [ComponentMenuitemProperty] {
|
|
@@ -273,11 +246,19 @@ extension KMHighlightController: ComponentCColorDelegate {
|
|
|
extension KMHighlightController: ComponentSliderDelegate {
|
|
|
func componentSliderDidUpdate(_ view: ComponentSlider) {
|
|
|
let opacity = view.properties.percent
|
|
|
+
|
|
|
CPDFAnnotation.updateAnnotations(annotations, newOpacity: opacity, withPDFView: pdfView)
|
|
|
|
|
|
- updateDefaultInfo(nil, opacity)
|
|
|
+ if annotations.count == 0 {
|
|
|
+ CPDFMarkupAnnotation.updateMarkupAnnotationDefaultOpacity(KMPDFViewManager.getValidPDFAnnotationType(viewManager?.subToolMode), opacity)
|
|
|
+ } else {
|
|
|
+ for annotation in annotations {
|
|
|
+ CPDFMarkupAnnotation.updateMarkupAnnotationDefaultOpacity(annotation.exchangeToAnnotationType(annotation.markupType()), opacity)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
reloadData()
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -291,7 +272,13 @@ extension KMHighlightController: ComponentSelectDelegate {
|
|
|
let opacity = max(0, min(1, result.stringToCGFloat()/100))
|
|
|
CPDFAnnotation.updateAnnotations(annotations, newOpacity: opacity, withPDFView: pdfView)
|
|
|
|
|
|
- updateDefaultInfo(nil, opacity)
|
|
|
+ if annotations.count == 0 {
|
|
|
+ CPDFMarkupAnnotation.updateMarkupAnnotationDefaultOpacity(KMPDFViewManager.getValidPDFAnnotationType(viewManager?.subToolMode), opacity)
|
|
|
+ } else {
|
|
|
+ for annotation in annotations {
|
|
|
+ CPDFMarkupAnnotation.updateMarkupAnnotationDefaultOpacity(annotation.exchangeToAnnotationType(annotation.markupType()), opacity)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
reloadData()
|
|
|
}
|
|
@@ -302,9 +289,16 @@ extension KMHighlightController: ComponentSelectDelegate {
|
|
|
let opacity = max(0, min(1, result.stringToCGFloat()/100))
|
|
|
CPDFAnnotation.updateAnnotations(annotations, newOpacity: opacity, withPDFView: pdfView)
|
|
|
|
|
|
- updateDefaultInfo(nil, opacity)
|
|
|
+ if annotations.count == 0 {
|
|
|
+ CPDFMarkupAnnotation.updateMarkupAnnotationDefaultOpacity(KMPDFViewManager.getValidPDFAnnotationType(viewManager?.subToolMode), opacity)
|
|
|
+ } else {
|
|
|
+ for annotation in annotations {
|
|
|
+ CPDFMarkupAnnotation.updateMarkupAnnotationDefaultOpacity(annotation.exchangeToAnnotationType(annotation.markupType()), opacity)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
reloadData()
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|