1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-11-14 01:48:49 +03:00

Update sources after generation

This commit is contained in:
Igor Zapletnev 2016-08-03 13:39:21 +06:00
parent 1e815c767f
commit 42bbe0c53f
38 changed files with 182 additions and 159 deletions

View File

@ -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] = []) {
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())
}
}

View File

@ -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)
}
}

View File

@ -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(

View File

@ -3,30 +3,32 @@ import RxSwift
public class Group: Node {
public var contentsVar: Variable<[Node]>
public var contentsVar: ObservableArray<Node>
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<Node>(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
}

View File

@ -39,7 +39,7 @@ 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] = []) {
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<String>(src)
self.xAlignVar = Variable<Align>(xAlign)
self.yAlignVar = Variable<Align>(yAlign)
@ -49,9 +49,11 @@ public class Image: Node {
super.init(
pos: pos,
opaque: opaque,
visible: visible,
opacity: opacity,
clip: clip,
tag: tag
visible: visible,
tag: tag,
bounds: bounds
)
}

View File

@ -15,10 +15,10 @@ public class Node: Drawable {
set(val) { opaqueVar.value = val }
}
public let visibleVar: Variable<NSObject>
public var visible: NSObject {
get { return visibleVar.value }
set(val) { visibleVar.value = val }
public let opacityVar: Variable<Double>
public var opacity: Double {
get { return opacityVar.value }
set(val) { opacityVar.value = val }
}
public let clipVar: Variable<Locus?>
@ -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<Transform>(pos)
self.opaqueVar = Variable<NSObject>(opaque)
self.visibleVar = Variable<NSObject>(visible)
self.opacityVar = Variable<Double>(opacity)
self.clipVar = Variable<Locus?>(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())
}
}

View File

@ -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<Locus>(form)
self.fillVar = Variable<Fill?>(fill)
self.strokeVar = Variable<Stroke?>(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? {

View File

@ -33,7 +33,7 @@ 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] = []) {
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<String>(text)
self.fontVar = Variable<Font>(font)
self.fillVar = Variable<Fill>(fill)
@ -42,9 +42,11 @@ public class Text: Node {
super.init(
pos: pos,
opaque: opaque,
visible: visible,
opacity: opacity,
clip: clip,
tag: tag
visible: visible,
tag: tag,
bounds: bounds
)
}

View File

@ -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) }