Skip to main content

LayoutEngine

Struct LayoutEngine 

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

Layout engine backed by Taffy.

Manages a tree of layout nodes associated with widget IDs, computes CSS Flexbox and Grid layout, and returns integer-cell results.

Implementations§

Source§

impl LayoutEngine

Source

pub fn new() -> Self

Create a new empty layout engine.

Source

pub fn add_node( &mut self, widget_id: WidgetId, style: Style, ) -> Result<(), LayoutError>

Add a leaf node with the given style.

Source

pub fn add_node_with_children( &mut self, widget_id: WidgetId, style: Style, children: &[WidgetId], ) -> Result<(), LayoutError>

Add a node with children.

Source

pub fn set_root(&mut self, widget_id: WidgetId) -> Result<(), LayoutError>

Set the root node for layout computation.

Source

pub fn update_style( &mut self, widget_id: WidgetId, style: Style, ) -> Result<(), LayoutError>

Update the style of an existing node.

Source

pub fn remove_node(&mut self, widget_id: WidgetId) -> Result<(), LayoutError>

Remove a node from the layout tree.

Source

pub fn compute( &mut self, available_width: u16, available_height: u16, ) -> Result<(), LayoutError>

Compute layout using the given available space.

Source

pub fn layout(&self, widget_id: WidgetId) -> Result<LayoutRect, LayoutError>

Get the computed layout for a widget as a LayoutRect.

Source

pub fn layout_rect(&self, widget_id: WidgetId) -> Result<Rect, LayoutError>

Get the computed layout for a widget as a Rect.

Source

pub fn has_node(&self, widget_id: WidgetId) -> bool

Check if a widget has a layout node.

Source

pub fn node_count(&self) -> usize

Return the number of nodes in the tree.

Trait Implementations§

Source§

impl Default for LayoutEngine

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.