]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-extender.cc
* lily/lyric-phrasing-engraver.cc: move from
[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 #include "note-head.hh"
18
19 MAKE_SCHEME_CALLBACK (Lyric_extender,brew_molecule,1)
20 SCM 
21 Lyric_extender::brew_molecule (SCM smob) 
22 {
23   Spanner *me = unsmob_spanner (smob);
24   Item *l = me->get_bound (LEFT);
25   Item *r = me->get_bound (RIGHT);
26   Grob *common = l->common_refpoint (r, X_AXIS);
27   
28   Real left_point = l->extent (common, X_AXIS)[RIGHT];
29
30   Real sl = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));  
31
32
33   /*
34     It seems that short extenders are even lengthened to go past the note head,  but
35     haven't found a pattern in it yet. --hwn  1/1/04
36     
37    */
38   Real right_point = r->extent (common, X_AXIS)
39     [(Note_head::has_interface (r)) ? RIGHT : LEFT];
40   
41   Real w = right_point - left_point;
42
43   Real h = sl * gh_scm2double (me->get_grob_property ("thickness"));
44   
45   Molecule  mol (Lookup::filledbox (Box (Interval (0,w), Interval (0,h))));
46   mol.translate_axis (left_point - me->relative_coordinate (common, X_AXIS), X_AXIS);
47   return mol.smobbed_copy ();
48 }
49
50 void
51 Lyric_extender::set_textitem (Spanner *me, Direction d, Grob *s)
52 {
53   me->set_bound (d, s);
54   me->add_dependency (s);
55 }
56
57
58
59
60 ADD_INTERFACE (Lyric_extender,"lyric-extender-interface",
61   "The extender is a simple line at the baseline of the lyric "
62   " that helps show the length of a melissima (tied/slurred note).",
63   "thickness");