]> git.donarmstrong.com Git - lilypond.git/commitdiff
Centers tremoli on double stems in TabVoice contexts.
authorMike Solomon <mike@apollinemike.com>
Wed, 28 Dec 2011 09:22:39 +0000 (10:22 +0100)
committerMike Solomon <mike@apollinemike.com>
Wed, 28 Dec 2011 09:22:39 +0000 (10:22 +0100)
input/regression/tablature-double-stem-tremolo.ly [new file with mode: 0644]
ly/property-init.ly
scm/define-grobs.scm
scm/tablature.scm

diff --git a/input/regression/tablature-double-stem-tremolo.ly b/input/regression/tablature-double-stem-tremolo.ly
new file mode 100644 (file)
index 0000000..fd76588
--- /dev/null
@@ -0,0 +1,11 @@
+\version "2.15.24"
+
+\header {
+  texidoc = "Tremoli applied to double stems in a @code{TabVoice}
+should be centered on the double stem.
+"
+}
+\new TabVoice \relative c' {
+  \tabFullNotation
+  a2:32
+}
\ No newline at end of file
index 3f0c1185f0e79650e9a2c7c2de167de7fbac6954..37a68917e724a1b121ea44c8c205cff4ebc3609e 100644 (file)
@@ -448,6 +448,7 @@ tabFullNotation = {
   \revert TabVoice.Stem #'transparent
   \revert TabVoice.Flag #'transparent
   \override TabVoice.Stem #'stencil = #tabvoice::draw-double-stem-for-half-notes
+  \override TabVoice.Stem #'X-extent = #tabvoice::make-double-stem-width-for-half-notes
   \set autoBeaming = ##t
   \revert NoteColumn #'ignore-collision
   % beams, dots
index 157055779a0722e8160a745c323ddbde31dec450..35d82c3f3735415267f8c821117545848c684f9a 100644 (file)
        (stencil . ,ly:stem-tremolo::print)
        (style . ,ly:stem-tremolo::calc-style)
        (X-extent . ,ly:stem-tremolo::width)
+       (X-offset . ,(ly:make-simple-closure
+                     `(,+
+                       ,(ly:make-simple-closure
+                         (list ly:self-alignment-interface::centered-on-x-parent))
+                       ,(ly:make-simple-closure
+                         (list ly:self-alignment-interface::x-aligned-on-self)))))
        (Y-offset . ,ly:stem-tremolo::calc-y-offset)
        (meta . ((class . Item)
-                (interfaces . (stem-tremolo-interface))))))
+                (interfaces . (self-alignment-interface
+                                stem-tremolo-interface))))))
 
     (StringNumber
      . (
index c26af257c8df13b1c14161a7314a6c201ffd99a7..5dd774aac83f58d397caab89ee0156bb8a917bbf 100644 (file)
 
 ;; if stems are drawn, it is nice to have a double stem for
 ;; (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)))
+
 (define-public (tabvoice::draw-double-stem-for-half-notes grob)
   (let ((stem (ly:stem::print grob)))