From 99d4f653f6934120234cbe04dd3d810d5b965043 Mon Sep 17 00:00:00 2001 From: Louis D'hauwe Date: Mon, 2 Apr 2018 20:07:38 +0200 Subject: [PATCH] Make components open --- HueKit/View/ColorBarPicker.swift | 22 +++++++++++----------- HueKit/View/ColorBarView.swift | 4 ++-- HueKit/View/ColorIndicatorView.swift | 6 +++--- HueKit/View/ColorSquarePicker.swift | 12 ++++++------ HueKit/View/ColorSquareView.swift | 4 ++-- HueKit/View/SourceColorView.swift | 16 ++++++++-------- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/HueKit/View/ColorBarPicker.swift b/HueKit/View/ColorBarPicker.swift index 71c4ab5..ff9bd61 100644 --- a/HueKit/View/ColorBarPicker.swift +++ b/HueKit/View/ColorBarPicker.swift @@ -10,7 +10,7 @@ import Foundation import UIKit @IBDesignable -public class ColorBarPicker: UIControl { +open class ColorBarPicker: UIControl { private var isVertical: Bool = false { didSet { @@ -33,7 +33,7 @@ public class ColorBarPicker: UIControl { private static let indicatorSizeActive = CGSize(width: 40.0, height: 40.0) @IBInspectable - public var hue: CGFloat { + open var hue: CGFloat { get { if isVertical { return 1.0 - value @@ -112,7 +112,7 @@ public class ColorBarPicker: UIControl { // MARK: - Drawing - override public func layoutSubviews() { + override open func layoutSubviews() { if colorBarView.superview == nil { @@ -182,26 +182,26 @@ public class ColorBarPicker: UIControl { self.value = percent.pinned(between: 0, and: 1) } - override public func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { + override open func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { self.trackIndicator(with: touch) growIndicator() return true } - override public func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { + override open func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { self.trackIndicator(with: touch) return true } - override public func endTracking(_ touch: UITouch?, with event: UIEvent?) { + override open func endTracking(_ touch: UITouch?, with event: UIEvent?) { super.endTracking(touch, with: event) shrinkIndicator() } - override public func cancelTracking(with event: UIEvent?) { + override open func cancelTracking(with event: UIEvent?) { super.cancelTracking(with: event) shrinkIndicator() @@ -250,7 +250,7 @@ public class ColorBarPicker: UIControl { private let accessibilityInterval: CGFloat = 0.05 - public override var accessibilityTraits: UIAccessibilityTraits { + open override var accessibilityTraits: UIAccessibilityTraits { get { var t = super.accessibilityTraits @@ -263,7 +263,7 @@ public class ColorBarPicker: UIControl { } } - public override func accessibilityIncrement() { + open override func accessibilityIncrement() { var newValue = self.value + accessibilityInterval @@ -274,7 +274,7 @@ public class ColorBarPicker: UIControl { self.value = newValue } - public override func accessibilityDecrement() { + open override func accessibilityDecrement() { var newValue = self.value - accessibilityInterval @@ -285,7 +285,7 @@ public class ColorBarPicker: UIControl { self.value = newValue } - public override var accessibilityValue: String? { + open override var accessibilityValue: String? { get { return String(format: "%d degrees hue", (self.value * 360.0)) } diff --git a/HueKit/View/ColorBarView.swift b/HueKit/View/ColorBarView.swift index f7c7bc6..bbf5c09 100644 --- a/HueKit/View/ColorBarView.swift +++ b/HueKit/View/ColorBarView.swift @@ -10,7 +10,7 @@ import Foundation import UIKit @IBDesignable -class ColorBarView: UIView { +open class ColorBarView: UIView { private static func createContentImage() -> CGImage? { @@ -19,7 +19,7 @@ class ColorBarView: UIView { return HSBGen.createHSVBarContentImage(hsbComponent: .hue, hsv: hsv) } - override func draw(_ rect: CGRect) { + override open func draw(_ rect: CGRect) { guard let context = UIGraphicsGetCurrentContext() else { return diff --git a/HueKit/View/ColorIndicatorView.swift b/HueKit/View/ColorIndicatorView.swift index e7d6c1a..96327d2 100644 --- a/HueKit/View/ColorIndicatorView.swift +++ b/HueKit/View/ColorIndicatorView.swift @@ -10,10 +10,10 @@ import Foundation import UIKit @IBDesignable -public class ColorIndicatorView: UIView { +open class ColorIndicatorView: UIView { @IBInspectable - public var color: UIColor = .black { + open var color: UIColor = .black { didSet { if oldValue != color { @@ -35,7 +35,7 @@ public class ColorIndicatorView: UIView { } - override public func draw(_ rect: CGRect) { + override open func draw(_ rect: CGRect) { guard let context = UIGraphicsGetCurrentContext() else { return diff --git a/HueKit/View/ColorSquarePicker.swift b/HueKit/View/ColorSquarePicker.swift index 0f298a7..9e5ec30 100644 --- a/HueKit/View/ColorSquarePicker.swift +++ b/HueKit/View/ColorSquarePicker.swift @@ -10,7 +10,7 @@ import Foundation import UIKit @IBDesignable -public class ColorSquarePicker: UIControl { +open class ColorSquarePicker: UIControl { private let contentInsetX: CGFloat = 20 private let contentInsetY: CGFloat = 20 @@ -60,7 +60,7 @@ public class ColorSquarePicker: UIControl { indicator.color = color } - public override func layoutSubviews() { + open override func layoutSubviews() { if colorSquareView.superview == nil { @@ -104,7 +104,7 @@ public class ColorSquarePicker: UIControl { self.value = touchValue } - override public func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { + override open func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { self.trackIndicator(with: touch) @@ -113,20 +113,20 @@ public class ColorSquarePicker: UIControl { return true } - override public func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { + override open func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { self.trackIndicator(with: touch) return true } - override public func endTracking(_ touch: UITouch?, with event: UIEvent?) { + override open func endTracking(_ touch: UITouch?, with event: UIEvent?) { super.endTracking(touch, with: event) shrinkIndicator() } - override public func cancelTracking(with event: UIEvent?) { + override open func cancelTracking(with event: UIEvent?) { super.cancelTracking(with: event) shrinkIndicator() diff --git a/HueKit/View/ColorSquareView.swift b/HueKit/View/ColorSquareView.swift index 42cfb01..b8bda9f 100644 --- a/HueKit/View/ColorSquareView.swift +++ b/HueKit/View/ColorSquareView.swift @@ -9,12 +9,12 @@ import UIKit @IBDesignable -class ColorSquareView: UIImageView { +open class ColorSquareView: UIImageView { private var drawnHue: CGFloat = 0.0 @IBInspectable - var hue: CGFloat = 0.0 { + open var hue: CGFloat = 0.0 { didSet { if self.image != nil && abs(drawnHue - hue) <= 1e-10 { diff --git a/HueKit/View/SourceColorView.swift b/HueKit/View/SourceColorView.swift index dd21245..78bf0d9 100644 --- a/HueKit/View/SourceColorView.swift +++ b/HueKit/View/SourceColorView.swift @@ -10,10 +10,10 @@ import Foundation import UIKit @IBDesignable -public class SourceColorView: UIControl { +open class SourceColorView: UIControl { @IBInspectable - public var isTrackingInside: Bool = false { + open var isTrackingInside: Bool = false { didSet { if oldValue != isTrackingInside { self.setNeedsDisplay() @@ -22,7 +22,7 @@ public class SourceColorView: UIControl { } @IBInspectable - public var dontShrinkWhenPressed: Bool = false { + open var dontShrinkWhenPressed: Bool = false { didSet { if oldValue != dontShrinkWhenPressed { self.setNeedsDisplay() @@ -30,7 +30,7 @@ public class SourceColorView: UIControl { } } - public override func draw(_ rect: CGRect) { + open override func draw(_ rect: CGRect) { super.draw(rect) guard isEnabled && isTrackingInside && !dontShrinkWhenPressed else { @@ -52,7 +52,7 @@ public class SourceColorView: UIControl { // MARK: - UIControl overrides - public override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { + open override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { guard self.isEnabled else { return false @@ -63,7 +63,7 @@ public class SourceColorView: UIControl { return super.beginTracking(touch, with: event) } - public override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { + open override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { let isTrackingInside = self.bounds.contains(touch.location(in: self)) @@ -72,14 +72,14 @@ public class SourceColorView: UIControl { return super.continueTracking(touch, with: event) } - public override func endTracking(_ touch: UITouch?, with event: UIEvent?) { + open override func endTracking(_ touch: UITouch?, with event: UIEvent?) { self.isTrackingInside = false super.endTracking(touch, with: event) } - public override func cancelTracking(with event: UIEvent?) { + open override func cancelTracking(with event: UIEvent?) { self.isTrackingInside = false