From: Marc Hohl Date: Fri, 11 Sep 2009 08:07:07 +0000 (+0200) Subject: Extending TabNoteHead properties X-Git-Tag: release/2.13.4-1~44 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3417b5edd0596f128bc5faca6c600c3b11915709;p=lilypond.git Extending TabNoteHead properties 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. --- diff --git a/input/regression/tablature-tie-behaviour.ly b/input/regression/tablature-tie-behaviour.ly index 8760c9f204..b42e50de8f 100644 --- a/input/regression/tablature-tie-behaviour.ly +++ b/input/regression/tablature-tie-behaviour.ly @@ -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 + } >> - diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index df6fb25e88..7069652e42 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -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 diff --git a/ly/property-init.ly b/ly/property-init.ly index 2880bffb2f..b982843cf9 100644 --- a/ly/property-init.ly +++ b/ly/property-init.ly @@ -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 diff --git a/scm/define-grob-interfaces.scm b/scm/define-grob-interfaces.scm index 23d200ebde..8099e37a70 100644 --- a/scm/define-grob-interfaces.scm +++ b/scm/define-grob-interfaces.scm @@ -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." diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 766f2f928a..eeef0385c8 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1867,6 +1867,10 @@ (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) diff --git a/scm/tablature.scm b/scm/tablature.scm index d28f2fc483..5998918553 100644 --- a/scm/tablature.scm +++ b/scm/tablature.scm @@ -153,9 +153,9 @@ (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) @@ -163,18 +163,41 @@ (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