diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-12-28 00:29:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-28 00:29:15 +0100 |
| commit | 9624ad635bd8adb0e421c37c63c7310ecc71a708 (patch) | |
| tree | 0062b38db54c1fd785eedecbd9b77a12800bc340 /src/library/flow.rs | |
| parent | f6c7a8292dc1ab0560408fca9d74505e9d7cf13a (diff) | |
| parent | 7f7e14d95f7240727e0163451190ff63b230e393 (diff) | |
Merge pull request #52 from typst/basicc-cols
Introduce equal-width columns
Diffstat (limited to 'src/library/flow.rs')
| -rw-r--r-- | src/library/flow.rs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/library/flow.rs b/src/library/flow.rs index cfa761b6..6bfa3ddd 100644 --- a/src/library/flow.rs +++ b/src/library/flow.rs @@ -36,24 +36,28 @@ pub enum FlowChild { Spacing(SpacingNode), /// An arbitrary node. Node(PackedNode), + /// Skip the rest of the region and move to the next. + Skip, } impl FlowChild { /// A reference to the child's styles. - pub fn styles(&self) -> &Styles { + pub fn styles(&self) -> Option<&Styles> { match self { - Self::Break(styles) => styles, - Self::Spacing(node) => &node.styles, - Self::Node(node) => &node.styles, + Self::Break(styles) => Some(styles), + Self::Spacing(node) => Some(&node.styles), + Self::Node(node) => Some(&node.styles), + Self::Skip => None, } } /// A mutable reference to the child's styles. - pub fn styles_mut(&mut self) -> &mut Styles { + pub fn styles_mut(&mut self) -> Option<&mut Styles> { match self { - Self::Break(styles) => styles, - Self::Spacing(node) => &mut node.styles, - Self::Node(node) => &mut node.styles, + Self::Break(styles) => Some(styles), + Self::Spacing(node) => Some(&mut node.styles), + Self::Node(node) => Some(&mut node.styles), + Self::Skip => None, } } } @@ -69,6 +73,7 @@ impl Debug for FlowChild { } Self::Spacing(node) => node.fmt(f), Self::Node(node) => node.fmt(f), + Self::Skip => f.pad("Skip"), } } } @@ -138,6 +143,9 @@ impl<'a> FlowLayouter<'a> { let amount = chain.get(ParNode::SPACING).resolve(em); self.layout_absolute(amount.into()); } + FlowChild::Skip => { + self.finish_region(); + } FlowChild::Spacing(node) => match node.kind { SpacingKind::Linear(v) => self.layout_absolute(v), SpacingKind::Fractional(v) => { |
