]> git.donarmstrong.com Git - lilypond.git/blob - lily/sustain-pedal.cc
patch::: 1.3.58.jcn1
[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 ("pedal-");
39       if (text.cut_str (i, i + 2) == "Ped")
40         {
41           idx += "Ped";
42           i += 2;
43         }
44       else
45         idx += String (&text.byte_C ()[i], 1);
46       Molecule m = lookup_l ()->afm_find (idx);
47       if (!m.empty_b ())
48         mol.add_at_edge (X_AXIS, RIGHT, m, 0);
49     }
50     
51   return mol;
52 }
53
54 Sustain_pedal ::Sustain_pedal(SCM s )
55   : Item (s)
56 {
57 }