LayoutModifierNode

Trait LayoutModifierNode 

Source
pub trait LayoutModifierNode: ModifierNode {
    // Provided methods
    fn measure(
        &self,
        _context: &mut dyn ModifierNodeContext,
        measurable: &dyn Measurable,
        constraints: Constraints,
    ) -> LayoutModifierMeasureResult { ... }
    fn min_intrinsic_width(
        &self,
        _measurable: &dyn Measurable,
        _height: f32,
    ) -> f32 { ... }
    fn max_intrinsic_width(
        &self,
        _measurable: &dyn Measurable,
        _height: f32,
    ) -> f32 { ... }
    fn min_intrinsic_height(
        &self,
        _measurable: &dyn Measurable,
        _width: f32,
    ) -> f32 { ... }
    fn max_intrinsic_height(
        &self,
        _measurable: &dyn Measurable,
        _width: f32,
    ) -> f32 { ... }
    fn create_measurement_proxy(&self) -> Option<Box<dyn MeasurementProxy>> { ... }
}
Expand description

Marker trait for layout-specific modifier nodes.

Layout nodes participate in the measure and layout passes of the render pipeline. They can intercept and modify the measurement and placement of their wrapped content.

Provided Methods§

Source

fn measure( &self, _context: &mut dyn ModifierNodeContext, measurable: &dyn Measurable, constraints: Constraints, ) -> LayoutModifierMeasureResult

Measures the wrapped content and returns both the size this modifier occupies and where the wrapped content should be placed.

The node receives a measurable representing the wrapped content and the incoming constraints from the parent.

Returns a LayoutModifierMeasureResult containing:

  • size: The final size this modifier will occupy
  • placement_offset_x/y: Where to place the wrapped content relative to this modifier’s top-left corner

For example, a padding modifier would:

  • Measure child with deflated constraints
  • Return size = child size + padding
  • Return placement offset = (padding.left, padding.top)

The default implementation delegates to the wrapped content without modification (size = child size, offset = 0).

NOTE: This takes &self not &mut self to match Jetpack Compose semantics. Nodes that need mutable state should use interior mutability (Cell/RefCell).

Source

fn min_intrinsic_width(&self, _measurable: &dyn Measurable, _height: f32) -> f32

Returns the minimum intrinsic width of this modifier node.

Source

fn max_intrinsic_width(&self, _measurable: &dyn Measurable, _height: f32) -> f32

Returns the maximum intrinsic width of this modifier node.

Source

fn min_intrinsic_height(&self, _measurable: &dyn Measurable, _width: f32) -> f32

Returns the minimum intrinsic height of this modifier node.

Source

fn max_intrinsic_height(&self, _measurable: &dyn Measurable, _width: f32) -> f32

Returns the maximum intrinsic height of this modifier node.

Source

fn create_measurement_proxy(&self) -> Option<Box<dyn MeasurementProxy>>

Creates a measurement proxy for this node that can perform measurement without holding a borrow to the modifier chain.

This method enables custom layout modifiers to work with the coordinator chain while respecting Rust’s borrow checker constraints. The proxy should capture a snapshot of the node’s current configuration.

The default implementation returns None, which causes the coordinator to use a passthrough strategy that delegates directly to the wrapped content.

§Example
impl LayoutModifierNode for MyCustomLayoutNode {
    fn create_measurement_proxy(&self) -> Option<Box<dyn MeasurementProxy>> {
        Some(Box::new(MyCustomLayoutProxy {
            // Snapshot node configuration here
            padding: self.padding,
        }))
    }
}

Implementors§