]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/output-lib.scm
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[lilypond.git] / scm / output-lib.scm
index 22e4377046c47ed3034bea7a7c52ebc9a055a2a3..db1181f740d87e27264992185eca317470ccdd84 100644 (file)
@@ -2,7 +2,7 @@
 ;;;;
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;; 
-;;;; (c) 1998--2007 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; (c) 1998--2009 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
 
 
   ))
 
 
-; default tunings for common string instruments
-(define-public guitar-tuning '(4 -1 -5 -10 -15 -20))
-(define-public guitar-open-g-tuning '(2 -1 -5 -10 -17 -22))
-(define-public bass-tuning '(-17 -22 -27 -32))
-(define-public mandolin-tuning '(16 9 2 -5))
-
-;; tunings for 5-string banjo
-(define-public banjo-open-g-tuning '(2 -1 -5 -10 7))
-(define-public banjo-c-tuning '(2 -1 -5 -12 7))
-(define-public banjo-modal-tuning '(2 0 -5 -10 7))
-(define-public banjo-open-d-tuning '(2 -3 -6 -10 9))
-(define-public banjo-open-dm-tuning '(2 -3 -6 -10 9))
-;; convert 5-string banjo tuning to 4-string by removing the 5th string
-(define-public (four-string-banjo tuning)
-  (reverse (cdr (reverse tuning))))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; note heads
 
@@ -202,6 +186,15 @@ centered, X==1 is at the right, X == -1 is at the left."
 
 (define-public (first-bar-number-invisible barnum) (> barnum 1))
 
+(define-public (all-bar-numbers-visible barnum) #t)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; percent repeat counters
+
+(define-public ((every-nth-repeat-count-visible n) count context) (= 0 (modulo count n)))
+
+(define-public (all-repeat-counts-visible count context) #t)
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; break visibility
 
@@ -243,6 +236,7 @@ centered, X==1 is at the right, X == -1 is at the left."
     ("" . ("" . ""))
     (":" . (":" . ""))
     ("." . ("." . ()))
+    ("'" . ("'" . ()))
     ("empty" . (() . ()))
     ("brace" . (() . "brace"))
     ("bracket" . (() . "bracket")) 
@@ -290,6 +284,53 @@ centered, X==1 is at the right, X == -1 is at the left."
            (ly:event-property ev 'denominator)
            (ly:event-property ev 'numerator))))
 
+
+; a formatter function, which is simply a wrapper around an existing 
+; tuplet formatter function. It takes the value returned by the given
+; function and appends a note of given length. 
+(define-public ((tuplet-number::append-note-wrapper function note) grob)
+  (let* ((txt (if function (function grob) #f)))
+    (if txt 
+      (markup txt #:fontsize -5 #:note note UP)
+      (markup #:fontsize -5 #:note note UP))))
+
+; Print a tuplet denominator with a different number than the one derived from 
+; the actual tuplet fraction
+(define-public ((tuplet-number::non-default-tuplet-denominator-text denominator) grob)
+(number->string (if denominator 
+                    denominator 
+                    (ly:event-property (event-cause grob) 'denominator))))
+
+; Print a tuplet fraction with different numbers than the ones derived from 
+; the actual tuplet fraction
+(define-public ((tuplet-number::non-default-tuplet-fraction-text denominator numerator) grob)
+  (let* ((ev (event-cause grob))
+         (den (if denominator denominator (ly:event-property ev 'denominator)))
+         (num (if numerator numerator (ly:event-property ev 'numerator))))
+     (format "~a:~a" den num)))
+
+; Print a tuplet fraction with note durations appended to the numerator and the 
+; denominator
+(define-public ((tuplet-number::fraction-with-notes denominatornote numeratornote) grob)
+  (let* ((ev (event-cause grob))
+         (denominator (ly:event-property ev 'denominator))
+         (numerator (ly:event-property ev 'numerator)))
+    ((tuplet-number::non-default-fraction-with-notes denominator denominatornote numerator numeratornote) grob)))
+
+; Print a tuplet fraction with note durations appended to the numerator and the 
+; denominator
+(define-public ((tuplet-number::non-default-fraction-with-notes denominator denominatornote numerator numeratornote) grob)
+  (let* ((ev (event-cause grob))
+         (den (if denominator denominator (ly:event-property ev 'denominator)))
+         (num (if numerator numerator (ly:event-property ev 'numerator))))
+     (make-concat-markup (list 
+          (make-simple-markup (format "~a" den)) 
+          (markup #:fontsize -5 #:note denominatornote UP)
+          (make-simple-markup " : ")
+          (make-simple-markup (format "~a" num)) 
+          (markup #:fontsize -5 #:note numeratornote UP)))))
+
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Color
 
@@ -530,6 +571,8 @@ centered, X==1 is at the right, X == -1 is at the left."
                                                                 left-span X)
                                        X))
        (common-y (ly:grob-common-refpoint spanner left-span Y))
+       (minimum-length (ly:grob-property spanner 'minimum-length 0.5))
+
        (left-x (+ padding
                  (max (interval-end (ly:grob-robust-relative-extent
                                      left-span common X))
@@ -540,9 +583,9 @@ centered, X==1 is at the right, X == -1 is at the left."
                            (interval-end (ly:grob-robust-relative-extent dots common X))
                            -10000) ;; TODO: use real infinity constant.
                        )))
-       (right-x (- (interval-start
-                   (ly:grob-robust-relative-extent right-span common X))
-                  padding))
+       (right-x (max (- (interval-start (ly:grob-robust-relative-extent right-span common X))
+                       padding)
+                    (+ left-x minimum-length)))
        (self-x (ly:grob-relative-coordinate spanner common X))
        (dx (- right-x left-x))
        (exp (list 'path thickness 
@@ -662,4 +705,21 @@ centered, X==1 is at the right, X == -1 is at the left."
 
 (define-public (script-interface::calc-x-offset grob)
   (ly:grob-property grob 'positioning-done)
-  (ly:self-alignment-interface::centered-on-x-parent grob))
+  (let* ((shift (ly:grob-property grob 'toward-stem-shift 0.0))
+        (note-head-location (ly:self-alignment-interface::centered-on-x-parent grob))
+        (note-head-grob (ly:grob-parent grob X))
+        (stem-grob (ly:grob-object note-head-grob 'stem)))
+    (+ note-head-location
+       ;; If the property 'toward-stem-shift is defined and the script has the
+       ;; same direction as the stem, move the script accordingly. Since scripts can
+       ;; also be over skips, we need to check whether the grob has a stem at all.
+       (if (ly:grob? stem-grob)
+          (let ((dir1 (ly:grob-property grob 'direction))
+                (dir2 (ly:grob-property stem-grob 'direction)))
+            (if (equal? dir1 dir2)
+                (let* ((common-refp (ly:grob-common-refpoint grob stem-grob X))
+                       (stem-location (ly:grob-relative-coordinate stem-grob common-refp X)))
+                  (* shift (- stem-location
+                              note-head-location)))
+                0.0))
+          0.0))))