Skip to main content

SubcomposeMeasureScopeImpl

Struct SubcomposeMeasureScopeImpl 

Source
pub struct SubcomposeMeasureScopeImpl<'a> { /* private fields */ }
Expand description

Concrete implementation of SubcomposeMeasureScope.

Implementations§

Source§

impl<'a> SubcomposeMeasureScopeImpl<'a>

Source

pub fn new( composer: Composer, state: &'a mut SubcomposeState, constraints: Constraints, measurer: Box<dyn FnMut(NodeId, Constraints) -> Size + 'a>, error: Rc<RefCell<Option<NodeError>>>, parent_handle: SubcomposeLayoutNodeHandle, root_id: NodeId, ) -> Self

Source§

impl<'a> SubcomposeMeasureScopeImpl<'a>

Source

pub fn subcompose_with_size<Content, F>( &mut self, slot_id: SlotId, content: Content, estimate_size: F, ) -> Vec<SubcomposeChild>
where Content: FnOnce(), F: Fn(usize) -> Size,

Subcomposes content and assigns estimated sizes to children.

This is used by lazy layouts where true measurement happens later. The estimate_size function provides size estimates based on index.

Source

pub fn active_slots_count(&self) -> usize

Returns the number of active slots in the subcompose state.

Used by lazy layouts to report statistics about slot usage.

Source

pub fn reusable_slots_count(&self) -> usize

Returns the number of reusable slots in the pool.

Used by lazy layouts to report statistics about cached slots.

Source

pub fn register_content_type(&mut self, slot_id: SlotId, content_type: u64)

Registers the content type for a slot.

Call this before subcompose() to enable content-type-aware slot reuse. If the policy supports content types (like ContentTypeReusePolicy), slots with matching content types can reuse each other’s nodes.

Source

pub fn update_content_type( &mut self, slot_id: SlotId, content_type: Option<u64>, )

Updates the content type for a slot, handling Some→None transitions.

If content_type is Some(type), registers the type for the slot. If content_type is None, removes any previously registered type. This ensures stale types don’t drive incorrect reuse after transitions.

Source

pub fn was_last_slot_reused(&self) -> Option<bool>

Returns whether the last subcomposed slot was reused.

Returns Some(true) if the slot already existed (was reused from pool or was recomposed), Some(false) if it was newly created, or None if no slot has been subcomposed yet this pass.

This is useful for tracking composition statistics in lazy layouts.

Trait Implementations§

Source§

impl<'a> SubcomposeLayoutScope for SubcomposeMeasureScopeImpl<'a>

Source§

fn constraints(&self) -> Constraints

Source§

fn layout<I>(&mut self, width: f32, height: f32, placements: I) -> MeasureResult
where I: IntoIterator<Item = Placement>,

Source§

impl<'a> SubcomposeMeasureScope for SubcomposeMeasureScopeImpl<'a>

Source§

fn subcompose<Content>( &mut self, slot_id: SlotId, content: Content, ) -> Vec<SubcomposeChild>
where Content: FnOnce(),

Source§

fn measure( &mut self, child: SubcomposeChild, constraints: Constraints, ) -> SubcomposePlaceable

Measures a subcomposed child with the given constraints.
Source§

fn node_has_no_parent(&self, node_id: NodeId) -> bool

Checks if a node has no parent (is a root node). Used to filter subcompose results to only include true root nodes.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.