Remove `ComputeResult` type (#139)
1//! Final and cached data structures that represent the high-level UI layout
2
3use crate::geometry::{Point, Size};
4use crate::number::Number;
5
6/// The final result of a layout algorithm for a single [`Node`](crate::node::Node).
7#[derive(Copy, Debug, Clone)]
8pub struct Layout {
9 /// The relative ordering of the node
10 ///
11 /// Nodes with a higher order should be rendered on top of those with a lower order.
12 /// This is effectively a topological sort of each tree.
13 pub order: u32,
14 /// The width and height of the node
15 pub size: Size<f32>,
16 /// The bottom-left corner of the node
17 pub location: Point<f32>,
18}
19
20impl Layout {
21 /// Creates a new [`Layout`] struct with zero size positioned at the origin
22 #[must_use]
23 pub(crate) fn new() -> Self {
24 Self { order: 0, size: Size::zero(), location: Point::zero() }
25 }
26}
27
28/// Cached intermediate layout results
29#[derive(Debug, Clone)]
30pub(crate) struct Cache {
31 /// The initial cached size of the node itself
32 pub(crate) node_size: Size<Number>,
33 /// The initial cached size of the parent's node
34 pub(crate) parent_size: Size<Number>,
35 /// Whether or not layout should be recomputed
36 pub(crate) perform_layout: bool,
37
38 /// The cached size of the item
39 pub(crate) size: Size<f32>,
40}