]> git.donarmstrong.com Git - lilypond.git/blob - lily/sustain-pedal.cc
Issue 4550 (1/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / sustain-pedal.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2000--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
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.
10
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.
15
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/>.
18 */
19 #include "grob.hh"
20 #include "stencil.hh"
21 #include "font-interface.hh"
22
23 using std::string;
24
25 // update comment --hwn
26 /*
27   Urg.
28   This is almost text
29   Problem is:
30   * we have no kerning
31   * symbols are at wrong place in font
32
33
34
35   Properties:
36
37   glyph -- text string (TODO: make one large glyph of the Ped symbol, removes need for member_print ())
38 */
39
40 /*
41   FIXME. Need to use markup.
42 */
43 struct Sustain_pedal
44 {
45 public:
46   DECLARE_SCHEME_CALLBACK (print, (SCM));
47 };
48
49 MAKE_SCHEME_CALLBACK (Sustain_pedal, print, 1);
50 SCM
51 Sustain_pedal::print (SCM smob)
52 {
53   Grob *e = unsmob<Grob> (smob);
54
55   Stencil mol;
56   SCM glyph = e->get_property ("text");
57   if (!scm_is_string (glyph))
58     return mol.smobbed_copy ();
59
60   string text = ly_scm2string (glyph);
61
62   for (ssize i = 0; i < text.length (); i++)
63     {
64       string idx ("pedal.");
65       if (text.substr (i, 3) == "Ped")
66         {
67           idx += "Ped";
68           i += 2;
69         }
70       else
71         idx += string (&text.c_str ()[i], 1);
72       Stencil m = Font_interface::get_default_font (e)->find_by_name (idx);
73       if (!m.is_empty ())
74         mol.add_at_edge (X_AXIS, RIGHT, m, 0);
75     }
76
77   return mol.smobbed_copy ();
78 }
79