Skip to main content

LayoutEngine

Struct LayoutEngine 

Source
pub struct LayoutEngine;

Implementations§

Source§

impl LayoutEngine

Source

pub fn layout(root: &mut LayoutNode, width: f32, height: f32)

Main layout entry point. Initiates layout computation from the root node with specified viewport dimensions.

§TODO
  • Implement CSS-correct flex-basis precedence.
    • flex-basis should override width/height on the main axis, but the current algorithm does not guarantee this.
Examples found in repository?
examples/layout_flex_chain_bench.rs (line 85)
77fn main() {
78    println!("flex-chain layout benchmark");
79    println!("----------------------------");
80
81    let mut root = make_tree();
82
83    let t1 = {
84        let start = Instant::now();
85        LayoutEngine::layout(&mut root, 800.0, 600.0);
86        start.elapsed()
87    };
88
89    println!("1st layout: {:?}", t1);
90
91    let t2 = {
92        let start = Instant::now();
93        LayoutEngine::layout(&mut root, 800.0, 600.0);
94        start.elapsed()
95    };
96
97    println!("2nd layout: {:?}", t2);
98}
More examples
Hide additional examples
examples/layout_bench.rs (line 89)
73fn main() {
74    const TOTAL_NODES: usize = 7_000;
75    const DEPTH: usize = 16;
76
77    println!("layout performance benchmark");
78    println!("TOTAL_NODES = {}", TOTAL_NODES);
79    println!("DEPTH       = {}", DEPTH);
80    println!("-------------------------");
81
82    let mut remaining = TOTAL_NODES - 1;
83    let mut root = make_tree(0, DEPTH, &mut remaining);
84
85    println!("remaining nodes unused = {}", remaining);
86
87    let t1 = {
88        let start = Instant::now();
89        LayoutEngine::layout(&mut root, 800.0, 600.0);
90        start.elapsed()
91    };
92
93    println!("1st layout: {:?}", t1);
94
95    let t2 = {
96        let start = Instant::now();
97        LayoutEngine::layout(&mut root, 800.0, 600.0);
98        start.elapsed()
99    };
100
101    println!("2nd layout: {:?}", t2);
102}

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.