Crate float_pigment_layout

Source
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 a LayoutNode 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§

Enums§

  • A length type that can be undefined or auto.

Traits§

Functions§

Type Aliases§