Skip to main content

LayoutEngine

Struct LayoutEngine 

Source
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>

Source

pub fn new() -> Self

Source

pub fn create(&mut self, style: &LayoutStyle, context: Option<K>) -> LayoutId

Creates a node. Leaves that need measuring get a context.

Source

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).

Source

pub fn set_style(&mut self, id: LayoutId, style: &LayoutStyle)

Source

pub fn set_children(&mut self, id: LayoutId, children: &[LayoutId])

Source

pub fn mark_dirty(&mut self, id: LayoutId)

Marks a leaf as needing re-measurement (e.g. its text changed).

Source

pub fn is_dirty(&self, id: LayoutId) -> bool

Source

pub fn remove(&mut self, id: LayoutId)

Source

pub fn node_count(&self) -> usize

Source

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.

Source

pub fn layout(&self, id: LayoutId) -> NodeLayout

The computed layout of a node.

Trait Implementations§

Source§

impl<K: Copy + 'static> Default for LayoutEngine<K>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<K> !Send for LayoutEngine<K>

§

impl<K> !Sync for LayoutEngine<K>

§

impl<K> Freeze for LayoutEngine<K>
where TaffyTree<K>: Freeze,

§

impl<K> RefUnwindSafe for LayoutEngine<K>

§

impl<K> Unpin for LayoutEngine<K>
where TaffyTree<K>: Unpin,

§

impl<K> UnsafeUnpin for LayoutEngine<K>

§

impl<K> UnwindSafe for LayoutEngine<K>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.