]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3999: Make tablature half-note stem-spacing adjustable.
authorMark Polesky <markpolesky@yahoo.com>
Wed, 9 Jul 2014 00:04:25 +0000 (17:04 -0700)
committerMark Polesky <markpolesky@yahoo.com>
Fri, 18 Jul 2014 18:31:04 +0000 (11:31 -0700)
This adds a new property to the Stem grob called
'double-stem-separation (default=0.5), that allows users to adjust
the space between the double-stemmed half-notes in tablature:

\new TabStaff {
  \tabFullNotation
  c4 c2 c4
  \override Stem.double-stem-separation = 0.3
  c4 c2 c4
}

It also centers the stems on the fret number and adjusts the
X-extent accordingly.

lily/stem.cc
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/tablature.scm

index 39a77a3858fea8ab3d6a7da92df1f26182830439..cc488e312570ede4a4cc6270ab46b110c0431dee 100644 (file)
@@ -1152,6 +1152,7 @@ ADD_INTERFACE (Stem,
                "default-direction "
                "details "
                "direction "
+               "double-stem-separation "
                "duration-log "
                "flag "
                "french-beaming "
index 8f7b29c10de748615c9b5c072cad435a62546f80..cd5b663f3bd1a687aa5fd7b8ae2f538a87582ca7 100644 (file)
@@ -239,6 +239,11 @@ elements closer together.")
      (dot-placement-list ,list? "List consisting of
 @code{(@var{description} @var{string-number} @var{fret-number}
 @var{finger-number})} entries used to define fret diagrams.")
+     (double-stem-separation ,number? "The distance between the two
+stems of a half note in tablature when using @code{\\tabFullNotation},
+not counting the width of the stems themselves, expressed as a multiple
+of the default height of a staff-space in the traditional five-line
+staff.")
      (duration-log ,integer? "The 2-log of the note head duration,
 i.e., @code{0} = whole note, @code{1} = half note, etc.")
 
index 14805f8eb98ffa397288114871a05ac8be439ef4..4a05d4b32caa24ee706e0a3c54d5e3b9aca1dbf2 100644 (file)
         ;; and the extreme minima as abolute minimum length.
 
         (direction . ,ly:stem::calc-direction)
+        (double-stem-separation . 0.5)
         (duration-log . ,stem::calc-duration-log)
         (length . ,(ly:make-unpure-pure-container ly:stem::calc-length ly:stem::pure-calc-length))
         (neutral-direction . ,DOWN)
index 36b81106c1bcb0046b9f2a73f5b7f1aab842bacf..615a6dcdf0dd616fac330360c53b7897e485ac01 100644 (file)
 ;; (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: