]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-extender.cc
patch::: 1.3.76.gp1
[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--2000 Jan Nieuwenhuizen <janneke@gnu.org>
6   Han-Wen Nienhuys
7 */
8
9
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"
17
18
19 MAKE_SCHEME_CALLBACK(Lyric_extender,brew_molecule)
20 SCM 
21 Lyric_extender::brew_molecule (SCM smob) 
22 {
23   Spanner *sp = dynamic_cast<Spanner*> (unsmob_element (smob));
24   
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);
31   }
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))
35     {
36       leftext -=  gh_scm2double (space)*ss;
37     }
38   Real w = sp->spanner_length () - leftext - righttrim*ss;
39   
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();
44 }
45
46 void
47 Lyric_extender::set_textitem (Direction d, Score_element*s)
48 {
49   elt_l_->set_bound (d, s);
50   elt_l_->add_dependency (s);
51 }
52
53 Lyric_extender::Lyric_extender (Spanner*s)
54 {
55   elt_l_ = s;
56 }
57