Kieren MacMillan <kieren_macmil...@sympatico.ca> writes: > Hi all, > > I’ve been using David K’s lovely \after function (which should, IMO, be > polished up and rolled into the distro!) to great effect in my recent > engravings. > > However, I’m having difficulty figuring out how to apply tweaks to the grobs > that are \after-ed. > For example, see the snippet included below. > > Any hints would be appreciated. > > Thanks, > Kieren. > > ________________________ > > %%% SNIPPET BEGINS > \version "2.19" > > \paper { ragged-right = ##f } > > hairpinWithCenteredText = > #(define-music-function (parser location text) (markup?) > #{ > \once \override Voice.Hairpin.after-line-breaking =
[...] That's not a tweak. _That's_ a tweak:
%%% SNIPPET BEGINS \version "2.19" \paper { ragged-right = ##f } hairpinWithCenteredText = #(define-event-function (parser location text ev) (markup? ly:event?) #{ -\tweak Hairpin.after-line-breaking #(lambda (grob) (let* ((stencil (ly:hairpin::print grob)) (par-y (ly:grob-parent grob Y)) (dir (ly:grob-property par-y 'direction)) (new-stencil (ly:stencil-aligned-to (ly:stencil-combine-at-edge (ly:stencil-aligned-to stencil X CENTER) Y dir (ly:stencil-aligned-to (grob-interpret-markup grob text) X CENTER)) X LEFT)) (staff-space (ly:output-def-lookup (ly:grob-layout grob) 'staff-space)) (staff-line-thickness (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness)) (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name))) (par-x (ly:grob-parent grob X)) (dyn-text (eq? (grob-name par-x) 'DynamicText )) (dyn-text-stencil-x-length (if dyn-text (interval-length (ly:stencil-extent (ly:grob-property par-x 'stencil) X)) 0)) (x-shift (if dyn-text (- (+ staff-space dyn-text-stencil-x-length) (* 0.5 staff-line-thickness)) 0)) (original (ly:grob-original grob)) (pieces (if (ly:grob? original) (ly:spanner-broken-into original) '()))) (ly:grob-set-property! grob 'Y-offset 0) ;; ensure correct alignment (ly:grob-set-property! grob 'stencil (ly:stencil-translate-axis (if (or (null? pieces) (and (pair? pieces) (eq? grob (car pieces)))) new-stencil stencil) x-shift X)))) #ev #}) hairpinPoco = \hairpinWithCenteredText \markup \italic poco \etc after = #(define-music-function (parser location t e m) (ly:duration? ly:music? ly:music?) #{ \context Bottom << #m { \skip $t <> -\tweak extra-spacing-width #empty-interval $e } >> #}) test = { g1\hairpinPoco\< g\! \after 2 \hairpinPoco\< g1 g\! } \score { \test } %%% SNIPPET ENDS
-- David Kastrup
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user