Implement multiple tracks drag & drop in the document window.

This commit is contained in:
Damiano Galassi committed 2019-01-28 14:10:19 +01:00
1 parent cdddba7f3b
commit 3778909a69
3 files changed
+14 -8

No files matched your search

+4 -4
View File
@@ -273,12 +273,12 @@ class TracksViewController: NSViewController, NSTableViewDataSource, NSTableView
row: Int,
dropOperation: NSTableView.DropOperation) -> Bool {
let data: Data = info.draggingPasteboard.data(forType: pasteboardType)!
let rowIndexes: IndexSet = NSKeyedUnarchiver.unarchiveObject(with: data) as! IndexSet
if let rowIndexes: IndexSet = NSKeyedUnarchiver.unarchiveObject(with: data) as? IndexSet, rowIndexes.isEmpty == false {
let tracks = mp4.tracks.enumerated().filter { rowIndexes.contains($0.offset + 1)} .map { $0.element }
mp4.moveTracks(tracks, to: UInt(row - 1))
if let dragRow = rowIndexes.first {
mp4.moveTrack(at: UInt(dragRow - 1), to: UInt(row - 1))
tableView.reloadData()
// TODO: Support multiple rows drag
return true
}