|
@@ -18,19 +18,19 @@ import Cocoa
|
|
self.init(nibName: "KMGeneralAnnotationViewController", bundle: nil)
|
|
self.init(nibName: "KMGeneralAnnotationViewController", bundle: nil)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ override func awakeFromNib() {
|
|
|
|
+ super.awakeFromNib()
|
|
|
|
+
|
|
|
|
+ self.initSubviews()
|
|
|
|
+ }
|
|
|
|
+
|
|
override func viewDidLoad() {
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
super.viewDidLoad()
|
|
|
|
|
|
self.initDefaultValue()
|
|
self.initDefaultValue()
|
|
}
|
|
}
|
|
|
|
|
|
- func initDefaultValue() {
|
|
|
|
- self.borderItemButtonHeightConst.constant = 64
|
|
|
|
- self.lineStyleBox.isHidden = true
|
|
|
|
- self.lineStyleButton.isHidden = true
|
|
|
|
- self.dottedLineStyleBox.isHidden = true
|
|
|
|
- self.dottedLineStyleButton.isHidden = true
|
|
|
|
-
|
|
|
|
|
|
+ func initSubviews() {
|
|
let view = KMLineAndBorderItemView.createFromNib()
|
|
let view = KMLineAndBorderItemView.createFromNib()
|
|
self.lineAndBorderItemView = view
|
|
self.lineAndBorderItemView = view
|
|
let borderAndLineView = self.kBorderAndLineView
|
|
let borderAndLineView = self.kBorderAndLineView
|
|
@@ -39,11 +39,96 @@ import Cocoa
|
|
view?.autoresizingMask = [.width]
|
|
view?.autoresizingMask = [.width]
|
|
self.kBorderAndLineView.addSubview(view!)
|
|
self.kBorderAndLineView.addSubview(view!)
|
|
|
|
|
|
- view?.lineImageButon.imagePosition = .imageOnly
|
|
|
|
- view?.lineImageButon.image = self.borderStyleSolid(false)
|
|
|
|
|
|
+ self.lineAndBorderItemView?.lineRadio.target = self
|
|
|
|
+ self.lineAndBorderItemView?.lineRadio.action = #selector(lineRadioAction)
|
|
|
|
+
|
|
|
|
+ self.lineAndBorderItemView?.dashRadio.target = self
|
|
|
|
+ self.lineAndBorderItemView?.dashRadio.action = #selector(dashRadioAction)
|
|
|
|
+
|
|
|
|
+ self.lineAndBorderItemView?.dashComboBox.target = self
|
|
|
|
+ self.lineAndBorderItemView?.dashComboBox.action = #selector(dashComboAction)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func initDefaultValue() {
|
|
|
|
+ self.borderItemButtonHeightConst.constant = 64
|
|
|
|
+ self.lineStyleBox.isHidden = true
|
|
|
|
+ self.lineStyleButton.isHidden = true
|
|
|
|
+ self.dottedLineStyleBox.isHidden = true
|
|
|
|
+ self.dottedLineStyleButton.isHidden = true
|
|
|
|
+
|
|
|
|
+ self.borderButton.isHidden = true
|
|
|
|
+
|
|
|
|
+ self.lineAndBorderItemView?.lineImageButon.imagePosition = .imageOnly
|
|
|
|
+ self.lineAndBorderItemView?.lineImageButon.image = self.borderStyleSolid(false)
|
|
|
|
+
|
|
|
|
+ self.lineAndBorderItemView?.dashImageButton.imagePosition = .imageOnly
|
|
|
|
+ self.lineAndBorderItemView?.dashImageButton.image = self.borderStyleDashed(false)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override func reloadData() {
|
|
|
|
+ super.reloadData()
|
|
|
|
+
|
|
|
|
+ let style = self.annotationModel?.style() ?? .solid
|
|
|
|
+ self.selectBorderStyle(style)
|
|
|
|
+
|
|
|
|
+ if let datas = self.annotationModel?.dashPattern() {
|
|
|
|
+ if let data = datas.first as? CGFloat {
|
|
|
|
+ self.lineAndBorderItemView?.dashComboBox.stringValue = String(format: "%0.1f pt", data)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func selectBorderStyle(_ style: CPDFBorderStyle) {
|
|
|
|
+ if style == .dashed {
|
|
|
|
+ self.lineAndBorderItemView?.lineRadio.state = .off
|
|
|
|
+ self.lineAndBorderItemView?.dashRadio.state = .on
|
|
|
|
+
|
|
|
|
+ self.lineAndBorderItemView?.dashComboBox.isEnabled = true
|
|
|
|
+ } else {
|
|
|
|
+ self.lineAndBorderItemView?.lineRadio.state = .on
|
|
|
|
+ self.lineAndBorderItemView?.dashRadio.state = .off
|
|
|
|
+
|
|
|
|
+ self.lineAndBorderItemView?.dashComboBox.isEnabled = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // MARK: - Actions
|
|
|
|
+
|
|
|
|
+ @objc func lineRadioAction(_ sender: NSButton) {
|
|
|
|
+ self.annotationModel?.setStyle(.solid)
|
|
|
|
+
|
|
|
|
+ self.selectBorderStyle(.solid)
|
|
|
|
+
|
|
|
|
+ self.reloadData()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc func dashRadioAction(_ sender: NSButton) {
|
|
|
|
+ self.annotationModel?.setStyle(.dashed)
|
|
|
|
+
|
|
|
|
+ self.selectBorderStyle(.dashed)
|
|
|
|
+
|
|
|
|
+ self.reloadData()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @IBAction func dashComboAction(_ sender: Any) {
|
|
|
|
+ var lineWidth = self.lineAndBorderItemView?.dashComboBox.floatValue ?? 0
|
|
|
|
+ if lineWidth > 18 {
|
|
|
|
+ lineWidth = 18
|
|
|
|
+ } else if lineWidth < 0.5 {
|
|
|
|
+ lineWidth = 0.5
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if let data = self.annotationModel?.annotation {
|
|
|
|
+ data.setDashPattern([lineWidth])
|
|
|
|
+
|
|
|
|
+ self.pdfView?.setNeedsDisplayAnnotationViewFor(data.page)
|
|
|
|
+ } else {
|
|
|
|
+ let userDefaults = UserDefaults.standard
|
|
|
|
+ userDefaults.set([lineWidth], forKey: CInkNoteDashPatternKey)
|
|
|
|
+ }
|
|
|
|
|
|
- view?.dashImageButton.imagePosition = .imageOnly
|
|
|
|
- view?.dashImageButton.image = self.borderStyleDashed(false)
|
|
|
|
|
|
+// self.updateAnnotation()
|
|
|
|
+ self.reloadData()
|
|
}
|
|
}
|
|
|
|
|
|
override func borderStyleSolid(_ isSelect: Bool) -> NSImage {
|
|
override func borderStyleSolid(_ isSelect: Bool) -> NSImage {
|