@@ -320,9 +320,7 @@ open class TableViewDiffableDataSource<Section, Item>: NSObject, NSTableViewData
320
320
public func previewImage( for item: Item ) -> NSImage ? {
321
321
let columns = tableView. tableColumns
322
322
guard !columns. isEmpty else { return nil }
323
-
324
- Swift . print ( " previewImage " , columns. count, columns. compactMap ( { previewImage ( for: item, tableColumn: $0, useColumnWidth: $0 !== columns. last!) ? . size} ) . alignHorizontal ( alignment: . top) , NSImage ( combineHorizontalAlt: columns. compactMap ( { previewImage ( for: item, tableColumn: $0, useColumnWidth: $0 !== columns. last!) } ) , alignment: . top) ? . size ?? " nil " )
325
- return NSImage ( combineHorizontalAlt: columns. compactMap ( { previewImage ( for: item, tableColumn: $0, useColumnWidth: $0 !== columns. last!) } ) , alignment: . top)
323
+ return NSImage ( combineHorizontal: columns. compactMap ( { previewImage ( for: item, tableColumn: $0, useColumnWidth: $0 !== columns. last!) } ) , alignment: . top)
326
324
}
327
325
328
326
/// Returns a preview image of the table cell for the specified item and table column.
@@ -332,8 +330,7 @@ open class TableViewDiffableDataSource<Section, Item>: NSObject, NSTableViewData
332
330
333
331
/// Returns a preview image of the table row for the specified items.
334
332
public func previewImage( for items: [ Item ] ) -> NSImage ? {
335
- Swift . print ( " previewImage " , items. count)
336
- return NSImage ( combineVerticalAlt: items. compactMap ( { previewImage ( for: $0) } ) . reversed ( ) , alignment: . left)
333
+ return NSImage ( combineVertical: items. compactMap ( { previewImage ( for: $0) } ) . reversed ( ) , alignment: . left)
337
334
}
338
335
339
336
private func previewImage( for item: Item , tableColumn: NSTableColumn , useColumnWidth: Bool ) -> NSImage ? {
@@ -1309,7 +1306,7 @@ open class TableViewDiffableDataSource<Section, Item>: NSObject, NSTableViewData
1309
1306
public var animates : Bool = true
1310
1307
1311
1308
/// A Boolean value that indicates whether the rows for the proposed drop items are previewed.
1312
- public var previewDroppedItems = true
1309
+ public var previewDroppedItems = false
1313
1310
1314
1311
/// The handler that determines whether the proposed drop can be dropped to an item.
1315
1312
public var canDropInto : ( ( _ dropInfo: DropInfo , _ item: Item ) -> Bool ) ?
@@ -1468,47 +1465,3 @@ extension CGRect {
1468
1465
return sqrt ( dx * dx + dy * dy)
1469
1466
}
1470
1467
}
1471
-
1472
- extension NSUIImage {
1473
- /**
1474
- Creates a new image by combining the specified images.
1475
-
1476
- - Parameters:
1477
- - images: The images to combine.
1478
- - orientation: The orientation of the images when combining them.
1479
- - alignment: The alignment of the images when combining them.
1480
- - Returns: The combined images, or `nil` if the images couldn't be combined.
1481
- */
1482
- public convenience init ? ( combineVerticalAlt images: [ NSUIImage ] , alignment: HorizontalAlignment = . center) {
1483
- guard let image = NSUIImage . combined ( images: images, vertical: true , alignment: alignment. rawValue) else { return nil }
1484
- self . init ( size: image. size)
1485
- lockFocus ( )
1486
- defer { unlockFocus ( ) }
1487
- image. draw ( at: . zero, from: CGRect ( origin: . zero, size: image. size) , operation: . copy, fraction: 1.0 )
1488
- }
1489
-
1490
- public convenience init ? ( combineHorizontalAlt images: [ NSUIImage ] , alignment: VerticalAlignment = . center) {
1491
- guard let image = NSUIImage . combined ( images: images, vertical: false , alignment: alignment. rawValue) else { return nil }
1492
- self . init ( size: image. size)
1493
- lockFocus ( )
1494
- defer { unlockFocus ( ) }
1495
- image. draw ( at: . zero, from: CGRect ( origin: . zero, size: image. size) , operation: . copy, fraction: 1.0 )
1496
- }
1497
-
1498
- private static func combined( images: [ NSUIImage ] , vertical: Bool , alignment: Int ) -> NSUIImage ? {
1499
- guard !images. isEmpty else { return nil }
1500
- let rects = vertical ? images. map ( { $0. size} ) . alignVertical ( alignment: . init( rawValue: alignment) !) : images. map ( { $0. size} ) . alignHorizontal ( alignment: . init( rawValue: alignment) !)
1501
- let finalImage = NSUIImage ( size: rects. union ( ) . size)
1502
- finalImage. lockFocus ( )
1503
- defer { finalImage. unlockFocus ( ) }
1504
- var currentPoint : CGPoint = . zero
1505
- for value in zip ( images, rects) {
1506
- let image = value. 0
1507
- let drawRect = value. 1
1508
- image. draw ( in: drawRect)
1509
- currentPoint = vertical ? CGPoint ( x: currentPoint. x, y: currentPoint. y + image. size. height) : CGPoint ( x: currentPoint. x + image. size. width, y: currentPoint. y)
1510
- }
1511
- Swift . print ( " combined " , finalImage. size, vertical, alignment, images. compactMap ( { $0. size} ) , rects, rects. union ( ) . size, NSGraphicsContext . current? . imageInterpolation. rawValue)
1512
- return finalImage
1513
- }
1514
- }
0 commit comments