|
@@ -83,6 +83,8 @@ class KMEditPDfHanddler: NSObject {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private var startPoint_: NSPoint = .zero
|
|
|
|
+
|
|
func enterEditPDF() {
|
|
func enterEditPDF() {
|
|
let toolMode = self.listView?.toolMode ?? .none
|
|
let toolMode = self.listView?.toolMode ?? .none
|
|
if toolMode != .editPDFToolMode { // 退出
|
|
if toolMode != .editPDFToolMode { // 退出
|
|
@@ -90,8 +92,14 @@ class KMEditPDfHanddler: NSObject {
|
|
self.listView?.setNeedsDisplayForVisiblePages()
|
|
self.listView?.setNeedsDisplayForVisiblePages()
|
|
self.listView?.commitEditFormText()
|
|
self.listView?.commitEditFormText()
|
|
self.closeRightPane()
|
|
self.closeRightPane()
|
|
|
|
+
|
|
|
|
+ self.hiddenPopWindow()
|
|
|
|
+ self._removeNotification()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ self._addNotification()
|
|
|
|
+
|
|
if self.rightSideLastState == .open {
|
|
if self.rightSideLastState == .open {
|
|
self.openRightPane()
|
|
self.openRightPane()
|
|
} else {
|
|
} else {
|
|
@@ -184,9 +192,11 @@ class KMEditPDfHanddler: NSObject {
|
|
let area = (self.listView?.editingAreas().first as? CPDFEditArea)
|
|
let area = (self.listView?.editingAreas().first as? CPDFEditArea)
|
|
let areaBounds = (self.listView?.convert(area!.bounds, from: area!.page) as? NSRect) ?? .zero
|
|
let areaBounds = (self.listView?.convert(area!.bounds, from: area!.page) as? NSRect) ?? .zero
|
|
|
|
|
|
|
|
+ self.startPoint_ = self.listView?.documentView().documentVisibleRect.origin ?? .zero
|
|
win.show(relativeTo: areaBounds, of: self.viewC!.listView, preferredEdge: .maxY)
|
|
win.show(relativeTo: areaBounds, of: self.viewC!.listView, preferredEdge: .maxY)
|
|
|
|
+
|
|
win.animator().alphaValue = 1
|
|
win.animator().alphaValue = 1
|
|
- self.viewC?.view.window?.addChildWindow(win, ordered: .above)
|
|
|
|
|
|
+ self._kAddchildwindow(win)
|
|
win.itemClick = { [weak self] itemKey, obj in
|
|
win.itemClick = { [weak self] itemKey, obj in
|
|
if itemKey == .color {
|
|
if itemKey == .color {
|
|
self?.fontColorAction(color: obj as? NSColor)
|
|
self?.fontColorAction(color: obj as? NSColor)
|
|
@@ -262,7 +272,7 @@ class KMEditPDfHanddler: NSObject {
|
|
let frame = NSMakeRect(x, winFrame.origin.y, 84, 44)
|
|
let frame = NSMakeRect(x, winFrame.origin.y, 84, 44)
|
|
winC.window?.setFrame(frame, display: true)
|
|
winC.window?.setFrame(frame, display: true)
|
|
winC.showWindow(nil)
|
|
winC.showWindow(nil)
|
|
- self.viewC?.view.window?.addChildWindow(winC.window!, ordered: .above)
|
|
|
|
|
|
+ self._kAddchildwindow(winC.window!)
|
|
winC.itemAction = { [weak self] idx, _ in
|
|
winC.itemAction = { [weak self] idx, _ in
|
|
self?.hiddenCropComfirmWindow()
|
|
self?.hiddenCropComfirmWindow()
|
|
|
|
|
|
@@ -324,7 +334,7 @@ class KMEditPDfHanddler: NSObject {
|
|
guideWC.window?.setFrame(winFrame, display: false)
|
|
guideWC.window?.setFrame(winFrame, display: false)
|
|
guideWC.window?.minSize = winFrame.size
|
|
guideWC.window?.minSize = winFrame.size
|
|
guideWC.window?.maxSize = winFrame.size
|
|
guideWC.window?.maxSize = winFrame.size
|
|
- self.viewC?.view.window?.addChildWindow(guideWC.window!, ordered: .above)
|
|
|
|
|
|
+ self._kAddchildwindow(guideWC.window!)
|
|
guideWC.show()
|
|
guideWC.show()
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
guideWC.interfaceThemeDidChanged(NSApp.appearance?.name ?? .aqua)
|
|
guideWC.interfaceThemeDidChanged(NSApp.appearance?.name ?? .aqua)
|
|
@@ -341,6 +351,13 @@ class KMEditPDfHanddler: NSObject {
|
|
// MARK: - Private Methods
|
|
// MARK: - Private Methods
|
|
|
|
|
|
extension KMEditPDfHanddler {
|
|
extension KMEditPDfHanddler {
|
|
|
|
+ private func _kAddchildwindow(_ childW: NSWindow?) {
|
|
|
|
+ guard let win = childW else {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ self.viewC?.view.window?.addChildWindow(win, ordered: .above)
|
|
|
|
+ }
|
|
|
|
+
|
|
private func _kRemoveChildWindow(_ childW: NSWindow?) {
|
|
private func _kRemoveChildWindow(_ childW: NSWindow?) {
|
|
guard let win = childW else {
|
|
guard let win = childW else {
|
|
return
|
|
return
|
|
@@ -350,6 +367,39 @@ extension KMEditPDfHanddler {
|
|
self.viewC?.view.window?.removeChildWindow(win)
|
|
self.viewC?.view.window?.removeChildWindow(win)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private func _addNotification() {
|
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(_scrollViewDidScroll), name: NSScrollView.didLiveScrollNotification, object: self.listView?.documentView())
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private func _removeNotification() {
|
|
|
|
+ NotificationCenter.default.removeObserver(self, name: NSScrollView.didLiveScrollNotification, object: self.listView?.documentView())
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc private func _scrollViewDidScroll(_ noti: Notification) {
|
|
|
|
+ if let data = self.listView?.documentView().isEqual(to: noti.object), data {
|
|
|
|
+ let win = KMEditPDFPopToolBarWindow.shared
|
|
|
|
+ if win.isVisible == false {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ guard let area = (self.listView?.editingAreas().first as? CPDFEditArea) else {
|
|
|
|
+ self.hiddenPopWindow()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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
|
|
|
|
+ let wframe = NSMakeRect(position.x, position.y, win.frame.size.width, 44)
|
|
|
|
+ win.setFrame(wframe, display: true)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - Action
|
|
// MARK: - Action
|
|
@@ -463,6 +513,12 @@ extension KMEditPDfHanddler {
|
|
|
|
|
|
// FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_PageEdit", withProperties: ["SubTbr_Btn": "Btn_SubTbr_PageEdit_Rotate"])
|
|
// FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_PageEdit", withProperties: ["SubTbr_Btn": "Btn_SubTbr_PageEdit_Rotate"])
|
|
self.listView?.rotate(with: area, rotate: -90)
|
|
self.listView?.rotate(with: area, rotate: -90)
|
|
|
|
+
|
|
|
|
+// var frame = area.bounds
|
|
|
|
+// frame.size.width += 100
|
|
|
|
+// self.listView?.setBoundsEditArea(area, withBounds: frame)
|
|
|
|
+ // 文档拖拽、tooltip、多选场景、暗黑场景
|
|
|
|
+
|
|
// if self.listView.editingAreas()!.count == 1 && (self.listView.editingAreas()!.first is CPDFEditImageArea) {
|
|
// if self.listView.editingAreas()!.count == 1 && (self.listView.editingAreas()!.first is CPDFEditImageArea) {
|
|
// self.listView.selectImageAreas = self.listView.editingAreas()!.first as? CPDFEditImageArea
|
|
// self.listView.selectImageAreas = self.listView.editingAreas()!.first as? CPDFEditImageArea
|
|
// }
|
|
// }
|
|
@@ -812,6 +868,8 @@ extension KMEditPDfHanddler: CPDFViewDelegate {
|
|
|
|
|
|
let areas = self.listView?.editingAreas() as? [CPDFEditArea] ?? []
|
|
let areas = self.listView?.editingAreas() as? [CPDFEditArea] ?? []
|
|
if areas.isEmpty {
|
|
if areas.isEmpty {
|
|
|
|
+ self.hiddenPopWindow()
|
|
|
|
+
|
|
let toolMode = self.listView?.toolMode ?? .none
|
|
let toolMode = self.listView?.toolMode ?? .none
|
|
let annotationType = self.annotationType
|
|
let annotationType = self.annotationType
|
|
if toolMode == .editPDFToolMode {
|
|
if toolMode == .editPDFToolMode {
|