1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-09-17 16:07:44 +03:00

Merge pull request #669 from amarunko/swift_5.2

Updated to swift 5.2
This commit is contained in:
Yuri Strot 2020-03-26 18:16:17 +07:00 committed by GitHub
commit 0fb13450b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 36 additions and 25 deletions

View File

@ -269,7 +269,6 @@ class AnimationProducer {
}
let currentDate = Date()
var animationsToRemove = [Animation]()
let count = contentsAnimations.count
for (index, animationDesc) in contentsAnimations.reversed().enumerated() {

View File

@ -116,12 +116,12 @@ extension AnimationProducer {
func addCombineAnimation(_ combineAnimation: Animation, _ context: AnimationContext) {
guard let combine = combineAnimation as? CombineAnimation,
let renderer = combine.nodeRenderer,
let view = renderer.view else {
let _ = renderer.view else {
return
}
var animations = combine.animations
if let fromBounds = combine.node?.bounds, let toBounds = combine.toNodes.group().bounds {
if let _ = combine.node?.bounds, let _ = combine.toNodes.group().bounds {
let childAnimations = createChildAnimations(combine) as! [BasicAnimation]
animations.append(contentsOf: childAnimations)
}

View File

@ -190,7 +190,10 @@ open class Color: Fill {
return rgbt( r: r, g: g, b: b, t: 0 )
}
override func equals<T>(other: T) -> Bool where T: Color {
override func equals<T>(other: T) -> Bool where T: Fill {
guard let other = other as? Color else {
return false
}
return val == other.val
}
}

View File

@ -8,17 +8,15 @@ open class Gradient: Fill {
self.stops = stops
}
override func equals<T>(other: T) -> Bool where T: Gradient {
if userSpace == other.userSpace {
if stops.isEmpty && other.stops.isEmpty {
return true
}
return stops.elementsEqual(other.stops)
} else {
override func equals<T>(other: T) -> Bool where T: Fill {
guard let other = other as? Gradient, userSpace == other.userSpace else {
return false
}
if stops.isEmpty && other.stops.isEmpty {
return true
}
return stops.elementsEqual(other.stops)
}
}

View File

@ -52,7 +52,10 @@ open class LinearGradient: Gradient {
)
}
override func equals<T>(other: T) -> Bool where T: LinearGradient {
override func equals<T>(other: T) -> Bool where T: Fill {
guard let other = other as? LinearGradient else {
return false
}
return super.equals(other: other) && x1 == other.x1 && x2 == other.x2 && y1 == other.y1 && y2 == other.y2
}
}

View File

@ -18,7 +18,15 @@ open class RadialGradient: Gradient {
)
}
override func equals<T>(other: T) -> Bool where T: RadialGradient {
return super.equals(other: other) && cx == other.cx && cy == other.cy && fx == other.fx && fy == other.fy && r == other.r
override func equals<T>(other: T) -> Bool where T: Fill {
guard let other = other as? RadialGradient else {
return false
}
let cxEquals = cx == other.cx
let cyEquals = cy == other.cy
let fxEquals = fx == other.fx
let fyEquals = fy == other.fy
let rEquals = r == other.r
return super.equals(other: other) && cxEquals && cyEquals && fxEquals && fyEquals && rEquals
}
}

View File

@ -465,7 +465,7 @@ open class SVGParser {
if let units = element.allAttributes["patternContentUnits"]?.text, units == "objectBoundingBox" {
contentUserSpace = false
}
var contentNode: Node?
if pattern.children.isEmpty {
if let parentPattern = parentPattern {
@ -483,7 +483,7 @@ open class SVGParser {
}
contentNode = Group(contents: shapes)
}
return UserSpacePattern(content: contentNode!,
bounds: bounds,
userSpace: userSpace,
@ -1599,7 +1599,7 @@ open class SVGParser {
guard let element = stop.element else {
return .none
}
var offset: Double = 0 // This is default value, value can be omitted
if let parsedOffset = getDoubleValueFromPercentage(element, attribute: "offset") {
offset = parsedOffset

View File

@ -101,12 +101,12 @@ open class MacawView: MView, MGestureRecognizerDelegate {
#if os(OSX)
open override var layer: CALayer? {
didSet {
guard self.layer != nil else {
return
}
initializeView()
guard self.layer != nil else {
return
}
initializeView()
self.renderer = RenderUtils.createNodeRenderer(node, view: self)
self.renderer = RenderUtils.createNodeRenderer(node, view: self)
}
}
#endif