[icon]

GNU LilyPond

Welcome to the home of the GNU Music Typesetter

What is LilyPond
General information
Simple examples
Complex examples
Download
GNU/Linux binaries
Windows
Source code
Documentation
Tutorial
Manual
Glossary
other ...

Support
Mailing lists
Search
WikiWiki
FAQs

External sites
lilypond.org/development
lilypond.org/stable
ftp.lilypond.org
Mutopia
Other music online

Node:Callbacks, Next:, Previous:What is a grob?, Up:Grobs



Callbacks

Offsets of grobs are relative to a parent reference point. Most positions are not known when an object is created, so these are calculated as needed. This is done by adding a callback for a specific direction.

Suppose you have the following code in a .ly file.

        #(define (my-callback gr axis)
                (*  2.0 (get-grob-property gr 'direction))
        )

....

        \property Voice.Stem \override #'Y-offset-callbacks = #(list
                        my-callback)

When the Y-offset of a Stem object is needed, LilyPond will automatically execute all callbacks for that object. In this case, it will find my-callback, and execute that. The result is that the stem is translated by two staff spaces in its direction.

(note: Y-offset-callbacks is also a property)

Offset callbacks can be stacked, i.e.

        \property .... \override #'Y-offset-callbacks = #(list
                callback1 callback2 callback3)

The callbacks will be executed in the order callback3 callback2 callback1. This is used for quantized positioning: the staccato dot is above or below a note head, and it must not be on a staff-line. To achieve this, the staccato dot has two callbacks: one that positions the grob above or below the note head, and one that rounds the Y-position of the grob to the nearest open space.

Similarly, the size of a grob are determined through callbacks, settable with grob properties X-extent-callback and Y-extent-callback. There can be only one extent-callback for each axis. No callback (Scheme value #f) means: "empty in this direction". If you fill in a pair of numbers, that pair hard-codes the extent in that coordinate.

Go back to index of LilyPond.

Please send GNU LilyPond questions and comments to lilypond-user@gnu.org.

Please send comments on these web pages to lilypond@packages.debian.org

Copyright (c) 1997--2001 Han-Wen Nienhuys and Jan Nieuwenhuizen.

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.


This page was built from LilyPond-1.4.12 (stable-branch) by

Anthony Fok <lilypond@packages.debian.org>, Tue Mar 12 01:35:39 2002 HKT.