diff options
| author | Martin Haug <mhaug@live.de> | 2021-12-18 18:04:26 +0100 |
|---|---|---|
| committer | Martin Haug <mhaug@live.de> | 2021-12-26 15:59:24 +0100 |
| commit | b22ce6f8b84e0a75d162feb6f3699e26f86f2453 (patch) | |
| tree | 76c564484d2d020d23ffbb75b133fc8bacae9454 /src/library/flow.rs | |
| parent | f6c7a8292dc1ab0560408fca9d74505e9d7cf13a (diff) | |
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..ca730db1 100644 --- a/src/library/flow.rs +++ b/src/library/flow.rs @@ -32,6 +32,8 @@ impl Debug for FlowNode { pub enum FlowChild { /// A paragraph/block break. Break(Styles), + /// Skip the rest of the region and move to the next. + Skip, /// Vertical spacing between other children. Spacing(SpacingNode), /// An arbitrary node. @@ -40,20 +42,22 @@ pub enum FlowChild { 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 => write!(f, "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) => { |
