2 lyric-extender.cc -- implement Lyric_extender
3 source file of the GNU LilyPond music typesetter
5 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "molecule.hh"
14 #include "paper-column.hh"
15 #include "paper-def.hh"
16 #include "lyric-extender.hh"
19 MAKE_SCHEME_CALLBACK(Lyric_extender,brew_molecule)
21 Lyric_extender::brew_molecule (SCM smob)
23 Spanner *sp = dynamic_cast<Spanner*> (unsmob_element (smob));
25 Real leftext = sp->get_bound (LEFT)->extent (X_AXIS).length ();
26 Real ss = sp->paper_l ()->get_var ("staffspace");
27 Real righttrim = 0.5; // default to half a staffspace gap on the right
28 SCM righttrim_scm = sp->get_elt_property("right-trim-amount");
29 if (gh_number_p (righttrim_scm)) {
30 righttrim = gh_scm2double (righttrim_scm);
32 // The extender can exist in the word space of the left lyric ...
33 SCM space = sp->get_bound (LEFT)->get_elt_property ("word-space");
34 if (gh_number_p (space))
36 leftext -= gh_scm2double (space)*ss;
38 Real w = sp->spanner_length () - leftext - righttrim*ss;
40 Real h = sp->paper_l ()->get_var ("extender_height");
41 Molecule mol (sp->lookup_l ()->filledbox ( Box (Interval (0,w), Interval (0,h))));
42 mol.translate (Offset (leftext, 0));
43 return mol.create_scheme();
47 Lyric_extender::set_textitem (Direction d, Score_element*s)
49 elt_l_->set_bound (d, s);
50 elt_l_->add_dependency (s);
53 Lyric_extender::Lyric_extender (Spanner*s)