on master help sign in
Make components open
99d4f65Louis D'hauwe
HueKit/View/ColorBarPicker.swift+11−11
@@ -10,7 +10,7 @@ import Foundation
10import UIKit
10import UIKit
11
11
12@IBDesignable
12@IBDesignable
13−public class ColorBarPicker: UIControl {
13+open class ColorBarPicker: UIControl {
14
14
15 private var isVertical: Bool = false {
15 private var isVertical: Bool = false {
16 didSet {
16 didSet {
@@ -33,7 +33,7 @@ public class ColorBarPicker: UIControl {
33 private static let indicatorSizeActive = CGSize(width: 40.0, height: 40.0)
33 private static let indicatorSizeActive = CGSize(width: 40.0, height: 40.0)
34
34
35 @IBInspectable
35 @IBInspectable
36− public var hue: CGFloat {
36+ open var hue: CGFloat {
37 get {
37 get {
38 if isVertical {
38 if isVertical {
39 return 1.0 - value
39 return 1.0 - value
@@ -112,7 +112,7 @@ public class ColorBarPicker: UIControl {
112
112
113 // MARK: - Drawing
113 // MARK: - Drawing
114
114
115− override public func layoutSubviews() {
115+ override open func layoutSubviews() {
116
116
117 if colorBarView.superview == nil {
117 if colorBarView.superview == nil {
118
118
@@ -182,26 +182,26 @@ public class ColorBarPicker: UIControl {
182 self.value = percent.pinned(between: 0, and: 1)
182 self.value = percent.pinned(between: 0, and: 1)
183 }
183 }
184
184
185− override public func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
185+ override open func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
186 self.trackIndicator(with: touch)
186 self.trackIndicator(with: touch)
187
187
188 growIndicator()
188 growIndicator()
189 return true
189 return true
190 }
190 }
191
191
192− override public func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
192+ override open func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
193 self.trackIndicator(with: touch)
193 self.trackIndicator(with: touch)
194
194
195 return true
195 return true
196 }
196 }
197
197
198− override public func endTracking(_ touch: UITouch?, with event: UIEvent?) {
198+ override open func endTracking(_ touch: UITouch?, with event: UIEvent?) {
199 super.endTracking(touch, with: event)
199 super.endTracking(touch, with: event)
200
200
201 shrinkIndicator()
201 shrinkIndicator()
202 }
202 }
203
203
204− override public func cancelTracking(with event: UIEvent?) {
204+ override open func cancelTracking(with event: UIEvent?) {
205 super.cancelTracking(with: event)
205 super.cancelTracking(with: event)
206
206
207 shrinkIndicator()
207 shrinkIndicator()
@@ -250,7 +250,7 @@ public class ColorBarPicker: UIControl {
250
250
251 private let accessibilityInterval: CGFloat = 0.05
251 private let accessibilityInterval: CGFloat = 0.05
252
252
253− public override var accessibilityTraits: UIAccessibilityTraits {
253+ open override var accessibilityTraits: UIAccessibilityTraits {
254 get {
254 get {
255 var t = super.accessibilityTraits
255 var t = super.accessibilityTraits
256
256
@@ -263,7 +263,7 @@ public class ColorBarPicker: UIControl {
263 }
263 }
264 }
264 }
265
265
266− public override func accessibilityIncrement() {
266+ open override func accessibilityIncrement() {
267
267
268 var newValue = self.value + accessibilityInterval
268 var newValue = self.value + accessibilityInterval
269
269
@@ -274,7 +274,7 @@ public class ColorBarPicker: UIControl {
274 self.value = newValue
274 self.value = newValue
275 }
275 }
276
276
277− public override func accessibilityDecrement() {
277+ open override func accessibilityDecrement() {
278
278
279 var newValue = self.value - accessibilityInterval
279 var newValue = self.value - accessibilityInterval
280
280
@@ -285,7 +285,7 @@ public class ColorBarPicker: UIControl {
285 self.value = newValue
285 self.value = newValue
286 }
286 }
287
287
288− public override var accessibilityValue: String? {
288+ open override var accessibilityValue: String? {
289 get {
289 get {
290 return String(format: "%d degrees hue", (self.value * 360.0))
290 return String(format: "%d degrees hue", (self.value * 360.0))
291 }
291 }
HueKit/View/ColorBarView.swift+2−2
@@ -10,7 +10,7 @@ import Foundation
10import UIKit
10import UIKit
11
11
12@IBDesignable
12@IBDesignable
13−class ColorBarView: UIView {
13+open class ColorBarView: UIView {
14
14
15 private static func createContentImage() -> CGImage? {
15 private static func createContentImage() -> CGImage? {
16
16
@@ -19,7 +19,7 @@ class ColorBarView: UIView {
19 return HSBGen.createHSVBarContentImage(hsbComponent: .hue, hsv: hsv)
19 return HSBGen.createHSVBarContentImage(hsbComponent: .hue, hsv: hsv)
20 }
20 }
21
21
22− override func draw(_ rect: CGRect) {
22+ override open func draw(_ rect: CGRect) {
23
23
24 guard let context = UIGraphicsGetCurrentContext() else {
24 guard let context = UIGraphicsGetCurrentContext() else {
25 return
25 return
HueKit/View/ColorIndicatorView.swift+3−3
@@ -10,10 +10,10 @@ import Foundation
10import UIKit
10import UIKit
11
11
12@IBDesignable
12@IBDesignable
13−public class ColorIndicatorView: UIView {
13+open class ColorIndicatorView: UIView {
14
14
15 @IBInspectable
15 @IBInspectable
16− public var color: UIColor = .black {
16+ open var color: UIColor = .black {
17 didSet {
17 didSet {
18
18
19 if oldValue != color {
19 if oldValue != color {
@@ -35,7 +35,7 @@ public class ColorIndicatorView: UIView {
35
35
36 }
36 }
37
37
38− override public func draw(_ rect: CGRect) {
38+ override open func draw(_ rect: CGRect) {
39
39
40 guard let context = UIGraphicsGetCurrentContext() else {
40 guard let context = UIGraphicsGetCurrentContext() else {
41 return
41 return
HueKit/View/ColorSquarePicker.swift+6−6
@@ -10,7 +10,7 @@ import Foundation
10import UIKit
10import UIKit
11
11
12@IBDesignable
12@IBDesignable
13−public class ColorSquarePicker: UIControl {
13+open class ColorSquarePicker: UIControl {
14
14
15 private let contentInsetX: CGFloat = 20
15 private let contentInsetX: CGFloat = 20
16 private let contentInsetY: CGFloat = 20
16 private let contentInsetY: CGFloat = 20
@@ -60,7 +60,7 @@ public class ColorSquarePicker: UIControl {
60 indicator.color = color
60 indicator.color = color
61 }
61 }
62
62
63− public override func layoutSubviews() {
63+ open override func layoutSubviews() {
64
64
65 if colorSquareView.superview == nil {
65 if colorSquareView.superview == nil {
66
66
@@ -104,7 +104,7 @@ public class ColorSquarePicker: UIControl {
104 self.value = touchValue
104 self.value = touchValue
105 }
105 }
106
106
107− override public func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
107+ override open func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
108
108
109 self.trackIndicator(with: touch)
109 self.trackIndicator(with: touch)
110
110
@@ -113,20 +113,20 @@ public class ColorSquarePicker: UIControl {
113 return true
113 return true
114 }
114 }
115
115
116− override public func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
116+ override open func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
117
117
118 self.trackIndicator(with: touch)
118 self.trackIndicator(with: touch)
119
119
120 return true
120 return true
121 }
121 }
122
122
123− override public func endTracking(_ touch: UITouch?, with event: UIEvent?) {
123+ override open func endTracking(_ touch: UITouch?, with event: UIEvent?) {
124 super.endTracking(touch, with: event)
124 super.endTracking(touch, with: event)
125
125
126 shrinkIndicator()
126 shrinkIndicator()
127 }
127 }
128
128
129− override public func cancelTracking(with event: UIEvent?) {
129+ override open func cancelTracking(with event: UIEvent?) {
130 super.cancelTracking(with: event)
130 super.cancelTracking(with: event)
131
131
132 shrinkIndicator()
132 shrinkIndicator()
HueKit/View/ColorSquareView.swift+2−2
@@ -9,12 +9,12 @@
9import UIKit
9import UIKit
10
10
11@IBDesignable
11@IBDesignable
12−class ColorSquareView: UIImageView {
12+open class ColorSquareView: UIImageView {
13
13
14 private var drawnHue: CGFloat = 0.0
14 private var drawnHue: CGFloat = 0.0
15
15
16 @IBInspectable
16 @IBInspectable
17− var hue: CGFloat = 0.0 {
17+ open var hue: CGFloat = 0.0 {
18 didSet {
18 didSet {
19
19
20 if self.image != nil && abs(drawnHue - hue) <= 1e-10 {
20 if self.image != nil && abs(drawnHue - hue) <= 1e-10 {
HueKit/View/SourceColorView.swift+8−8
@@ -10,10 +10,10 @@ import Foundation
10import UIKit
10import UIKit
11
11
12@IBDesignable
12@IBDesignable
13−public class SourceColorView: UIControl {
13+open class SourceColorView: UIControl {
14
14
15 @IBInspectable
15 @IBInspectable
16− public var isTrackingInside: Bool = false {
16+ open var isTrackingInside: Bool = false {
17 didSet {
17 didSet {
18 if oldValue != isTrackingInside {
18 if oldValue != isTrackingInside {
19 self.setNeedsDisplay()
19 self.setNeedsDisplay()
@@ -22,7 +22,7 @@ public class SourceColorView: UIControl {
22 }
22 }
23
23
24 @IBInspectable
24 @IBInspectable
25− public var dontShrinkWhenPressed: Bool = false {
25+ open var dontShrinkWhenPressed: Bool = false {
26 didSet {
26 didSet {
27 if oldValue != dontShrinkWhenPressed {
27 if oldValue != dontShrinkWhenPressed {
28 self.setNeedsDisplay()
28 self.setNeedsDisplay()
@@ -30,7 +30,7 @@ public class SourceColorView: UIControl {
30 }
30 }
31 }
31 }
32
32
33− public override func draw(_ rect: CGRect) {
33+ open override func draw(_ rect: CGRect) {
34 super.draw(rect)
34 super.draw(rect)
35
35
36 guard isEnabled && isTrackingInside && !dontShrinkWhenPressed else {
36 guard isEnabled && isTrackingInside && !dontShrinkWhenPressed else {
@@ -52,7 +52,7 @@ public class SourceColorView: UIControl {
52
52
53 // MARK: - UIControl overrides
53 // MARK: - UIControl overrides
54
54
55− public override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
55+ open override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
56
56
57 guard self.isEnabled else {
57 guard self.isEnabled else {
58 return false
58 return false
@@ -63,7 +63,7 @@ public class SourceColorView: UIControl {
63 return super.beginTracking(touch, with: event)
63 return super.beginTracking(touch, with: event)
64 }
64 }
65
65
66− public override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
66+ open override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
67
67
68 let isTrackingInside = self.bounds.contains(touch.location(in: self))
68 let isTrackingInside = self.bounds.contains(touch.location(in: self))
69
69
@@ -72,14 +72,14 @@ public class SourceColorView: UIControl {
72 return super.continueTracking(touch, with: event)
72 return super.continueTracking(touch, with: event)
73 }
73 }
74
74
75− public override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
75+ open override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
76
76
77 self.isTrackingInside = false
77 self.isTrackingInside = false
78
78
79 super.endTracking(touch, with: event)
79 super.endTracking(touch, with: event)
80 }
80 }
81
81
82− public override func cancelTracking(with event: UIEvent?) {
82+ open override func cancelTracking(with event: UIEvent?) {
83
83
84 self.isTrackingInside = false
84 self.isTrackingInside = false
85
85