2 lyric-extender.cc -- implement Lyric_extender
3 source file of the GNU LilyPond music typesetter
5 (c) 1998--2003 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
= unsmob_spanner (smob
);
24 Item
* l
= sp
->get_bound (LEFT
);
25 Item
*r
= sp
->get_bound (RIGHT
);
27 Real leftext
= l
->extent (l
, X_AXIS
).length ();
29 Real sl
= sp
->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
30 Real righttrim
= 0.5; // default to half a space gap on the right
34 If we're broken, we shouldn't extend past the end of the line.
36 if (r
->break_status_dir () == CENTER
)
38 SCM righttrim_scm
= sp
->get_grob_property ("right-trim-amount");
39 if (gh_number_p (righttrim_scm
))
41 righttrim
= gh_scm2double (righttrim_scm
);
45 // The extender can exist in the word space of the left lyric ...
46 SCM space
= sp
->get_bound (LEFT
)->get_grob_property ("word-space");
47 if (gh_number_p (space
))
49 leftext
-= gh_scm2double (space
);
51 Real w
= sp
->spanner_length () - leftext
- righttrim
;
53 Real h
= sl
* gh_scm2double (sp
->get_grob_property ("height"));
54 Molecule
mol (Lookup::filledbox (Box (Interval (0,w
), Interval (0,h
))));
55 mol
.translate (Offset (leftext
, 0));
56 return mol
.smobbed_copy ();
60 Lyric_extender::set_textitem (Spanner
*sp
, Direction d
, Grob
*s
)
63 sp
->add_dependency (s
);
69 ADD_INTERFACE (Lyric_extender
,"lyric-extender-interface",
70 "The extender is a simple line at the baseline of the lyric "
71 " that helps show the length of a melissima (tied/slurred note).",
72 "word-space height right-trim-amount");