]> git.donarmstrong.com Git - lilypond.git/commitdiff
Extending TabNoteHead properties
authorMarc Hohl <marc@hohlart.de>
Fri, 11 Sep 2009 08:07:07 +0000 (10:07 +0200)
committerCarl Sorensen <c_sorensen@byu.edu>
Tue, 15 Sep 2009 03:17:01 +0000 (21:17 -0600)
By introducing TabNoteHead #'details, we now have
better control about the appearance of split ties
and repeat ties.

To simplify the usage, two new commands are supported in
ly/property-init.ly: \showSplitTiedTabNotes and
                     \hideSplitTiedTabNotes, respectively.

input/regression/tablature-tie-behaviour.ly
ly/engraver-init.ly
ly/property-init.ly
scm/define-grob-interfaces.scm
scm/define-grobs.scm
scm/tablature.scm

index 8760c9f204c0519c0a6031d761c57d4c527a9b2d..b42e50de8f4151e755fde3c27b84f745f0d6153e 100644 (file)
@@ -1,31 +1,63 @@
 \version "2.13.4"
 
 \header{ texidoc = "In tablature, notes that are tied to are invisible
-                    except after a line break or within a second volta;
-                    here, the fret number is displayed in parentheses."
-       }
+                     except after a line break or within a second volta;
+                    here, the fret number is displayed in parentheses.
 
-tietest = \relative c {
-  \override Voice.StringNumber #'transparent = ##t % remove circled string numbers
-  \repeat volta 2 {
-    f2 ~ f4  e
-    g8 g ~ g g ~ g g~ g g ~
-    g1
-    c1 ~ \break  c2 ~ c
+                    As an option, the notes that are tied to may become
+                    invisible completely, even after line breaks."
+        }
+
+firstpart = \relative c {
+  f2 ~ f4  e
+  g8 g ~ g g ~ g g~ g g ~
+  g1
+}
+
+secondpart = \relative c' {
+  c1 ~ \break c2 ~ c
+}
+
+thirdpart = \relative c' {
+    \repeat volta 2 {
     < c\3 e\2 g\1 >4 < c\3 e\2 g\1 > ~ < c\3 e\2 g\1 >\laissezVibrer r
     c4. d8 e2 ~
+   }
+   \alternative { { e2 r } { e2\repeatTie e2^\fermata } }
+ }
+
+\context StaffGroup <<
+  \context Staff {
+     \clef "G_8"
+    \override Voice.StringNumber #'transparent = ##t % remove circled string numbers
+    \firstpart
+    \secondpart
+    \thirdpart
   }
-  \alternative { { e2 r } { e2\repeatTie e2^\fermata } }
-  \bar "|."
-}
+  \context TabStaff {
+    \firstpart
+    \secondpart
+    \thirdpart
+  }
+>>
 
 \context StaffGroup <<
-  \context Staff <<
+  \context Staff {
     \clef "G_8"
-    \tietest
-  >>
-  \context TabStaff <<
-    \tietest
-  >>
+    \override Voice.StringNumber #'transparent = ##t % remove circled string numbers
+    \firstpart
+    \secondpart
+    \thirdpart
+    \secondpart
+    \thirdpart
+  }
+  \context TabStaff {
+    \hideSplitTiedTabNotes
+    \firstpart
+    \secondpart
+    \thirdpart
+    \showSplitTiedTabNotes
+    \secondpart
+    \thirdpart
+  }
 >>
-
index df6fb25e883ec8004b31996567fa0b8acf63d23a..7069652e42ed75da55d5f0c8a23bbb6da067f7c2 100644 (file)
@@ -727,8 +727,8 @@ context."
   \override Slur #'stencil = ##f
   \override PhrasingSlur #'stencil = ##f
   %% 'tied to' fret numbers become invisible or parenthesized, respectively)
-  \override Tie #'after-line-breaking = #tie::handle-tab-tie
-  \override RepeatTie #'after-line-breaking = #repeat-tie::parenthesize-tab-note-head
+  \override Tie #'after-line-breaking = #tie::handle-tab-note-head
+  \override RepeatTie #'after-line-breaking = #repeat-tie::handle-tab-note-head
   %% ... and all kinds of markups, spanners etc.
   \override TupletBracket #'stencil = ##f
   \override TupletNumber #'stencil = ##f
index 2880bffb2f2d61135c8e646014ca36a7fd771fde..b982843cf9d3ec8f2f145acb2da0a1dbb5503839 100644 (file)
@@ -368,8 +368,9 @@ stemDown    = \override Stem #'direction = #DOWN
 stemNeutral = \revert Stem #'direction
 
 
-%% tabFullNotation
+%% tablature
 
