From 42bbe0c53f649c177290b3205b06f6d7fd6074db Mon Sep 17 00:00:00 2001 From: Igor Zapletnev Date: Wed, 3 Aug 2016 13:39:21 +0600 Subject: [PATCH] Update sources after generation --- Source/model/draw/Color.swift | 2 +- Source/model/draw/Drawable.swift | 13 +++++++++-- Source/model/draw/Font.swift | 12 +++++----- Source/model/draw/LinearGradient.swift | 12 +++++----- Source/model/draw/Stop.swift | 4 ++-- Source/model/draw/Stroke.swift | 10 ++++----- Source/{ => model}/extensions/Node.swift | 0 Source/model/geom2d/Arc.swift | 6 ++--- Source/model/geom2d/Circle.swift | 6 ++--- Source/model/geom2d/Cubic.swift | 12 +++++----- Source/model/geom2d/Ellipse.swift | 8 +++---- Source/model/geom2d/Elliptical.swift | 14 ++++++------ Source/model/geom2d/HLine.swift | 2 +- Source/model/geom2d/Insets.swift | 8 +++---- Source/model/geom2d/Line.swift | 8 +++---- Source/model/geom2d/Move.swift | 4 ++-- Source/model/geom2d/PLine.swift | 4 ++-- Source/model/geom2d/Path.swift | 2 +- Source/model/geom2d/PathSegment.swift | 2 +- Source/model/geom2d/Point.swift | 13 ++++++----- Source/model/geom2d/Polygon.swift | 2 +- Source/model/geom2d/Polyline.swift | 2 +- Source/model/geom2d/Quadratic.swift | 8 +++---- Source/model/geom2d/Rect.swift | 13 ++++++----- Source/model/geom2d/RoundRect.swift | 6 ++--- Source/model/geom2d/SCubic.swift | 8 +++---- Source/model/geom2d/SQuadratic.swift | 4 ++-- Source/model/geom2d/Size.swift | 4 ++-- Source/model/geom2d/Transform.swift | 28 ++++++++++++------------ Source/model/geom2d/VLine.swift | 2 +- Source/model/input/Mouse.swift | 10 ++++----- Source/model/input/MouseButton.swift | 10 ++++----- Source/model/scene/Group.swift | 20 +++++++++-------- Source/model/scene/Image.swift | 20 +++++++++-------- Source/model/scene/Node.swift | 26 ++++++++++++---------- Source/model/scene/Shape.swift | 13 ++++++----- Source/model/scene/Text.swift | 18 ++++++++------- Source/render/GroupRenderer.swift | 5 +++-- 38 files changed, 182 insertions(+), 159 deletions(-) rename Source/{ => model}/extensions/Node.swift (100%) diff --git a/Source/model/draw/Color.swift b/Source/model/draw/Color.swift index 10d71aa6..da36f0df 100644 --- a/Source/model/draw/Color.swift +++ b/Source/model/draw/Color.swift @@ -23,7 +23,7 @@ public class Color: Fill { public static let purple: Color = Color( val: 0x800080 ) public init(val: Int = 0) { - self.val = val + self.val = val } // GENERATED diff --git a/Source/model/draw/Drawable.swift b/Source/model/draw/Drawable.swift index 380f944a..f44329a4 100644 --- a/Source/model/draw/Drawable.swift +++ b/Source/model/draw/Drawable.swift @@ -3,10 +3,19 @@ import RxSwift public class Drawable { + public let visible: NSObject public let tag: [String] + public let bounds: Rect? - public init(tag: [String] = []) { - self.tag = tag + public init(visible: NSObject = true, tag: [String] = [], bounds: Rect? = nil) { + self.visible = visible + self.tag = tag + self.bounds = bounds + } + + // GENERATED + public func mouse() -> Mouse { + return Mouse(pos: Point(), onEnter: Signal(), onExit: Signal(), onWheel: Signal()) } } diff --git a/Source/model/draw/Font.swift b/Source/model/draw/Font.swift index 9286d15c..6d7fe55a 100644 --- a/Source/model/draw/Font.swift +++ b/Source/model/draw/Font.swift @@ -11,12 +11,12 @@ public class Font { public let strike: NSObject public init(name: String = "Serif", size: Int = 12, bold: NSObject = false, italic: NSObject = false, underline: NSObject = false, strike: NSObject = false) { - self.name = name - self.size = size - self.bold = bold - self.italic = italic - self.underline = underline - self.strike = strike + self.name = name + self.size = size + self.bold = bold + self.italic = italic + self.underline = underline + self.strike = strike } } diff --git a/Source/model/draw/LinearGradient.swift b/Source/model/draw/LinearGradient.swift index a2652d1a..f3a955cb 100644 --- a/Source/model/draw/LinearGradient.swift +++ b/Source/model/draw/LinearGradient.swift @@ -11,12 +11,12 @@ public class LinearGradient: Fill { public let y2: Double public init(userSpace: Bool = false, stops: [Stop] = [], x1: Double = 0, y1: Double = 0, x2: Double = 0, y2: Double = 0) { - self.userSpace = userSpace - self.stops = stops - self.x1 = x1 - self.y1 = y1 - self.x2 = x2 - self.y2 = y2 + self.userSpace = userSpace + self.stops = stops + self.x1 = x1 + self.y1 = y1 + self.x2 = x2 + self.y2 = y2 } } diff --git a/Source/model/draw/Stop.swift b/Source/model/draw/Stop.swift index 17dc675a..63b26e79 100644 --- a/Source/model/draw/Stop.swift +++ b/Source/model/draw/Stop.swift @@ -7,8 +7,8 @@ public class Stop { public let color: Color public init(offset: Double = 0, color: Color) { - self.offset = offset - self.color = color + self.offset = offset + self.color = color } } diff --git a/Source/model/draw/Stroke.swift b/Source/model/draw/Stroke.swift index 6d6a31b2..bd681dbe 100644 --- a/Source/model/draw/Stroke.swift +++ b/Source/model/draw/Stroke.swift @@ -10,11 +10,11 @@ public class Stroke { public let dashes: [Double] public init(fill: Fill, width: Double = 1, cap: LineCap = .butt, join: LineJoin = .miter, dashes: [Double] = []) { - self.fill = fill - self.width = width - self.cap = cap - self.join = join - self.dashes = dashes + self.fill = fill + self.width = width + self.cap = cap + self.join = join + self.dashes = dashes } } diff --git a/Source/extensions/Node.swift b/Source/model/extensions/Node.swift similarity index 100% rename from Source/extensions/Node.swift rename to Source/model/extensions/Node.swift diff --git a/Source/model/geom2d/Arc.swift b/Source/model/geom2d/Arc.swift index 823fab6d..b28d6d42 100644 --- a/Source/model/geom2d/Arc.swift +++ b/Source/model/geom2d/Arc.swift @@ -8,9 +8,9 @@ public class Arc: Locus { public let extent: Double public init(ellipse: Ellipse, shift: Double = 0, extent: Double = 0) { - self.ellipse = ellipse - self.shift = shift - self.extent = extent + self.ellipse = ellipse + self.shift = shift + self.extent = extent } } diff --git a/Source/model/geom2d/Circle.swift b/Source/model/geom2d/Circle.swift index 048702e0..eef3bb3b 100644 --- a/Source/model/geom2d/Circle.swift +++ b/Source/model/geom2d/Circle.swift @@ -8,9 +8,9 @@ public class Circle: Locus { public let r: Double public init(cx: Double = 0, cy: Double = 0, r: Double = 0) { - self.cx = cx - self.cy = cy - self.r = r + self.cx = cx + self.cy = cy + self.r = r } } diff --git a/Source/model/geom2d/Cubic.swift b/Source/model/geom2d/Cubic.swift index 74165422..62b47bc5 100644 --- a/Source/model/geom2d/Cubic.swift +++ b/Source/model/geom2d/Cubic.swift @@ -11,12 +11,12 @@ public class Cubic: PathSegment { public let y: Double public init(x1: Double = 0, y1: Double = 0, x2: Double = 0, y2: Double = 0, x: Double = 0, y: Double = 0, absolute: Bool = false) { - self.x1 = x1 - self.y1 = y1 - self.x2 = x2 - self.y2 = y2 - self.x = x - self.y = y + self.x1 = x1 + self.y1 = y1 + self.x2 = x2 + self.y2 = y2 + self.x = x + self.y = y super.init( absolute: absolute ) diff --git a/Source/model/geom2d/Ellipse.swift b/Source/model/geom2d/Ellipse.swift index 449851d1..29a3444a 100644 --- a/Source/model/geom2d/Ellipse.swift +++ b/Source/model/geom2d/Ellipse.swift @@ -9,10 +9,10 @@ public class Ellipse: Locus { public let ry: Double public init(cx: Double = 0, cy: Double = 0, rx: Double = 0, ry: Double = 0) { - self.cx = cx - self.cy = cy - self.rx = rx - self.ry = ry + self.cx = cx + self.cy = cy + self.rx = rx + self.ry = ry } // GENERATED NOT diff --git a/Source/model/geom2d/Elliptical.swift b/Source/model/geom2d/Elliptical.swift index 834e7859..beb42f07 100644 --- a/Source/model/geom2d/Elliptical.swift +++ b/Source/model/geom2d/Elliptical.swift @@ -12,13 +12,13 @@ public class Elliptical: PathSegment { public let y: Double public init(rx: Double = 0, ry: Double = 0, angle: Double = 0, largeArc: Bool = false, sweep: Bool = false, x: Double = 0, y: Double = 0, absolute: Bool = false) { - self.rx = rx - self.ry = ry - self.angle = angle - self.largeArc = largeArc - self.sweep = sweep - self.x = x - self.y = y + self.rx = rx + self.ry = ry + self.angle = angle + self.largeArc = largeArc + self.sweep = sweep + self.x = x + self.y = y super.init( absolute: absolute ) diff --git a/Source/model/geom2d/HLine.swift b/Source/model/geom2d/HLine.swift index 16f155ba..79c3442e 100644 --- a/Source/model/geom2d/HLine.swift +++ b/Source/model/geom2d/HLine.swift @@ -6,7 +6,7 @@ public class HLine: PathSegment { public let x: Double public init(x: Double = 0, absolute: Bool = false) { - self.x = x + self.x = x super.init( absolute: absolute ) diff --git a/Source/model/geom2d/Insets.swift b/Source/model/geom2d/Insets.swift index eadc6cb5..52b133af 100644 --- a/Source/model/geom2d/Insets.swift +++ b/Source/model/geom2d/Insets.swift @@ -9,10 +9,10 @@ public class Insets { public let left: Double public init(top: Double = 0, right: Double = 0, bottom: Double = 0, left: Double = 0) { - self.top = top - self.right = right - self.bottom = bottom - self.left = left + self.top = top + self.right = right + self.bottom = bottom + self.left = left } } diff --git a/Source/model/geom2d/Line.swift b/Source/model/geom2d/Line.swift index 3d9bd743..dc1e583c 100644 --- a/Source/model/geom2d/Line.swift +++ b/Source/model/geom2d/Line.swift @@ -9,10 +9,10 @@ public class Line: Locus { public let y2: Double public init(x1: Double = 0, y1: Double = 0, x2: Double = 0, y2: Double = 0) { - self.x1 = x1 - self.y1 = y1 - self.x2 = x2 - self.y2 = y2 + self.x1 = x1 + self.y1 = y1 + self.x2 = x2 + self.y2 = y2 } } diff --git a/Source/model/geom2d/Move.swift b/Source/model/geom2d/Move.swift index 35e6bbc1..5f13f256 100644 --- a/Source/model/geom2d/Move.swift +++ b/Source/model/geom2d/Move.swift @@ -7,8 +7,8 @@ public class Move: PathSegment { public let y: Double public init(x: Double = 0, y: Double = 0, absolute: Bool = false) { - self.x = x - self.y = y + self.x = x + self.y = y super.init( absolute: absolute ) diff --git a/Source/model/geom2d/PLine.swift b/Source/model/geom2d/PLine.swift index ae499d35..422e117e 100644 --- a/Source/model/geom2d/PLine.swift +++ b/Source/model/geom2d/PLine.swift @@ -7,8 +7,8 @@ public class PLine: PathSegment { public let y: Double public init(x: Double = 0, y: Double = 0, absolute: Bool = false) { - self.x = x - self.y = y + self.x = x + self.y = y super.init( absolute: absolute ) diff --git a/Source/model/geom2d/Path.swift b/Source/model/geom2d/Path.swift index 0c45829f..70f11660 100644 --- a/Source/model/geom2d/Path.swift +++ b/Source/model/geom2d/Path.swift @@ -6,7 +6,7 @@ public class Path: Locus { public let segments: [PathSegment] public init(segments: [PathSegment] = []) { - self.segments = segments + self.segments = segments } } diff --git a/Source/model/geom2d/PathSegment.swift b/Source/model/geom2d/PathSegment.swift index 5d9a273d..8c371bd8 100644 --- a/Source/model/geom2d/PathSegment.swift +++ b/Source/model/geom2d/PathSegment.swift @@ -6,7 +6,7 @@ public class PathSegment { public let absolute: Bool public init(absolute: Bool = false) { - self.absolute = absolute + self.absolute = absolute } } diff --git a/Source/model/geom2d/Point.swift b/Source/model/geom2d/Point.swift index eca7af8d..fd94b4b4 100644 --- a/Source/model/geom2d/Point.swift +++ b/Source/model/geom2d/Point.swift @@ -1,7 +1,7 @@ import Foundation import RxSwift -public class Point: Locus { +public class Point: Locus { public let x: Double public let y: Double @@ -11,10 +11,6 @@ public class Point: Locus { self.y = y } - // GENERATED NOT - public class func zero() -> Point { - return Point(x: 0.0, y: 0.0) - } // GENERATED NOT public func add(point: Point) -> Point { @@ -22,4 +18,9 @@ public class Point: Locus { x: self.x + point.x, y: self.y + point.y) } -} + + // GENERATED NOT + public class func zero() -> Point { + return Point(x: 0.0, y: 0.0) + } +} \ No newline at end of file diff --git a/Source/model/geom2d/Polygon.swift b/Source/model/geom2d/Polygon.swift index d36639f3..c2022841 100644 --- a/Source/model/geom2d/Polygon.swift +++ b/Source/model/geom2d/Polygon.swift @@ -6,7 +6,7 @@ public class Polygon: Locus { public let points: [Double] public init(points: [Double] = []) { - self.points = points + self.points = points } } diff --git a/Source/model/geom2d/Polyline.swift b/Source/model/geom2d/Polyline.swift index 670d1101..736cb735 100644 --- a/Source/model/geom2d/Polyline.swift +++ b/Source/model/geom2d/Polyline.swift @@ -6,7 +6,7 @@ public class Polyline: Locus { public let points: [Double] public init(points: [Double] = []) { - self.points = points + self.points = points } } diff --git a/Source/model/geom2d/Quadratic.swift b/Source/model/geom2d/Quadratic.swift index 991c7533..f4ba5f15 100644 --- a/Source/model/geom2d/Quadratic.swift +++ b/Source/model/geom2d/Quadratic.swift @@ -9,10 +9,10 @@ public class Quadratic: PathSegment { public let y: Double public init(x1: Double = 0, y1: Double = 0, x: Double = 0, y: Double = 0, absolute: Bool = false) { - self.x1 = x1 - self.y1 = y1 - self.x = x - self.y = y + self.x1 = x1 + self.y1 = y1 + self.x = x + self.y = y super.init( absolute: absolute ) diff --git a/Source/model/geom2d/Rect.swift b/Source/model/geom2d/Rect.swift index faed76af..df57b891 100644 --- a/Source/model/geom2d/Rect.swift +++ b/Source/model/geom2d/Rect.swift @@ -1,7 +1,7 @@ import Foundation import RxSwift -public class Rect: Locus { +public class Rect: Locus { public let x: Double public let y: Double @@ -24,10 +24,6 @@ public class Rect: Locus { return false } - // GENERATED NOT - class func zero() -> Rect { - return Rect(x: 0.0, y: 0.0, w: 0.0, h: 0.0) - } // GENERATED NOT public func union(rect: Rect) -> Rect { @@ -38,6 +34,11 @@ public class Rect: Locus { h: max(self.y + self.h, rect.y + rect.h) - min(self.y, rect.y)) } + // GENERATED NOT + class func zero() -> Rect { + return Rect(x: 0.0, y: 0.0, w: 0.0, h: 0.0) + } + // GENERATED NOT public func move(offset: Point) -> Rect { return Rect( @@ -46,4 +47,4 @@ public class Rect: Locus { w: self.w, h: self.h) } -} +} \ No newline at end of file diff --git a/Source/model/geom2d/RoundRect.swift b/Source/model/geom2d/RoundRect.swift index 9e1157f4..57e1c0ba 100644 --- a/Source/model/geom2d/RoundRect.swift +++ b/Source/model/geom2d/RoundRect.swift @@ -8,9 +8,9 @@ public class RoundRect: Locus { public let ry: Double public init(rect: Rect, rx: Double = 0, ry: Double = 0) { - self.rect = rect - self.rx = rx - self.ry = ry + self.rect = rect + self.rx = rx + self.ry = ry } } diff --git a/Source/model/geom2d/SCubic.swift b/Source/model/geom2d/SCubic.swift index 0833526d..5c1695fc 100644 --- a/Source/model/geom2d/SCubic.swift +++ b/Source/model/geom2d/SCubic.swift @@ -9,10 +9,10 @@ public class SCubic: PathSegment { public let y: Double public init(x2: Double = 0, y2: Double = 0, x: Double = 0, y: Double = 0, absolute: Bool = false) { - self.x2 = x2 - self.y2 = y2 - self.x = x - self.y = y + self.x2 = x2 + self.y2 = y2 + self.x = x + self.y = y super.init( absolute: absolute ) diff --git a/Source/model/geom2d/SQuadratic.swift b/Source/model/geom2d/SQuadratic.swift index 579a46ea..ad9ef014 100644 --- a/Source/model/geom2d/SQuadratic.swift +++ b/Source/model/geom2d/SQuadratic.swift @@ -7,8 +7,8 @@ public class SQuadratic: PathSegment { public let y: Double public init(x: Double = 0, y: Double = 0, absolute: Bool = false) { - self.x = x - self.y = y + self.x = x + self.y = y super.init( absolute: absolute ) diff --git a/Source/model/geom2d/Size.swift b/Source/model/geom2d/Size.swift index ee43fde5..35847035 100644 --- a/Source/model/geom2d/Size.swift +++ b/Source/model/geom2d/Size.swift @@ -7,8 +7,8 @@ public class Size { public let h: Double public init(w: Double = 0, h: Double = 0) { - self.w = w - self.h = h + self.w = w + self.h = h } } diff --git a/Source/model/geom2d/Transform.swift b/Source/model/geom2d/Transform.swift index 8487da4e..a1ae6b5b 100644 --- a/Source/model/geom2d/Transform.swift +++ b/Source/model/geom2d/Transform.swift @@ -11,18 +11,18 @@ public final class Transform { public let dy: Double public init(m11: Double = 1, m12: Double = 0, m21: Double = 0, m22: Double = 1, dx: Double = 0, dy: Double = 0) { - self.m11 = m11 - self.m12 = m12 - self.m21 = m21 - self.m22 = m22 - self.dx = dx - self.dy = dy + self.m11 = m11 + self.m12 = m12 + self.m21 = m21 + self.m22 = m22 + self.dx = dx + self.dy = dy } // GENERATED NOT public func move(mx: Double, my: Double) -> Transform { - return Transform(m11: m11, m12: m12, m21: m21, m22: m22, - dx: mx * m11 + my * m21 + dx, dy: mx * m12 + my * m22 + dy) + return Transform(m11: m11, m12: m12, m21: m21, m22: m22, + dx: mx * m11 + my * m21 + dx, dy: mx * m12 + my * m22 + dy) } // GENERATED NOT public func scale(sx: Double, sy: Double) -> Transform { @@ -31,14 +31,14 @@ public final class Transform { // GENERATED NOT public func shear(shx: Double, shy: Double) -> Transform { return Transform(m11: m11 + m21 * shy, m12: m12 + m22 * shy, - m21: m11 * shx + m21, m22: m12 * shx + m22, dx: dx, dy: dy) + m21: m11 * shx + m21, m22: m12 * shx + m22, dx: dx, dy: dy) } // GENERATED NOT public func rotate(angle: Double) -> Transform { - let asin = sin(angle); let acos = cos(angle) - return Transform(m11: acos * m11 + asin * m21, m12: acos * m12 + asin * m22, - m21: -asin * m11 + acos * m21, m22: -asin * m12 + acos * m22, dx: dx, dy: dy) - } + let asin = sin(angle); let acos = cos(angle) + return Transform(m11: acos * m11 + asin * m21, m12: acos * m12 + asin * m22, + m21: -asin * m11 + acos * m21, m22: -asin * m12 + acos * m22, dx: dx, dy: dy) + } // GENERATED public class func move(mx: Double, my: Double) -> Transform { @@ -57,7 +57,7 @@ public final class Transform { // GENERATED NOT public class func rotate(angle: Double) -> Transform { - let asin = sin(angle); let acos = cos(angle) + let asin = sin(angle); let acos = cos(angle) return Transform(m11: acos, m12: asin, m21: -asin, m22: acos) } diff --git a/Source/model/geom2d/VLine.swift b/Source/model/geom2d/VLine.swift index ed8d0a1c..c773b5d9 100644 --- a/Source/model/geom2d/VLine.swift +++ b/Source/model/geom2d/VLine.swift @@ -6,7 +6,7 @@ public class VLine: PathSegment { public let y: Double public init(y: Double = 0, absolute: Bool = false) { - self.y = y + self.y = y super.init( absolute: absolute ) diff --git a/Source/model/input/Mouse.swift b/Source/model/input/Mouse.swift index e902ff36..3c11d3e2 100644 --- a/Source/model/input/Mouse.swift +++ b/Source/model/input/Mouse.swift @@ -34,11 +34,11 @@ public class Mouse { } public init(hover: Bool = false, pos: Point, onEnter: Signal, onExit: Signal, onWheel: Signal) { - self.hoverVar = Variable(hover) - self.posVar = Variable(pos) - self.onEnterVar = Variable(onEnter) - self.onExitVar = Variable(onExit) - self.onWheelVar = Variable(onWheel) + self.hoverVar = Variable(hover) + self.posVar = Variable(pos) + self.onEnterVar = Variable(onEnter) + self.onExitVar = Variable(onExit) + self.onWheelVar = Variable(onWheel) } // GENERATED NOT diff --git a/Source/model/input/MouseButton.swift b/Source/model/input/MouseButton.swift index 40b43314..34982d20 100644 --- a/Source/model/input/MouseButton.swift +++ b/Source/model/input/MouseButton.swift @@ -34,11 +34,11 @@ public class MouseButton { } public init(pressed: Bool = false, onPress: Signal, onRelease: Signal, onClick: Signal, onDoubleClick: Signal) { - self.pressedVar = Variable(pressed) - self.onPressVar = Variable(onPress) - self.onReleaseVar = Variable(onRelease) - self.onClickVar = Variable(onClick) - self.onDoubleClickVar = Variable(onDoubleClick) + self.pressedVar = Variable(pressed) + self.onPressVar = Variable(onPress) + self.onReleaseVar = Variable(onRelease) + self.onClickVar = Variable(onClick) + self.onDoubleClickVar = Variable(onDoubleClick) } } diff --git a/Source/model/scene/Group.swift b/Source/model/scene/Group.swift index 11afb469..e54a3b1e 100644 --- a/Source/model/scene/Group.swift +++ b/Source/model/scene/Group.swift @@ -3,30 +3,32 @@ import RxSwift public class Group: Node { - public var contentsVar: Variable<[Node]> + public var contentsVar: ObservableArray - public init(contents: [Node] = [], pos: Transform = Transform(), opaque: NSObject = true, visible: NSObject = true, clip: Locus? = nil, tag: [String] = []) { - self.contentsVar = Variable<[Node]>(contents) + public init(contents: [Node] = [], pos: Transform = Transform(), opaque: NSObject = true, opacity: Double = 1, clip: Locus? = nil, visible: NSObject = true, tag: [String] = [], bounds: Rect? = nil) { + self.contentsVar = ObservableArray(array: contents) super.init( pos: pos, opaque: opaque, - visible: visible, + opacity: opacity, clip: clip, - tag: tag + visible: visible, + tag: tag, + bounds: bounds ) } // GENERATED NOT override public func bounds() -> Rect? { - guard let firstPos = contentsVar.value.first?.pos else { + guard let firstPos = contentsVar.first?.pos else { return .None } - guard var union = contentsVar.value.first?.bounds()?.applyTransform(firstPos) else { + guard var union = contentsVar.first?.bounds()?.applyTransform(firstPos) else { return .None } - contentsVar.value.forEach { node in + contentsVar.forEach { node in guard let nodeBounds = node.bounds() else { return } @@ -36,4 +38,4 @@ public class Group: Node { return union // .applyTransform(pos) } -} +} \ No newline at end of file diff --git a/Source/model/scene/Image.swift b/Source/model/scene/Image.swift index fcd8da24..b049ce63 100644 --- a/Source/model/scene/Image.swift +++ b/Source/model/scene/Image.swift @@ -39,19 +39,21 @@ public class Image: Node { set(val) { hVar.value = val } } - public init(src: String, xAlign: Align = .min, yAlign: Align = .min, aspectRatio: AspectRatio = .none, w: Int = 0, h: Int = 0, pos: Transform = Transform(), opaque: NSObject = true, visible: NSObject = true, clip: Locus? = nil, tag: [String] = []) { - self.srcVar = Variable(src) - self.xAlignVar = Variable(xAlign) - self.yAlignVar = Variable(yAlign) - self.aspectRatioVar = Variable(aspectRatio) - self.wVar = Variable(w) - self.hVar = Variable(h) + public init(src: String, xAlign: Align = .min, yAlign: Align = .min, aspectRatio: AspectRatio = .none, w: Int = 0, h: Int = 0, pos: Transform = Transform(), opaque: NSObject = true, opacity: Double = 1, clip: Locus? = nil, visible: NSObject = true, tag: [String] = [], bounds: Rect? = nil) { + self.srcVar = Variable(src) + self.xAlignVar = Variable(xAlign) + self.yAlignVar = Variable(yAlign) + self.aspectRatioVar = Variable(aspectRatio) + self.wVar = Variable(w) + self.hVar = Variable(h) super.init( pos: pos, opaque: opaque, - visible: visible, + opacity: opacity, clip: clip, - tag: tag + visible: visible, + tag: tag, + bounds: bounds ) } diff --git a/Source/model/scene/Node.swift b/Source/model/scene/Node.swift index 17129944..a94c8a7c 100644 --- a/Source/model/scene/Node.swift +++ b/Source/model/scene/Node.swift @@ -15,10 +15,10 @@ public class Node: Drawable { set(val) { opaqueVar.value = val } } - public let visibleVar: Variable - public var visible: NSObject { - get { return visibleVar.value } - set(val) { visibleVar.value = val } + public let opacityVar: Variable + public var opacity: Double { + get { return opacityVar.value } + set(val) { opacityVar.value = val } } public let clipVar: Variable @@ -27,23 +27,25 @@ public class Node: Drawable { set(val) { clipVar.value = val } } - public init(pos: Transform, opaque: NSObject = true, visible: NSObject = true, clip: Locus? = nil, tag: [String] = []) { + public init(pos: Transform, opaque: NSObject = true, opacity: Double = 1, clip: Locus? = nil, visible: NSObject = true, tag: [String] = [], bounds: Rect? = nil) { self.posVar = Variable(pos) self.opaqueVar = Variable(opaque) - self.visibleVar = Variable(visible) + self.opacityVar = Variable(opacity) self.clipVar = Variable(clip) super.init( - tag: tag + visible: visible, + tag: tag, + bounds: bounds ) } - // GENERATED NOT - public func mouse() -> Mouse { - return Mouse(pos: Point(), onEnter: Signal(), onExit: Signal(), onWheel: Signal()) - } // GENERATED NOT public func bounds() -> Rect? { return Rect() } -} + // GENERATED NOT + public override func mouse() -> Mouse { + return Mouse(pos: Point(), onEnter: Signal(), onExit: Signal(), onWheel: Signal()) + } +} \ No newline at end of file diff --git a/Source/model/scene/Shape.swift b/Source/model/scene/Shape.swift index c29b592a..bfb92f6d 100644 --- a/Source/model/scene/Shape.swift +++ b/Source/model/scene/Shape.swift @@ -1,7 +1,7 @@ import Foundation import RxSwift -public class Shape: Node { +public class Shape: Node { public let formVar: Variable public var form: Locus { @@ -21,19 +21,22 @@ public class Shape: Node { set(val) { strokeVar.value = val } } - public init(form: Locus, fill: Fill? = nil, stroke: Stroke? = nil, pos: Transform = Transform(), opaque: NSObject = true, visible: NSObject = true, clip: Locus? = nil, tag: [String] = []) { + public init(form: Locus, fill: Fill? = nil, stroke: Stroke? = nil, pos: Transform = Transform(), opaque: NSObject = true, opacity: Double = 1, clip: Locus? = nil, visible: NSObject = true, tag: [String] = [], bounds: Rect? = nil) { self.formVar = Variable(form) self.fillVar = Variable(fill) self.strokeVar = Variable(stroke) super.init( pos: pos, opaque: opaque, - visible: visible, + opacity: opacity, clip: clip, - tag: tag + visible: visible, + tag: tag, + bounds: bounds ) } + // GENERATED NOT override public func bounds() -> Rect? { @@ -61,4 +64,4 @@ public class Shape: Node { return form.bounds() } -} +} \ No newline at end of file diff --git a/Source/model/scene/Text.swift b/Source/model/scene/Text.swift index 4d8f09e3..36dcbefd 100644 --- a/Source/model/scene/Text.swift +++ b/Source/model/scene/Text.swift @@ -33,18 +33,20 @@ public class Text: Node { set(val) { baselineVar.value = val } } - public init(text: String, font: Font, fill: Fill, align: Align = .min, baseline: Baseline = .top, pos: Transform = Transform(), opaque: NSObject = true, visible: NSObject = true, clip: Locus? = nil, tag: [String] = []) { - self.textVar = Variable(text) - self.fontVar = Variable(font) - self.fillVar = Variable(fill) - self.alignVar = Variable(align) - self.baselineVar = Variable(baseline) + public init(text: String, font: Font, fill: Fill, align: Align = .min, baseline: Baseline = .top, pos: Transform = Transform(), opaque: NSObject = true, opacity: Double = 1, clip: Locus? = nil, visible: NSObject = true, tag: [String] = [], bounds: Rect? = nil) { + self.textVar = Variable(text) + self.fontVar = Variable(font) + self.fillVar = Variable(fill) + self.alignVar = Variable(align) + self.baselineVar = Variable(baseline) super.init( pos: pos, opaque: opaque, - visible: visible, + opacity: opacity, clip: clip, - tag: tag + visible: visible, + tag: tag, + bounds: bounds ) } diff --git a/Source/render/GroupRenderer.swift b/Source/render/GroupRenderer.swift index 8d94754e..bb464f6b 100644 --- a/Source/render/GroupRenderer.swift +++ b/Source/render/GroupRenderer.swift @@ -20,7 +20,8 @@ class GroupRenderer: NodeRenderer { func onGroupChange(new: [Node]) { ctx.view?.setNeedsDisplay() } - group.contentsVar.asObservable().subscribeNext { new in + + group.contentsVar.rx_elements().asObservable().subscribeNext { new in onGroupChange(new) }.addDisposableTo(disposeBag) } @@ -35,7 +36,7 @@ class GroupRenderer: NodeRenderer { } } - let staticContents = group.contentsVar.value.filter { !$0.animating } + let staticContents = group.contentsVar.filter { !$0.animating } let contentRenderers = staticContents.map { RenderUtils.createNodeRenderer($0, context: ctx) }