Fixe recursive prototype search
This commit is contained in:
parent
aca1a8af78
commit
56e4ba2903
@ -5,6 +5,7 @@ package hep.dataforge.vis.spatial
|
||||
import hep.dataforge.meta.Config
|
||||
import hep.dataforge.meta.Laminate
|
||||
import hep.dataforge.meta.MetaItem
|
||||
import hep.dataforge.meta.descriptors.NodeDescriptor
|
||||
import hep.dataforge.meta.get
|
||||
import hep.dataforge.names.*
|
||||
import hep.dataforge.vis.*
|
||||
@ -88,6 +89,9 @@ class Proxy private constructor(
|
||||
|
||||
//override fun findAllStyles(): Laminate = Laminate((styles + prototype.styles).mapNotNull { findStyle(it) })
|
||||
|
||||
override val descriptor: NodeDescriptor?
|
||||
get() = prototype.descriptor
|
||||
|
||||
inner class ProxyChild(val name: Name) : AbstractVisualObject(),
|
||||
VisualGroup {
|
||||
|
||||
@ -139,6 +143,9 @@ class Proxy private constructor(
|
||||
override fun allProperties(): Laminate =
|
||||
Laminate(properties, mergedStyles, prototype.allProperties(), parent?.allProperties())
|
||||
|
||||
|
||||
override val descriptor: NodeDescriptor?
|
||||
get() = prototype.descriptor
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -40,8 +40,8 @@ class VisualGroup3D : AbstractVisualGroup(), VisualObject3D, PrototypeHolder {
|
||||
*/
|
||||
fun prototypes(builder: MutableVisualGroup.() -> Unit): Unit {
|
||||
(prototypes ?: Prototypes().also {
|
||||
attach(it)
|
||||
prototypes = it
|
||||
attach(it)
|
||||
}).run(builder)
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ class VisualGroup3D : AbstractVisualGroup(), VisualObject3D, PrototypeHolder {
|
||||
* Ger a prototype redirecting the request to the parent if prototype is not found
|
||||
*/
|
||||
tailrec fun PrototypeHolder.getPrototype(name: Name): VisualObject3D? =
|
||||
prototypes?.get(name) as? VisualObject3D ?: (parent as? VisualGroup3D)?.getPrototype(name)
|
||||
prototypes?.get(name) as? VisualObject3D ?: (parent as? PrototypeHolder)?.getPrototype(name)
|
||||
|
||||
/**
|
||||
* Define a group with given [name], attach it to this parent and return it.
|
||||
|
Loading…
Reference in New Issue
Block a user