On Mon, Jan 5, 2015 at 4:08 PM, David Nalesnik <[email protected]>
wrote:

>
>
> I've adapted this to create the divider.
>
>
A bit cleaner--overrides moved to grob definition.
\version "2.19.15"

\header {
  tagline = ##f
}

#(define (add-grob-definition grob-name grob-entry)
   (let* ((meta-entry   (assoc-get 'meta grob-entry))
          (class        (assoc-get 'class meta-entry))
          (ifaces-entry (assoc-get 'interfaces meta-entry)))
     ; if version is 2.19.13 or before, replace ly:grob-properties?
     ; in the following line with list?
     (set-object-property! grob-name 'translation-type? ly:grob-properties?)
     (set-object-property! grob-name 'is-grob? #t)
     (set! ifaces-entry (append (case class
                                  ((Item) '(item-interface))
                                  ((Spanner) '(spanner-interface))
                                  ((Paper_column) '((item-interface
                                                     paper-column-interface)))
                                  ((System) '((system-interface
                                               spanner-interface)))
                                  (else '(unknown-interface)))
                          ifaces-entry))
     (set! ifaces-entry (uniq-list (sort ifaces-entry symbol<?)))
     (set! ifaces-entry (cons 'grob-interface ifaces-entry))
     (set! meta-entry (assoc-set! meta-entry 'name grob-name))
     (set! meta-entry (assoc-set! meta-entry 'interfaces
                        ifaces-entry))
     (set! grob-entry (assoc-set! grob-entry 'meta meta-entry))
     (set! all-grob-descriptions
           (cons (cons grob-name grob-entry)
             all-grob-descriptions))))

#(add-grob-definition
  'LyricSeparator
  `(
     (bound-details . ((left . ((Y . 0)
                                (padding . 0)
                                (attach-dir . ,LEFT)
                                ))
                       (right . ((Y . 0)
                                 (padding . 0)
                                 (attach-dir . ,RIGHT)
                                 ))
                       ))
     (dash-fraction . 0.2)
     (dash-period . 3.0)
     (direction . ,DOWN)
     (font-shape . italic)
     (left-bound-info . ,ly:line-spanner::calc-left-bound-info)
     ;(outside-staff-priority . 350)
     (right-bound-info . ,ly:line-spanner::calc-right-bound-info)
     (staff-padding . 0.8)
     (stencil . ,ly:line-spanner::print)
     (style . line)

     (meta . ((class . Spanner)
              (interfaces . (font-interface
                             line-interface
                             line-spanner-interface
                             outside-staff-interface
                             side-position-interface))))))


#(define (add-bound-item spanner item)
   (if (null? (ly:spanner-bound spanner LEFT))
       (ly:spanner-set-bound! spanner LEFT item)
       (ly:spanner-set-bound! spanner RIGHT item)))

#(define (axis-offset-symbol axis)
   (if (eq? axis X) 'X-offset 'Y-offset))

#(define (set-axis! grob axis)
   (if (not (number? (ly:grob-property grob 'side-axis)))
       (begin
        (set! (ly:grob-property grob 'side-axis) axis)
        (ly:grob-chain-callback
         grob
         (if (eq? axis X)
             ly:side-position-interface::x-aligned-side
             side-position-interface::y-aligned-side)
         (axis-offset-symbol axis)))))

LyricSeparatorEngraver =
#(lambda (context)
   (let ((span '()))
     (make-engraver
      (acknowledgers
       ((stanza-number-interface engraver grob source-engraver)
        (if (ly:spanner? span)
            (begin
             (ly:pointer-group-interface::add-grob span 'lyric-bits grob)
             (ly:spanner-set-bound! span LEFT grob))))
       ((lyric-syllable-interface engraver grob source-engraver)
        (if (ly:spanner? span)
            (begin
             (ly:pointer-group-interface::add-grob span 'lyric-bits grob)
             (add-bound-item span grob)))))
      ((process-music trans)
       (if (not (ly:spanner? span))
           (let ((ccc (ly:context-property context 'currentCommandColumn)))
             (set! span (ly:engraver-make-grob trans 'LyricSeparator ccc))
             (set-axis! span Y))))
      ((finalize trans)
       (set! span '())))))


\score {
  \new Staff <<
    \new Voice = "melody" {
      \time 3/4
      g'2 g'4
      \break
      e'2 a'4
      g'2. e'
    }
    \new Lyrics \lyricsto "melody"{
      \set stanza = #"1. "
      Na na na na na na  
    }
    \new Lyrics \lyricsto "melody"{
      \set stanza = #"2. "
      Na na na na na na  
    }
    \new Lyrics \with {
      \consists \LyricSeparatorEngraver
      % the following line controls space above and below
      \override LyricSeparator #'Y-extent = #'(-1 . 1)
    }
    \lyricsto "melody" {
      \set stanza = #"3. "
      Na na na na na naaaaaaaaaaah
    } 
    \new Lyrics \lyricsto "melody"{
      \set stanza = #"4. "
      Na na na na na na  
    }
    \new Lyrics \lyricsto "melody"{
      \set stanza = #"5. "
      Na na na na na na  
    }
  >>
  \layout {
    \context {
      \Global
      \grobdescriptions #all-grob-descriptions
    }
  }
}
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to