]> git.donarmstrong.com Git - lilypond.git/commitdiff
New markup command : pattern
authorBertrand Bordage <bordage.bertrand@gmail.com>
Thu, 24 Feb 2011 22:50:18 +0000 (23:50 +0100)
committerGraham Percival <graham@percival-music.ca>
Tue, 1 Mar 2011 09:01:37 +0000 (09:01 +0000)
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

Documentation/changes.tely
Documentation/notation/input.itely
ly/toc-init.ly
scm/define-markup-commands.scm

index 002f6a89cf094a54f6707a1e4deea9468e588602..d6700d995af2adb4e7e8cda75eb12e3ad49c1475 100644 (file)
@@ -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
index 50f61545fef1bcdc93fd19099ab167cc348aa02a..a7b36aac63f9029e5c1bfdfead6bc7490dc9ea4e 100644 (file)
@@ -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}.
index dda4f31ab4d13250336decea7f2c3e57c87485e6..488e22ba2a6eb823a43f048dac5bdcfef344abec 100644 (file)
@@ -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
index 5dbc5d2f5254b61bd4e3bd4c42b4143807501812..3e7c69429c8be25c07fd736449305201c1492301 100644 (file)
@@ -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
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;