diff options
Diffstat (limited to 'library/src')
| -rw-r--r-- | library/src/layout/container.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs index bac0cb7f..0f81a1df 100644 --- a/library/src/layout/container.rs +++ b/library/src/layout/container.rs @@ -88,6 +88,10 @@ pub struct BoxElem { #[fold] pub outset: Sides<Option<Rel<Length>>>, + /// Whether to clip the content inside the box. + #[default(false)] + pub clip: bool, + /// The contents of the box. #[positional] pub body: Option<Content>, @@ -133,6 +137,11 @@ impl Layout for BoxElem { frame.set_baseline(frame.baseline() - shift); } + // Clip the contents + if self.clip(styles) { + frame.clip(); + } + // Prepare fill and stroke. let fill = self.fill(styles); let stroke = self.stroke(styles).map(|s| s.map(PartialStroke::unwrap_or_default)); @@ -296,6 +305,10 @@ pub struct BlockElem { #[default(VElem::block_spacing(Em::new(1.2).into()))] pub below: VElem, + /// Whether to clip the content inside the block. + #[default(false)] + pub clip: bool, + /// The contents of the block. #[positional] pub body: Option<Content>, @@ -369,6 +382,13 @@ impl Layout for BlockElem { body.layout(vt, styles, pod)?.into_frames() }; + // Clip the contents + if self.clip(styles) { + for frame in frames.iter_mut() { + frame.clip(); + } + } + // Prepare fill and stroke. let fill = self.fill(styles); let stroke = self.stroke(styles).map(|s| s.map(PartialStroke::unwrap_or_default)); |
