lilypond-1.3.121
[lilypond.git] / lily / lyric-extender.cc
bloba56bae3fa4689200886674cff0d48d643ffc4674
1 /*
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>
6 Han-Wen Nienhuys
7 */
10 #include "box.hh"
11 #include "debug.hh"
12 #include "lookup.hh"
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,1)
20 SCM
21 Lyric_extender::brew_molecule (SCM smob)
23 Spanner *sp = dynamic_cast<Spanner*> (unsmob_grob (smob));
25 // ugh: refp
26 Real leftext = sp->get_bound (LEFT)->extent (sp->get_bound (LEFT),
27 X_AXIS).length ();
29 Real sl = sp->paper_l ()->get_var ("stafflinethickness");
30 Real righttrim = 0.5; // default to half a space gap on the right
31 SCM righttrim_scm = sp->get_grob_property("right-trim-amount");
32 if (gh_number_p (righttrim_scm)) {
33 righttrim = gh_scm2double (righttrim_scm);
35 // The extender can exist in the word space of the left lyric ...
36 SCM space = sp->get_bound (LEFT)->get_grob_property ("word-space");
37 if (gh_number_p (space))
39 leftext -= gh_scm2double (space);
41 Real w = sp->spanner_length () - leftext - righttrim;
43 Real h = sl * gh_scm2double (sp->get_grob_property ("height"));
44 Molecule mol (Lookup::filledbox ( Box (Interval (0,w), Interval (0,h))));
45 mol.translate (Offset (leftext, 0));
46 return mol.smobbed_copy();
49 void
50 Lyric_extender::set_textitem (Direction d, Grob*s)
52 elt_l_->set_bound (d, s);
53 elt_l_->add_dependency (s);
56 Lyric_extender::Lyric_extender (Spanner*s)
58 elt_l_ = s;