| [ << Interfaces for programmers ] | [Top][Contents][Index][ ? ] | [ Literature list >> ] | ||
| [ < Using Scheme code instead of \tweak ] | [ Up : Interfaces for programmers ] | [ Literature list > ] | ||
6.8 Difficult tweaks
There are a few classes of difficult adjustments.
-
One type of difficult adjustment is the appearance of spanner objects,
such as slur and tie. Initially, only one of these objects is created,
and they can be adjusted with the normal mechanism. However, in some
cases the spanners cross line breaks. If this happens, these objects
are cloned. A separate object is created for every system that it is
in. These are clones of the original object and inherit all
properties, including
\overrides.In other words, an
\overridealways affects all pieces of a broken spanner. To change only one part of a spanner at a line break, it is necessary to hook into the formatting process. Theafter-line-breakingcallback contains the Scheme procedure that is called after the line breaks have been determined, and layout objects have been split over different systems.In the following example, we define a procedure
my-callback. This procedure- determines if we have been split across line breaks
- if yes, retrieves all the split objects
- checks if we are the last of the split objects
-
if yes, it sets
extra-offset.
This procedure is installed into Tie, so the last part of the broken tie is translated up.
#(define (my-callback grob) (let* ( ; have we been split? (orig (ly:grob-original grob)) ; if yes, get the split pieces (our siblings) (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() ))) (if (and (>= (length siblings) 2) (eq? (car (last-pair siblings)) grob)) (ly:grob-set-property! grob 'extra-offset '(-2 . 5))))) \relative c'' { \override Tie #'after-line-breaking = #my-callback c1 ~ \break c2 ~ c }When applying this trick, the new
after-line-breakingcallback should also call the old oneafter-line-breaking, if there is one. For example, if using this withHairpin,ly:hairpin::after-line-breakingshould also be called. - Some objects cannot be changed with
\overridefor technical reasons. Examples of those areNonMusicalPaperColumnandPaperColumn. They can be changed with the\overridePropertyfunction, which works similar to\once \override, but uses a different syntax.\overrideProperty #"Score.NonMusicalPaperColumn" % Grob name #'line-break-system-details % Property name #'((next-padding . 20)) % Value
Note, however, that
\override, applied toNonMusicalPaperColumnandPaperColumn, still works as expected within\contextblocks.
| [ << Interfaces for programmers ] | [Top][Contents][Index][ ? ] | [ Literature list >> ] | ||
| [ < Using Scheme code instead of \tweak ] | [ Up : Interfaces for programmers ] | [ Literature list > ] | ||