|
@@ -233,7 +233,22 @@ class KMEditPDfHanddler: NSObject {
|
|
|
win.model.opacitys = self._editAreasOpacitys()
|
|
|
|
|
|
let area = (self.listView?.editingAreas().first as? CPDFEditArea)
|
|
|
- let areaBounds = (self.listView?.convert(area!.bounds, from: area!.page) as? NSRect) ?? .zero
|
|
|
+ var areaBounds = (self.listView?.convert(area!.bounds, from: area!.page) as? NSRect) ?? .zero
|
|
|
+
|
|
|
+ var maxX = NSMaxX(areaBounds)
|
|
|
+ var maxY = NSMaxY(areaBounds)
|
|
|
+ for area in self.editingAreas {
|
|
|
+// let bounds = area.bounds
|
|
|
+ var bounds = (self.listView?.convert(area.bounds, from: area.page) as? NSRect) ?? .zero
|
|
|
+ areaBounds.origin.x = min(areaBounds.origin.x, bounds.origin.x)
|
|
|
+ areaBounds.origin.y = min(areaBounds.origin.y, bounds.origin.y)
|
|
|
+
|
|
|
+ maxX = max(maxX, NSMaxX(bounds))
|
|
|
+ areaBounds.size.width = maxX-areaBounds.origin.x
|
|
|
+
|
|
|
+ maxY = max(maxY, NSMaxY(bounds))
|
|
|
+ areaBounds.size.height = maxY-areaBounds.origin.y
|
|
|
+ }
|
|
|
|
|
|
self.startPoint_ = self.listView?.documentView().documentVisibleRect.origin ?? .zero
|
|
|
win.show(relativeTo: areaBounds, of: self.viewC!.listView, preferredEdge: .maxY)
|
|
@@ -444,10 +459,49 @@ extension KMEditPDfHanddler {
|
|
|
if let data = self.listView?.documentView().isEqual(to: noti.object), data {
|
|
|
let win = KMEditPDFPopToolBarWindow.shared
|
|
|
if win.isVisible == false {
|
|
|
- return
|
|
|
+// return
|
|
|
}
|
|
|
- guard let area = (self.listView?.editingAreas().first as? CPDFEditArea) else {
|
|
|
+ guard let area = (self.listView?.editingAreas()?.first as? CPDFEditArea) else {
|
|
|
self.hiddenPopWindow()
|
|
|
+ self.hiddenCropComfirmWindow()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ let isEditImage = self.listView?.isEditImage ?? false
|
|
|
+ if isEditImage {
|
|
|
+ let winC = KMEditPDFCropComfirmWindowController.shared
|
|
|
+ let winW: CGFloat = 84
|
|
|
+ let areaBounds = (self.listView?.convert(area.bounds, from: area.page) as? NSRect) ?? .zero
|
|
|
+
|
|
|
+ let winFrame = self.listView?.window?.frame ?? .zero
|
|
|
+ let view: NSView? = nil
|
|
|
+ var position = self.listView?.convert(areaBounds.origin, to: view) ?? .zero
|
|
|
+ position.x += winFrame.origin.x
|
|
|
+ position.y += winFrame.origin.y
|
|
|
+ position.y += areaBounds.size.height
|
|
|
+ position.y += 26
|
|
|
+
|
|
|
+ var x = position.x + (NSWidth(areaBounds)-84) * 0.5
|
|
|
+// let frame = NSMakeRect(x, position.y, 84, 44)
|
|
|
+
|
|
|
+// position.x += (areaBounds.size.width*0.5-win.frame.size.width*0.5)
|
|
|
+ x = max(0, x)
|
|
|
+ var y = max(0, position.y)
|
|
|
+
|
|
|
+ let screenFrame = NSScreen.main?.frame ?? .zero
|
|
|
+ if y + 44 + 40 >= screenFrame.size.height {
|
|
|
+ y = screenFrame.size.height - 44 - 40
|
|
|
+ }
|
|
|
+
|
|
|
+ let wframe = NSMakeRect(x, y, winW, 44)
|
|
|
+ winC.window?.setFrame(wframe, display: true)
|
|
|
+
|
|
|
+ if CGRectContainsRect(winFrame, wframe) == false {
|
|
|
+ self.hiddenCropComfirmWindow()
|
|
|
+ } else {
|
|
|
+ self.showCropComfirmWindow()
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1259,6 +1313,7 @@ extension KMEditPDfHanddler: CPDFViewDelegate {
|
|
|
let areas = self.listView?.editingAreas() as? [CPDFEditArea] ?? []
|
|
|
if areas.isEmpty {
|
|
|
self.hiddenPopWindow()
|
|
|
+ self.hiddenCropComfirmWindow()
|
|
|
|
|
|
let toolMode = self.listView?.toolMode ?? .none
|
|
|
let annotationType = self.annotationType
|
|
@@ -1291,6 +1346,7 @@ extension KMEditPDfHanddler: CPDFViewDelegate {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ self.hiddenCropComfirmWindow()
|
|
|
self.viewC?.model.isPDFTextImageEdited = true
|
|
|
let subViewType = self.rightViewC?.subViewType ?? .None
|
|
|
if self.annotationType == .addImage {
|
|
@@ -1380,6 +1436,7 @@ extension KMEditPDfHanddler: CPDFViewDelegate {
|
|
|
if (window.isVisible) {
|
|
|
self.listView?.updateEditing([])
|
|
|
self.hiddenPopWindow()
|
|
|
+ self.hiddenCropComfirmWindow()
|
|
|
return
|
|
|
}
|
|
|
|