Best way to express UI nodes

I need the following:

  • A extendable set of component types, possibly with more than one supertype. For example, TextArea → FeathersControl → DisplayObjectContainer → DisplayObject
  • Contravariant conversion to any subtype (like someDisplayObjectContainer to FeathersControl)
  • Covariant conversion to any supertype (like someFeathersControl to DisplayObjectContainer)
  • Wrap the node into a reference type (Rc, Weak, Arc or Gc)

I've been told about making my own Any type (using the mopa crate) and explicitly providing covariant conversion methods manually in each subtype. I find this anti-idiomatic, so any other idea?

There is another issue as well:

  • Fields in super types
    • The reason is so that I don't need to reimplement methods like add_child(...) for subtypes of DisplayObjectContainer, which would require an internal children vector.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.