]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-extender.cc
* scm/font.scm (paper20-font-vector): add bold-narrow series (only
[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 h = sl * gh_scm2double (me->get_grob_property ("thickness"));
42
43   right_point += h;
44
45   Real w = right_point - left_point;
46
47   if (w < 0)
48     return SCM_EOL;
49   
50   Molecule  mol (Lookup::round_filled_box (Box (Interval (0,w), Interval (0,h)),
51                                            0.8 * h));
52   mol.translate_axis (left_point - me->relative_coordinate (common, X_AXIS), X_AXIS);
53   return mol.smobbed_copy ();
54 }
55
56 void
57 Lyric_extender::set_textitem (Spanner *me, Direction d, Grob *s)
58 {
59   me->set_bound (d, s);
60   me->add_dependency (s);
61 }
62
63
64
65
66 ADD_INTERFACE (Lyric_extender,"lyric-extender-interface",
67   "The extender is a simple line at the baseline of the lyric "
68   " that helps show the length of a melissima (tied/slurred note).",
69   "thickness");