From ae14152d6cb63504972ad2379d553581f36cbf08 Mon Sep 17 00:00:00 2001 From: Mark Polesky Date: Tue, 8 Jul 2014 17:04:25 -0700 Subject: [PATCH] Issue 3999: Make tablature half-note stem-spacing adjustable. 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 | 1 + scm/define-grob-properties.scm | 5 +++++ scm/define-grobs.scm | 1 + scm/tablature.scm | 40 +++++++++++++++++++++------------- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/lily/stem.cc b/lily/stem.cc index 39a77a3858..cc488e3125 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -1152,6 +1152,7 @@ ADD_INTERFACE (Stem, "default-direction " "details " "direction " + "double-stem-separation " "duration-log " "flag " "french-beaming " diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 8f7b29c10d..cd5b663f3b 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -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.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 14805f8eb9..4a05d4b32c 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -2114,6 +2114,7 @@ ;; 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) diff --git a/scm/tablature.scm b/scm/tablature.scm index 36b81106c1..615a6dcdf0 100644 --- a/scm/tablature.scm +++ b/scm/tablature.scm @@ -81,23 +81,33 @@ ;; (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: -- 2.39.2