mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
33 lines
754 B
Rust
33 lines
754 B
Rust
//! Hiding of nodes without affecting layout.
|
|
|
|
use super::prelude::*;
|
|
|
|
/// Hide a node without affecting layout.
|
|
#[derive(Debug, Hash)]
|
|
pub struct HideNode(pub LayoutNode);
|
|
|
|
#[class]
|
|
impl HideNode {
|
|
fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> {
|
|
Ok(Template::inline(Self(args.expect("body")?)))
|
|
}
|
|
}
|
|
|
|
impl Layout for HideNode {
|
|
fn layout(
|
|
&self,
|
|
ctx: &mut Context,
|
|
regions: &Regions,
|
|
styles: StyleChain,
|
|
) -> TypResult<Vec<Arc<Frame>>> {
|
|
let mut frames = self.0.layout(ctx, regions, styles)?;
|
|
|
|
// Clear the frames.
|
|
for frame in &mut frames {
|
|
*frame = Arc::new(Frame { elements: vec![], ..**frame });
|
|
}
|
|
|
|
Ok(frames)
|
|
}
|
|
}
|