mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-11 05:05:23 +03:00
Restore tag search
This commit is contained in:
parent
149332e6e6
commit
3d875f731e
@ -25,6 +25,35 @@ open class Group: Node {
|
||||
self.contentsVar.node = self
|
||||
}
|
||||
|
||||
// Searching
|
||||
|
||||
override public func nodeBy(tag: String) -> Node? {
|
||||
if let node = super.nodeBy(tag: tag) {
|
||||
return node
|
||||
}
|
||||
|
||||
for child in contents {
|
||||
if let node = child.nodeBy(tag: tag) {
|
||||
return node
|
||||
}
|
||||
}
|
||||
|
||||
return .none
|
||||
}
|
||||
|
||||
override public func nodesBy(tag: String) -> [Node] {
|
||||
var result = [Node]()
|
||||
contents.forEach { child in
|
||||
result.append(contentsOf: child.nodesBy(tag: tag))
|
||||
}
|
||||
|
||||
if let node = super.nodeBy(tag: tag) {
|
||||
result.append(node)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
override open var bounds: Rect? {
|
||||
return BoundsUtils.getNodesBounds(contents)
|
||||
}
|
||||
|
@ -38,6 +38,20 @@ open class Node: Drawable {
|
||||
set(val) { effectVar.value = val }
|
||||
}
|
||||
|
||||
// MARK: - Searching
|
||||
public func nodeBy(tag: String) -> Node? {
|
||||
if self.tag.contains(tag) {
|
||||
return self
|
||||
}
|
||||
|
||||
return .none
|
||||
}
|
||||
|
||||
public func nodesBy(tag: String) -> [Node] {
|
||||
return [nodeBy(tag: tag)].compactMap { $0 }
|
||||
}
|
||||
|
||||
// MARK: - Events
|
||||
internal var animationObservers = [AnimationObserver]()
|
||||
|
||||
var touchPressedHandlers = [ChangeHandler<TouchEvent>]()
|
||||
|
@ -196,7 +196,7 @@ open class MacawView: MView, MGestureRecognizerDelegate {
|
||||
renderer.render(in: ctx, force: false, opacity: node.opacity)
|
||||
}
|
||||
|
||||
private func calculateZPosition(_ nodeRenderer: NodeRenderer?, currentIndex: Int = 0) -> Int {
|
||||
@discardableResult private func calculateZPosition(_ nodeRenderer: NodeRenderer?, currentIndex: Int = 0) -> Int {
|
||||
nodeRenderer?.zPosition = currentIndex
|
||||
if let groupRenderer = nodeRenderer as? GroupRenderer {
|
||||
var i = currentIndex + 1
|
||||
|
Loading…
Reference in New Issue
Block a user