Skip to content

0.12.0

Latest

Choose a tag to compare

@cyypherus cyypherus released this 30 May 15:43

What's Changed

Recursive -> Iterative Traversal

  • To remove the possibility of stack overflow on deep trees, backer now does zero recursion during layout.
  • This might also contribute performance gains as well? Not sure, honestly
  • Resolves #65

Significant Performance Gains for Large Trees

  • Before, passes didn't scale well & had unclear time complexity
  • With this PR, tree passes are very clear. Backer performs two iterations of one upwards pass & one downwards pass to finalize a layout.

Attach over / Attach under -> Inertness

  • The attach functions are removed, instead, a more powerful, composable inertness api has been added.
  • Attachment was always used to force layout to ignore certain nodes, and have those nodes passively use area available to them. Moving to inertness more accurately represents the core utility of attachment, adding many new possibilities including inertness along specific axes or in rows / columns.
  • For example - if you want a node to take up as much space as the tallest item in a row, without giving the row an unconstrained height, now you can do that!
  • To recreate attach under / over, you simply use a stack, marking the attached node as inert. Inertness prevents nodes from being considered during constraint calculation along both axes or a specific axis.

Generics & Lifetimes Changed

  • Backer layouts now produce values for each draw node, rather than performing work with mutable access inline. The generic D is the type of value that will be produced when you layout your tree.
  • Backer layouts now have access to a global, mutable context object - the generic S. This value is shared by the entire tree & can be used for things like text layout caches
  • There's a lifetime in the interface now 😵, this lifetime is the lifetime of the draw closures. Exposing this in the interface allows draw closures to borrow state from the environment with more flexibility.

Layers Added

  • Backer now supports layers, known as z index in other libraries. Layers are global, and determine the order of the values that are collected when you call Layout::draw. Closes #67

AreaReader Removed

  • Area readers turned out to be unnecessary complexity which caused lifetime problems, forcing 'static.
  • One can now accomplish the exact same thing using a draw node, which constructs a Layout, calls Layout::draw, and returns the resulting Vec
  • This approach maintains the constraint barrier which prevents cyclical layout dependencies between parent & child, & simplifies the library.

Full Changelog: 0.11.1...0.12.0