Function commit_layout_element

Source
pub fn commit_layout_element<A: 'static>(
    tree: &mut ElementTree<A>,
    ctx: &mut LayoutCtx<'_>,
    element_id: ElementId,
    origin: Offset,
)
Expand description

Commits authoritative layout bounds and notifies retained widgets recursively.

origin is an absolute logical-pixel translation for the root result’s paint_bounds. Unknown elements and elements without a cached layout are no-ops. A widget is notified only when its layout changed or its absolute bounds changed; clean, unchanged subtrees are skipped.

Direct-child records are paired with retained children by index. Missing layout entries skip excess tree children, and excess layout entries are ignored. Descendant bounds use the parent’s committed origin plus child offset and size; a child’s paint_bounds is not used for that calculation. A real authoritative widget layout callback also receives exactly one hook after publication, even if it returned equal geometry. Stable cache hits do not receive a hook unless their absolute bounds or retained hook inputs changed.

Geometry and commit flags for the complete visited subtree are published before the first widget callback runs. If a callback panics, all retained bounds therefore stay authoritative while later callbacks are not invoked. A panicking hook also keeps its previous reactive dependency set.

§Examples

use ailloli_ui_core::{ElementId, Offset, Scale};
use ailloli_ui_runtime::element::ElementTree;
use ailloli_ui_runtime::layout::{commit_layout_element, LayoutCtx};

let mut tree = ElementTree::<()>::new();
let mut ctx = LayoutCtx::new(Scale::new(1.0));
// Missing IDs are intentionally harmless.
commit_layout_element(&mut tree, &mut ctx, ElementId(99), Offset::new(5.0, 8.0));
assert!(tree.root().is_none());