diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-10-17 14:38:48 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-10-23 20:23:47 +0200 |
| commit | 5becb32ba463d6b0ace914ab06bb237483a94fbc (patch) | |
| tree | 684efb242ddb04e71c54f9665cc59891f734e518 /src/layout/spacing.rs | |
| parent | c627847cb39572c08f3b53db07ea325ef0d352fa (diff) | |
Introduce page / block / inline levels
Diffstat (limited to 'src/layout/spacing.rs')
| -rw-r--r-- | src/layout/spacing.rs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/layout/spacing.rs b/src/layout/spacing.rs deleted file mode 100644 index 68fab3e6..00000000 --- a/src/layout/spacing.rs +++ /dev/null @@ -1,50 +0,0 @@ -use super::*; - -/// Spacing between other nodes. -#[derive(Debug)] -#[cfg_attr(feature = "layout-cache", derive(Hash))] -pub struct SpacingNode { - /// Which axis to space on. - pub axis: SpecAxis, - /// How much spacing to add. - pub amount: Linear, -} - -impl Layout for SpacingNode { - fn layout( - &self, - _: &mut LayoutContext, - regions: &Regions, - ) -> Vec<Constrained<Rc<Frame>>> { - let base = regions.base.get(self.axis); - let resolved = self.amount.resolve(base); - let limit = regions.current.get(self.axis); - - // Generate constraints. - let mut cts = Constraints::new(regions.expand); - if self.amount.is_relative() { - cts.base.set(self.axis, Some(base)); - } - - // If the spacing fits into the region, any larger region would also do. - // If it was limited though, any change it region size might lead to - // different results. - if resolved < limit { - cts.min.set(self.axis, Some(resolved)); - } else { - cts.exact.set(self.axis, Some(limit)); - } - - // Create frame with limited spacing size along spacing axis and zero - // extent along the other axis. - let mut size = Size::zero(); - size.set(self.axis, resolved.min(limit)); - vec![Frame::new(size, size.h).constrain(cts)] - } -} - -impl From<SpacingNode> for LayoutNode { - fn from(spacing: SpacingNode) -> Self { - Self::new(spacing) - } -} |
