lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PATCH: accessors for note-column's dot-column, accidentals


From: Nicolas Sceaux
Subject: PATCH: accessors for note-column's dot-column, accidentals
Date: Sun, 4 Apr 2010 11:46:40 +0200

Hi,

While working on a scheme engraver for adding harpsichord ornementations
to note heads, I'd like to be able to shift accidentals or dots attached
to notes.

Is it OK to add this `lily/note-column-scheme.cc' file?

Attachment: note-column-scheme.patch
Description: Binary data


It makes it possible to access dot-column and accidentals from a note
column, so that one can modify their placement, like in this customized
parenthesis engraver:

\version "2.13.18"

#(define (parenthesize-engraver-acknowledge-note-head engraver note-grob 
source-engraver)
   (let* ((note-event (ly:grob-property note-grob 'cause)))
     (if (eqv? #t (ly:event-property note-event 'parenthesize))
         (let ((paren (ly:engraver-make-grob engraver 'ParenthesesItem 
note-grob)))
           (ly:pointer-group-interface::add-grob paren 'elements note-grob)
           (set! (ly:grob-parent paren Y) note-grob)
           (set! (ly:grob-property paren 'font-size)
                 (+ (ly:grob-property paren 'font-size 0.0)
                    (ly:grob-property note-grob 'font-size 0.0)))
           ;; shift accidentals or dots, so that they do not
           ;; collide with the parenthesis
           ;; TODO: compute width
           ;; TODO: account for directions and priorities
           (let* ((note-column (ly:grob-object note-grob 'axis-group-parent-X))
                  (acc (ly:note-column::accidentals note-column))
                  (dot-col (ly:note-column::dot-column note-column))
                  (width 0.5))
             (if dot-col
                 (set! (ly:grob-property dot-col 'positioning-done)
                       (lambda (grob)
                         (ly:dot-column::calc-positioning-done grob)
                         (ly:grob-translate-axis! grob width X))))
             (if acc
                 (set! (ly:grob-property acc 'padding) width)))))))

#(define parenthesize-engraver
   `((acknowledgers
      (note-head-interface . ,parenthesize-engraver-acknowledge-note-head))))

test = {
  \parenthesize cis'4. \parenthesize ceses'4.  c'4 <\parenthesize cis' e' g'>4.
}

\score {
  \test
  \layout {
    \context {
      \Score
      \remove "Parenthesis_engraver"
      \consists #parenthesize-engraver
    }
  }
}

{ \test }

PNG image





reply via email to

[Prev in Thread] Current Thread [Next in Thread]