4 releases
new 0.1.1 | Dec 4, 2024 |
---|---|
0.1.0 | Dec 3, 2024 |
0.1.0-alpha.3 |
|
0.1.0-alpha.1 | Nov 29, 2024 |
#1189 in GUI
596 downloads per month
Used in 2 crates
1MB
21K
SLoC
float-pigment-layout
A light-weight layout engine which supports common web layout algorithms.
This is a crate of the float-pigment project. See its documentation for details.
lib.rs
:
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.
Dependencies
~8.5MB
~159K SLoC