2 lyric-extender.cc -- implement Lyric_extender
3 source file of the GNU LilyPond music typesetter
5 (c) 1998--2001 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
,1)
21 Lyric_extender::brew_molecule (SCM smob
)
23 Spanner
*sp
= dynamic_cast<Spanner
*> (unsmob_grob (smob
));
26 Real leftext
= sp
->get_bound (LEFT
)->extent (sp
->get_bound (LEFT
),
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 ();
50 Lyric_extender::set_textitem (Spanner
*sp
, Direction d
, Grob
*s
)
53 sp
->add_dependency (s
);