Hi,

Thanks for your watchfulness ! (Can we say this? I'm pretty bad at
English...)
I added Graham and Neil's changes.

Regards,
Bertrand

(Git patch attached with the commit's informations)
From fe20aad02a7c4a6ace4a9c31670b5f4c7dbe87ba Mon Sep 17 00:00:00 2001
From: Bertrand Bordage <bordage.bertr...@gmail.com>
Date: Thu, 24 Feb 2011 23:50:18 +0100
Subject: [PATCH] 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
---
 Documentation/changes.tely         |   19 +++++++++
 Documentation/notation/input.itely |   16 +++++++
 ly/toc-init.ly                     |    3 +
 scm/define-markup-commands.scm     |   77 ++++++++++++++++++++++++++++++++++++
 4 files changed, 115 insertions(+), 0 deletions(-)

diff --git a/Documentation/changes.tely b/Documentation/changes.tely
index 002f6a8..d6700d9 100644
--- a/Documentation/changes.tely
+++ b/Documentation/changes.tely
@@ -62,6 +62,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
 converted to its @notation{retrograde} within any scale.
diff --git a/Documentation/notation/input.itely b/Documentation/notation/input.itely
index 50f6154..a7b36aa 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 dda4f31..488e22b 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 5dbc5d2..3e7c694 100644
--- a/scm/define-markup-commands.scm
+++ b/scm/define-markup-commands.scm
@@ -3397,6 +3397,83 @@ Negative values may be used to produce mirror images.
     (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
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-- 
1.7.1

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to