Skip to main content

LayoutEngine

Trait LayoutEngine 

Source
pub trait LayoutEngine {
    // Required methods
    fn clear(&mut self);
    fn request_layout(
        &mut self,
        style: &EngineLayoutStyle,
        rem_size: Pixels,
        scale_factor: f32,
        children: &[LayoutId],
    ) -> LayoutId;
    fn request_measured_layout(
        &mut self,
        style: &EngineLayoutStyle,
        rem_size: Pixels,
        scale_factor: f32,
        measure: Box<dyn FnMut(Size<Option<Pixels>>, Size<AvailableSpace>, &mut dyn MeasureContext) -> Size<Pixels>>,
    ) -> LayoutId;
    fn stretch_auto_size_to_fill(
        &mut self,
        id: LayoutId,
        size: Size<Pixels>,
        scale_factor: f32,
    );
    fn compute_layout(
        &mut self,
        id: LayoutId,
        available_space: Size<AvailableSpace>,
        scale_factor: f32,
        context: &mut dyn MeasureContext,
    );
    fn layout_bounds(
        &mut self,
        id: LayoutId,
        scale_factor: f32,
    ) -> Bounds<Pixels>;
}
Expand description

A layout solver.

The facade drives the whole frame lifecycle through this trait, so the layout implementation can be swapped without the authoring layer naming it.

Required Methods§

Source

fn clear(&mut self)

Discards every node and cached bounds, ready for a fresh frame.

Source

fn request_layout( &mut self, style: &EngineLayoutStyle, rem_size: Pixels, scale_factor: f32, children: &[LayoutId], ) -> LayoutId

Adds a leaf or container node built from style.

Source

fn request_measured_layout( &mut self, style: &EngineLayoutStyle, rem_size: Pixels, scale_factor: f32, measure: Box<dyn FnMut(Size<Option<Pixels>>, Size<AvailableSpace>, &mut dyn MeasureContext) -> Size<Pixels>>, ) -> LayoutId

Adds a leaf whose size is resolved by measure during layout.

Source

fn stretch_auto_size_to_fill( &mut self, id: LayoutId, size: Size<Pixels>, scale_factor: f32, )

Treats any auto dimension of id’s style as filling size.

Source

fn compute_layout( &mut self, id: LayoutId, available_space: Size<AvailableSpace>, scale_factor: f32, context: &mut dyn MeasureContext, )

Computes the layout of id within available_space, invoking stored measure callbacks with context.

Source

fn layout_bounds(&mut self, id: LayoutId, scale_factor: f32) -> Bounds<Pixels>

Returns the pixel-snapped bounds of id relative to the window.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§