|
@@ -43,6 +43,13 @@ class KMRedactPropertiesWindowController: KMNBaseWindowController {
|
|
|
|
|
|
var callback: ((_ anno: CPDFRedactAnnotation?)->Void)?
|
|
|
|
|
|
+ var isChangeProperites = false {
|
|
|
+ didSet {
|
|
|
+ self.makePropertiesButton.properties.isDisabled = !isChangeProperites
|
|
|
+ self.makePropertiesButton.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
convenience init() {
|
|
|
self.init(windowNibName: "KMRedactPropertiesWindowController")
|
|
|
}
|
|
@@ -319,6 +326,7 @@ class KMRedactPropertiesWindowController: KMNBaseWindowController {
|
|
|
makePropertiesButton.isHidden = true
|
|
|
}
|
|
|
|
|
|
+ self.isChangeProperites = false
|
|
|
updateLabelUI()
|
|
|
}
|
|
|
|
|
@@ -331,6 +339,8 @@ class KMRedactPropertiesWindowController: KMNBaseWindowController {
|
|
|
alightLeftButton.reloadData()
|
|
|
alightCenteButton.reloadData()
|
|
|
alightRightButton.reloadData()
|
|
|
+
|
|
|
+ self.updatePropertiesState()
|
|
|
}
|
|
|
|
|
|
@objc func alightRightButtonClicked(_ sender: NSView) {
|
|
@@ -341,6 +351,8 @@ class KMRedactPropertiesWindowController: KMNBaseWindowController {
|
|
|
alightLeftButton.reloadData()
|
|
|
alightCenteButton.reloadData()
|
|
|
alightRightButton.reloadData()
|
|
|
+
|
|
|
+ self.updatePropertiesState()
|
|
|
}
|
|
|
|
|
|
@objc func alightCenterButtonClicked(_ sender: NSView) {
|
|
@@ -351,6 +363,8 @@ class KMRedactPropertiesWindowController: KMNBaseWindowController {
|
|
|
alightLeftButton.reloadData()
|
|
|
alightCenteButton.reloadData()
|
|
|
alightRightButton.reloadData()
|
|
|
+
|
|
|
+ self.updatePropertiesState()
|
|
|
}
|
|
|
|
|
|
@objc func makePropertiesButtonClicked(_ sender: AnyObject?) {
|
|
@@ -410,6 +424,47 @@ class KMRedactPropertiesWindowController: KMNBaseWindowController {
|
|
|
@IBAction func useOverlayText_button(_ sender: AnyObject?) {
|
|
|
updateLabelUI()
|
|
|
}
|
|
|
+
|
|
|
+ func updatePropertiesState() {
|
|
|
+ let s = (fontSizeComboSelect.properties.text as? NSString)?.trimmingCharacters(in: CharacterSet(charactersIn: " pt")) ?? ""
|
|
|
+ let fontsize = Int(s) ?? 12
|
|
|
+
|
|
|
+ var alignment: NSTextAlignment = .left
|
|
|
+ if alightCenteButton.properties.state == .pressed {
|
|
|
+ alignment = .center
|
|
|
+ } else if alightRightButton.properties.state == .pressed {
|
|
|
+ alignment = .right
|
|
|
+ }
|
|
|
+
|
|
|
+ if let anno = readactAnnotation {
|
|
|
+ var isChange = false
|
|
|
+ if anno.borderColor() != outlineColorItem.properties?.color {
|
|
|
+ isChange = true
|
|
|
+ }
|
|
|
+
|
|
|
+ if anno.interiorColor() != fillColorItem.properties?.color {
|
|
|
+ isChange = true
|
|
|
+ }
|
|
|
+
|
|
|
+ if anno.fontColor() != fontColorItem.properties?.color {
|
|
|
+ isChange = true
|
|
|
+ }
|
|
|
+
|
|
|
+ if anno.fontSize != fontsize.cgFloat {
|
|
|
+ isChange = true
|
|
|
+ }
|
|
|
+
|
|
|
+ if anno.alignment() != alignment {
|
|
|
+ isChange = true
|
|
|
+ }
|
|
|
+
|
|
|
+ if anno.overlayText() != overlayTextarea.properties.text {
|
|
|
+ isChange = true
|
|
|
+ }
|
|
|
+
|
|
|
+ self.isChangeProperites = isChange
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//MARK: - ComponentTextareaDelegate
|
|
@@ -420,10 +475,12 @@ extension KMRedactPropertiesWindowController: ComponentTextareaDelegate {
|
|
|
|
|
|
func componentTextareaTextDidChange(_ view: ComponentTextarea) {
|
|
|
updateLabelUI()
|
|
|
+
|
|
|
+ self.updatePropertiesState()
|
|
|
}
|
|
|
|
|
|
func componentTextareaTextDidEndEditing(_ view: ComponentTextarea) {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -431,7 +488,7 @@ extension KMRedactPropertiesWindowController: ComponentTextareaDelegate {
|
|
|
extension KMRedactPropertiesWindowController: ComponentSelectDelegate {
|
|
|
|
|
|
func componentSelectDidSelect(view: ComponentSelect?, menuItemProperty: ComponentMenuitemProperty?) {
|
|
|
-
|
|
|
+ self.updatePropertiesState()
|
|
|
}
|
|
|
|
|
|
func componentSelectTextDidBeginEditing(_ view: ComponentSelect) {
|
|
@@ -447,13 +504,15 @@ extension KMRedactPropertiesWindowController: ComponentSelectDelegate {
|
|
|
}
|
|
|
|
|
|
func componentSelectTextDidEndEditing(_ view: ComponentSelect, removeUnit text: String?) {
|
|
|
-
|
|
|
+ self.updatePropertiesState()
|
|
|
}
|
|
|
|
|
|
@objc func fontColorChange(_ sender: Any) {
|
|
|
if let color = (sender as? NSColorPanel)?.color {
|
|
|
fontColorItem.properties?.color = color
|
|
|
fontColorItem.reloadData()
|
|
|
+
|
|
|
+ self.updatePropertiesState()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -461,6 +520,8 @@ extension KMRedactPropertiesWindowController: ComponentSelectDelegate {
|
|
|
if let color = (sender as? NSColorPanel)?.color {
|
|
|
outlineColorItem.properties?.color = color
|
|
|
outlineColorItem.reloadData()
|
|
|
+
|
|
|
+ self.updatePropertiesState()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -468,6 +529,8 @@ extension KMRedactPropertiesWindowController: ComponentSelectDelegate {
|
|
|
if let color = (sender as? NSColorPanel)?.color {
|
|
|
fillColorItem.properties?.color = color
|
|
|
fillColorItem.reloadData()
|
|
|
+
|
|
|
+ self.updatePropertiesState()
|
|
|
}
|
|
|
}
|
|
|
|