pub trait LayoutModifierNode: ModifierNode {
// Provided methods
fn measure(
&self,
_context: &mut dyn ModifierNodeContext,
measurable: &dyn Measurable,
constraints: Constraints,
) -> LayoutModifierMeasureResult { ... }
fn measure_hold(
&self,
_density: f32,
_constraints: Constraints,
_size: Size,
_wrapped: WrappedHold,
) -> Option<ConstraintsHold> { ... }
fn min_intrinsic_width(
&self,
measurable: &dyn Measurable,
height: f32,
_density: f32,
) -> f32 { ... }
fn max_intrinsic_width(
&self,
measurable: &dyn Measurable,
height: f32,
_density: f32,
) -> f32 { ... }
fn min_intrinsic_height(
&self,
measurable: &dyn Measurable,
width: f32,
_density: f32,
) -> f32 { ... }
fn max_intrinsic_height(
&self,
measurable: &dyn Measurable,
width: f32,
_density: 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§
Sourcefn measure(
&self,
_context: &mut dyn ModifierNodeContext,
measurable: &dyn Measurable,
constraints: Constraints,
) -> LayoutModifierMeasureResult
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 occupyplacement_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).
Sourcefn measure_hold(
&self,
_density: f32,
_constraints: Constraints,
_size: Size,
_wrapped: WrappedHold,
) -> Option<ConstraintsHold>
fn measure_hold( &self, _density: f32, _constraints: Constraints, _size: Size, _wrapped: WrappedHold, ) -> Option<ConstraintsHold>
The incoming constraints the last measure of this node, which gave
size under constraints, holds for: every constraints inside give
the same result. wrapped is what the content this node wraps
measured. None, the default, holds for constraints alone; a node
that tells must give the range its own measure keeps its result and
hands its content constraints that wrapped holds for.
Sourcefn min_intrinsic_width(
&self,
measurable: &dyn Measurable,
height: f32,
_density: f32,
) -> f32
fn min_intrinsic_width( &self, measurable: &dyn Measurable, height: f32, _density: f32, ) -> f32
Returns the minimum intrinsic width of this modifier node. The default is the wrapped content’s, for a node that keeps the content’s size.
Sourcefn max_intrinsic_width(
&self,
measurable: &dyn Measurable,
height: f32,
_density: f32,
) -> f32
fn max_intrinsic_width( &self, measurable: &dyn Measurable, height: f32, _density: f32, ) -> f32
Returns the maximum intrinsic width of this modifier node. The default is the wrapped content’s, for a node that keeps the content’s size.
Sourcefn min_intrinsic_height(
&self,
measurable: &dyn Measurable,
width: f32,
_density: f32,
) -> f32
fn min_intrinsic_height( &self, measurable: &dyn Measurable, width: f32, _density: f32, ) -> f32
Returns the minimum intrinsic height of this modifier node. The default is the wrapped content’s, for a node that keeps the content’s size.
Sourcefn max_intrinsic_height(
&self,
measurable: &dyn Measurable,
width: f32,
_density: f32,
) -> f32
fn max_intrinsic_height( &self, measurable: &dyn Measurable, width: f32, _density: f32, ) -> f32
Returns the maximum intrinsic height of this modifier node. The default is the wrapped content’s, for a node that keeps the content’s size.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".