Skip to main content

LayoutView

Trait LayoutView 

Source
pub trait LayoutView: Send {
    // Required methods
    fn size_that_fits(
        &self,
        proposal: SizeProposal,
        subviews: &[&dyn LayoutView],
        cache: &mut LayoutCache,
    ) -> Size;
    fn place_subviews(
        &self,
        bounds: Rect,
        subviews: &mut [&mut dyn LayoutView],
        cache: &mut LayoutCache,
    );

    // Provided methods
    fn flex_weight(&self) -> f32 { ... }
    fn debug_layout(&self, indent: usize) -> String { ... }
}
Expand description

A view that can participate in layout

Required Methods§

Source

fn size_that_fits( &self, proposal: SizeProposal, subviews: &[&dyn LayoutView], cache: &mut LayoutCache, ) -> Size

Propose a size for this view given the available space

Source

fn place_subviews( &self, bounds: Rect, subviews: &mut [&mut dyn LayoutView], cache: &mut LayoutCache, )

Place subviews within the given bounds

Provided Methods§

Source

fn flex_weight(&self) -> f32

Returns the flex weight of this view (default is 0.0, which means fixed/intrinsic)

Source

fn debug_layout(&self, indent: usize) -> String

Return a debug representation of this layout subtree. The indent parameter controls the indentation level for nested display.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§