summaryrefslogtreecommitdiff
path: root/src/library/structure/table.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-23 21:55:58 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-23 21:55:58 +0200
commit04fb8b288aa7c80607da79db7d085a4820b95a9d (patch)
tree7ca96d09d511274ebac298c329d5eef53a290d9c /src/library/structure/table.rs
parent7a2cc3e7d29d16c5cf9b5a93a688e14da93c8662 (diff)
Show rules with type ascribed object
Diffstat (limited to 'src/library/structure/table.rs')
-rw-r--r--src/library/structure/table.rs31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/library/structure/table.rs b/src/library/structure/table.rs
index 96d3bd5b..aefd01b5 100644
--- a/src/library/structure/table.rs
+++ b/src/library/structure/table.rs
@@ -9,7 +9,7 @@ pub struct TableNode {
/// Defines sizing of gutter rows and columns between content.
pub gutter: Spec<Vec<TrackSizing>>,
/// The nodes to be arranged in the table.
- pub children: Vec<Content>,
+ pub cells: Vec<Content>,
}
#[node(showable)]
@@ -37,7 +37,7 @@ impl TableNode {
column_gutter.unwrap_or_else(|| base_gutter.clone()),
row_gutter.unwrap_or(base_gutter),
),
- children: args.all()?,
+ cells: args.all()?,
}))
}
@@ -53,9 +53,24 @@ impl TableNode {
}
impl Show for TableNode {
- fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> {
- let args = self.children.iter().map(|child| Value::Content(child.clone()));
- if let Some(content) = styles.show::<Self, _>(ctx, args)? {
+ fn encode(&self) -> Dict {
+ dict! {
+ "cells" => Value::Array(
+ self.cells
+ .iter()
+ .map(|cell| Value::Content(cell.clone()))
+ .collect()
+ ),
+ }
+ }
+
+ fn show(
+ &self,
+ _: &mut Context,
+ styles: StyleChain,
+ realized: Option<Content>,
+ ) -> TypResult<Content> {
+ if let Some(content) = realized {
return Ok(content);
}
@@ -65,8 +80,8 @@ impl Show for TableNode {
let padding = styles.get(Self::PADDING);
let cols = self.tracks.x.len().max(1);
- let children = self
- .children
+ let cells = self
+ .cells
.iter()
.cloned()
.enumerate()
@@ -90,7 +105,7 @@ impl Show for TableNode {
Ok(Content::block(GridNode {
tracks: self.tracks.clone(),
gutter: self.gutter.clone(),
- children,
+ cells,
}))
}
}