pub trait SubView {
// Required methods
fn size_that_fits(&self, proposal: ProposalSize) -> Size;
fn stretch_axis(&self) -> StretchAxis;
fn priority(&self) -> i32;
}Expand description
A proxy for querying child view sizes during layout.
This trait allows layout containers to negotiate with children by asking “if I propose this size, how big would you be?” multiple times with different proposals.
§Pure Functions
All methods are pure (take &self) with no side effects. Caching of
measurement results is handled by the native backend, not in Rust.
Required Methods§
Sourcefn size_that_fits(&self, proposal: ProposalSize) -> Size
fn size_that_fits(&self, proposal: ProposalSize) -> Size
Query the child’s size for a given proposal.
This method may be called multiple times with different proposals to probe the child’s flexibility:
ProposalSize::new(None, None)- ideal/intrinsic sizeProposalSize::new(Some(0.0), None)- minimum widthProposalSize::new(Some(f32::INFINITY), None)- maximum widthProposalSize::new(Some(200.0), None)- constrained width
Sourcefn stretch_axis(&self) -> StretchAxis
fn stretch_axis(&self) -> StretchAxis
Which axis (or axes) this view stretches to fill available space.
StretchAxis::None: Content-sized, uses intrinsic sizeStretchAxis::Horizontal: Expands width only (e.g.,TextField, Slider)StretchAxis::Vertical: Expands height onlyStretchAxis::Both: Greedy, fills all space (e.g., Spacer, Color)
Layout containers use this to distribute remaining space appropriately:
VStackchecksstretches_vertical()for height distributionHStackchecksstretches_horizontal()for width distribution