Re: [frogs] Changing subproperties with grob-set-property (working on bug #40)

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


Neil Puttock schrieb:
[...]
Or is my approach aiming in the wrong direction?

I think it's fine for a tweak, but a better fix would involve working
directly on the code in line-spanner.cc.

              (set! right-X (- right-X 30)))

You could get a compensatory value automatically by using
ly:grob-extent on the accidental.
Assuming that ly:grob-set-nested-property! will find its way into the
code, I tried to solve the accidental/glissando collision problem
in scheme first (I still feel more comfortable with scheme than with c++).

It works as expected, but there is one more thing that I want to
take into account automatically: the fingering. When fingering numbers are
on the left or on the right, the glissando line should be shortened accordingly.

How can I get access to the fingering grob? I need its x-extent and the
orientation, but strangely, I cannot use the same mechanism as for accidentals; here (ly:grob-object right-bound 'accidental-grob) works, but it seems that there
is no (ly:grob-object right-bound 'fingering).
In scm/translation-functions.scm are some routines concerning fingerings, so
I found out how to check whether there is a fingering or not, but I still cannot access its grob (I fear this is just an easy function call someplace, but I just don't see
it now, and this will show my lack of deeper scheme knowledge as well :-( )

I attach my test file for sake of completeness.

Thanks in advance

Marc
Whatever you decide to do, allowing nested properties in
ly:grob-set-property! would be a useful enhancement.

Regards,
Neil

---

----
Join the Frogs!



\version "2.13.6"

\paper {
   indent = 0
   ragged-right = ##f
}

#(define (glissando::calc-extra-dy grob)
   (let* ((original (ly:grob-original grob))
          (left-bound (ly:spanner-bound original LEFT))
          (right-bound (ly:spanner-bound original RIGHT))
          (left-pitch (ly:event-property (event-cause left-bound) 'pitch))
          (right-pitch (ly:event-property (event-cause right-bound) 'pitch)))

     (if (and (= (ly:pitch-octave left-pitch) (ly:pitch-octave right-pitch))
              (= (ly:pitch-notename left-pitch) (ly:pitch-notename right-pitch)))
         (- (ly:pitch-alteration right-pitch) (ly:pitch-alteration left-pitch))
         0 )))

#(define (glissando::print grob)
    (let* ((original (ly:grob-original grob))
           (right-bound (ly:spanner-bound original RIGHT))
           (right-bound-info (ly:line-spanner::calc-right-bound-info grob))
           (right-X (assoc-get 'X right-bound-info 0))
           (accidental (ly:grob-object right-bound 'accidental-grob))
           (articulations (ly:event-property (event-cause right-bound) 'articulations))
           (fingering #f)
           (string-number #f))

          ; from translation-functions.scm
          (map (lambda (art)
               (let* ((num (ly:event-property art 'digit)))

                     (if (and (eq? 'fingering-event (ly:event-property art 'class))
                              (number? num))
                         (set! fingering num))))
           articulations)

          (display "\nFingering: ")(display fingering)

          (if (ly:grob? accidental)
              (let* ((accidental-width (cdr (ly:grob-extent accidental accidental X)))
                     (right-X (- right-X accidental-width)))

                    (ly:grob-set-nested-property! grob '(bound-details right X) right-X)))

          (ly:line-spanner::print grob)))


noten = \relative c {
   c4 \glissando <cis-3>
   c4 \glissando <cis-5>
   <c\5>4 \glissando <ces\5>
   c4 \glissando ces
   c4 \glissando d \glissando <e-4> \glissando <f-0>
   c2 \glissando c
   c4 \glissando dis e \glissando ges
}

\score {
    \new Staff { \clef "G_8"
                 \noten \break
                 \override Glissando #'extra-dy = #glissando::calc-extra-dy
                 \override  Glissando #'stencil = #glissando::print
                 \set fingeringOrientations = #'(left)
                 \noten \break
                 \set fingeringOrientations = #'(right)
                 \noten }
}



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/