Skip to main content

Layout

Trait Layout 

Source
pub trait Layout: 'static {
    // Required methods
    fn measure(
        &self,
        cx: &mut dyn LayoutOps,
        children: &[RNode],
        p: Proposal,
    ) -> Size;
    fn place(&self, cx: &mut dyn LayoutOps, children: &[RNode], bounds: Rect);

    // Provided method
    fn baseline(
        &self,
        _cx: &mut dyn LayoutOps,
        _children: &[RNode],
        _size: Size,
    ) -> Option<f64> { ... }
}
Expand description

Open layout protocol (§7.2). children are the node’s direct children; group nodes (when/each anchors) are layout-transparent: stacks expand them inline.

Required Methods§

Source

fn measure( &self, cx: &mut dyn LayoutOps, children: &[RNode], p: Proposal, ) -> Size

Source

fn place(&self, cx: &mut dyn LayoutOps, children: &[RNode], bounds: Rect)

Provided Methods§

Source

fn baseline( &self, _cx: &mut dyn LayoutOps, _children: &[RNode], _size: Size, ) -> Option<f64>

Where this node’s own first text baseline falls, measured from the top of a box of size (docs/baseline.md). None (the default) means the node has no baseline to offer, so a baseline-aligned parent falls back to box alignment for it.

A container answers on behalf of its content: a column reports its first baseline-bearing child’s, shifted by where that child sits. Leaves never reach here; LayoutOps::baseline_of asks the toolkit for those.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Day API ↩ Guides· daybrite.dev