;;;; This file is part of LilyPond, the GNU music typesetter.
;;;;
-;;;; Copyright (C) 2000--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;; Copyright (C) 2000--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
;;;; Jan Nieuwenhuizen <janneke@gnu.org>
;;;;
;;;; LilyPond is free software: you can redistribute it and/or modify
(y (cdr dest)))
(make-line-stencil th 0 0 x y)))
+(define-markup-command (draw-hline layout props)
+ ()
+ #:category graphic
+ #:properties ((draw-line-markup)
+ (line-width)
+ (span-factor 1))
+ "
+@cindex drawing a line across a page
+
+Draws a line across a page, where the property @code{span-factor}
+controls what fraction of the page is taken up.
+@lilypond[verbatim,quote]
+\\markup {
+ \\column {
+ \\draw-hline
+ \\override #'(span-factor . 1/3)
+ \\draw-hline
+ }
+}
+@end lilypond"
+ (interpret-markup layout
+ props
+ (markup #:draw-line (cons (* line-width
+ span-factor)
+ 0))))
+
(define-markup-command (draw-circle layout props radius thickness filled)
(number? number? boolean?)
#:category graphic
(ly:stencil-add (ly:make-stencil url-expr xextent yextent) stil)))
+(define-markup-command (page-link layout props page-number arg)
+ (number? markup?)
+ #:category other
+ "
+@cindex referencing page numbers in text
+
+Add a link to the page @var{page-number} around @var{arg}. This only works in
+the PDF backend.
+
+@lilypond[verbatim,quote]
+\\markup {
+ \\page-link #2 { \\italic { This links to page 2... } }
+}
+@end lilypond"
+ (let* ((stil (interpret-markup layout props arg))
+ (xextent (ly:stencil-extent stil X))
+ (yextent (ly:stencil-extent stil Y))
+ (old-expr (ly:stencil-expr stil))
+ (link-expr (list 'page-link page-number `(quote ,xextent) `(quote ,yextent))))
+
+ (ly:stencil-add (ly:make-stencil link-expr xextent yextent) stil)))
+
+(define-markup-command (with-link layout props label arg)
+ (symbol? markup?)
+ #:category other
+ "
+@cindex referencing page labels in text
+
+Add a link to the page holding label @var{label} around @var{arg}. This
+only works in the PDF backend.
+
+@lilypond[verbatim,quote]
+\\markup {
+ \\with-link #\"label\" { \\italic { This links to the page containing the label... } }
+}
+@end lilypond"
+ (let* ((arg-stencil (interpret-markup layout props arg))
+ (x-ext (ly:stencil-extent arg-stencil X))
+ (y-ext (ly:stencil-extent arg-stencil Y)))
+ (ly:make-stencil
+ `(delay-stencil-evaluation
+ ,(delay (ly:stencil-expr
+ (let* ((table (ly:output-def-lookup layout 'label-page-table))
+ (page-number (if (list? table)
+ (assoc-get label table)
+ #f))
+ (link-expr (list 'page-link page-number
+ `(quote ,x-ext) `(quote ,y-ext))))
+ (ly:stencil-add (ly:make-stencil link-expr x-ext y-ext)
+arg-stencil)))))
+ x-ext
+ y-ext)))
+
+
(define-markup-command (beam layout props width slope thickness)
(number? number? number?)
#:category graphic
(list markup?))
(interpret-markup layout props (list anonymous-with-signature arg))))
+(define-markup-command (footnote layout props mkup note)
+ (markup? markup?)
+ #:category other
+ "Have footnote @var{note} act as an annotation to the markup @var{mkup}."
+ (ly:stencil-combine-at-edge
+ (interpret-markup layout props mkup)
+ X
+ RIGHT
+ (ly:make-stencil
+ `(footnote ,(interpret-markup layout props note))
+ '(0 . 0)
+ '(0 . 0))
+ 0.0))
+
(define-markup-command (override layout props new-prop arg)
(pair? markup?)
#:category other
;; symbols.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(define-markup-command (musicglyph layout props glyph-name)
+ (string?)
+ #:category music
+ "@var{glyph-name} is converted to a musical symbol; for example,
+@code{\\musicglyph #\"accidentals.natural\"} selects the natural sign from
+the music font. See @ruser{The Feta font} for a complete listing of
+the possible glyphs.
+
+@lilypond[verbatim,quote]
+\\markup {
+ \\musicglyph #\"f\"
+ \\musicglyph #\"rests.2\"
+ \\musicglyph #\"clefs.G_change\"
+}
+@end lilypond"
+ (let* ((font (ly:paper-get-font layout
+ (cons '((font-encoding . fetaMusic)
+ (font-name . #f))
+
+ props)))
+ (glyph (ly:font-get-glyph font glyph-name)))
+ (if (null? (ly:stencil-expr glyph))
+ (ly:warning (_ "Cannot find glyph ~a") glyph-name))
+
+ glyph))
+
(define-markup-command (doublesharp layout props)
()
#:category music
props))
name)))
-(define-markup-command (musicglyph layout props glyph-name)
- (string?)
- #:category music
- "@var{glyph-name} is converted to a musical symbol; for example,
-@code{\\musicglyph #\"accidentals.natural\"} selects the natural sign from
-the music font. See @ruser{The Feta font} for a complete listing of
-the possible glyphs.
-
-@lilypond[verbatim,quote]
-\\markup {
- \\musicglyph #\"f\"
- \\musicglyph #\"rests.2\"
- \\musicglyph #\"clefs.G_change\"
-}
-@end lilypond"
- (let* ((font (ly:paper-get-font layout
- (cons '((font-encoding . fetaMusic)
- (font-name . #f))
-
- props)))
- (glyph (ly:font-get-glyph font glyph-name)))
- (if (null? (ly:stencil-expr glyph))
- (ly:warning (_ "Cannot find glyph ~a") glyph-name))
-
- glyph))
-
-
(define-markup-command (lookup layout props glyph-name)
(string?)
#:category other
(sy (cdr factor-pair)))
(ly:stencil-scale stil sx sy)))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Repeating
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define-markup-command (pattern layout props count axis space pattern)
+ (integer? integer? number? markup?)
+ #:category other
+ "
+Prints @var{count} times a @var{pattern} markup.
+Patterns are spaced apart by @var{space}.
+Patterns are distributed on @var{axis}.
+
+@lilypond[verbatim, quote]
+\\markup \\column {
+ \"Horizontally repeated :\"
+ \\pattern #7 #X #2 \\flat
+ \\null
+ \"Vertically repeated :\"
+ \\pattern #3 #Y #0.5 \\flat
+}
+@end lilypond"
+ (let ((pattern-width (interval-length
+ (ly:stencil-extent (interpret-markup layout props pattern) X)))
+ (new-props (prepend-alist-chain 'word-space 0 (prepend-alist-chain 'baseline-skip 0 props))))
+ (let loop ((i (1- count)) (patterns (markup)))
+ (if (zero? i)
+ (interpret-markup
+ layout
+ new-props
+ (if (= axis X)
+ (markup patterns pattern)
+ (markup #:column (patterns pattern))))
+ (loop (1- i)
+ (if (= axis X)
+ (markup patterns pattern #:hspace space)
+ (markup #:column (patterns pattern #:vspace space))))))))
+
+(define-markup-command (fill-with-pattern layout props space dir pattern left right)
+ (number? ly:dir? markup? markup? markup?)
+ #:category align
+ #:properties ((word-space)
+ (line-width))
+ "
+Put @var{left} and @var{right} in a horizontal line of width @code{line-width}
+with a line of markups @var{pattern} in between.
+Patterns are spaced apart by @var{space}.
+Patterns are aligned to the @var{dir} markup.
+
+@lilypond[verbatim, quote]
+\\markup \\column {
+ \"right-aligned :\"
+ \\fill-with-pattern #1 #RIGHT . first right
+ \\fill-with-pattern #1 #RIGHT . second right
+ \\null
+ \"center-aligned :\"
+ \\fill-with-pattern #1.5 #CENTER - left right
+ \\null
+ \"left-aligned :\"
+ \\override #'(line-width . 50) \\fill-with-pattern #2 #LEFT : left first
+ \\override #'(line-width . 50) \\fill-with-pattern #2 #LEFT : left second
+}
+@end lilypond"
+ (let* ((pattern-x-extent (ly:stencil-extent (interpret-markup layout props pattern) X))
+ (pattern-width (interval-length pattern-x-extent))
+ (left-width (interval-length (ly:stencil-extent (interpret-markup layout props left) X)))
+ (right-width (interval-length (ly:stencil-extent (interpret-markup layout props right) X)))
+ (middle-width (max 0 (- line-width (+ (+ left-width right-width) (* word-space 2)))))
+ (period (+ space pattern-width))
+ (count (truncate (/ (- middle-width pattern-width) period)))
+ (x-offset (+ (* (- (- middle-width (* count period)) pattern-width) (/ (1+ dir) 2)) (abs (car pattern-x-extent)))))
+ (interpret-markup layout props
+ (markup left
+ #:with-dimensions (cons 0 middle-width) '(0 . 0)
+ #:translate (cons x-offset 0)
+ #:pattern (1+ count) X space pattern
+ right))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Markup list commands
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;