]> git.donarmstrong.com Git - lilypond.git/blob - lily/sustain-pedal.cc
release: 1.3.55
[lilypond.git] / lily / sustain-pedal.cc
1 /*   
2   sustain-pedal.cc --  implement Sustain_pedal
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "sustain-pedal.hh"
11 #include "side-position-interface.hh"
12 #include "molecule.hh"
13 #include "lookup.hh"
14 #include "staff-symbol-referencer.hh"
15
16 void
17 Sustain_pedal::after_line_breaking ()
18 {
19   /*
20     UGH. Should work automatically via offset callback. 
21    */
22   Side_position_interface i (this);
23   Direction d =  i.get_direction ();
24   i.set_direction (d);
25 }
26
27 Molecule
28 Sustain_pedal::do_brew_molecule () const
29 {
30   Molecule mol;
31   SCM glyph = get_elt_property ("text");
32   if (glyph == SCM_UNDEFINED)
33     return mol;
34   String text = ly_scm2string (glyph);
35
36   for (int i = 0; i < text.length_i (); i++)
37     {
38       String idx = String ("pedal-") + String (&text.byte_C ()[i], 1);
39       Molecule m = lookup_l ()->afm_find (idx);
40       if (m.empty_b ())
41         continue;
42       Real kern = 0;
43       if (i)
44         {
45           SCM s = scm_eval (gh_list (ly_symbol2scm ("pedal-kerning"),
46                                      ly_str02scm (String (&text.byte_C ()[i - 1], 1).ch_C ()),
47                                      ly_str02scm (String (&text.byte_C ()[i], 1).ch_C ()),
48                                      SCM_UNDEFINED));
49           if (gh_number_p (s))
50             {
51               Staff_symbol_referencer_interface st (this);
52               Real staff_space = st.staff_space ();
53               kern = gh_scm2double (s) * staff_space;
54             }
55         }
56       mol.add_at_edge (X_AXIS, RIGHT, m, kern);
57     }
58     
59   return mol;
60 }
61
62
63
64 Sustain_pedal ::Sustain_pedal(SCM s )
65   : Item (s)
66 {}