Skip to main content

LayoutTree

Struct LayoutTree 

Source
pub struct LayoutTree { /* private fields */ }
Expand description

Árbol de layout. Encapsula la TaffyTree y la lógica de absolutización.

Implementations§

Source§

impl LayoutTree

Source

pub fn new() -> Self

Source

pub fn clear(&mut self)

Vacía el árbol conservando la capacidad ya asignada. Permite reusar la misma LayoutTree entre frames sin re-allocar el slotmap interno de taffy: clear() + mount en vez de LayoutTree::new() por frame. Los NodeId emitidos antes de clear() quedan inválidos (el caller ya volcó lo que necesitaba a un ComputedLayout, que es dueño de sus rects).

Source

pub fn leaf(&mut self, style: Style) -> Result<NodeId, LayoutError>

Crea una hoja (nodo sin hijos).

Source

pub fn node( &mut self, style: Style, children: &[NodeId], ) -> Result<NodeId, LayoutError>

Crea un nodo contenedor con hijos.

Source

pub fn compute( &mut self, root: NodeId, viewport: (f32, f32), ) -> Result<ComputedLayout, LayoutError>

Calcula el layout para root con viewport (w, h) y devuelve rects absolutos.

Source

pub fn compute_with_measure<F>( &mut self, root: NodeId, viewport: (f32, f32), measure: F, ) -> Result<ComputedLayout, LayoutError>

Como Self::compute pero pasando una función de medición por nodo. Taffy la invoca sobre las hojas que necesita dimensionar (texto que envuelve, contenido intrínseco) con el NodeId, las dimensiones ya conocidas y el espacio disponible; el caller devuelve el tamaño en px. Devolver Size::ZERO deja que el estilo decida (el comportamiento de Self::compute para hojas sin contenido). El NodeId permite al caller mantener su propio mapa nodo→contenido (p. ej. texto a shapear con parley) sin acoplar este crate a la capa de tipografía.

Source

pub fn inner(&self) -> &TaffyTree<()>

Source

pub fn inner_mut(&mut self) -> &mut TaffyTree<()>

Trait Implementations§

Source§

impl Default for LayoutTree

Source§

fn default() -> Self

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

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.