Hello,

I made a patch that adds a postscript dotted line in tocItemMarkup.
What do you think about it ? Can this be "officially" added to LilyPond ?

Regards,
Bertrand
From a678dfdd7c329482a42f405df4a3238fa7195e32 Mon Sep 17 00:00:00 2001
From: Bertrand Bordage <bordage.bertr...@gmail.com>
Date: Mon, 14 Feb 2011 11:22:05 +0100
Subject: [PATCH] Adding dots to tocItemMarkup

- New markup command fill-with-dots
- Add it to tocItemMarkup
---
 ly/toc-init.ly                 |    4 +---
 scm/define-markup-commands.scm |   20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ly/toc-init.ly b/ly/toc-init.ly
index dda4f31..1f07fb6 100644
--- a/ly/toc-init.ly
+++ b/ly/toc-init.ly
@@ -26,9 +26,7 @@
     \fill-line { \null "Table of Contents" \null }
     \hspace #1
   }
-  tocItemMarkup = \markup \fill-line {
-    \fromproperty #'toc:text \fromproperty #'toc:page
-  }
+  tocItemMarkup = \markup \fill-with-dots \fromproperty #'toc:text \fromproperty #'toc:page
 }
 
 #(define-markup-list-command (table-of-contents layout props) ()
diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm
index 5dbc5d2..9ef539f 100644
--- a/scm/define-markup-commands.scm
+++ b/scm/define-markup-commands.scm
@@ -1340,6 +1340,26 @@ curly braces as an argument; the follow example will not compile:
 	 (s2 (interpret-markup layout props arg2)))
     (ly:stencil-add s1 s2)))
 
+#(define-markup-command (fill-with-dots layout props left right)
+  (markup? markup?)
+  #:category align
+  "
+@cindex filling line with dots
+Fill-line between markups @code{left} and @code{right} with a postscript dotted line
+@lilypond[verbatim, quote]
+\\markup {
+  \\fill-with-dots left right
+}
+@end lilypond"
+  (let* ((left-length (cdr (ly:stencil-extent (interpret-markup layout props left) X)))
+         (right-length (cdr (ly:stencil-extent (interpret-markup layout props right) X)))
+         (middle-length (- (ly:output-def-lookup layout 'line-width) (+ left-length right-length)))
+         (offset (- middle-length (* (truncate (/ middle-length 1.5)) 1.5))))
+    (interpret-markup layout props
+                      (markup left
+                              #:with-dimensions (cons 0 middle-length) '(0 . 0) #:postscript (string-append "0.25 setlinewidth 1 setlinecap [0 1.5] 0 setdash " (number->string offset) " 0.12 moveto " (number->string middle-length) " 0 rlineto stroke")
+                              right))))
+
 ;;
 ;; TODO: should extract baseline-skip from each argument somehow..
 ;;
-- 
1.7.1

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

Reply via email to