Skip to main content

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 { ... }
}
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.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§