Improve handling of nested overrides using list syntax.
[lilypond/mpolesky.git] / lily / sustain-pedal.cc
blob7880e0e0da51cd8a4d2fac46c93d31382986feaa
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
19 #include "grob.hh"
20 #include "stencil.hh"
21 #include "font-interface.hh"
23 // update comment --hwn
25 Urg.
26 This is almost text
27 Problem is:
28 * we have no kerning
29 * symbols are at wrong place in font
33 Properties:
35 glyph -- text string (TODO: make one large glyph of the Ped symbol, removes need for member_print ())
39 FIXME. Need to use markup.
41 struct Sustain_pedal
43 public:
44 DECLARE_SCHEME_CALLBACK (print, (SCM));
47 MAKE_SCHEME_CALLBACK (Sustain_pedal, print, 1);
48 SCM
49 Sustain_pedal::print (SCM smob)
51 Grob *e = unsmob_grob (smob);
53 Stencil mol;
54 SCM glyph = e->get_property ("text");
55 if (!scm_is_string (glyph))
56 return mol.smobbed_copy ();
58 string text = ly_scm2string (glyph);
60 for (ssize i = 0; i < text.length (); i++)
62 string idx ("pedal.");
63 if (text.substr (i, 3) == "Ped")
65 idx += "Ped";
66 i += 2;
68 else
69 idx += string (&text.c_str ()[i], 1);
70 Stencil m = Font_interface::get_default_font (e)->find_by_name (idx);
71 if (!m.is_empty ())
72 mol.add_at_edge (X_AXIS, RIGHT, m, 0);
75 return mol.smobbed_copy ();