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: BoxedMeasureFn,
) -> 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§
Sourcefn request_layout(
&mut self,
style: &EngineLayoutStyle,
rem_size: Pixels,
scale_factor: f32,
children: &[LayoutId],
) -> LayoutId
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.
Sourcefn request_measured_layout(
&mut self,
style: &EngineLayoutStyle,
rem_size: Pixels,
scale_factor: f32,
measure: BoxedMeasureFn,
) -> LayoutId
fn request_measured_layout( &mut self, style: &EngineLayoutStyle, rem_size: Pixels, scale_factor: f32, measure: BoxedMeasureFn, ) -> LayoutId
Adds a leaf whose size is resolved by measure during layout.
Sourcefn stretch_auto_size_to_fill(
&mut self,
id: LayoutId,
size: Size<Pixels>,
scale_factor: f32,
)
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.
Sourcefn compute_layout(
&mut self,
id: LayoutId,
available_space: Size<AvailableSpace>,
scale_factor: f32,
context: &mut dyn MeasureContext,
)
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".