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

Group contents parents fix. Fixes #95

This commit is contained in:
Viktor Sukochev 2017-02-13 18:55:21 +07:00
parent bec2f10c0d
commit 8eb9ed6470
2 changed files with 19 additions and 1 deletions

View File

@ -5,7 +5,19 @@ open class Group: Node {
open var contentsVar: AnimatableVariable<[Node]>
open var contents: [Node] {
get { return contentsVar.value }
set(val) { contentsVar.value = val }
set(val) {
contentsVar.value = val
if let view = nodesMap.getView(self) {
val.forEach { subNode in
nodesMap.add(subNode, view: view)
}
}
val.forEach { subNode in
nodesMap.add(subNode, parent: self)
}
}
}

View File

@ -35,6 +35,12 @@ class NodesMap {
} else {
parentsMap[node] = Set([parent])
}
if let group = node as? Group {
group.contents.forEach { child in
self.add(child, parent: node)
}
}
}
func parents(_ node: Node) -> [Node] {