tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81412 Sutichaykuna

⎇ 8de95f09cab31cdf16888d276aa042613f80820d src/layout.rs Rust · 33 siq'ikuna · 948 B Ñawpa willay Pi imata llamkarqan ch'uya

Add `#[must_use]` to all static methods (#125) 8de95f09c · Andreas Weibye ·

1use crate::flexbox::ComputeResult;
2use crate::geometry::{Point, Size};
3use crate::number::Number;
4
5/// The final result of a layout algorithm for a single [`Node`](crate::node::Node).
6#[derive(Copy, Debug, Clone)]
7pub struct Layout {
8    /// The relative ordering of the node
9    ///
10    /// Nodes with a higher order should be rendered on top of those with a lower order.
11    /// This is effectively a topological sort of each tree.
12    pub order: u32,
13    // The width and height of the node
14    pub size: Size<f32>,
15    // The bottom-left corner of the node
16    pub location: Point<f32>,
17}
18
19impl Layout {
20    #[must_use]
21    pub(crate) fn new() -> Self {
22        Self { order: 0, size: Size::zero(), location: Point::zero() }
23    }
24}
25
26#[derive(Debug, Clone)]
27pub(crate) struct Cache {
28    pub(crate) node_size: Size<Number>,
29    pub(crate) parent_size: Size<Number>,
30    pub(crate) perform_layout: bool,
31
32    pub(crate) result: ComputeResult,
33}