Expand description
Layout engine with common CSS block and flexbox support.
Note: it is not a full web-compatible layout engine because it supports a subset of web layout algorithms.
Supported layout strategies:
display: blockdisplay: flexdisplay: noneposition: absolute- with an optional external text layout engine:
display: inlinedisplay: inline-blockdisplay: inline-flex
§Basic Usages
This crate does not construct node trees itself. You should firstly:
- write a node tree struct that implements
LayoutTreeNode, each node should owns aLayoutNodeinside it; - or use the float-pigment-forest crate (the
float_pigment_forest::node::Nodeis a good implementation).
Each tree node has a corresponding LayoutNode.
Calls the Layoutnode::update or Layoutnode::update_with_containing_size of tree root node every time you need a new layout result.
(The all results in the tree will be updated when Layoutnode::update* is called on the tree root.)
Then you can read any result in any node with LayoutNode::result* and LayoutNode::computed_style.
When any property of any node has been updated, calls the LayoutNode::mark_dirty.
The next Layoutnode::update* call on the tree root will carefully read the new properties and update the results.
§About Text Layout
Text layout means to compose text glyphs and other structures (images, inline-blocks, etc.) in lines. It is a complex problem and deeply coupled with system environment interfaces.
This crate does not solve text layout problems. Thus by default it does not support display: inline and similar features.
However, you are informed the inline layout parts so that you can implement a text layout engine to handle them.
Structs§
- Computed
Style - The computed
marginpaddingborderwidth. - Edge
- Four edge lengths.
- Edge
Option - Four edge lengths, each edge can be undetermined.
- Layout
Node - The layout information of a tree node.
- Measure
Result - The result of the measure function.
- Option
Num - A number or undetermined.
Enums§
- DefLength
- A length type that can be undefined or auto.
Traits§
- Inline
Measure - A helper type to measure inline nodes.
- Inline
Unit - A helper type as the inline form of a tree node.
- Layout
Style - The styles of a tree node.
- Layout
Tree Node - The main tree node type.
- Layout
Tree Visitor - A helper type for tree traversal.
- Screen
Query - A type to get screen size.
Functions§
- is_
independent_ positioning - Returns if the node has a special position, e.g.
display: noneorposition: absolute.
Type Aliases§
- Option
Size - Size, but each value can be
Nonefor undetermined. - Point
- Position.
- Rect
- Position with size.
- Size
- Size.
- Vector
- 2D Vector.