diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-28 15:50:48 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-28 23:54:34 +0100 |
| commit | 3ca5b238238e1128aa7bbfbd5db9e632045d8600 (patch) | |
| tree | 2471f4b340a15695b7f4d518c0b39fabaea676c4 /src/library/deco.rs | |
| parent | b63c21c91d99a1554a019dc275f955d3e6a34271 (diff) | |
Reorganize library
Diffstat (limited to 'src/library/deco.rs')
| -rw-r--r-- | src/library/deco.rs | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/library/deco.rs b/src/library/deco.rs deleted file mode 100644 index 8c2b5a9a..00000000 --- a/src/library/deco.rs +++ /dev/null @@ -1,74 +0,0 @@ -//! Text decorations. - -use super::prelude::*; -use super::TextNode; - -/// Typeset underline, striken-through or overlined text. -#[derive(Debug, Hash)] -pub struct DecoNode<const L: DecoLine>(pub Template); - -#[class] -impl<const L: DecoLine> DecoNode<L> { - /// Stroke color of the line, defaults to the text color if `None`. - #[shorthand] - pub const STROKE: Option<Paint> = None; - /// Thickness of the line's strokes (dependent on scaled font size), read - /// from the font tables if `None`. - #[shorthand] - pub const THICKNESS: Option<Linear> = None; - /// Position of the line relative to the baseline (dependent on scaled font - /// size), read from the font tables if `None`. - pub const OFFSET: Option<Linear> = None; - /// Amount that the line will be longer or shorter than its associated text - /// (dependent on scaled font size). - pub const EXTENT: Linear = Linear::zero(); - /// Whether the line skips sections in which it would collide - /// with the glyphs. Does not apply to strikethrough. - pub const EVADE: bool = true; - - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::show(Self(args.expect::<Template>("body")?))) - } -} - -impl<const L: DecoLine> Show for DecoNode<L> { - fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Template> { - Ok(styles - .show(self, ctx, [Value::Template(self.0.clone())])? - .unwrap_or_else(|| { - self.0.clone().styled(TextNode::LINES, vec![Decoration { - line: L, - stroke: styles.get(Self::STROKE), - thickness: styles.get(Self::THICKNESS), - offset: styles.get(Self::OFFSET), - extent: styles.get(Self::EXTENT), - evade: styles.get(Self::EVADE), - }]) - })) - } -} - -/// Defines a line that is positioned over, under or on top of text. -/// -/// For more details, see [`DecoNode`]. -#[derive(Debug, Clone, Eq, PartialEq, Hash)] -pub struct Decoration { - pub line: DecoLine, - pub stroke: Option<Paint>, - pub thickness: Option<Linear>, - pub offset: Option<Linear>, - pub extent: Linear, - pub evade: bool, -} - -/// A kind of decorative line. -pub type DecoLine = usize; - -/// A line under text. -pub const UNDERLINE: DecoLine = 0; - -/// A line through text. -pub const STRIKETHROUGH: DecoLine = 1; - -/// A line over text. -pub const OVERLINE: DecoLine = 2; |
