|
@@ -23,7 +23,7 @@ let TABLE_OFFSET: CGFloat = 8.0
|
|
|
var SKTransitionPropertiesObservationContext = UnsafeMutableRawPointer(mutating: "SKTransitionPropertiesObservationContext")
|
|
|
var SKPDFViewTransitionsObservationContext: CChar?
|
|
|
|
|
|
-class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate, KMBotaTableViewDelegate, NSTableViewDataSource, NSTableViewDelegate{
|
|
|
+class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate {
|
|
|
@IBOutlet var notesDocumentPopUpButton: NSPopUpButton!
|
|
|
@IBOutlet var tableView: KMBotaTableView!
|
|
|
@IBOutlet var separateCheckButton: NSButton!
|
|
@@ -111,6 +111,11 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
|
|
|
// transition = KMTransitionInfo()
|
|
|
// transitions = nil
|
|
|
// }
|
|
|
+
|
|
|
+ override var windowNibName: NSNib.Name?{
|
|
|
+ return "TransitionSheet"
|
|
|
+ }
|
|
|
+
|
|
|
override init(window: NSWindow?) {
|
|
|
super.init(window: window)
|
|
|
}
|
|
@@ -119,65 +124,16 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
|
|
|
super.init(coder: coder)
|
|
|
}
|
|
|
|
|
|
- @objc func handleDocumentsDidChangeNotification(notification: Notification?) {
|
|
|
- guard let currentDoc = notesDocumentPopUpButton.selectedItem?.representedObject else { return }
|
|
|
- while notesDocumentPopUpButton.numberOfItems > 1 {
|
|
|
- notesDocumentPopUpButton.removeItem(at: notesDocumentPopUpButton.numberOfItems - 1)
|
|
|
- }
|
|
|
-
|
|
|
- guard let document = controller?.document as? NSDocument,
|
|
|
- let pageCount = controller?.listView.document?.pageCount else { return }
|
|
|
-
|
|
|
- let documents = NSMutableArray()
|
|
|
- for doc in NSDocumentController.shared.documents {
|
|
|
- if let pdfDoc = doc as? CPDFDocument,
|
|
|
- doc != document,
|
|
|
- pdfDoc.pageCount == pageCount {
|
|
|
- documents.add(doc)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- let sortDescriptor = NSSortDescriptor(key: "displayName", ascending: true)
|
|
|
- documents.sort(using: [sortDescriptor])
|
|
|
-
|
|
|
- for doc in documents {
|
|
|
- notesDocumentPopUpButton.addItem(withTitle: (doc as AnyObject).displayName)
|
|
|
- notesDocumentPopUpButton.lastItem?.representedObject = doc
|
|
|
- }
|
|
|
-
|
|
|
- let docIndex = notesDocumentPopUpButton.indexOfItem(withRepresentedObject: currentDoc)
|
|
|
- notesDocumentPopUpButton.selectItem(at: docIndex == -1 ? 0 : docIndex)
|
|
|
- }
|
|
|
-
|
|
|
- func stopObservingTransitions(infos: [KMTransitionInfo]) {
|
|
|
-// for info in infos {
|
|
|
-// info.removeObserver(self, forKeyPath: TRANSITIONSTYLE_KEY)
|
|
|
-// info.removeObserver(self, forKeyPath: DURATION_KEY)
|
|
|
-// info.removeObserver(self, forKeyPath: SHOULDRESTRICT_KEY)
|
|
|
-// }
|
|
|
- }
|
|
|
-
|
|
|
- func creatTransitionController() {
|
|
|
- transitionController = SKTransitionController(for: controller?.listView)//controller?.mainViewController.listView.transitionController
|
|
|
- let options: NSKeyValueObservingOptions = [.new, .old]
|
|
|
- transitionController?.addObserver(self, forKeyPath: "transitionStyle", options: options, context: &SKPDFViewTransitionsObservationContext)
|
|
|
- transitionController?.addObserver(self, forKeyPath: "duration", options: options, context: &SKPDFViewTransitionsObservationContext)
|
|
|
- transitionController?.addObserver(self, forKeyPath: "shouldRestrict", options: options, context: &SKPDFViewTransitionsObservationContext)
|
|
|
- transitionController?.addObserver(self, forKeyPath: "pageTransitions", options: options, context: &SKPDFViewTransitionsObservationContext)
|
|
|
- }
|
|
|
-
|
|
|
override func windowDidLoad() {
|
|
|
super.windowDidLoad()
|
|
|
|
|
|
let count = SKTransitionController.transitionNames().count
|
|
|
-// let transitionStylePopUpButton = transitionControls[0] as! NSPopUpButton
|
|
|
-// transitionStylePopUpButton.removeAllItems()
|
|
|
for i in 0..<count {
|
|
|
- effectPopUpButton.addItem(withTitle: SKTransitionController.localizedName(for: SKAnimationTransitionStyle(rawValue: UInt(i)) ?? .noTransition))
|
|
|
- effectPopUpButton.lastItem?.tag = i
|
|
|
+ self.effectPopUpButton.addItem(withTitle: SKTransitionController.localizedName(for: SKAnimationTransitionStyle(rawValue: UInt(i)) ?? .noTransition))
|
|
|
+ self.effectPopUpButton.lastItem?.tag = i
|
|
|
}
|
|
|
|
|
|
- notesDocumentPopUpButton.item(at: 0)?.title = NSLocalizedString("None", comment: "Menu item title")
|
|
|
+ self.notesDocumentPopUpButton.item(at: 0)?.title = NSLocalizedString("None", comment: "Menu item title")
|
|
|
|
|
|
creatTransitionController()
|
|
|
transition.transitionStyle = transitionController?.transitionStyle ?? .noTransition
|
|
@@ -228,6 +184,53 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(handleDocumentsDidChangeNotification(notification:)), name: NSNotification.Name("SKDocumentControllerDidRemoveDocumentNotification"), object: nil)
|
|
|
}
|
|
|
|
|
|
+ @objc func handleDocumentsDidChangeNotification(notification: Notification?) {
|
|
|
+ guard let currentDoc = notesDocumentPopUpButton.selectedItem?.representedObject else { return }
|
|
|
+ while notesDocumentPopUpButton.numberOfItems > 1 {
|
|
|
+ notesDocumentPopUpButton.removeItem(at: notesDocumentPopUpButton.numberOfItems - 1)
|
|
|
+ }
|
|
|
+
|
|
|
+ guard let document = controller?.document as? NSDocument,
|
|
|
+ let pageCount = controller?.listView.document?.pageCount else { return }
|
|
|
+
|
|
|
+ let documents = NSMutableArray()
|
|
|
+ for doc in NSDocumentController.shared.documents {
|
|
|
+ if let pdfDoc = doc as? CPDFDocument,
|
|
|
+ doc != document,
|
|
|
+ pdfDoc.pageCount == pageCount {
|
|
|
+ documents.add(doc)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let sortDescriptor = NSSortDescriptor(key: "displayName", ascending: true)
|
|
|
+ documents.sort(using: [sortDescriptor])
|
|
|
+
|
|
|
+ for doc in documents {
|
|
|
+ notesDocumentPopUpButton.addItem(withTitle: (doc as AnyObject).displayName)
|
|
|
+ notesDocumentPopUpButton.lastItem?.representedObject = doc
|
|
|
+ }
|
|
|
+
|
|
|
+ let docIndex = notesDocumentPopUpButton.indexOfItem(withRepresentedObject: currentDoc)
|
|
|
+ notesDocumentPopUpButton.selectItem(at: docIndex == -1 ? 0 : docIndex)
|
|
|
+ }
|
|
|
+
|
|
|
+ func stopObservingTransitions(infos: [KMTransitionInfo]) {
|
|
|
+// for info in infos {
|
|
|
+// info.removeObserver(self, forKeyPath: TRANSITIONSTYLE_KEY)
|
|
|
+// info.removeObserver(self, forKeyPath: DURATION_KEY)
|
|
|
+// info.removeObserver(self, forKeyPath: SHOULDRESTRICT_KEY)
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ func creatTransitionController() {
|
|
|
+ transitionController = SKTransitionController(for: controller?.listView)//controller?.mainViewController.listView.transitionController
|
|
|
+ let options: NSKeyValueObservingOptions = [.new, .old]
|
|
|
+ transitionController?.addObserver(self, forKeyPath: "transitionStyle", options: options, context: &SKPDFViewTransitionsObservationContext)
|
|
|
+ transitionController?.addObserver(self, forKeyPath: "duration", options: options, context: &SKPDFViewTransitionsObservationContext)
|
|
|
+ transitionController?.addObserver(self, forKeyPath: "shouldRestrict", options: options, context: &SKPDFViewTransitionsObservationContext)
|
|
|
+ transitionController?.addObserver(self, forKeyPath: "pageTransitions", options: options, context: &SKPDFViewTransitionsObservationContext)
|
|
|
+ }
|
|
|
+
|
|
|
func startObservingTransitions(_ infos: [KMTransitionInfo]) {
|
|
|
// for info in infos {
|
|
|
// info.addObserver(self, forKeyPath: TRANSITIONSTYLE_KEY, options: [.new, .old], context: &SKTransitionPropertiesObservationContext)
|
|
@@ -273,9 +276,7 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
|
|
|
|
|
|
transitions = array as NSArray
|
|
|
}
|
|
|
- override var windowNibName: NSNib.Name?{
|
|
|
- return "TransitionSheet"
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
func changePageTransitionType() {
|
|
|
// SKImageToolTipWindow.sharedToolTipWindow().orderOut(nil)
|
|
@@ -324,7 +325,6 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
|
|
|
changePageTransitionType()
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@IBAction func changeDurationSlider(_ sender: NSSlider) {
|
|
|
self.durationTF.stringValue = sender.stringValue
|
|
|
}
|
|
@@ -376,6 +376,10 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
|
|
|
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+extension SKPresentationOptionsSheetController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
func numberOfRows(in tableView: NSTableView) -> Int {
|
|
|
return transitions?.count ?? 0
|
|
|
}
|
|
@@ -383,9 +387,9 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
|
|
|
// let identifier = tableColumn!.identifier
|
|
|
// let info = transitions?[row]
|
|
|
// if identifier.rawValue == PAGE_COLUMNID {
|
|
|
-//
|
|
|
+//
|
|
|
// } else if identifier.rawValue == IMAGE_COLUMNID {
|
|
|
-//
|
|
|
+//
|
|
|
// }
|
|
|
// return nil
|
|
|
// }
|
|
@@ -430,6 +434,9 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+extension SKPresentationOptionsSheetController: KMBotaTableViewDelegate {
|
|
|
func tableView(_ aTableView: NSTableView, imageContextForRow rowIndex: Int) -> AnyObject? {
|
|
|
return controller?.document?.page(at: UInt(rowIndex))
|
|
|
}
|
|
@@ -454,6 +461,3 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
|
|
|
return transitions?.value(forKeyPath: "thumbnail.label") as! NSArray
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-//
|