]> git.donarmstrong.com Git - lilypond.git/blob - lily/sustain-pedal.cc
lilypond-1.3.59
[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   return ;
20   /*
21     UGH. Should work automatically via offset callback. 
22    */
23   Side_position_interface i (this);
24   Direction d =  i.get_direction ();
25   i.set_direction (d);
26 }
27
28 MAKE_SCHEME_SCORE_ELEMENT_NON_DEFAULT_CALLBACKS(Sustain_pedal);
29
30
31 SCM
32 Sustain_pedal::scheme_molecule (SCM smob) 
33 {
34   Score_element * e = unsmob_element (smob);
35   
36   Molecule mol;
37   SCM glyph = e->get_elt_property ("text");
38   if (!gh_string_p (glyph))
39     return mol.create_scheme();
40   String text = ly_scm2string (glyph);
41
42   for (int i = 0; i < text.length_i (); i++)
43     {
44       String idx ("pedal-");
45       if (text.cut_str (i, 3) == "Ped")
46         {
47           idx += "Ped";
48           i += 2;
49         }
50       else
51         idx += String (&text.byte_C ()[i], 1);
52       Molecule m = e->lookup_l ()->afm_find (idx);
53       if (!m.empty_b ())
54         mol.add_at_edge (X_AXIS, RIGHT, m, 0);
55     }
56     
57   return mol.create_scheme ();
58 }
59
60 Sustain_pedal ::Sustain_pedal(SCM s )
61   : Item (s)
62 {
63 }