mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-25 23:02:35 +03:00
GH-296 Better drag image
This commit is contained in:
parent
278c1af454
commit
53f5928aa3
@ -152,11 +152,24 @@ extension WorkspaceToolButton {
|
|||||||
self.dehighlight()
|
self.dehighlight()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.raywenderlich.com/136272/drag-and-drop-tutorial-for-macos
|
// Modified version of snapshot() from https://www.raywenderlich.com/136272/drag-and-drop-tutorial-for-macos
|
||||||
fileprivate func snapshot() -> NSImage {
|
fileprivate func snapshot() -> NSImage {
|
||||||
let pdfData = self.dataWithPDF(inside: self.bounds)
|
let pdfData = self.dataWithPDF(inside: self.bounds)
|
||||||
let image = NSImage(data: pdfData)
|
guard let image = NSImage(data: pdfData) else {
|
||||||
return image ?? NSImage()
|
return NSImage()
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = NSImage()
|
||||||
|
let rect = CGRect(origin: .zero, size: image.size)
|
||||||
|
result.size = rect.size
|
||||||
|
|
||||||
|
result.lockFocus()
|
||||||
|
NSColor.controlShadowColor.set()
|
||||||
|
NSRectFill(rect)
|
||||||
|
image.draw(in: rect)
|
||||||
|
result.unlockFocus()
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user