-
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift 3.0 beta 6 (acegreen's branch, but with fixes for OS X) #1353
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,14 +51,14 @@ open class ChartDataEntry: NSObject | |
|
||
open override func isEqual(_ object: Any?) -> Bool | ||
{ | ||
let object = object as? AnyObject | ||
if (object === nil) | ||
{ | ||
return false | ||
} | ||
if (!object!.isKind(of: type(of: self))) | ||
if (object == nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure which implementation is better. |
||
{ | ||
return false | ||
} | ||
|
||
let object = object as AnyObject | ||
|
||
if (!object.isKind(of: type(of: self))) | ||
{ | ||
return false | ||
} | ||
|
@@ -68,12 +68,12 @@ open class ChartDataEntry: NSObject | |
return false | ||
} | ||
|
||
if (object!.xIndex != xIndex) | ||
if (object.xIndex != xIndex) | ||
{ | ||
return false | ||
} | ||
|
||
if (fabs(object!.value - value) > 0.00001) | ||
if (fabs(object.value - value) > 0.00001) | ||
{ | ||
return false | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,40 +122,39 @@ open class ChartHighlight: NSObject | |
|
||
open override func isEqual(_ object: Any?) -> Bool | ||
{ | ||
|
||
let object = object as? AnyObject | ||
|
||
if (object === nil) | ||
if (object == nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure which implementation is better |
||
{ | ||
return false | ||
} | ||
|
||
let object = object as AnyObject | ||
|
||
if (!object!.isKind(of: type(of: self))) | ||
if (!object.isKind(of: type(of: self))) | ||
{ | ||
return false | ||
} | ||
|
||
if (object!.xIndex != _xIndex) | ||
if (object.xIndex != _xIndex) | ||
{ | ||
return false | ||
} | ||
|
||
if (object!.dataIndex != dataIndex) | ||
if (object.dataIndex != dataIndex) | ||
{ | ||
return false | ||
} | ||
|
||
if (object!.dataSetIndex != _dataSetIndex) | ||
if (object.dataSetIndex != _dataSetIndex) | ||
{ | ||
return false | ||
} | ||
|
||
if (object!.stackIndex != _stackIndex) | ||
if (object.stackIndex != _stackIndex) | ||
{ | ||
return false | ||
} | ||
|
||
if (object!.value != value) | ||
if (object.value != value) | ||
{ | ||
return false | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,6 +200,12 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple | |
UIGraphicsBeginImageContextWithOptions(size, opaque, scale) | ||
} | ||
|
||
extension NSUIFont { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure why, but the indent seems not 4 spaces.. |
||
static var nsuiSystemFontSize: CGFloat { | ||
return NSUIFont.systemFontSize | ||
} | ||
} | ||
|
||
#endif | ||
|
||
#if os(OSX) | ||
|
@@ -221,6 +227,12 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple | |
public typealias NSUIRotationGestureRecognizer = NSRotationGestureRecognizer | ||
public typealias NSUIScreen = NSScreen | ||
|
||
extension NSUIFont { | ||
static var nsuiSystemFontSize: CGFloat { | ||
return NSUIFont.systemFontSize() | ||
} | ||
} | ||
|
||
/** On OS X there is no CADisplayLink. Use a 60 fps timer to render the animations. */ | ||
open class NSUIDisplayLink | ||
{ | ||
|
@@ -251,7 +263,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple | |
_self._target?.performSelector(onMainThread: _self._selector, with: _self, waitUntilDone: false) | ||
|
||
return kCVReturnSuccess | ||
}, UnsafeMutablePointer(unsafeAddress(of: self))) | ||
}, Unmanaged.passUnretained(self).toOpaque()) | ||
} | ||
else | ||
{ | ||
|
@@ -375,7 +387,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple | |
|
||
open class NSUIView: NSView | ||
{ | ||
open final override var isFlipped: Bool | ||
open override var isFlipped: Bool | ||
{ | ||
return true | ||
} | ||
|
@@ -385,17 +397,17 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple | |
self.setNeedsDisplay(self.bounds) | ||
} | ||
|
||
open final override func touchesBegan(with event: NSEvent) | ||
open override func touchesBegan(with event: NSEvent) | ||
{ | ||
self.nsuiTouchesBegan(event.touches(matching: .any, in: self), with: event) | ||
} | ||
|
||
open final override func touchesEnded(with event: NSEvent) | ||
open override func touchesEnded(with event: NSEvent) | ||
{ | ||
self.nsuiTouchesEnded(event.touches(matching: .any, in: self), with: event) | ||
} | ||
|
||
open final override func touchesMoved(with event: NSEvent) | ||
open override func touchesMoved(with event: NSEvent) | ||
{ | ||
self.nsuiTouchesMoved(event.touches(matching: .any, in: self), with: event) | ||
} | ||
|
@@ -503,9 +515,8 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple | |
|
||
func NSUIGraphicsPushContext(_ context: CGContext) | ||
{ | ||
let address = unsafeAddress(of: context) | ||
let ptr: UnsafeMutablePointer<CGContext> = UnsafeMutablePointer(UnsafePointer<CGContext>(address)) | ||
let cx = NSGraphicsContext(graphicsPort: ptr, flipped: true) | ||
let address = Unmanaged.passUnretained(context).toOpaque() | ||
let cx = NSGraphicsContext(graphicsPort: address, flipped: true) | ||
NSGraphicsContext.saveGraphicsState() | ||
NSGraphicsContext.setCurrent(cx) | ||
} | ||
|
@@ -550,8 +561,8 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple | |
|
||
let colorSpace = CGColorSpaceCreateDeviceRGB() | ||
let ctx = CGContext(data: nil, width: width, height: height, bitsPerComponent: 8, bytesPerRow: 4*width, space: colorSpace, bitmapInfo: (opaque ? CGImageAlphaInfo.noneSkipFirst.rawValue : CGImageAlphaInfo.premultipliedFirst.rawValue)) | ||
ctx?.concatCTM(CGAffineTransform(a: 1, b: 0, c: 0, d: -1, tx: 0, ty: CGFloat(height))) | ||
ctx?.scale(x: scale, y: scale) | ||
ctx?.concatenate(CGAffineTransform(a: 1, b: 0, c: 0, d: -1, tx: 0, ty: CGFloat(height))) | ||
ctx?.scaleBy(x: scale, y: scale) | ||
NSUIGraphicsPushContext(ctx!) | ||
} | ||
} | ||
|
@@ -586,6 +597,13 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple | |
return NSUIScreen.main() | ||
} | ||
|
||
extension NSParagraphStyle { | ||
// This, oddly, is different on iOS (default is a static function on OS X) | ||
static var `default`: NSParagraphStyle { | ||
return NSParagraphStyle.default() | ||
} | ||
} | ||
|
||
extension NSString { | ||
/** On OS X, only size(withAttributes:) exists. It is expected that OSX will catch up and also change to | ||
size(attributes:). For now, use this as proxy. */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,30 +77,29 @@ open class ChartSelectionDetail: NSObject | |
|
||
open override func isEqual(_ object: Any?) -> Bool | ||
{ | ||
|
||
let object = object as? AnyObject | ||
|
||
if (object === nil) | ||
if (object == nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
{ | ||
return false | ||
} | ||
|
||
let object = object as AnyObject | ||
|
||
if (!object!.isKind(of: type(of: self))) | ||
if (!object.isKind(of: type(of: self))) | ||
{ | ||
return false | ||
} | ||
|
||
if (object!.value != _value) | ||
if (object.value != _value) | ||
{ | ||
return false | ||
} | ||
|
||
if (object!.dataSetIndex != _dataSetIndex) | ||
if (object.dataSetIndex != _dataSetIndex) | ||
{ | ||
return false | ||
} | ||
|
||
if (object!.dataSet !== _dataSet) | ||
if (object.dataSet !== _dataSet) | ||
{ | ||
return false | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guess it is supposed to start with
NSUI
?