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
impl LayoutEngine
Sourcepub fn add_node(
&mut self,
widget_id: WidgetId,
style: Style,
) -> Result<(), LayoutError>
pub fn add_node( &mut self, widget_id: WidgetId, style: Style, ) -> Result<(), LayoutError>
Add a leaf node with the given style.
Sourcepub fn add_node_with_children(
&mut self,
widget_id: WidgetId,
style: Style,
children: &[WidgetId],
) -> Result<(), LayoutError>
pub fn add_node_with_children( &mut self, widget_id: WidgetId, style: Style, children: &[WidgetId], ) -> Result<(), LayoutError>
Add a node with children.
Sourcepub fn set_root(&mut self, widget_id: WidgetId) -> Result<(), LayoutError>
pub fn set_root(&mut self, widget_id: WidgetId) -> Result<(), LayoutError>
Set the root node for layout computation.
Sourcepub fn update_style(
&mut self,
widget_id: WidgetId,
style: Style,
) -> Result<(), LayoutError>
pub fn update_style( &mut self, widget_id: WidgetId, style: Style, ) -> Result<(), LayoutError>
Update the style of an existing node.
Sourcepub fn remove_node(&mut self, widget_id: WidgetId) -> Result<(), LayoutError>
pub fn remove_node(&mut self, widget_id: WidgetId) -> Result<(), LayoutError>
Remove a node from the layout tree.
Sourcepub fn compute(
&mut self,
available_width: u16,
available_height: u16,
) -> Result<(), LayoutError>
pub fn compute( &mut self, available_width: u16, available_height: u16, ) -> Result<(), LayoutError>
Compute layout using the given available space.
Sourcepub fn layout(&self, widget_id: WidgetId) -> Result<LayoutRect, LayoutError>
pub fn layout(&self, widget_id: WidgetId) -> Result<LayoutRect, LayoutError>
Get the computed layout for a widget as a LayoutRect.
Sourcepub fn layout_rect(&self, widget_id: WidgetId) -> Result<Rect, LayoutError>
pub fn layout_rect(&self, widget_id: WidgetId) -> Result<Rect, LayoutError>
Get the computed layout for a widget as a Rect.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Return the number of nodes in the tree.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LayoutEngine
impl RefUnwindSafe for LayoutEngine
impl Send for LayoutEngine
impl Sync for LayoutEngine
impl Unpin for LayoutEngine
impl UnwindSafe for LayoutEngine
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