pub struct LayoutEngine<K: Copy + 'static> { /* private fields */ }Expand description
An incremental layout tree.
Nodes keep their computed layout between frames; changing a style or
marking a leaf dirty only recomputes the affected ancestors. Leaves with a
measure context K are sized through the measure callback passed to
LayoutEngine::compute.
Implementations§
Source§impl<K: Copy + 'static> LayoutEngine<K>
impl<K: Copy + 'static> LayoutEngine<K>
pub fn new() -> Self
Sourcepub fn create(&mut self, style: &LayoutStyle, context: Option<K>) -> LayoutId
pub fn create(&mut self, style: &LayoutStyle, context: Option<K>) -> LayoutId
Creates a node. Leaves that need measuring get a context.
Sourcepub fn set_context(&mut self, id: LayoutId, context: Option<K>)
pub fn set_context(&mut self, id: LayoutId, context: Option<K>)
Sets or clears the measure context of a node (making it a measured leaf).
pub fn set_style(&mut self, id: LayoutId, style: &LayoutStyle)
pub fn set_children(&mut self, id: LayoutId, children: &[LayoutId])
Sourcepub fn mark_dirty(&mut self, id: LayoutId)
pub fn mark_dirty(&mut self, id: LayoutId)
Marks a leaf as needing re-measurement (e.g. its text changed).
pub fn is_dirty(&self, id: LayoutId) -> bool
pub fn remove(&mut self, id: LayoutId)
pub fn node_count(&self) -> usize
Sourcepub fn compute(
&mut self,
root: LayoutId,
available: Size,
measure: impl FnMut(K, MeasureInput) -> Size,
)
pub fn compute( &mut self, root: LayoutId, available: Size, measure: impl FnMut(K, MeasureInput) -> Size, )
Computes layout for the subtree rooted at root within available.
Sourcepub fn layout(&self, id: LayoutId) -> NodeLayout
pub fn layout(&self, id: LayoutId) -> NodeLayout
The computed layout of a node.
Trait Implementations§
Auto Trait Implementations§
impl<K> !Send for LayoutEngine<K>
impl<K> !Sync for LayoutEngine<K>
impl<K> Freeze for LayoutEngine<K>
impl<K> RefUnwindSafe for LayoutEngine<K>where
TaffyTree<K>: RefUnwindSafe,
impl<K> Unpin for LayoutEngine<K>
impl<K> UnsafeUnpin for LayoutEngine<K>where
TaffyTree<K>: UnsafeUnpin,
impl<K> UnwindSafe for LayoutEngine<K>where
TaffyTree<K>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more