[Top][All Lists]

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

Re: Extra check in define-event-class patch

From: Neil Puttock
Subject: Re: Extra check in define-event-class patch
Date: Wed, 18 Aug 2010 23:10:50 +0100

Hi Mike,

Here are the comments I made copied from Rietveld:

+#(ly:define-event-class 'scheme-text-span-event
+                        '(scheme-text-span-event
+                          span-event

It would be great if the hierarchy could be completed automatically
rather than having to specify each class up to StreamEvent.

+#(define (axis-offset-symbol sym)

(axis-offset-symbol axis)

+#(set-object-property! 'file-name 'backend-type? string?)
+#(set-object-property! 'y-spread-left 'backend-type? list?)
+#(set-object-property! 'y-spread-right 'backend-type? list?)

remove these

+schemeTextSpannerEngraver =
+#(lambda (context)
+         (let ((span 0)

if you set defaults to '(), then it's easier to check if they don't exist

+               (finished 0)
+               (current-event 0)
+               (event-drul '(0 . 0)))
+         (list (cons 'listeners
+                     (list (cons 'scheme-text-span-event
+                                 (lambda (engraver event)
+                                         (if (eq? LEFT
(ly:event-property event 'span-direction))


+                                             (set! event-drul (cons
event (cdr event-drul)))
+                                             (set! event-drul (cons
(car event-drul) event)))))))

you could use set-car!/set-cdr! here

+               (cons 'acknowledgers
+                     (list (cons 'note-column-interface
+                                 (lambda (engraver grob source-engraver)
+                                         (if (not (eq? span 0))

(if (ly:spanner? span)

+                                               (begin
(ly:pointer-group-interface::add-grob span 'note-columns grob)
+                                                 (add-bound-item span grob)))
+                                          (if (not (eq? span 0))

(if (ly:spanner finished)

+                                               (begin
(ly:pointer-group-interface::add-grob span 'note-columns grob)

(ly:pointer-group-interface::add-grob finished 'note-columns grob)

+                                                 (add-bound-item span

(add-bound-item finished grob)

+               (cons 'process-music
+                     (lambda (trans)
+                             (if (not (eq? 0 (cdr event-drul)))

(if (ly:stream-event? (cdr event-drul))

+                                 (if (eq? span 0)

(if (null? span)

assuming you set to '() instead of 0

+                                     (ly:warning "You're trying to
end a scheme text spanner but you haven't started one.")
+                                     (begin (set! finished span)
(ly:engraver-announce-end-grob trans finished current-event)
+                                            (set! span 0)
+                                            (set! current-event 0))))
+                             (if (not (eq? 0 (car event-drul)))

(if (ly:stream-event? (car event-drul))

+                                 (begin (set! current-event (car event-drul))
+                                        (set! span
(ly:engraver-make-grob trans 'SchemeTextSpanner current-event))
+                                        (set-axis! span Y)
+                                        (set! event-drul (cons 0 (cdr

(set-car! event-drul 0)

+               (cons 'stop-translation-timestep
+                     (lambda (trans)
+                             (if (and (not (eq? span 0)) (null?
(ly:spanner-bound span LEFT)))

(if (and (ly:spanner? span)

+                               (ly:spanner-set-bound! span LEFT
(ly:context-property context 'currentMusicalColumn)))
+                             (if (not (eq? 0 finished))
+                                 (if (null? (ly:spanner-bound finished RIGHT))
+                                     (ly:spanner-set-bound! finished
RIGHT (ly:context-property context 'currentMusicalColumn))))

(if (ly:spanner? finished)
      (if (null? (ly:spanner-bound finished RIGHT))
          (ly:spanner-set-bound! finished RIGHT (ly:context-property
context 'currentMusicalColumn)))
      (set! finished 0)))

+                             (set! event-drul '(0 . 0))))
+               (cons 'finalize
+                     (lambda (trans)
+                             (format "finalizin'\n")


+                             (if (not (eq? 0 finished))

(if (ly:spanner? finished)

+                                 (if (null? (ly:spanner-bound finished RIGHT))
+                                     (ly:spanner-set-bound! finished
RIGHT (ly:context-property context 'currentMusicalColumn))))


(set! finished 0)

+                             (if (not (eq? 0 span))
+                                 (begin
+                                   (ly:warning "I think there's a
dangling scheme text spanner :-(")
+                                   (ly:grob-suicide span)

(ly:grob-suicide! span)

+                                   (set! span 0))))))))
+schemeTextSpannerStart =
+#(define-music-function (parser location music)

You don't need a music function for this; the event will be added to
the EventChord automatically:

schemeTextSpannerStart =
#(make-music 'SchemeTextSpanEvent span-direction START)

or more idiomatically,

#(make-span-event 'SchemeTextSpanEvent START)

(same for schemeTextSpannerEnd)

+\relative c' {
+a \schemeTextSpannerStart b c d |
+a b c d |

\repeat unfold (or make the snippet shorted using \break)

A test for ly:engraver-announce-end-grob would be useful; you could
add another span with 'to-barline set for this.

Index: scm/define-event-classes.scm
diff --git a/scm/define-event-classes.scm b/scm/define-event-classes.scm
--- a/scm/define-event-classes.scm
+++ b/scm/define-event-classes.scm
@@ -71,6 +71,17 @@
     (cdr rel)))

+(define-public (ly:define-event-class leaf heritage)

remove `ly:' prefix

(should also be removed from ly:make-event-class)


reply via email to

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