2017-11-01 22:06 GMT+01:00 Bernardo Barros <bernardo.bar...@nyu.edu>:
> On 11/1/17 15:27, Thomas Morley wrote:
>>
>>
>> Another possibility is to clone all of the
>> TextSpanner-grob/engraver/etc under a different name.
>>
>> https://archiv.lilypondforum.de/index.php/topic,2503.msg14199.html#msg14199
>> Scroll down to the code - it was developed by Xaver and myself, based
>> upon the scheme-text-engraver from our regtests.
>
>
> I'm not able to compile 'scheme-text-spanner.ly' Does it work for you?

Where did you get the code below?
It's not the current coding
>
> Starting lilypond 2.19.65 [lily-b5b7fd74.ly]...
> Processing `/Users/smoge/Downloads/lily-b5b7fd74.ly'
> Parsing...
> warning: type check for `SchemeTextSpanner' failed; value
> `#<Grob_properties>' must be of type `list'
> Interpreting music...
> Exited with exit status 1.
>
> \version "2.19.49"
>
> \header {
>   texidoc = "Use @code{define-event-class}, scheme engraver methods,
> and grob creation methods to create a fully functional text spanner
> in scheme."
> }
>
> #(define-event-class 'scheme-text-span-event 'span-event)
>
> #(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)))
>      (set-object-property! grob-name 'translation-type? list?)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Above was fixed with issue 2507:

Pushed to staging as
commit [re328b7a10ec1a4e13ba11104825bf54e027d0dd0]
Author: David Kastrup <d...@gnu.org>
Date:   Wed Jul 30 17:34:55 2014 +0200

    Issue 2507: Stop the entanglement of context properties and grob
property internals

    This introduces a semi-opaque structure Grob_properties meeting the
    predicate ly:grob-properties? that is algorithmically handled at the C++
    level via a wrapper structure Grob_property_info.

    Encapsulating grob properties in that manner reduces the potential for
    clashes and makes it easier to change algorithms and/or internal
    representation.

    While the principal distinction between context properties (one value
    per context) and context-based grob property templates (one stack per
    context) remains, at least the separation of the handling is more
    pronounced.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Labels: -Patch-push Fixed_2_19_13
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Status: Fixed


>      (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
>   'SchemeTextSpanner
>   `(
>     (bound-details . ((left . ((Y . 0)
>                                (padding . 0.25)
>                                (attach-dir . ,LEFT)
>                                ))
>                       (left-broken . ((end-on-note . #t)))
>                       (right . ((Y . 0)
>                                 (padding . 0.25)
>                                 ))
>                       ))
>     (dash-fraction . 0.2)
>     (dash-period . 3.0)
>     (direction . ,UP)
>     (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 . dashed-line)
>
>     (meta . ((class . Spanner)
>              (interfaces . (font-interface
>                             line-interface
>                             line-spanner-interface
>                             side-position-interface))))))
>
> #(define scheme-event-spanner-types
>    '(
>      (SchemeTextSpanEvent
>       . ((description . "Used to signal where scheme text spanner brackets
> start and stop.")
>          (types . (general-music scheme-text-span-event span-event event))
>          ))
>      ))
>
> #(set!
>   scheme-event-spanner-types
>   (map (lambda (x)
>          (set-object-property! (car x)
>                                'music-description
>                                (cdr (assq 'description (cdr x))))
>          (let ((lst (cdr x)))
>            (set! lst (assoc-set! lst 'name (car x)))
>            (set! lst (assq-remove! lst 'description))
>            (hashq-set! music-name-to-property-table (car x) lst)
>            (cons (car x) lst)))
>        scheme-event-spanner-types))
>
> #(set! music-descriptions
>        (append scheme-event-spanner-types music-descriptions))
>
> #(set! music-descriptions
>        (sort music-descriptions alist<?))
>
> #(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)))))
>
> schemeTextSpannerEngraver =
> #(lambda (context)
>    (let ((span '())
>          (finished '())
>          (event-start '())
>          (event-stop '()))
>      (make-engraver
>       (listeners ((scheme-text-span-event engraver event)
>                   (if (= START (ly:event-property event 'span-direction))
>                       (set! event-start event)
>                       (set! event-stop event))))
>       (acknowledgers ((note-column-interface engraver grob source-engraver)
>                       (if (ly:spanner? span)
>                           (begin
>                             (ly:pointer-group-interface::add-grob span
> 'note-columns grob)
>                             (add-bound-item span grob)))
>                       (if (ly:spanner? finished)
>                           (begin
>                             (ly:pointer-group-interface::add-grob finished
> 'note-columns grob)
>                             (add-bound-item finished grob)))))
>       ((process-music trans)
>        (if (ly:stream-event? event-stop)
>            (if (null? span)
>                (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
> event-start)
>                       (set! span '())
>                       (set! event-stop '()))))
>        (if (ly:stream-event? event-start)
>            (begin (set! span (ly:engraver-make-grob trans 'SchemeTextSpanner
> event-start))
>                   (set-axis! span Y)
>                   (set! event-start '()))))
>       ((stop-translation-timestep trans)
>        (if (and (ly:spanner? span)
>                 (null? (ly:spanner-bound span LEFT)))
>            (set! (ly:spanner-bound span LEFT)
>                  (ly:context-property context 'currentMusicalColumn)))
>        (if (ly:spanner? finished)
>            (begin
>              (if (null? (ly:spanner-bound finished RIGHT))
>                  (set! (ly:spanner-bound finished RIGHT)
>                        (ly:context-property context 'currentMusicalColumn)))
>              (set! finished '())
>              (set! event-start '())
>              (set! event-stop '()))))
>       ((finalize trans)
>        (if (ly:spanner? finished)
>            (begin
>              (if (null? (ly:spanner-bound finished RIGHT))
>                  (set! (ly:spanner-bound finished RIGHT)
>                        (ly:context-property context 'currentMusicalColumn)))
>              (set! finished '())))
>        (if (ly:spanner? span)
>            (begin
>              (ly:warning "I think there's a dangling scheme text spanner
> :-(")
>              (ly:grob-suicide! span)
>              (set! span '())))))))
>
> schemeTextSpannerStart =
> #(make-span-event 'SchemeTextSpanEvent START)
>
> schemeTextSpannerEnd =
> #(make-span-event 'SchemeTextSpanEvent STOP)
>
> \layout {
>   \context {
>     \Global
>     \grobdescriptions #all-grob-descriptions
>   }
>   \context {
>     \Voice
>     \consists \schemeTextSpannerEngraver
>   }
> }
>
> \relative c' {
>   a4 b\schemeTextSpannerStart c d |
>   \repeat unfold 20 { a4 b c d | }
>   a4 b c\schemeTextSpannerEnd d |
>   \override SchemeTextSpanner.to-barline = ##t
>   a4\schemeTextSpannerStart b d c |
>   \repeat unfold 20 { a4 b c d | }
>   a1\schemeTextSpannerEnd |
> }
>
>

Cheers,
  Harm

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to