summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/math/underover.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-09-11 14:40:22 +0200
committerLaurenz <laurmaedje@gmail.com>2023-09-11 14:40:22 +0200
commitb471ac7d590abd2398ce25193b4e4df373bf2e9c (patch)
treeb5f7a6fdc807ee3340a4f42b0ad3cc563fe45429 /crates/typst-library/src/math/underover.rs
parent8f36fca68447a5d42a3d54b5fac7e5546ee244be (diff)
First-class types
Makes types first-class values.
Diffstat (limited to 'crates/typst-library/src/math/underover.rs')
-rw-r--r--crates/typst-library/src/math/underover.rs44
1 files changed, 10 insertions, 34 deletions
diff --git a/crates/typst-library/src/math/underover.rs b/crates/typst-library/src/math/underover.rs
index 796c9ebc..3e8dba1a 100644
--- a/crates/typst-library/src/math/underover.rs
+++ b/crates/typst-library/src/math/underover.rs
@@ -11,14 +11,10 @@ enum LineKind {
/// A horizontal line under content.
///
-/// ## Example { #example }
/// ```example
/// $ underline(1 + 2 + ... + 5) $
/// ```
-///
-/// Display: Underline
-/// Category: math
-#[element(LayoutMath)]
+#[elem(LayoutMath)]
pub struct UnderlineElem {
/// The content above the line.
#[required]
@@ -34,14 +30,10 @@ impl LayoutMath for UnderlineElem {
/// A horizontal line over content.
///
-/// ## Example { #example }
/// ```example
/// $ overline(1 + 2 + ... + 5) $
/// ```
-///
-/// Display: Overline
-/// Category: math
-#[element(LayoutMath)]
+#[elem(LayoutMath)]
pub struct OverlineElem {
/// The content below the line.
#[required]
@@ -103,10 +95,10 @@ fn layout_underoverline(
frame.push(
line_pos,
FrameItem::Shape(
- Geometry::Line(Point::with_x(width)).stroked(Stroke {
+ Geometry::Line(Point::with_x(width)).stroked(FixedStroke {
paint: TextElem::fill_in(ctx.styles()),
thickness: bar_height,
- ..Stroke::default()
+ ..FixedStroke::default()
}),
span,
),
@@ -119,14 +111,10 @@ fn layout_underoverline(
/// A horizontal brace under content, with an optional annotation below.
///
-/// ## Example { #example }
/// ```example
/// $ underbrace(1 + 2 + ... + 5, "numbers") $
/// ```
-///
-/// Display: Underbrace
-/// Category: math
-#[element(LayoutMath)]
+#[elem(LayoutMath)]
pub struct UnderbraceElem {
/// The content above the brace.
#[required]
@@ -154,14 +142,10 @@ impl LayoutMath for UnderbraceElem {
/// A horizontal brace over content, with an optional annotation above.
///
-/// ## Example { #example }
/// ```example
/// $ overbrace(1 + 2 + ... + 5, "numbers") $
/// ```
-///
-/// Display: Overbrace
-/// Category: math
-#[element(LayoutMath)]
+#[elem(LayoutMath)]
pub struct OverbraceElem {
/// The content below the brace.
#[required]
@@ -189,14 +173,10 @@ impl LayoutMath for OverbraceElem {
/// A horizontal bracket under content, with an optional annotation below.
///
-/// ## Example { #example }
/// ```example
/// $ underbracket(1 + 2 + ... + 5, "numbers") $
/// ```
-///
-/// Display: Underbracket
-/// Category: math
-#[element(LayoutMath)]
+#[elem(LayoutMath)]
pub struct UnderbracketElem {
/// The content above the bracket.
#[required]
@@ -224,14 +204,10 @@ impl LayoutMath for UnderbracketElem {
/// A horizontal bracket over content, with an optional annotation above.
///
-/// ## Example { #example }
/// ```example
/// $ overbracket(1 + 2 + ... + 5, "numbers") $
/// ```
-///
-/// Display: Overbracket
-/// Category: math
-#[element(LayoutMath)]
+#[elem(LayoutMath)]
pub struct OverbracketElem {
/// The content below the bracket.
#[required]
@@ -294,7 +270,7 @@ fn layout_underoverspreader(
baseline = rows.len() - 1;
}
- let frame = stack(ctx, rows, Align::Center, gap, baseline);
+ let frame = stack(ctx, rows, FixedAlign::Center, gap, baseline);
ctx.push(FrameFragment::new(ctx, frame).with_class(body_class));
Ok(())
@@ -307,7 +283,7 @@ fn layout_underoverspreader(
pub(super) fn stack(
ctx: &MathContext,
rows: Vec<MathRow>,
- align: Align,
+ align: FixedAlign,
gap: Abs,
baseline: usize,
) -> Frame {