|
@@ -27,6 +27,7 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
@IBOutlet weak var opacitySlider: NSSlider!
|
|
|
@IBOutlet weak var opacityBox: NSBox!
|
|
|
@IBOutlet weak var opacityBoxBottomMaginConstraint: NSLayoutConstraint!
|
|
|
+ @IBOutlet weak var opacityBoxTopConstraint: NSLayoutConstraint!
|
|
|
|
|
|
@IBOutlet weak var cropBox: NSBox!
|
|
|
@IBOutlet weak var confirmBox: NSBox!
|
|
@@ -44,6 +45,9 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
@IBOutlet weak var flipHorizontalBox: NSBox!
|
|
|
@IBOutlet weak var flipVerticalBox: NSBox!
|
|
|
|
|
|
+ @IBOutlet weak var alignmentView: KMEditPropertyAlignmentView!
|
|
|
+ @IBOutlet weak var alignmentViewTopConstraint: NSLayoutConstraint!
|
|
|
+
|
|
|
var rotateLeftVC: KMDesignPropertySelector?
|
|
|
var rotateRightVC: KMDesignPropertySelector?
|
|
|
var flipHorizontalVC: KMDesignPropertySelector?
|
|
@@ -56,7 +60,6 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
var replaceVC: KMDesignButton?
|
|
|
var exportVC: KMDesignButton?
|
|
|
|
|
|
- @IBOutlet weak var alignmentView: KMEditPropertyAlignmentView!
|
|
|
var imagesAreas : [CPDFEditImageArea] = []
|
|
|
var listView : CPDFListView!
|
|
|
|
|
@@ -193,8 +196,14 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
exportVC?.updateUI()
|
|
|
}
|
|
|
|
|
|
- func updateLanguage(){
|
|
|
- self.titleLabel.stringValue = NSLocalizedString("Image", comment: "")
|
|
|
+ func updateLanguage() {
|
|
|
+ let areas = self.editingAreas
|
|
|
+ if imagesAreas.count > 0 && imagesAreas.count != areas.count { //多选图片跟文字
|
|
|
+ self.titleLabel.stringValue = NSLocalizedString("General Properties", comment: "")
|
|
|
+ } else {
|
|
|
+ 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: "")
|
|
@@ -224,12 +233,14 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
self.opacityBox.isHidden = false
|
|
|
self.opacityBoxHeight.constant = 56
|
|
|
self.opacityBoxBottomMaginConstraint.constant = 16
|
|
|
+ self.opacityBoxTopConstraint.constant = 16
|
|
|
self.buttonBox.isHidden = false
|
|
|
self.cropBox.isHidden = false
|
|
|
self.cancelBox.isHidden = false
|
|
|
self.replaceBox.isHidden = false
|
|
|
self.buttonBoxHeight.constant = 112
|
|
|
self.editImageView.image = self.listView.selectImageAreas.thumbnailImage
|
|
|
+ self.alignmentViewTopConstraint.constant = 16
|
|
|
|
|
|
let opacity: CGFloat = self.listView.opacity(for: imagesAreas.first)
|
|
|
self.updateImageAreasOpacity(opacity: opacity, state: .ended, needListView: false)
|
|
@@ -242,11 +253,13 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
self.opacityBox.isHidden = false
|
|
|
self.opacityBoxHeight.constant = 56
|
|
|
self.opacityBoxBottomMaginConstraint.constant = 0
|
|
|
+ self.opacityBoxTopConstraint.constant = 0
|
|
|
self.buttonBox.isHidden = false
|
|
|
self.cropBox.isHidden = true
|
|
|
self.cancelBox.isHidden = true
|
|
|
self.replaceBox.isHidden = true
|
|
|
self.buttonBoxHeight.constant = 0
|
|
|
+ self.alignmentViewTopConstraint.constant = 16
|
|
|
var opacity = self.listView.opacity(for: imagesAreas.first)
|
|
|
for area in imagesAreas {
|
|
|
let newOpacity = self.listView.opacity(for: area)
|
|
@@ -256,8 +269,12 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
}
|
|
|
self.updateImageAreasOpacity(opacity: opacity, state: .ended, needListView: false)
|
|
|
} else if imagesAreas.count > 0 && imagesAreas.count != areas.count { //多选图片跟文字
|
|
|
- self.headerBox.isHidden = true
|
|
|
- self.headerBoxHeight.constant = 0
|
|
|
+ self.opacityBoxBottomMaginConstraint.constant = 0
|
|
|
+ self.headerBoxMaginWidthConstraint.constant = 0
|
|
|
+ self.alignmentViewTopConstraint.constant = 0
|
|
|
+ self.opacityBoxTopConstraint.constant = 0
|
|
|
+// self.headerBox.isHidden = true
|
|
|
+ self.headerBoxHeight.constant = 48
|
|
|
self.imageBox.isHidden = true
|
|
|
self.imageBoxHeight.constant = 0
|
|
|
self.opacityBox.isHidden = true
|
|
@@ -265,6 +282,7 @@ class KMEditImagePropertyViewController: NSViewController {
|
|
|
self.buttonBox.isHidden = true
|
|
|
self.buttonBoxHeight.constant = 0
|
|
|
}
|
|
|
+ self.updateLanguage()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -496,20 +514,21 @@ extension KMEditImagePropertyViewController {
|
|
|
if imagesAreas.count == 1 {
|
|
|
let panel = NSSavePanel()
|
|
|
panel.nameFieldStringValue = "\(NSLocalizedString("Untitled", comment: "")).png"
|
|
|
- let button = NSButton.init(checkboxWithTitle: NSLocalizedString("Open the document after saving", comment: ""), target: nil, action: nil)
|
|
|
- button.state = .on
|
|
|
- panel.accessoryView = button
|
|
|
+// let button = NSButton.init(checkboxWithTitle: NSLocalizedString("Open the document after saving", comment: ""), target: nil, action: nil)
|
|
|
+// button.state = .on
|
|
|
+// panel.accessoryView = button
|
|
|
panel.isExtensionHidden = true
|
|
|
let response = panel.runModal()
|
|
|
if response == .OK {
|
|
|
let url = panel.url
|
|
|
let result = self.listView.extractImage(with: self.listView.selectImageAreas, toImagePath: url!.path)
|
|
|
if result {
|
|
|
- if button.state == .on { /// 开启文档
|
|
|
- NSWorkspace.shared.openFile(url!.path)
|
|
|
- } else {
|
|
|
-
|
|
|
- }
|
|
|
+// if button.state == .on { /// 开启文档
|
|
|
+// NSWorkspace.shared.openFile(url!.path)
|
|
|
+ NSWorkspace.shared.activateFileViewerSelecting([url!])
|
|
|
+// } else {
|
|
|
+//
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
} else if imagesAreas.count > 1 {
|