summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/layout/transform.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2025-07-09 10:16:36 +0200
committerGitHub <noreply@github.com>2025-07-09 08:16:36 +0000
commite5e1dcd9c01341d2cd3473ac94a70223d5966086 (patch)
treed648efad9463cb10270d55ba35210eeb1e91ee22 /crates/typst-library/src/layout/transform.rs
parent0a3c6939dd274f40672484695d909c2cc0d0d755 (diff)
Target-specific native show rules (#6569)
Diffstat (limited to 'crates/typst-library/src/layout/transform.rs')
-rw-r--r--crates/typst-library/src/layout/transform.rs50
1 files changed, 6 insertions, 44 deletions
diff --git a/crates/typst-library/src/layout/transform.rs b/crates/typst-library/src/layout/transform.rs
index d153d97d..c2d9a21c 100644
--- a/crates/typst-library/src/layout/transform.rs
+++ b/crates/typst-library/src/layout/transform.rs
@@ -1,11 +1,5 @@
-use crate::diag::SourceResult;
-use crate::engine::Engine;
-use crate::foundations::{
- cast, elem, Content, NativeElement, Packed, Show, Smart, StyleChain,
-};
-use crate::layout::{
- Abs, Alignment, Angle, BlockElem, HAlignment, Length, Ratio, Rel, VAlignment,
-};
+use crate::foundations::{cast, elem, Content, Smart};
+use crate::layout::{Abs, Alignment, Angle, HAlignment, Length, Ratio, Rel, VAlignment};
/// Moves content without affecting layout.
///
@@ -25,7 +19,7 @@ use crate::layout::{
/// )
/// ))
/// ```
-#[elem(Show)]
+#[elem]
pub struct MoveElem {
/// The horizontal displacement of the content.
pub dx: Rel<Length>,
@@ -38,14 +32,6 @@ pub struct MoveElem {
pub body: Content,
}
-impl Show for Packed<MoveElem> {
- fn show(&self, engine: &mut Engine, _: StyleChain) -> SourceResult<Content> {
- Ok(BlockElem::single_layouter(self.clone(), engine.routines.layout_move)
- .pack()
- .spanned(self.span()))
- }
-}
-
/// Rotates content without affecting layout.
///
/// Rotates an element by a given angle. The layout will act as if the element
@@ -60,7 +46,7 @@ impl Show for Packed<MoveElem> {
/// .map(i => rotate(24deg * i)[X]),
/// )
/// ```
-#[elem(Show)]
+#[elem]
pub struct RotateElem {
/// The amount of rotation.
///
@@ -107,14 +93,6 @@ pub struct RotateElem {
pub body: Content,
}
-impl Show for Packed<RotateElem> {
- fn show(&self, engine: &mut Engine, _: StyleChain) -> SourceResult<Content> {
- Ok(BlockElem::single_layouter(self.clone(), engine.routines.layout_rotate)
- .pack()
- .spanned(self.span()))
- }
-}
-
/// Scales content without affecting layout.
///
/// Lets you mirror content by specifying a negative scale on a single axis.
@@ -125,7 +103,7 @@ impl Show for Packed<RotateElem> {
/// #scale(x: -100%)[This is mirrored.]
/// #scale(x: -100%, reflow: true)[This is mirrored.]
/// ```
-#[elem(Show)]
+#[elem]
pub struct ScaleElem {
/// The scaling factor for both axes, as a positional argument. This is just
/// an optional shorthand notation for setting `x` and `y` to the same
@@ -179,14 +157,6 @@ pub struct ScaleElem {
pub body: Content,
}
-impl Show for Packed<ScaleElem> {
- fn show(&self, engine: &mut Engine, _: StyleChain) -> SourceResult<Content> {
- Ok(BlockElem::single_layouter(self.clone(), engine.routines.layout_scale)
- .pack()
- .spanned(self.span()))
- }
-}
-
/// To what size something shall be scaled.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum ScaleAmount {
@@ -215,7 +185,7 @@ cast! {
/// This is some fake italic text.
/// ]
/// ```
-#[elem(Show)]
+#[elem]
pub struct SkewElem {
/// The horizontal skewing angle.
///
@@ -265,14 +235,6 @@ pub struct SkewElem {
pub body: Content,
}
-impl Show for Packed<SkewElem> {
- fn show(&self, engine: &mut Engine, _: StyleChain) -> SourceResult<Content> {
- Ok(BlockElem::single_layouter(self.clone(), engine.routines.layout_skew)
- .pack()
- .spanned(self.span()))
- }
-}
-
/// A scale-skew-translate transformation.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub struct Transform {