From: Bertrand Bordage Date: Thu, 24 Feb 2011 22:50:18 +0000 (+0100) Subject: New markup command : pattern X-Git-Tag: release/2.13.52-1~3^2~7 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6255791221fd8197a23d3299fdad85a3a79336ab;p=lilypond.git New markup command : pattern Issue 1517 * scm/define-markup-commands.scm New markup commands : pattern fill-with-pattern * ly/toc-init.ly Create tocItemWithDotsMarkup * Documentation/changes.tely * Documentation/notation/input.itely How to use tocItemWithDotsMarkup --- diff --git a/Documentation/changes.tely b/Documentation/changes.tely index 002f6a89cf..d6700d995a 100644 --- a/Documentation/changes.tely +++ b/Documentation/changes.tely @@ -61,6 +61,25 @@ which scares away people. @end ignore +@item +Dots can be added to the table of contents items using: +@example +\paper @{ + tocItemMarkup = \tocItemWithDotsMarkup +@} +@end example + +@item +New markup commands @code{\pattern} and @code{\fill-with-pattern} are available. +@lilypond +\markup \column { + \pattern #3 #Y #0.3 \flat + \null + \pattern #7 #X #2 \flat + \override #'(line-width . 40) \fill-with-pattern #1 #CENTER . left right +} +@end lilypond + @item A minimal composer toolkit of modal transformations is provided. A motif may be @notation{transposed}, @notation{inverted} and/or diff --git a/Documentation/notation/input.itely b/Documentation/notation/input.itely index 50f61545fe..a7b36aac63 100644 --- a/Documentation/notation/input.itely +++ b/Documentation/notation/input.itely @@ -957,6 +957,22 @@ tocAct = } @end lilypond +Dots can be added to fill the line between an item and its page number: + +@lilypond[verbatim,quote] +\header { tagline = ##f } +\paper { + tocItemMarkup = \tocItemWithDotsMarkup +} + +\book { + \markuplines \table-of-contents + \tocItem \markup { Allegro } + \tocItem \markup { Largo } + \markup \null +} +@end lilypond + @seealso Init files: @file{../ly/toc-init.ly}. diff --git a/ly/toc-init.ly b/ly/toc-init.ly index dda4f31ab4..488e22ba2a 100644 --- a/ly/toc-init.ly +++ b/ly/toc-init.ly @@ -31,6 +31,9 @@ } } +tocItemWithDotsMarkup = \markup \fill-with-pattern #1 #RIGHT . + \fromproperty #'toc:text \fromproperty #'toc:page + #(define-markup-list-command (table-of-contents layout props) () ( _i "Outputs the table of contents, using the paper variable @code{tocTitleMarkup} for its title, then the list of lines diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 5dbc5d2f52..3e7c69429c 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -3396,6 +3396,83 @@ Negative values may be used to produce mirror images. (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 (- 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;