summaryrefslogtreecommitdiff
path: root/src/library/structure
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/structure')
-rw-r--r--src/library/structure/heading.rs14
-rw-r--r--src/library/structure/list.rs24
-rw-r--r--src/library/structure/table.rs5
3 files changed, 24 insertions, 19 deletions
diff --git a/src/library/structure/heading.rs b/src/library/structure/heading.rs
index 8b143865..dcf87f90 100644
--- a/src/library/structure/heading.rs
+++ b/src/library/structure/heading.rs
@@ -1,5 +1,5 @@
use crate::library::prelude::*;
-use crate::library::text::{FontFamily, FontSize, TextNode, Toggle};
+use crate::library::text::{FontFamily, TextNode, TextSize, Toggle};
/// A section heading.
#[derive(Debug, Hash)]
@@ -21,9 +21,9 @@ impl HeadingNode {
pub const FILL: Leveled<Smart<Paint>> = Leveled::Value(Smart::Auto);
/// The size of text in the heading.
#[property(referenced)]
- pub const SIZE: Leveled<FontSize> = Leveled::Mapping(|level| {
+ pub const SIZE: Leveled<TextSize> = Leveled::Mapping(|level| {
let upscale = (1.6 - 0.1 * level as f64).max(0.75);
- FontSize(Ratio::new(upscale).into())
+ TextSize(Em::new(upscale).into())
});
/// Whether text in the heading is strengthend.
#[property(referenced)]
@@ -36,10 +36,10 @@ impl HeadingNode {
pub const UNDERLINE: Leveled<bool> = Leveled::Value(false);
/// The extra padding above the heading.
#[property(referenced)]
- pub const ABOVE: Leveled<Length> = Leveled::Value(Length::zero());
+ pub const ABOVE: Leveled<RawLength> = Leveled::Value(Length::zero().into());
/// The extra padding below the heading.
#[property(referenced)]
- pub const BELOW: Leveled<Length> = Leveled::Value(Length::zero());
+ pub const BELOW: Leveled<RawLength> = Leveled::Value(Length::zero().into());
/// Whether the heading is block-level.
#[property(referenced)]
pub const BLOCK: Leveled<bool> = Leveled::Value(true);
@@ -95,14 +95,14 @@ impl Show for HeadingNode {
let above = resolve!(Self::ABOVE);
if !above.is_zero() {
- seq.push(Content::Vertical(above.into()));
+ seq.push(Content::Vertical(above.resolve(styles).into()));
}
seq.push(body);
let below = resolve!(Self::BELOW);
if !below.is_zero() {
- seq.push(Content::Vertical(below.into()));
+ seq.push(Content::Vertical(below.resolve(styles).into()));
}
let mut content = Content::sequence(seq).styled_with_map(map);
diff --git a/src/library/structure/list.rs b/src/library/structure/list.rs
index c58e8648..c3eae1af 100644
--- a/src/library/structure/list.rs
+++ b/src/library/structure/list.rs
@@ -1,6 +1,6 @@
use crate::library::layout::{GridNode, TrackSizing};
use crate::library::prelude::*;
-use crate::library::text::{ParNode, TextNode};
+use crate::library::text::ParNode;
use crate::library::utility::Numbering;
use crate::parse::Scanner;
@@ -34,15 +34,20 @@ impl<const L: ListKind> ListNode<L> {
#[property(referenced)]
pub const LABEL: Label = Label::Default;
/// The spacing between the list items of a non-wide list.
- pub const SPACING: Relative<Length> = Relative::zero();
+ #[property(resolve)]
+ pub const SPACING: RawLength = RawLength::zero();
/// The indentation of each item's label.
- pub const INDENT: Relative<Length> = Ratio::new(0.0).into();
+ #[property(resolve)]
+ pub const INDENT: RawLength = RawLength::zero();
/// The space between the label and the body of each item.
- pub const BODY_INDENT: Relative<Length> = Ratio::new(0.5).into();
+ #[property(resolve)]
+ pub const BODY_INDENT: RawLength = Em::new(0.5).into();
/// The extra padding above the list.
- pub const ABOVE: Length = Length::zero();
+ #[property(resolve)]
+ pub const ABOVE: RawLength = RawLength::zero();
/// The extra padding below the list.
- pub const BELOW: Length = Length::zero();
+ #[property(resolve)]
+ pub const BELOW: RawLength = RawLength::zero();
fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> {
Ok(Content::show(Self {
@@ -77,7 +82,6 @@ impl<const L: ListKind> Show for ListNode<L> {
number += 1;
}
- let em = styles.get(TextNode::SIZE);
let leading = styles.get(ParNode::LEADING);
let spacing = if self.wide {
styles.get(ParNode::SPACING)
@@ -85,9 +89,9 @@ impl<const L: ListKind> Show for ListNode<L> {
styles.get(Self::SPACING)
};
- let gutter = (leading + spacing).resolve(em);
- let indent = styles.get(Self::INDENT).resolve(em);
- let body_indent = styles.get(Self::BODY_INDENT).resolve(em);
+ let gutter = leading + spacing;
+ let indent = styles.get(Self::INDENT);
+ let body_indent = styles.get(Self::BODY_INDENT);
Content::block(GridNode {
tracks: Spec::with_x(vec![
diff --git a/src/library/structure/table.rs b/src/library/structure/table.rs
index e01ae908..d0ab0716 100644
--- a/src/library/structure/table.rs
+++ b/src/library/structure/table.rs
@@ -21,9 +21,10 @@ impl TableNode {
/// How to stroke the cells.
pub const STROKE: Option<Paint> = Some(Color::BLACK.into());
/// The stroke's thickness.
- pub const THICKNESS: Length = Length::pt(1.0);
+ #[property(resolve)]
+ pub const THICKNESS: RawLength = Length::pt(1.0).into();
/// How much to pad the cells's content.
- pub const PADDING: Relative<Length> = Length::pt(5.0).into();
+ pub const PADDING: Relative<RawLength> = Length::pt(5.0).into();
fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> {
let columns = args.named("columns")?.unwrap_or_default();