Skip to content

Commit

Permalink
Make View, Shape and Polygon open
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandro-isaza committed Dec 24, 2016
1 parent 4008595 commit 5f7b7b5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion C4/UI/Polygon.swift
Expand Up @@ -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.
///
Expand Down
6 changes: 3 additions & 3 deletions C4/UI/Shape.swift
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions C4/UI/View+KeyValues.swift
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
16 changes: 8 additions & 8 deletions C4/UI/View.swift
Expand Up @@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit 5f7b7b5

Please sign in to comment.