Skip to main content

MeasurePolicy

Trait MeasurePolicy 

Source
pub trait MeasurePolicy {
    // Required methods
    fn measure(
        &self,
        measurables: &[Box<dyn Measurable>],
        constraints: Constraints,
    ) -> MeasureResult;
    fn min_intrinsic_width(
        &self,
        measurables: &[Box<dyn Measurable>],
        height: f32,
    ) -> f32;
    fn max_intrinsic_width(
        &self,
        measurables: &[Box<dyn Measurable>],
        height: f32,
    ) -> f32;
    fn min_intrinsic_height(
        &self,
        measurables: &[Box<dyn Measurable>],
        width: f32,
    ) -> f32;
    fn max_intrinsic_height(
        &self,
        measurables: &[Box<dyn Measurable>],
        width: f32,
    ) -> f32;

    // Provided method
    fn measure_into(
        &self,
        measurables: &[Box<dyn Measurable>],
        constraints: Constraints,
        placements: &mut Vec<Placement>,
    ) -> Size { ... }
}
Expand description

Policy responsible for measuring and placing children.

Required Methods§

Source

fn measure( &self, measurables: &[Box<dyn Measurable>], constraints: Constraints, ) -> MeasureResult

Runs the measurement pass with the provided children and constraints.

Source

fn min_intrinsic_width( &self, measurables: &[Box<dyn Measurable>], height: f32, ) -> f32

Computes the minimum intrinsic width of this policy.

Source

fn max_intrinsic_width( &self, measurables: &[Box<dyn Measurable>], height: f32, ) -> f32

Computes the maximum intrinsic width of this policy.

Source

fn min_intrinsic_height( &self, measurables: &[Box<dyn Measurable>], width: f32, ) -> f32

Computes the minimum intrinsic height of this policy.

Source

fn max_intrinsic_height( &self, measurables: &[Box<dyn Measurable>], width: f32, ) -> f32

Computes the maximum intrinsic height of this policy.

Provided Methods§

Source

fn measure_into( &self, measurables: &[Box<dyn Measurable>], constraints: Constraints, placements: &mut Vec<Placement>, ) -> Size

Runs measurement into caller-owned placement storage.

The default preserves the public MeasurePolicy::measure contract for custom policies. Built-in policies override this to avoid allocating a fresh placement vector on every measure pass.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§