summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/layout/grid
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/grid
parent0a3c6939dd274f40672484695d909c2cc0d0d755 (diff)
Target-specific native show rules (#6569)
Diffstat (limited to 'crates/typst-library/src/layout/grid')
-rw-r--r--crates/typst-library/src/layout/grid/mod.rs44
1 files changed, 4 insertions, 40 deletions
diff --git a/crates/typst-library/src/layout/grid/mod.rs b/crates/typst-library/src/layout/grid/mod.rs
index 64e7464b..658523ec 100644
--- a/crates/typst-library/src/layout/grid/mod.rs
+++ b/crates/typst-library/src/layout/grid/mod.rs
@@ -11,10 +11,10 @@ use crate::diag::{bail, At, HintedStrResult, HintedString, SourceResult};
use crate::engine::Engine;
use crate::foundations::{
cast, elem, scope, Array, CastInfo, Content, Context, Fold, FromValue, Func,
- IntoValue, NativeElement, Packed, Reflect, Resolve, Show, Smart, StyleChain, Value,
+ IntoValue, Packed, Reflect, Resolve, Smart, StyleChain, Value,
};
use crate::layout::{
- Alignment, BlockElem, Length, OuterHAlignment, OuterVAlignment, Rel, Sides, Sizing,
+ Alignment, Length, OuterHAlignment, OuterVAlignment, Rel, Sides, Sizing,
};
use crate::model::{TableCell, TableFooter, TableHLine, TableHeader, TableVLine};
use crate::visualize::{Paint, Stroke};
@@ -136,7 +136,7 @@ use crate::visualize::{Paint, Stroke};
///
/// Furthermore, strokes of a repeated grid header or footer will take
/// precedence over regular cell strokes.
-#[elem(scope, Show)]
+#[elem(scope)]
pub struct GridElem {
/// The column sizes.
///
@@ -320,14 +320,6 @@ impl GridElem {
type GridFooter;
}
-impl Show for Packed<GridElem> {
- fn show(&self, engine: &mut Engine, _: StyleChain) -> SourceResult<Content> {
- Ok(BlockElem::multi_layouter(self.clone(), engine.routines.layout_grid)
- .pack()
- .spanned(self.span()))
- }
-}
-
/// Track sizing definitions.
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash)]
pub struct TrackSizings(pub SmallVec<[Sizing; 4]>);
@@ -648,7 +640,7 @@ pub struct GridVLine {
/// which allows you, for example, to apply styles based on a cell's position.
/// Refer to the examples of the [`table.cell`]($table.cell) element to learn
/// more about this.
-#[elem(name = "cell", title = "Grid Cell", Show)]
+#[elem(name = "cell", title = "Grid Cell")]
pub struct GridCell {
/// The cell's body.
#[required]
@@ -748,12 +740,6 @@ cast! {
v: Content => v.into(),
}
-impl Show for Packed<GridCell> {
- fn show(&self, _engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- show_grid_cell(self.body.clone(), self.inset.get(styles), self.align.get(styles))
- }
-}
-
impl Default for Packed<GridCell> {
fn default() -> Self {
Packed::new(
@@ -774,28 +760,6 @@ impl From<Content> for GridCell {
}
}
-/// Function with common code to display a grid cell or table cell.
-pub(crate) fn show_grid_cell(
- mut body: Content,
- inset: Smart<Sides<Option<Rel<Length>>>>,
- align: Smart<Alignment>,
-) -> SourceResult<Content> {
- let inset = inset.unwrap_or_default().map(Option::unwrap_or_default);
-
- if inset != Sides::default() {
- // Only pad if some inset is not 0pt.
- // Avoids a bug where using .padded() in any way inside Show causes
- // alignment in align(...) to break.
- body = body.padded(inset);
- }
-
- if let Smart::Custom(alignment) = align {
- body = body.aligned(alignment);
- }
-
- Ok(body)
-}
-
/// A value that can be configured per cell.
#[derive(Debug, Clone, PartialEq, Hash)]
pub enum Celled<T> {