|
@@ -29,10 +29,10 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
@IBOutlet weak var opacityBoxBottomMaginConstraint: NSLayoutConstraint!
|
|
|
|
|
|
@IBOutlet weak var cropBox: NSBox!
|
|
|
+ @IBOutlet weak var confirmBox: NSBox!
|
|
|
@IBOutlet weak var cancelBox: NSBox!
|
|
|
@IBOutlet weak var replaceBox: NSBox!
|
|
|
@IBOutlet weak var exportBox: NSBox!
|
|
|
- @IBOutlet weak var cropBoxWidthConstraint: NSLayoutConstraint!
|
|
|
|
|
|
// @IBOutlet weak var cutButton: NSButton!
|
|
|
// @IBOutlet weak var replaceButton: NSButton!
|
|
@@ -57,6 +57,7 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
var opacityVC: KMDesignSelect?
|
|
|
|
|
|
var cropVC: KMDesignButton?
|
|
|
+ var confirmVC: KMDesignButton?
|
|
|
var cancelVC: KMDesignButton?
|
|
|
var replaceVC: KMDesignButton?
|
|
|
var exportVC: KMDesignButton?
|
|
@@ -161,6 +162,15 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
cropVC?.stringValue = NSLocalizedString("Crop", comment: "")
|
|
|
cropVC?.updateUI()
|
|
|
|
|
|
+ confirmVC = KMDesignButton.init(withType: .Text)
|
|
|
+ confirmBox.contentView = confirmVC?.view
|
|
|
+ confirmBox.fillColor = NSColor.clear
|
|
|
+ confirmVC?.target = self
|
|
|
+ confirmVC?.action = #selector(confirmVCImageAction)
|
|
|
+ confirmVC?.button(type: .Cta, size: .m)
|
|
|
+ confirmVC?.stringValue = NSLocalizedString("Confirm Cut", comment: "")
|
|
|
+ confirmVC?.updateUI()
|
|
|
+
|
|
|
cancelVC = KMDesignButton.init(withType: .Text)
|
|
|
cancelBox.contentView = cancelVC?.view
|
|
|
cancelBox.fillColor = NSColor.clear
|
|
@@ -193,6 +203,7 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
self.titleLabel.stringValue = NSLocalizedString("Image", comment: "")
|
|
|
self.opacityTitleLabel.stringValue = NSLocalizedString("Opacity", comment: "")
|
|
|
self.cropVC?.stringValue = NSLocalizedString("Crop", comment: "")
|
|
|
+ self.confirmVC?.stringValue = NSLocalizedString("Confirm Cut", comment: "")
|
|
|
self.cancelVC?.stringValue = NSLocalizedString("Cancel", comment: "")
|
|
|
self.replaceVC?.stringValue = NSLocalizedString("Replace", comment: "")
|
|
|
self.exportVC?.stringValue = NSLocalizedString("Extract", comment: "")
|
|
@@ -266,28 +277,36 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
func updateButtonState(hidden:Bool) {
|
|
|
if hidden {
|
|
|
self.cancelBox.isHidden = true
|
|
|
- self.cropBoxWidthConstraint.constant = 0
|
|
|
- self.cropBox.title = NSLocalizedString("Crop", comment: "")
|
|
|
- self.replaceVC?.state = .Norm
|
|
|
- self.exportVC?.state = .Norm
|
|
|
+ self.confirmBox.isHidden = true
|
|
|
+ self.cropBox.isHidden = false
|
|
|
+ self.replaceVC?.enabled = true
|
|
|
+ self.exportVC?.enabled = true
|
|
|
self.opacitySlider.isEnabled = true
|
|
|
- self.opacityVC?.state = .Norm
|
|
|
- self.rotateLeftVC?.state = .Norm
|
|
|
- self.rotateRightVC?.state = .Norm
|
|
|
- self.flipVerticalVC?.state = .Norm
|
|
|
- self.flipHorizontalVC?.state = .Norm
|
|
|
+ self.opacityVC?.enabled = true
|
|
|
+ self.rotateLeftVC?.button.isEnabled = true
|
|
|
+ self.rotateLeftVC?.view.alphaValue = 1.0
|
|
|
+ self.rotateRightVC?.button.isEnabled = true
|
|
|
+ self.rotateRightVC?.view.alphaValue = 1.0
|
|
|
+ self.flipVerticalVC?.button.isEnabled = true
|
|
|
+ self.flipVerticalVC?.view.alphaValue = 1.0
|
|
|
+ self.flipHorizontalVC?.button.isEnabled = true
|
|
|
+ self.flipHorizontalVC?.view.alphaValue = 1.0
|
|
|
} else {
|
|
|
self.cancelBox.isHidden = false
|
|
|
- self.cropBoxWidthConstraint.constant = 120
|
|
|
- self.cropBox.title = NSLocalizedString("Confirm Cut", comment: "")
|
|
|
- self.replaceVC?.state = .Disabled
|
|
|
- self.exportVC?.state = .Disabled
|
|
|
+ self.confirmBox.isHidden = false
|
|
|
+ self.cropBox.isHidden = true
|
|
|
+ self.replaceVC?.enabled = false
|
|
|
+ self.exportVC?.enabled = false
|
|
|
self.opacitySlider.isEnabled = false
|
|
|
- self.opacityVC?.state = .Disabled
|
|
|
- self.rotateLeftVC?.state = .Disabled
|
|
|
- self.rotateRightVC?.state = .Disabled
|
|
|
- self.flipVerticalVC?.state = .Disabled
|
|
|
- self.flipHorizontalVC?.state = .Disabled
|
|
|
+ self.opacityVC?.enabled = false
|
|
|
+ self.rotateLeftVC?.button.isEnabled = false
|
|
|
+ self.rotateLeftVC?.view.alphaValue = 0.5
|
|
|
+ self.rotateRightVC?.button.isEnabled = false
|
|
|
+ self.rotateRightVC?.view.alphaValue = 0.5
|
|
|
+ self.flipVerticalVC?.button.isEnabled = false
|
|
|
+ self.flipVerticalVC?.view.alphaValue = 0.5
|
|
|
+ self.flipHorizontalVC?.button.isEnabled = false
|
|
|
+ self.flipHorizontalVC?.view.alphaValue = 0.5
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -432,13 +451,18 @@ extension KMEditImagePropertyViewController {
|
|
|
if self.listView.selectImageAreas == nil {
|
|
|
return
|
|
|
}
|
|
|
- if self.listView.cropAreas != nil && self.listView.selectImageAreas != nil{
|
|
|
- self.listView.cropEditImageArea(self.listView.selectImageAreas, withBounds: self.listView.cropAreas.cropRect)
|
|
|
- } else if self.listView.selectImageAreas != nil {
|
|
|
- self.listView.isEditImage = true
|
|
|
- self.listView.enterCrop(with: self.listView.selectImageAreas)
|
|
|
- self.updateButtonState(hidden: false)
|
|
|
+
|
|
|
+ self.listView.isEditImage = true
|
|
|
+ self.listView.enterCrop(with: self.listView.selectImageAreas)
|
|
|
+ self.updateButtonState(hidden: false)
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func confirmVCImageAction(_ sender: Any) {
|
|
|
+ if self.listView.selectImageAreas == nil {
|
|
|
+ return
|
|
|
}
|
|
|
+
|
|
|
+ self.listView.cropEditImageArea(self.listView.selectImageAreas, withBounds: self.listView.cropAreas.cropRect)
|
|
|
}
|
|
|
|
|
|
@IBAction func cancelCutImageAction(_ sender: Any) {
|