From 5f7b7b54e0e8f2a410c1e8560dbf1b5d2e2348cf Mon Sep 17 00:00:00 2001 From: Alejandro Isaza Date: Fri, 23 Dec 2016 16:56:00 -0800 Subject: [PATCH] Make View, Shape and Polygon open --- C4/UI/Polygon.swift | 2 +- C4/UI/Shape.swift | 6 +++--- C4/UI/View+KeyValues.swift | 4 ++-- C4/UI/View.swift | 16 ++++++++-------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/C4/UI/Polygon.swift b/C4/UI/Polygon.swift index 4a5eb887..2badb2e0 100644 --- a/C4/UI/Polygon.swift +++ b/C4/UI/Polygon.swift @@ -21,7 +21,7 @@ import Foundation import CoreGraphics /// Polygon is a concrete subclass of Shape that has a special initialzer that creates a non-uniform shape made up of 3 or more points. -public class Polygon: Shape { +open class Polygon: Shape { /// Returns the array of points that make up the polygon. /// diff --git a/C4/UI/Shape.swift b/C4/UI/Shape.swift index fbe71be2..0ab07fb4 100644 --- a/C4/UI/Shape.swift +++ b/C4/UI/Shape.swift @@ -21,7 +21,7 @@ import QuartzCore import UIKit /// Shape is a concrete subclass of View that draws a bezier path in its coordinate space. -public class Shape: View { +open class Shape: View { internal class ShapeView: UIView { var shapeLayer: ShapeLayer { return self.layer as! ShapeLayer // swiftlint:disable:this force_cast @@ -46,7 +46,7 @@ public class Shape: View { } /// Shape's contents are drawn on a ShapeLayer. - public var shapeLayer: ShapeLayer { + open var shapeLayer: ShapeLayer { return self.shapeView.shapeLayer } @@ -230,7 +230,7 @@ public class Shape: View { /// The current rotation value of the view. Animatable. /// - returns: A Double value representing the cumulative rotation of the view, measured in Radians. - public override var rotation: Double { + open override var rotation: Double { get { if let number = shapeLayer.value(forKeyPath: Layer.rotationKey) as? NSNumber { return number.doubleValue diff --git a/C4/UI/View+KeyValues.swift b/C4/UI/View+KeyValues.swift index 5b1652a7..254d2d7e 100644 --- a/C4/UI/View+KeyValues.swift +++ b/C4/UI/View+KeyValues.swift @@ -24,7 +24,7 @@ extension View { /// /// - parameter value: The value for the key identified by _key_. /// - parameter key: The name of one of the receiver's properties. - public override func setValue(_ value: Any?, forKey key: String) { + open override func setValue(_ value: Any?, forKey key: String) { switch (key, value) { case ("frame", let nsvalue as NSValue): frame = Rect(nsvalue.cgRectValue) @@ -54,7 +54,7 @@ extension View { /// - parameter key: The name of one of the receiver's properties. /// /// - returns: The value for the data specified by the key. - public override func value(forKey key: String) -> Any? { + open override func value(forKey key: String) -> Any? { switch key { case "frame": return NSValue(cgRect: CGRect(frame)) diff --git a/C4/UI/View.swift b/C4/UI/View.swift index 34155212..c9ee7e11 100644 --- a/C4/UI/View.swift +++ b/C4/UI/View.swift @@ -28,13 +28,13 @@ extension NSValue { } /// The View class defines a rectangular area on the screen and the interfaces for managing visual content in that area. The View class itself provides basic behavior for filling its rectangular area with a background color. More sophisticated content can be presented by subclassing UIView and implementing the necessary drawing and event-handling code yourself. The C4 framework also includes a set of standard subclasses that range from simple shapes to movies and images that can be used as-is. -public class View: NSObject { +open class View: NSObject { /// A UIView. Internally, View wraps and provides access to an internal UIView. - public var view: UIView = LayerView() + open var view: UIView = LayerView() /// The current rotation value of the view. Animatable. /// - returns: A Double value representing the cumulative rotation of the view, measured in Radians. - public var rotation: Double { + open var rotation: Double { get { if let number = animatableLayer.value(forKeyPath: Layer.rotationKey) as? NSNumber { return number.doubleValue @@ -47,23 +47,23 @@ public class View: NSObject { } /// The view that contains the receiver's animatable layer. - internal var layerView: LayerView { + open var layerView: LayerView { return self.view as! LayerView // swiftlint:disable:this force_cast } - internal class LayerView: UIView { - var animatableLayer: Layer { + open class LayerView: UIView { + open var animatableLayer: Layer { return self.layer as! Layer // swiftlint:disable:this force_cast } - override class var layerClass: AnyClass { + override open class var layerClass: AnyClass { return Layer.self } } /// The view's primary layer. /// - returns: A Layer, whose properties are animatable (e.g. rotation) - public var animatableLayer: Layer { + open var animatableLayer: Layer { return self.layerView.animatableLayer }