|
@@ -2804,6 +2804,14 @@ extension KMMainViewController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @objc func removeSecondaryPdfContentView(_ sender: Notification?) {
|
|
|
+ if let _ = sender {
|
|
|
+ NotificationCenter.default.removeObserver(self, name: KMSplitView.animationDidEndNotification, object: self.newPDFSplitView)
|
|
|
+ }
|
|
|
+ self.secondaryPdfContentView?.removeFromSuperview()
|
|
|
+ self.newPDFSplitView.adjustSubviews()
|
|
|
+ }
|
|
|
+
|
|
|
func singlePageScreen(isSinglePage: Bool, doublePagesScreen isHorizontal: Bool) -> Void {
|
|
|
if !isSinglePage && isHorizontal {
|
|
|
self.openSecondaryPdfView?.changeBenefit(ofContrastLabelWidth: 208)
|
|
@@ -2816,9 +2824,24 @@ extension KMMainViewController {
|
|
|
|
|
|
func displaySinglePageScreen(isSinglePage: Bool, doublePageScreen isHorizontal: Bool) -> Void {
|
|
|
if isSinglePage {
|
|
|
- pdfSplitView.dividerStyle = .thin
|
|
|
-
|
|
|
- pdfSplitView.setPosition(mianSplitView.maxPossiblePositionOfDivider(at: 1), ofDividerAt: 0, animate: false)
|
|
|
+// pdfSplitView.dividerStyle = .thin
|
|
|
+// pdfSplitView.setPosition(mianSplitView.maxPossiblePositionOfDivider(at: 1), ofDividerAt: 0, animate: false)
|
|
|
+ if self.newPDFSplitView.animating {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if self.secondaryPdfContentView?.window != nil {
|
|
|
+ self.lastSplitPDFHeight = self.lastSplitPDFHeightFloat(self.secondaryPdfContentView?.frame ?? .zero)
|
|
|
+ self.newPDFSplitView.setPosition(self.newPDFSplitView.maxPossiblePositionOfDivider(at: 0), ofDividerAt: 0, animate: true)
|
|
|
+ if self.newPDFSplitView.animating {
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(removeSecondaryPdfContentView), name: KMSplitView.animationDidEndNotification, object: self.newPDFSplitView)
|
|
|
+ } else {
|
|
|
+ self.removeSecondaryPdfContentView(nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.view.window?.recalculateKeyViewLoop()
|
|
|
+ if self.interactionMode == .SKLegacyFullScreenMode {
|
|
|
+ self.view.window?.makeFirstResponder(self.listView)
|
|
|
+ }
|
|
|
} else {
|
|
|
if self.newPDFSplitView.animating {
|
|
|
return
|
|
@@ -2836,7 +2859,7 @@ extension KMMainViewController {
|
|
|
var position = self.lastSplitPDFHeightFloat(frame)-self.lastSplitPDFHeight-Float(self.newPDFSplitView.dividerThickness)
|
|
|
var point: NSPoint = .zero
|
|
|
var page: CPDFPage?
|
|
|
- self.newPDFSplitView.setPosition(position.cgFloat, ofDividerAt: 0, animate: false)
|
|
|
+ self.newPDFSplitView.setPosition(position.cgFloat, ofDividerAt: 0, animate: true)
|
|
|
|
|
|
if (self.secondaryPdfContentView == nil) {
|
|
|
// secondaryPdfContentView = [[SKGradientView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 200.0, 20.0)];
|
|
@@ -2848,7 +2871,7 @@ extension KMMainViewController {
|
|
|
self.newPDFSplitView.addSubview(self.secondaryPdfContentView!)
|
|
|
// self.newPDFSplitView.addArrangedSubview(self.secondaryPdfContentView!)
|
|
|
// // Because of a PDFView bug, display properties can not be changed before it is placed in a window
|
|
|
-// [secondaryPdfView setSynchronizedPDFView:pdfView];
|
|
|
+ self.secondaryPdfView?.synchronizedPDFView = self.listView
|
|
|
self.secondaryPdfView?.backgroundColor = self.listView.backgroundColor
|
|
|
// [secondaryPdfView applyDefaultPageBackgroundColor];
|
|
|
self.secondaryPdfView?.displaysPageBreaks = false
|
|
@@ -2896,7 +2919,7 @@ extension KMMainViewController {
|
|
|
self.newPDFSplitView.addSubview(self.secondaryPdfContentView!)
|
|
|
}
|
|
|
|
|
|
- self.newPDFSplitView.setPosition(self.secondaryPdfContentView?.bounds.size.width ?? 120, ofDividerAt: 1, animate: false)
|
|
|
+ self.newPDFSplitView.setPosition(self.secondaryPdfContentView?.bounds.size.width ?? 120, ofDividerAt: 1, animate: true)
|
|
|
|
|
|
if (page != nil) {
|
|
|
self.secondaryPdfView?.go(toPageIndex: Int(page!.pageIndex()), animated: false)
|
|
@@ -2905,21 +2928,20 @@ extension KMMainViewController {
|
|
|
let conP = self.secondaryPdfView?.convert(tmpP, from: page) ?? .zero
|
|
|
point = self.secondaryPdfView?.convert(conP, to: self.secondaryPdfView?.documentView()) ?? .zero
|
|
|
if let docView = self.secondaryPdfView?.documentView(), docView.contentView.isFlipped == false {
|
|
|
-// point.y -= docView.isFlipped ? NSHeight(docView.visibleRect) : nshei
|
|
|
- // point.y -= [[secondaryPdfView documentView] isFlipped] ? -NSHeight([[secondaryPdfView documentView] visibleRect]) : NSHeight([[secondaryPdfView documentView] visibleRect]);
|
|
|
-
|
|
|
+ point.y -= docView.isFlipped ? -NSHeight(docView.visibleRect) : NSHeight(docView.visibleRect)
|
|
|
}
|
|
|
-// [[secondaryPdfView documentView] scrollPoint:point];
|
|
|
-// [secondaryPdfView layoutDocumentView];
|
|
|
+ self.secondaryPdfView?.documentView()?.scroll(point)
|
|
|
+ self.secondaryPdfView?.layoutDocumentView()
|
|
|
}
|
|
|
}
|
|
|
-// [[self window] recalculateKeyViewLoop];
|
|
|
-// if ([self interactionMode] == SKLegacyFullScreenMode)
|
|
|
-// [[self window] makeFirstResponder:pdfView];
|
|
|
-//
|
|
|
-// if (![self.secondaryPdfView document]) {
|
|
|
-// [openSecondaryPdfView viewHighlyAdaptive];
|
|
|
-// }
|
|
|
+ self.view.window?.recalculateKeyViewLoop()
|
|
|
+ if self.interactionMode == .SKLegacyFullScreenMode {
|
|
|
+ self.view.window?.makeFirstResponder(self.listView)
|
|
|
+ }
|
|
|
+
|
|
|
+ if self.secondaryPdfView?.document == nil {
|
|
|
+ self.openSecondaryPdfView?.viewHighlyAdaptive()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|