summaryrefslogtreecommitdiff
path: root/library/src/meta
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-08 13:02:41 +0100
committerLaurenz <laurmaedje@gmail.com>2023-03-08 14:35:33 +0100
commitd7a65fa26d131179d9d82226e5ee1b562084e48a (patch)
treec21ab20e9fb851e14e1ebea3e14fc351b1fdbcc9 /library/src/meta
parente5eab73374880077971f3f22acbdd3d302877128 (diff)
Rework style chain access
Diffstat (limited to 'library/src/meta')
-rw-r--r--library/src/meta/document.rs4
-rw-r--r--library/src/meta/heading.rs16
-rw-r--r--library/src/meta/link.rs4
-rw-r--r--library/src/meta/outline.rs14
4 files changed, 19 insertions, 19 deletions
diff --git a/library/src/meta/document.rs b/library/src/meta/document.rs
index 29ed38fe..1325d85b 100644
--- a/library/src/meta/document.rs
+++ b/library/src/meta/document.rs
@@ -58,8 +58,8 @@ impl LayoutRoot for DocumentNode {
Ok(Document {
pages,
- title: styles.get(Self::TITLE).clone(),
- author: styles.get(Self::AUTHOR).0.clone(),
+ title: Self::title_in(styles),
+ author: Self::author_in(styles).0,
})
}
}
diff --git a/library/src/meta/heading.rs b/library/src/meta/heading.rs
index bd95001b..f0107a6a 100644
--- a/library/src/meta/heading.rs
+++ b/library/src/meta/heading.rs
@@ -106,15 +106,15 @@ impl Prepare for HeadingNode {
}
let mut numbers = Value::None;
- if let Some(numbering) = styles.get(Self::NUMBERING) {
+ if let Some(numbering) = Self::numbering_in(styles) {
numbers = numbering.apply(vt.world(), counter.advance(self))?;
}
- this.push_field("outlined", Value::Bool(styles.get(Self::OUTLINED)));
+ this.push_field("outlined", Value::Bool(Self::outlined_in(styles)));
this.push_field("numbers", numbers);
let meta = Meta::Node(my_id, this.clone());
- Ok(this.styled(MetaNode::DATA, vec![meta]))
+ Ok(this.styled(MetaNode::set_data(vec![meta])))
}
}
@@ -145,11 +145,11 @@ impl Finalize for HeadingNode {
let below = Em::new(0.75) / scale;
let mut map = StyleMap::new();
- map.set(TextNode::SIZE, TextSize(size.into()));
- map.set(TextNode::WEIGHT, FontWeight::BOLD);
- map.set(BlockNode::ABOVE, VNode::block_around(above.into()));
- map.set(BlockNode::BELOW, VNode::block_around(below.into()));
- map.set(BlockNode::STICKY, true);
+ map.set(TextNode::set_size(TextSize(size.into())));
+ map.set(TextNode::set_weight(FontWeight::BOLD));
+ map.set(BlockNode::set_above(VNode::block_around(above.into())));
+ map.set(BlockNode::set_below(VNode::block_around(below.into())));
+ map.set(BlockNode::set_sticky(true));
realized.styled_with_map(map)
}
}
diff --git a/library/src/meta/link.rs b/library/src/meta/link.rs
index 4f07aaee..32b70153 100644
--- a/library/src/meta/link.rs
+++ b/library/src/meta/link.rs
@@ -91,8 +91,8 @@ impl Show for LinkNode {
impl Finalize for LinkNode {
fn finalize(&self, realized: Content) -> Content {
realized
- .styled(MetaNode::DATA, vec![Meta::Link(self.dest())])
- .styled(TextNode::HYPHENATE, Hyphenate(Smart::Custom(false)))
+ .styled(MetaNode::set_data(vec![Meta::Link(self.dest())]))
+ .styled(TextNode::set_hyphenate(Hyphenate(Smart::Custom(false))))
}
}
diff --git a/library/src/meta/outline.rs b/library/src/meta/outline.rs
index 4b5a44f7..3ccc991e 100644
--- a/library/src/meta/outline.rs
+++ b/library/src/meta/outline.rs
@@ -102,9 +102,9 @@ impl Show for OutlineNode {
styles: StyleChain,
) -> SourceResult<Content> {
let mut seq = vec![ParbreakNode::new().pack()];
- if let Some(title) = styles.get(Self::TITLE) {
+ if let Some(title) = Self::title_in(styles) {
let title = title.clone().unwrap_or_else(|| {
- TextNode::packed(match styles.get(TextNode::LANG) {
+ TextNode::packed(match TextNode::lang_in(styles) {
Lang::GERMAN => "Inhaltsverzeichnis",
Lang::ENGLISH | _ => "Contents",
})
@@ -113,13 +113,13 @@ impl Show for OutlineNode {
seq.push(
HeadingNode::new(title)
.pack()
- .styled(HeadingNode::NUMBERING, None)
- .styled(HeadingNode::OUTLINED, false),
+ .styled(HeadingNode::set_numbering(None))
+ .styled(HeadingNode::set_outlined(false)),
);
}
- let indent = styles.get(Self::INDENT);
- let depth = styles.get(Self::DEPTH);
+ let indent = Self::indent_in(styles);
+ let depth = Self::depth_in(styles);
let mut ancestors: Vec<&Content> = vec![];
for (_, node) in vt.locate(Selector::node::<HeadingNode>()) {
@@ -171,7 +171,7 @@ impl Show for OutlineNode {
seq.push(start.linked(Destination::Internal(loc)));
// Add filler symbols between the section name and page number.
- if let Some(filler) = styles.get(Self::FILL) {
+ if let Some(filler) = Self::fill_in(styles) {
seq.push(SpaceNode::new().pack());
seq.push(
BoxNode::new()