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: block
display: flex
display: none
position: absolute
- with an optional external text layout engine:
display: inline
display: inline-block
display: 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 aLayoutNode
inside it; - or use the float-pigment-forest crate (the
float_pigment_forest::node::Node
is 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§
- The computed
margin
padding
border
width. - Four edge lengths.
- Four edge lengths, each edge can be undetermined.
- The layout information of a tree node.
- The result of the measure function.
- A number or undetermined.
Enums§
- A length type that can be undefined or auto.
Traits§
- A helper type to measure inline nodes.
- A helper type as the inline form of a tree node.
- The styles of a tree node.
- The main tree node type.
- A helper type for tree traversal.
- A type to get screen size.
Functions§
- Returns if the node has a special position, e.g.
display: none
orposition: absolute
.
Type Aliases§
- Size, but each value can be
None
for undetermined. - Position.
- Position with size.
- Size.
- 2D Vector.