euv_core/layout/cache/impl.rs
1use super::*;
2
3/// Construction helpers for `AvailableSpace`.
4impl AvailableSpace {
5 /// Creates root-level `AvailableSpace` matching the window viewport.
6 ///
7 /// # Arguments
8 ///
9 /// - `Size` - Logical viewport dimensions.
10 ///
11 /// # Returns
12 ///
13 /// - `Self` - Root available space at `(0, 0)`.
14 #[must_use]
15 pub fn root(viewport: Size) -> Self {
16 Self::new(
17 viewport.get_width(),
18 viewport.get_height(),
19 viewport,
20 0.0,
21 0.0,
22 )
23 }
24
25 /// Marks whether this node's auto width or height is stretched to fill the available slot.
26 ///
27 /// # Arguments
28 ///
29 /// - `Self` - Source available space.
30 /// - `bool` - Whether auto width stretches to `width`.
31 /// - `bool` - Whether auto height stretches to `height`.
32 ///
33 /// # Returns
34 ///
35 /// - `Self` - Updated available space with stretch flags applied.
36 #[must_use]
37 pub fn with_stretch(mut self, stretch_width: bool, stretch_height: bool) -> Self {
38 self.set_stretch_width(stretch_width);
39 self.set_stretch_height(stretch_height);
40 self
41 }
42}