forked from HEL/chronos
merged with-ctx-style and get-ctx
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
#import "/src/cetz.typ": draw, styles
|
#import "/src/cetz.typ": draw, styles
|
||||||
|
|
||||||
#import "/src/consts.typ": *
|
#import "/src/consts.typ": *
|
||||||
#import "/src/core/utils.typ": normalize-units, set-y, with-ctx-style
|
#import "/src/core/utils.typ": get-ctx, normalize-units, set-y
|
||||||
|
|
||||||
#let separator-default-style = (
|
#let separator-default-style = (
|
||||||
inset: (
|
inset: (
|
||||||
@ -13,9 +13,9 @@
|
|||||||
outset: 20pt
|
outset: 20pt
|
||||||
)
|
)
|
||||||
|
|
||||||
#let render(sep) = with-ctx-style((ctx, glob-style) => {
|
#let render(sep) = get-ctx(ctx => {
|
||||||
let style = styles.resolve(
|
let style = styles.resolve(
|
||||||
glob-style,
|
ctx.style,
|
||||||
merge: sep.style,
|
merge: sep.style,
|
||||||
root: "separator",
|
root: "separator",
|
||||||
base: separator-default-style
|
base: separator-default-style
|
||||||
@ -23,7 +23,7 @@
|
|||||||
let gap = normalize-units(style.gap)
|
let gap = normalize-units(style.gap)
|
||||||
let outset = normalize-units(style.outset)
|
let outset = normalize-units(style.outset)
|
||||||
|
|
||||||
ctx.y -= glob-style.y-space
|
ctx.y -= ctx.style.y-space
|
||||||
|
|
||||||
let x0 = ctx.x-pos.first() - outset
|
let x0 = ctx.x-pos.first() - outset
|
||||||
let x1 = ctx.x-pos.last() + outset
|
let x1 = ctx.x-pos.last() + outset
|
||||||
|
@ -112,6 +112,13 @@
|
|||||||
|
|
||||||
#let get-ctx(func) = draw.get-ctx(c => {
|
#let get-ctx(func) = draw.get-ctx(c => {
|
||||||
let ctx = extract-ctx(c)
|
let ctx = extract-ctx(c)
|
||||||
|
ctx.style = styles.resolve(
|
||||||
|
c.style,
|
||||||
|
root: "chronos",
|
||||||
|
base: default-style
|
||||||
|
)
|
||||||
|
// Normalize because it is used very frequently
|
||||||
|
ctx.style.y-space = normalize-units(ctx.style.y-space)
|
||||||
func(ctx)
|
func(ctx)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -129,17 +136,3 @@
|
|||||||
}
|
}
|
||||||
return ctx
|
return ctx
|
||||||
})
|
})
|
||||||
|
|
||||||
#let with-ctx-style(func) = draw.get-ctx(cetz-ctx => {
|
|
||||||
let ctx = extract-ctx(cetz-ctx)
|
|
||||||
let glob-style = styles.resolve(
|
|
||||||
cetz-ctx.style,
|
|
||||||
root: "chronos",
|
|
||||||
base: default-style
|
|
||||||
)
|
|
||||||
|
|
||||||
// Normalize because it is used very frequently
|
|
||||||
glob-style.y-space = normalize-units(glob-style.y-space)
|
|
||||||
|
|
||||||
func(ctx, glob-style)
|
|
||||||
})
|
|
Reference in New Issue
Block a user