2011/9/23 David Nalesnik <david.nales...@gmail.com> > (...) > Well, it is possible to override a non-existent property (if you don't mind > the warnings). Here's a sketch which uses a tag to center a grob. (I > realize it will break with very little effort.) And with this, my descent > into hackishness is complete . . . > (...) >
Hi David, I thought a while about your "hackishness" :) As a first step it seems to be possible to add a grob-custom-property to define-grob-properties.scm in some way (thanks to Arnold from the german lilypond forum, who had the idea http://www.lilypondforum.de/index.php). The code below gives only the name, description and the type of argument of the new grob-custom-property. But the little test shows no problems and no warning in the log. \version "2.14.2" #(define (define-grob-custom-property symbol type? description) (if (not (equal? (object-property symbol 'backend-doc) #f)) (ly:error (_ "symbol ~S redefined") symbol)) (set-object-property! symbol 'backend-type? type?) (set-object-property! symbol 'backend-doc description) symbol) #(define all-user-grob-custom-properties (map (lambda (x) (apply define-grob-custom-property x)) `( (tigs ,string? "Tag marker in grob for function center-between") ))) #(define ((center-between tags extra-Y-offset) grob) (let* ((refp (ly:grob-system grob)) (all-grobs (ly:grob-array->list (ly:grob-object refp 'all-elements))) (X-extent (lambda (q) (ly:grob-extent q refp X))) (targets (filter (lambda (q) (equal? (ly:grob-property q 'tigs) tags)) all-grobs))) ; center between right of grob to left and left of grob to right (cons (- (- (interval-center (X-extent grob)) (/ (+ (cdr (X-extent (car targets))) (car (X-extent (cadr targets)))) 2))) extra-Y-offset))) \relative c' { \once \override Staff.TimeSignature #'tigs = #"hello" \once \override TextScript #'extra-offset = #(center-between "hello" 0) c^"hello" c c\once \override NoteHead #'test = ##f c \once \override Staff.BarLine #'tigs = #"hello" \once \override TextScript #'extra-offset = #(center-between "bla" 0) \once \override NoteHead #'tigs = #"bla" c^"xy|yx" \once \override NoteHead #'tigs = #"bla" c c c \once \override Script #'extra-offset = #(center-between "blub" 0) \once \override Stem #'tigs = #"blub" c\turn \once \override Stem #'tigs = #"blub" c c c } A second step might be to add a interface to the new grob-custom-property. But in define-grob-interfaces.scm you can read: ;; The interfaces defined here generally have no code (e.g., ;; dynamic-interface), or have callbacks defined entirely in ;; scheme. Others interfaces are defined in lily/*.cc with the ;; ADD_INTERFACE function So I don't know if it's possible. Best, Harm
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user