+% switch to full notation
 tabFullNotation = {
   % time signature
   \revert TabStaff.TimeSignature #'stencil
@@ -402,6 +403,20 @@ tabFullNotation = {
   \revert TabStaff.Arpeggio #'stencil
 }
 
+%tie/repeat tie behaviour
+hideSplitTiedTabNotes = {
+  \override TabVoice.TabNoteHead #'(details tied-properties break-visibility) = #all-invisible
+  \override TabVoice.TabNoteHead #'(details tied-properties parenthesize) = ##f
+  \override TabVoice.TabNoteHead #'(details repeat-tied-properties note-head-visible) = ##f
+  \override TabVoice.TabNoteHead #'(details repeat-tied-properties parenthesize) = ##f
+}
+
+showSplitTiedTabNotes = {
+  \override TabVoice.TabNoteHead #'(details tied-properties break-visibility) = #begin-of-line-visible
+  \override TabVoice.TabNoteHead #'(details tied-properties parenthesize) = ##t
+  \override TabVoice.TabNoteHead #'(details repeat-tied-properties note-head-visible) = ##t
+  \override TabVoice.TabNoteHead #'(details repeat-tied-properties parenthesize) = ##t
+}
 
 %% text length
 
index 23d200ebde905434de288e8fc10365f8eecf898f..8099e37a700dc34879adcef4c1979cfb24fb6567 100644 (file)
@@ -177,6 +177,11 @@ interesting enough to maintain a hara-kiri staff."
  "Text in front of the system."
  '(long-text self-alignment-X self-alignment-Y text))
 
+(ly:add-interface
+ 'tab-note-head-interface
+ "Details for TabNoteHeads."
+ '(details))
+
 (ly:add-interface
  'trill-spanner-interface
  "A trill spanner."
index 766f2f928af9b60db77781a13dec041640be6d32..eeef0385c86691e704f17c6159d6ba836b813590 100644 (file)
 
     (TabNoteHead
      . (
+       (details . ((tied-properties . ((break-visibility . ,begin-of-line-visible)
+                                       (parenthesize . #t)))
+                   (repeat-tied-properties . ((note-head-visible . #t)
+                                              (parenthesize . #t)))))
        (direction . ,CENTER)
        (duration-log . ,note-head::calc-duration-log)
        (font-series . bold)
index d28f2fc4831c84048de4771db531d07d838e1532..59989185538c473c77a9e6cd8d5ad7bc7f2a64ae 100644 (file)
                (parentheses-item::calc-parenthesis-stencils grob)))
         (parentheses-item::calc-parenthesis-stencils grob))))
 
-;; the handler for ties in tablature;; split ties yield in a parenthesized
-;; fret number, otherwise the fret number will be invisible.
-(define-public (tie::handle-tab-tie grob)
+;; the handler for ties in tablature; according to TabNoteHead #'details,
+;; the 'tied to' note is handled differently after a line break
+(define-public (tie::handle-tab-note-head grob)
   (let* ((original (ly:grob-original grob))
          (tied-tab-note-head (ly:spanner-bound grob RIGHT))
          (siblings (if (ly:grob? original)
 
     (if (and (>= (length siblings) 2)
              (eq? (car (last-pair siblings)) grob))
-        ;; tie is split -> parenthesize
-        (ly:grob-set-property! tied-tab-note-head 'stencil
-                               (lambda (grob)
-                                 (parenthesize-tab-note-head grob)))
+        ;; tie is split -> get TabNoteHead #'details
+        (let* ((details (ly:grob-property tied-tab-note-head 'details))
+               (tied-properties (assoc-get 'tied-properties details '()))
+               (tab-note-head-parenthesized (assoc-get 'parenthesize tied-properties #t))
+               ;; we need the begin-of-line entry in the 'break-visibility vector
+               (tab-note-head-visible
+                (vector-ref (assoc-get 'break-visibility
+                                       tied-properties #(#f #f #t)) 2)))
+
+              (if tab-note-head-visible
+                 ;; tab note head is visible
+                 (if tab-note-head-parenthesized
+                     (ly:grob-set-property! tied-tab-note-head 'stencil
+                                            (lambda (grob)
+                                                    (parenthesize-tab-note-head grob))))
+                 ;; tab note head is invisible
+                 (ly:grob-set-property! tied-tab-note-head 'transparent #t)))
 
         ;; tie is not split -> make fret number invisible
         (ly:grob-set-property! tied-tab-note-head 'transparent #t))))
 
 ;; repeat ties occur within alternatives in a repeat construct;
-;; the correspondig fret numbers are shown in parentheses:
-(define-public (repeat-tie::parenthesize-tab-note-head grob)
-  (let ((tied-tab-note-head (ly:grob-object grob 'note-head)))
-
-    (ly:grob-set-property! tied-tab-note-head 'stencil
-                           (lambda (grob) (parenthesize-tab-note-head grob)))))
+;; TabNoteHead #'details handles the appearance in this case
+(define-public (repeat-tie::handle-tab-note-head grob)
+  (let* ((tied-tab-note-head (ly:grob-object grob 'note-head))
+         (details (ly:grob-property tied-tab-note-head 'details))
+         (repeat-tied-properties (assoc-get 'repeat-tied-properties details '()))
+         (tab-note-head-visible (assoc-get 'note-head-visible repeat-tied-properties #t))
+         (tab-note-head-parenthesized (assoc-get 'parenthesize repeat-tied-properties #t)))
+
+        (if tab-note-head-visible
+            ;; tab note head is visible
+            ( if tab-note-head-parenthesized
+                 (ly:grob-set-property! tied-tab-note-head 'stencil
+                                        (lambda (grob)
+                                                (parenthesize-tab-note-head grob))))
+            ;; tab note head is invisible
+            (ly:grob-set-property! tied-tab-note-head 'transparent #t))))
\ No newline at end of file