|
@@ -53,8 +53,10 @@ class SKPresentationOptionsSheetController: KMBaseWindowController {
|
|
|
if self.transitions_ != newValue {
|
|
|
// (undoRedoManager?.prepare(withInvocationTarget: self) as AnyObject).transitions = transitions
|
|
|
self.transitions_ = newValue
|
|
|
- stopObservingTransitions(infos: transitions as! [KMTransitionInfo])
|
|
|
- startObservingTransitions(transitions as! [KMTransitionInfo])
|
|
|
+ if let data = self.transitions as? [KMTransitionInfo] {
|
|
|
+ stopObservingTransitions(infos: data)
|
|
|
+ startObservingTransitions(data)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -136,9 +138,9 @@ class SKPresentationOptionsSheetController: KMBaseWindowController {
|
|
|
}
|
|
|
|
|
|
// collapse the table
|
|
|
- self.window?.setFrame(NSInsetRect(window?.frame ?? .zero, 0.5 * (NSWidth(tableView.enclosingScrollView!.frame) + TABLE_OFFSET), 0.0), display: false)
|
|
|
+ self.window?.setFrame(NSInsetRect(window?.frame ?? .zero, 0.5 * (NSWidth(tableView.enclosingScrollView?.frame ?? .zero) + TABLE_OFFSET), 0.0), display: false)
|
|
|
|
|
|
- self.tableView.registerForDraggedTypes(KMTransitionInfo.readableTypesForPasteboard(pasteboard: NSPasteboard(name: NSPasteboard.Name.drag)) as! [NSPasteboard.PasteboardType])
|
|
|
+// self.tableView.registerForDraggedTypes(KMTransitionInfo.readableTypes(for: NSPasteboard(name: .drag)))
|
|
|
self.tableView.delegate = self
|
|
|
self.tableView.dataSource = self
|
|
|
self.tableView.botaDelegate = self
|
|
@@ -244,15 +246,15 @@ class SKPresentationOptionsSheetController: KMBaseWindowController {
|
|
|
let ptEnum = arr?.objectEnumerator()
|
|
|
var tn: KMThumbnail? = nil
|
|
|
|
|
|
- for next in (controller?.leftSideViewController.thumbnails)! {
|
|
|
+ for next in (controller?.leftSideViewController.thumbnails) ?? [] {
|
|
|
if tn != nil {
|
|
|
let info = KMTransitionInfo()
|
|
|
info.thumbnail = tn
|
|
|
- info.label = "\(tn!.label)"+"→"+"\(next.label)"
|
|
|
+ info.label = "\(tn?.label ?? "")"+"→"+"\(next.label)"
|
|
|
info.properties = ((ptEnum?.nextObject()) != nil) ? ptEnum?.nextObject() as? NSDictionary : dictionary
|
|
|
array.append(info)
|
|
|
(cell as AnyObject).setStringValue(info.label)
|
|
|
- labelWidth = max(labelWidth, ceil(((cell as AnyObject).cellSize?.width)!))
|
|
|
+ labelWidth = max(labelWidth, ceil(((cell as AnyObject).cellSize?.width) ?? 0))
|
|
|
}
|
|
|
tn = next
|
|
|
}
|
|
@@ -443,13 +445,13 @@ class SKPresentationOptionsSheetController: KMBaseWindowController {
|
|
|
func transforArr() -> NSArray {
|
|
|
let arr = NSMutableArray()
|
|
|
for i in 0..<(transitions?.count ?? 0) {
|
|
|
- let item: KMTransitionInfo = transitions?[i] as! KMTransitionInfo
|
|
|
-// item.properties
|
|
|
- let dic = NSMutableDictionary.init()
|
|
|
- dic.setValue(item.duration, forKey: "duration")
|
|
|
- dic.setValue(item.shouldRestrict, forKey: "shouldRestrict")
|
|
|
- dic.setValue(item.properties?[SKStyleNameKey], forKey: "styleName")
|
|
|
- arr.add(dic)
|
|
|
+ if let item = transitions?[i] as? KMTransitionInfo {
|
|
|
+ let dic = NSMutableDictionary.init()
|
|
|
+ dic.setValue(item.duration, forKey: "duration")
|
|
|
+ dic.setValue(item.shouldRestrict, forKey: "shouldRestrict")
|
|
|
+ dic.setValue(item.properties?[SKStyleNameKey], forKey: "styleName")
|
|
|
+ arr.add(dic)
|
|
|
+ }
|
|
|
}
|
|
|
return arr
|
|
|
}
|
|
@@ -603,11 +605,14 @@ extension SKPresentationOptionsSheetController: NSTableViewDelegate, NSTableView
|
|
|
} else if let id = identifier?.rawValue, id == IMAGE_COLUMNID {
|
|
|
let cell = tableColumn?.dataCell as? NSImageCell
|
|
|
let page = self.controller?.listView.document.page(at: UInt(info?.thumbnail?.pageIndex ?? 0))
|
|
|
- if let data = page?.PDFListViewTIFFData(for: page?.bounds ?? .zero) {
|
|
|
- let image = NSImage(data: data)
|
|
|
- cell?.image = image
|
|
|
- return image
|
|
|
- }
|
|
|
+ let image = page?.thumbnail(of: page?.bounds.size ?? .zero)
|
|
|
+ cell?.image = image
|
|
|
+ return image
|
|
|
+// if let data = page?.PDFListViewTIFFData(for: page?.bounds ?? .zero) {
|
|
|
+// let image = NSImage(data: data)
|
|
|
+// cell?.image = image
|
|
|
+// return image
|
|
|
+// }
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
@@ -657,8 +662,10 @@ extension SKPresentationOptionsSheetController: NSTableViewDelegate, NSTableView
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, writeRowsWith rowIndexes: IndexSet, to pboard: NSPasteboard) -> Bool {
|
|
|
if rowIndexes.count == 1 {
|
|
|
- pboard.clearContents()
|
|
|
- pboard.writeObjects([transitions?[rowIndexes.first ?? 0] as! NSPasteboardWriting])
|
|
|
+ if let data = transitions?[rowIndexes.first ?? 0] as? NSPasteboardWriting {
|
|
|
+ pboard.clearContents()
|
|
|
+ pboard.writeObjects([data])
|
|
|
+ }
|
|
|
return true
|
|
|
} else {
|
|
|
return false
|
|
@@ -666,31 +673,31 @@ extension SKPresentationOptionsSheetController: NSTableViewDelegate, NSTableView
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, validateDrop info: NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableView.DropOperation) -> NSDragOperation {
|
|
|
- if info.draggingPasteboard.canReadObject(forClasses: [KMTransitionInfo.self], options: [:]) {
|
|
|
- if dropOperation == .above {
|
|
|
- tableView.setDropRow(-1, dropOperation: .on)
|
|
|
- }
|
|
|
- return .every
|
|
|
- }
|
|
|
- return []
|
|
|
+// if info.draggingPasteboard.canReadObject(forClasses: [KMTransitionInfo.self], options: [:]) {
|
|
|
+// if dropOperation == .above {
|
|
|
+// tableView.setDropRow(-1, dropOperation: .on)
|
|
|
+// }
|
|
|
+// return .every
|
|
|
+// }
|
|
|
+ return NSDragOperation(rawValue: 0)
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, acceptDrop info: NSDraggingInfo, row: Int, dropOperation: NSTableView.DropOperation) -> Bool {
|
|
|
- let pboard = info.draggingPasteboard
|
|
|
- if dropOperation == .on {
|
|
|
- guard let infos = pboard.readObjects(forClasses: [KMTransitionInfo.self], options: [:]) as? [KMTransitionInfo], infos.count > 0 else {
|
|
|
- return false
|
|
|
- }
|
|
|
- let propertie: NSDictionary? = infos[0].properties
|
|
|
-
|
|
|
- if row == -1 {
|
|
|
- transitions?.setValue(propertie, forKey: PROPERTIES_KEY)
|
|
|
- } else {
|
|
|
- let transit: KMTransitionInfo = transitions?[row] as! KMTransitionInfo
|
|
|
- transit.properties = propertie
|
|
|
- }
|
|
|
- return true
|
|
|
- }
|
|
|
+// let pboard = info.draggingPasteboard
|
|
|
+// if dropOperation == .on {
|
|
|
+// guard let infos = pboard.readObjects(forClasses: [KMTransitionInfo.self], options: [:]) as? [KMTransitionInfo], infos.count > 0 else {
|
|
|
+// return false
|
|
|
+// }
|
|
|
+// let propertie: NSDictionary? = infos[0].properties
|
|
|
+//
|
|
|
+// if row == -1 {
|
|
|
+// transitions?.setValue(propertie, forKey: PROPERTIES_KEY)
|
|
|
+// } else {
|
|
|
+// let transit: KMTransitionInfo = transitions?[row] as! KMTransitionInfo
|
|
|
+// transit.properties = propertie
|
|
|
+// }
|
|
|
+// return true
|
|
|
+// }
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
@@ -701,22 +708,26 @@ extension SKPresentationOptionsSheetController: KMBotaTableViewDelegate {
|
|
|
}
|
|
|
|
|
|
func tableView(_ aTableView: NSTableView, copyRowsWithIndexes rowIndexes: IndexSet) {
|
|
|
- let pboard = NSPasteboard.general
|
|
|
- pboard.clearContents()
|
|
|
- pboard.writeObjects([transitions?[rowIndexes.first ?? 0] as! NSPasteboardWriting])
|
|
|
+ if let data = transitions?[rowIndexes.first ?? 0] as? NSPasteboardWriting {
|
|
|
+ let pboard = NSPasteboard.general
|
|
|
+ pboard.clearContents()
|
|
|
+ pboard.writeObjects([data])
|
|
|
+ }
|
|
|
}
|
|
|
func tableView(_ aTableView: NSTableView, canCopyRowsWithIndexes rowIndexes: IndexSet) -> Bool {
|
|
|
- return true
|
|
|
+ return false
|
|
|
}
|
|
|
func tableView(_ aTableView: NSTableView, pasteFromPasteboard pboard: NSPasteboard) {
|
|
|
- guard let infos = pboard.readObjects(forClasses: [KMTransitionInfo.self], options: [:]) as? [KMTransitionInfo], infos.count > 0 else { return }
|
|
|
- let arr = transitions?.objects(at: tableView.selectedRowIndexes) as? NSArray
|
|
|
- arr?.setValue(infos[0].properties, forKey: PROPERTIES_KEY)
|
|
|
+// guard let infos = pboard.readObjects(forClasses: [KMTransitionInfo.self], options: [:]) as? [KMTransitionInfo], infos.count > 0 else { return }
|
|
|
+// let arr = transitions?.objects(at: tableView.selectedRowIndexes) as? NSArray
|
|
|
+// arr?.setValue(infos[0].properties, forKey: PROPERTIES_KEY)
|
|
|
}
|
|
|
func tableView(_ aTableView: NSTableView, canPasteFromPasteboard pboard: NSPasteboard) -> Bool {
|
|
|
- return (tableView.selectedRow != -1 && pboard.canReadObject(forClasses: [KMTransitionInfo.self], options: [:]))
|
|
|
+// return (tableView.selectedRow != -1 && pboard.canReadObject(forClasses: [KMTransitionInfo.self], options: [:]))
|
|
|
+ return false
|
|
|
}
|
|
|
func tableView(_ aTableView: NSTableView, typeSelectHelperSelectionStrings aTypeSelectHelper: SKTypeSelectHelper) -> NSArray {
|
|
|
- return transitions?.value(forKeyPath: "thumbnail.label") as! NSArray
|
|
|
+// return transitions?.value(forKeyPath: "thumbnail.label") as! NSArray
|
|
|
+ return []
|
|
|
}
|
|
|
}
|