]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-extender.cc
updates
[lilypond.git] / lily / lyric-extender.cc
1 /*
2   lyric-extender.cc -- implement Lyric_extender
3   source file of the GNU LilyPond music typesetter
4
5   (c)  1998--2003 Jan Nieuwenhuizen <janneke@gnu.org>
6   Han-Wen Nienhuys
7 */
8
9
10 #include "box.hh"
11 #include "warn.hh"
12 #include "lookup.hh"
13 #include "molecule.hh"
14 #include "paper-column.hh"
15 #include "paper-def.hh"
16 #include "lyric-extender.hh"
17
18
19 MAKE_SCHEME_CALLBACK (Lyric_extender,brew_molecule,1)
20 SCM 
21 Lyric_extender::brew_molecule (SCM smob) 
22 {
23   Spanner *sp = unsmob_spanner (smob);
24   Item* l = sp->get_bound (LEFT);
25   Item*r = sp->get_bound (RIGHT);
26   
27   Real leftext = l->extent (l, X_AXIS).length ();
28
29   Real sl = sp->get_paper ()->get_var ("linethickness");  
30   Real righttrim = 0.5; // default to half a space gap on the right
31
32
33   /*
34     If we're broken, we shouldn't extend past the end of the line.
35    */
36   if (r->break_status_dir () == CENTER)
37     {
38       SCM righttrim_scm = sp->get_grob_property ("right-trim-amount");
39       if (gh_number_p (righttrim_scm))
40         {
41           righttrim = gh_scm2double (righttrim_scm);
42         }
43     }
44   
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))
48     {
49       leftext -=  gh_scm2double (space);
50     }
51   Real w = sp->spanner_length () - leftext - righttrim;
52   
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 ();
57 }
58
59 void
60 Lyric_extender::set_textitem (Spanner*sp, Direction d, Grob*s)
61 {
62   sp->set_bound (d, s);
63   sp->add_dependency (s);
64 }
65
66
67
68
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");