1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-01 18:39:52 +03:00
vimr/SwiftNeoVim/CocoaExtensions.swift
2017-05-30 23:51:57 +02:00

35 lines
756 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
extension CGRect {
public var hashValue: Int {
return Int(self.origin.x) << 10 ^ Int(self.origin.y) +
Int(self.size.width) << 10 ^ Int(self.size.height);
}
}
extension CGSize {
func scaling(_ factor: CGFloat) -> CGSize {
return CGSize(width: self.width * factor, height: self.height * factor)
}
}
extension NSView {
/// - Returns: Rects currently being drawn
/// - Warning: Call only in drawRect()
func rectsBeingDrawn() -> [CGRect] {
var rectsPtr: UnsafePointer<CGRect>? = nil
var count: Int = 0
self.getRectsBeingDrawn(&rectsPtr, count: &count)
return Array(UnsafeBufferPointer(start: rectsPtr, count: count))
}
}