]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/tablature.scm
Web-ja: update introduction
[lilypond.git] / scm / tablature.scm
index 668bf2faa3a1b390bc13f2552859fac18cbf1b9b..97f688c1d1e868d4242d3a085ab9d4856e3fddf3 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; This file is part of LilyPond, the GNU music typesetter.
 ;;;;
-;;;; Copyright (C) 2009--2014 Marc Hohl <marc@hohlart.de>
+;;;; Copyright (C) 2009--2015 Marc Hohl <marc@hohlart.de>
 ;;;;
 ;;;; LilyPond is free software: you can redistribute it and/or modify
 ;;;; it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
   (let ((style (ly:grob-property grob 'style)))
 
     (case style
-      ((cross slash) (stencil-whiteout (ly:note-head::print grob)))
+      ((cross slash) (stencil-whiteout-box (ly:note-head::print grob)))
       (else (tab-note-head::print grob)))))
 
 ;; definitions for the "moderntab" clef:
 ;; (dotted) half notes to distinguish them from quarter notes:
 (define-public (tabvoice::make-double-stem-width-for-half-notes grob)
   (let ((X-extent (ly:stem::width grob)))
-
-    ;; is the note a (dotted) half note?
-    (if (= 1 (ly:grob-property grob 'duration-log))
-        ;; yes -> return double stem width
-        (cons (car X-extent) (+ 0.5 (* 2 (cdr X-extent))))
-        ;; no -> return simple stem width
-        X-extent)))
+    ;; does the stem exist and is it on a (dotted) half note?
+    (if (and (not (equal? X-extent empty-interval))
+             (= 1 (ly:grob-property grob 'duration-log)))
+
+      ;; yes -> return double stem X-extent
+      (let* ((single-stem-width (- (cdr X-extent) (car X-extent)))
+             (separation (ly:grob-property grob 'double-stem-separation 0.5))
+             (total-width (+ single-stem-width separation))
+             (half-width (/ total-width 2)))
+        (cons (- half-width) half-width))
+      ;; no -> return simple stem X-extent
+      X-extent)))
 
 (define-public (tabvoice::draw-double-stem-for-half-notes grob)
-  (let ((stem (ly:stem::print grob)))
-
-    ;; is the note a (dotted) half note?
-    (if (= 1 (ly:grob-property grob 'duration-log))
-        ;; yes -> draw double stem
-        (ly:stencil-combine-at-edge stem X RIGHT stem 0.5)
-        ;; no -> draw simple stem
-        stem)))
+  (let ((stem-stencil (ly:stem::print grob)))
+    ;; does the stem exist and is it on a (dotted) half note?
+    (if (and (ly:stencil? stem-stencil)
+             (= 1 (ly:grob-property grob 'duration-log)))
+
+      ;; yes -> draw double stem
+      (let* ((separation (ly:grob-property grob 'double-stem-separation 0.5))
+             (half-separation (/ separation 2)))
+        (ly:stencil-add
+          (ly:stencil-translate-axis stem-stencil (- half-separation) X)
+          (ly:stencil-translate-axis stem-stencil half-separation X)))
+      ;; no -> draw simple stem (or none at all)
+      stem-stencil)))
 
 ;; as default, the glissando line between fret numbers goes
 ;; upwards, here we have a function to correct this behavior:
 
 
 ;; a callback for custom fret labels
-(define-public ((tab-note-head::print-custom-fret-label fret) grob)
-  (ly:grob-set-property! grob 'text fret)
+(define ((tab-note-head::print-custom-fret-label fret) grob)
+  (ly:grob-set-property! grob 'text (make-vcenter-markup fret))
   (tab-note-head::print grob))
+(export tab-note-head::print-custom-fret-label)
 
 (define-public (tab-note-head::print grob)
   (define (is-harmonic? grob)
          (offset-factor (assoc-get 'head-offset details 3/5))
          (column-offset (* offset-factor
                            (interval-length
-                            (ly:stencil-extent
-                             (grob-interpret-markup grob "8")
-                             X)))))
+                            (ly:stencil-extent ref-grob X)))))
 
     (if (is-harmonic? grob)
         (set! output-grob (harmonic-proc output-grob
                                            cautionary-width
                                            cautionary-angularity
                                            cautionary-padding)))
-    (ly:stencil-translate-axis (centered-stencil output-grob)
-                               column-offset
-                               X)))
+    (ly:stencil-translate-axis
+     (ly:stencil-aligned-to output-grob X CENTER)
+     column-offset
+     X)))
 
 ;; Harmonic definitions