|
@@ -218,130 +218,31 @@ class KMRectangleController: NSViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var _borderColor: NSColor?
|
|
|
+ var _fillColor: NSColor?
|
|
|
+ var _opacity: CGFloat?
|
|
|
|
|
|
- if annotations.count == 0 {
|
|
|
- if viewManager?.subToolMode == .Rectangle {
|
|
|
- colorGroup.currentColor = CPDFSquareAnnotation.defaultColor()
|
|
|
-
|
|
|
- fillColorGroup.currentColor = CPDFSquareAnnotation.defaultInteriorColor()
|
|
|
-
|
|
|
- let opacity = CPDFSquareAnnotation.defaultOpacity()
|
|
|
- colorSlider.properties.percent = opacity
|
|
|
- colorOpacitySelect.properties.text = String(format: "%.0f%@", opacity*100, "%")
|
|
|
-
|
|
|
- let border: CPDFBorder = CPDFSquareAnnotation.defaultBorder()
|
|
|
-
|
|
|
- dashProperty.state = .normal
|
|
|
- solidProperty.state = .normal
|
|
|
- if border.style == .dashed {
|
|
|
- dashProperty.state = .pressed
|
|
|
- } else if border.style == .solid {
|
|
|
- solidProperty.state = .pressed
|
|
|
- }
|
|
|
-
|
|
|
- let percent = border.lineWidth/18
|
|
|
- lineWidthSlider.properties.percent = percent
|
|
|
- lineWidthSlider.reloadData()
|
|
|
-
|
|
|
- lineWidthSelect.properties.text = String(format: "%.0f%@", border.lineWidth, " pt")
|
|
|
- lineWidthSelect.reloadData()
|
|
|
-
|
|
|
- linedashInfoView.isHidden = true
|
|
|
- if border.style == .dashed {
|
|
|
- linedashInfoView.isHidden = false
|
|
|
-
|
|
|
- var dash = 1.0
|
|
|
- for dashPattern in border.dashPattern {
|
|
|
- if let value = dashPattern as? CGFloat {
|
|
|
- dash = value
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- let percent: CGFloat = CGFloat(dash)/18
|
|
|
- lineDashSlider.properties.percent = percent
|
|
|
- lineDashSlider.reloadData()
|
|
|
-
|
|
|
- lineDashSelect.properties.text = String(format: "%.0f%@", CGFloat(dash), " pt")
|
|
|
- lineDashSelect.reloadData()
|
|
|
- }
|
|
|
-
|
|
|
- } else if viewManager?.subToolMode == .Circle {
|
|
|
- colorGroup.currentColor = CPDFCircleAnnotation.defaultColor()
|
|
|
-
|
|
|
- fillColorGroup.currentColor = CPDFCircleAnnotation.defaultInteriorColor()
|
|
|
-
|
|
|
- let opacity = CPDFCircleAnnotation.defaultOpacity()
|
|
|
- colorSlider.properties.percent = opacity
|
|
|
- colorOpacitySelect.properties.text = String(format: "%.0f%@", opacity*100, "%")
|
|
|
-
|
|
|
- let border: CPDFBorder = CPDFCircleAnnotation.defaultBorder()
|
|
|
-
|
|
|
- dashProperty.state = .normal
|
|
|
- solidProperty.state = .normal
|
|
|
- if border.style == .dashed {
|
|
|
- dashProperty.state = .pressed
|
|
|
- } else if border.style == .solid {
|
|
|
- solidProperty.state = .pressed
|
|
|
- }
|
|
|
-
|
|
|
- let percent = border.lineWidth/18
|
|
|
- lineWidthSlider.properties.percent = percent
|
|
|
- lineWidthSlider.reloadData()
|
|
|
-
|
|
|
- lineWidthSelect.properties.text = String(format: "%.0f%@", border.lineWidth, " pt")
|
|
|
- lineWidthSelect.reloadData()
|
|
|
-
|
|
|
- linedashInfoView.isHidden = true
|
|
|
- if border.style == .dashed {
|
|
|
- linedashInfoView.isHidden = false
|
|
|
-
|
|
|
- var dash = 1.0
|
|
|
- for dashPattern in border.dashPattern {
|
|
|
- if let value = dashPattern as? CGFloat {
|
|
|
- dash = value
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- let percent: CGFloat = CGFloat(dash)/18
|
|
|
- lineDashSlider.properties.percent = percent
|
|
|
- lineDashSlider.reloadData()
|
|
|
-
|
|
|
- lineDashSelect.properties.text = String(format: "%.0f%@", CGFloat(dash), " pt")
|
|
|
- lineDashSelect.reloadData()
|
|
|
- }
|
|
|
- }
|
|
|
- } else if annotations.count == 1, let annotation = firstAnnotation {
|
|
|
- colorGroup.currentColor = annotation.color
|
|
|
+ var _borderStyle: CPDFBorderStyle?
|
|
|
+ var _borderWidth: CGFloat?
|
|
|
+ var _borderDashWidth: CGFloat?
|
|
|
+
|
|
|
+ if let annotation = firstAnnotation {
|
|
|
+ _borderColor = annotation.color
|
|
|
|
|
|
- if firstAnnotation is CPDFCircleAnnotation {
|
|
|
- fillColorGroup.currentColor = (firstAnnotation as! CPDFCircleAnnotation).interiorColor
|
|
|
- } else if firstAnnotation is CPDFSquareAnnotation {
|
|
|
- fillColorGroup.currentColor = (firstAnnotation as! CPDFSquareAnnotation).interiorColor
|
|
|
+ if annotation is CPDFCircleAnnotation {
|
|
|
+ _fillColor = (annotation as! CPDFCircleAnnotation).interiorColor
|
|
|
+ } else if annotation is CPDFSquareAnnotation {
|
|
|
+ _fillColor = (annotation as! CPDFSquareAnnotation).interiorColor
|
|
|
}
|
|
|
|
|
|
- let opacity = annotation.opacity
|
|
|
- colorSlider.properties.percent = opacity
|
|
|
-
|
|
|
- colorOpacitySelect.properties.text = String(format: "%.0f%@", opacity*100, "%")
|
|
|
+ _opacity = annotation.opacity
|
|
|
|
|
|
let border: CPDFBorder = annotation.border ?? CPDFBorder()
|
|
|
- dashProperty.state = .normal
|
|
|
- solidProperty.state = .normal
|
|
|
- if border.style == .dashed {
|
|
|
- dashProperty.state = .pressed
|
|
|
- } else if border.style == .solid {
|
|
|
- solidProperty.state = .pressed
|
|
|
- }
|
|
|
-
|
|
|
- let percent = border.lineWidth/18
|
|
|
- lineWidthSlider.properties.percent = percent
|
|
|
|
|
|
- lineWidthSelect.properties.text = String(format: "%.0f%@", border.lineWidth, " pt")
|
|
|
+ _borderStyle = border.style
|
|
|
+ _borderWidth = border.lineWidth
|
|
|
|
|
|
- linedashInfoView.isHidden = true
|
|
|
if border.style == .dashed {
|
|
|
- linedashInfoView.isHidden = false
|
|
|
-
|
|
|
var dash = 1.0
|
|
|
for dashPattern in border.dashPattern {
|
|
|
if let value = dashPattern as? CGFloat {
|
|
@@ -349,135 +250,127 @@ class KMRectangleController: NSViewController {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
- let percent: CGFloat = CGFloat(dash)/18
|
|
|
- lineDashSlider.properties.percent = percent
|
|
|
-
|
|
|
- lineDashSelect.properties.text = String(format: "%.0f%@", CGFloat(dash), " pt")
|
|
|
-
|
|
|
- }
|
|
|
- } else {
|
|
|
- guard let annotation = firstAnnotation else {
|
|
|
- return
|
|
|
+ _borderDashWidth = dash
|
|
|
}
|
|
|
|
|
|
- if true {
|
|
|
- let multiColor: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .color)
|
|
|
- if multiColor == true {
|
|
|
- colorGroup.currentColor = nil
|
|
|
- } else {
|
|
|
- colorGroup.currentColor = annotation.color
|
|
|
+ if annotations.count > 1 {
|
|
|
+ if CPDFListView.isAnnotationsContainMultiType(annotations, withType: .color) == true {
|
|
|
+ _borderColor = nil
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if true {
|
|
|
- let multiColor: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .interiorColor)
|
|
|
- if multiColor == true {
|
|
|
- fillColorGroup.currentColor = nil
|
|
|
- } else {
|
|
|
- if firstAnnotation is CPDFSquareAnnotation {
|
|
|
- fillColorGroup.currentColor = (firstAnnotation as! CPDFSquareAnnotation).interiorColor
|
|
|
- } else if firstAnnotation is CPDFCircleAnnotation {
|
|
|
- fillColorGroup.currentColor = (firstAnnotation as! CPDFCircleAnnotation).interiorColor
|
|
|
- }
|
|
|
+
|
|
|
+ if CPDFListView.isAnnotationsContainMultiType(annotations, withType: .interiorColor) == true {
|
|
|
+ _fillColor = nil
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if true {
|
|
|
- let multiOpacity: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .opacity)
|
|
|
- if multiOpacity {
|
|
|
- colorSlider.properties.percent = 0
|
|
|
-
|
|
|
- colorOpacitySelect.resetText("-")
|
|
|
- } else {
|
|
|
- let opacity = annotation.opacity
|
|
|
-
|
|
|
- colorSlider.properties.percent = opacity
|
|
|
- colorSlider.reloadData()
|
|
|
-
|
|
|
- colorOpacitySelect.properties.text = String(format: "%.0f%@", opacity*100, "%")
|
|
|
- colorOpacitySelect.reloadData()
|
|
|
+
|
|
|
+ if CPDFListView.isAnnotationsContainMultiType(annotations, withType: .opacity) {
|
|
|
+ _opacity = nil
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if true {
|
|
|
- let multiStyle: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .border_Style)
|
|
|
|
|
|
- linedashInfoView.isHidden = true
|
|
|
- if multiStyle {
|
|
|
- dashProperty.state = .normal
|
|
|
- solidProperty.state = .normal
|
|
|
-
|
|
|
- lineTypeSelector.reloadData()
|
|
|
- } else {
|
|
|
- let style = annotation.border?.style
|
|
|
- dashProperty.state = .normal
|
|
|
- solidProperty.state = .normal
|
|
|
- if style == .dashed {
|
|
|
- dashProperty.state = .pressed
|
|
|
- } else if style == .solid {
|
|
|
- solidProperty.state = .pressed
|
|
|
- }
|
|
|
- lineTypeSelector.reloadData()
|
|
|
-
|
|
|
- if style == .dashed {
|
|
|
- linedashInfoView.isHidden = false
|
|
|
- }
|
|
|
+ if CPDFListView.isAnnotationsContainMultiType(annotations, withType: .border_Style) {
|
|
|
+ _borderStyle = nil
|
|
|
+ }
|
|
|
+
|
|
|
+ if CPDFListView.isAnnotationsContainMultiType(annotations, withType: .line_Width) {
|
|
|
+ _borderWidth = nil
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if true {
|
|
|
- let multiLineWidth: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .line_Width)
|
|
|
|
|
|
- if multiLineWidth {
|
|
|
- lineWidthSlider.properties.percent = 0
|
|
|
- lineWidthSlider.reloadData()
|
|
|
-
|
|
|
- lineWidthSelect.resetText("-")
|
|
|
- } else {
|
|
|
- let border: CPDFBorder = annotation.border ?? CPDFBorder()
|
|
|
-
|
|
|
- let percent = border.lineWidth/18
|
|
|
- lineWidthSlider.properties.percent = percent
|
|
|
- lineWidthSlider.reloadData()
|
|
|
-
|
|
|
- lineWidthSelect.properties.text = String(format: "%.0f%@", border.lineWidth, " pt")
|
|
|
- lineWidthSelect.reloadData()
|
|
|
+ if CPDFListView.isAnnotationsContainMultiType(annotations, withType: .dash_Pattern) {
|
|
|
+ _borderDashWidth = nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if true {
|
|
|
- let multiLineDash: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .dash_Pattern)
|
|
|
- if multiLineDash {
|
|
|
- lineDashSlider.properties.percent = 0
|
|
|
- lineDashSlider.reloadData()
|
|
|
-
|
|
|
- lineDashSelect.resetText("-")
|
|
|
- } else {
|
|
|
- var dashA = 1.0
|
|
|
- for dashPattern in annotation.border?.dashPattern ?? [] {
|
|
|
+ } else {
|
|
|
+ if viewManager?.subToolMode == .Rectangle {
|
|
|
+ _borderColor = CPDFSquareAnnotation.defaultColor()
|
|
|
+ _fillColor = CPDFSquareAnnotation.defaultInteriorColor()
|
|
|
+ _opacity = CPDFSquareAnnotation.defaultOpacity()
|
|
|
+
|
|
|
+ let border: CPDFBorder = CPDFSquareAnnotation.defaultBorder()
|
|
|
+
|
|
|
+ _borderStyle = border.style
|
|
|
+ _borderWidth = border.lineWidth
|
|
|
+
|
|
|
+ if border.style == .dashed {
|
|
|
+ var dash = 1.0
|
|
|
+ for dashPattern in border.dashPattern {
|
|
|
if let value = dashPattern as? CGFloat {
|
|
|
- dashA = value
|
|
|
+ dash = value
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- let percent = dashA / 18
|
|
|
- lineDashSlider.properties.percent = percent
|
|
|
- lineDashSlider.reloadData()
|
|
|
-
|
|
|
- lineDashSelect.properties.text = String(format: "%.0f%@", dashA, " pt")
|
|
|
- lineDashSelect.reloadData()
|
|
|
+ _borderDashWidth = dash
|
|
|
+ }
|
|
|
+ } else if viewManager?.subToolMode == .Circle {
|
|
|
+ _borderColor = CPDFCircleAnnotation.defaultColor()
|
|
|
+
|
|
|
+ _fillColor = CPDFCircleAnnotation.defaultInteriorColor()
|
|
|
+ _opacity = CPDFCircleAnnotation.defaultOpacity()
|
|
|
+
|
|
|
+ let border: CPDFBorder = CPDFCircleAnnotation.defaultBorder()
|
|
|
+
|
|
|
+ _borderStyle = border.style
|
|
|
+ _borderWidth = border.lineWidth
|
|
|
+ if border.style == .dashed {
|
|
|
+ var dash = 1.0
|
|
|
+ for dashPattern in border.dashPattern {
|
|
|
+ if let value = dashPattern as? CGFloat {
|
|
|
+ dash = value
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _borderDashWidth = dash
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ colorGroup.currentColor = _borderColor
|
|
|
colorGroup.refreshUI()
|
|
|
+
|
|
|
+ fillColorGroup.currentColor = _fillColor
|
|
|
fillColorGroup.refreshUI()
|
|
|
+
|
|
|
+ if let value = _opacity {
|
|
|
+ colorSlider.properties.percent = value
|
|
|
+ colorOpacitySelect.properties.text = String(format: "%.0f%@", value*100, "%")
|
|
|
+ } else {
|
|
|
+ colorSlider.properties.percent = 0
|
|
|
+ colorOpacitySelect.properties.text = "-"
|
|
|
+ }
|
|
|
colorSlider.reloadData()
|
|
|
colorOpacitySelect.reloadData()
|
|
|
+
|
|
|
+ linedashInfoView.isHidden = true
|
|
|
+ dashProperty.state = .normal
|
|
|
+ solidProperty.state = .normal
|
|
|
+ if let value = _borderStyle {
|
|
|
+ if value == .dashed {
|
|
|
+ linedashInfoView.isHidden = false
|
|
|
+ dashProperty.state = .pressed
|
|
|
+ } else if value == .solid {
|
|
|
+ solidProperty.state = .pressed
|
|
|
+ }
|
|
|
+ }
|
|
|
lineTypeSelector.reloadData()
|
|
|
+
|
|
|
+ if let value = _borderWidth {
|
|
|
+ let percent = value/18
|
|
|
+ lineWidthSlider.properties.percent = percent
|
|
|
+ lineWidthSelect.properties.text = String(format: "%.0f%@", value, " pt")
|
|
|
+ } else {
|
|
|
+ lineWidthSlider.properties.percent = 0
|
|
|
+ lineWidthSelect.properties.text = "-"
|
|
|
+ }
|
|
|
lineWidthSlider.reloadData()
|
|
|
lineWidthSelect.reloadData()
|
|
|
+
|
|
|
+ if let value = _borderDashWidth {
|
|
|
+ let percent = value / 18
|
|
|
+ lineDashSlider.properties.percent = percent
|
|
|
+ lineDashSelect.properties.text = String(format: "%.0f%@", value, " pt")
|
|
|
+ } else {
|
|
|
+ lineDashSlider.properties.percent = 0
|
|
|
+ lineDashSelect.properties.text = "-"
|
|
|
+ }
|
|
|
lineDashSlider.reloadData()
|
|
|
lineDashSelect.reloadData()
|
|
|
|
|
@@ -679,7 +572,7 @@ extension KMRectangleController: ComponentCSelectorGroupDelegate {
|
|
|
}
|
|
|
|
|
|
} else if item.properties == dashProperty {
|
|
|
- CPDFAnnotation.updateAnnotations(annotations, newBorderStyle: .solid, withPDFView: pdfView)
|
|
|
+ CPDFAnnotation.updateAnnotations(annotations, newBorderStyle: .dashed, withPDFView: pdfView)
|
|
|
|
|
|
if circleAnnotations.count > 0 || viewManager?.subToolMode == .Circle {
|
|
|
CPDFCircleAnnotation.updateDefault_Style(.dashed)
|