]> git.donarmstrong.com Git - lilypond.git/blob - lily/clef.cc
release: 1.5.47
[lilypond.git] / lily / clef.cc
1
2 /*
3   clef.cc -- implement Clef_item
4
5   source file of the GNU LilyPond music typesetter
6
7   (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9
10
11 #include "clef.hh"
12 #include "string.hh"
13 #include "molecule.hh"
14 #include "item.hh"
15 #include "font-interface.hh"
16
17 /*
18  FIXME: should use symbol for #'style.
19 */
20 MAKE_SCHEME_CALLBACK (Clef,before_line_breaking,1);
21 SCM
22 Clef::before_line_breaking (SCM smob)
23 {
24   Item * s = unsmob_item (smob);
25
26   SCM glyph = s->get_grob_property ("glyph-name");
27   
28   if (gh_string_p (glyph))
29     {
30       String str = ly_scm2string (glyph);
31
32       if (to_boolean (s->get_grob_property ("non-default"))
33           && s->break_status_dir () != RIGHT
34           && !to_boolean (s->get_grob_property ("full-size-change")))
35         {
36           str += "_change";
37           s->set_grob_property ("glyph-name", ly_str02scm (str.ch_C ()));         
38         }
39     }
40   else
41     {
42       s->suicide ();
43       return SCM_UNSPECIFIED;
44     }
45
46   return SCM_UNSPECIFIED;
47 }
48
49 bool
50 Clef::has_interface (Grob* me)
51 {
52   return me->has_interface (ly_symbol2scm ("clef-interface"));
53 }
54
55
56
57 MAKE_SCHEME_CALLBACK (Clef,brew_molecule,1)
58 SCM
59 Clef::brew_molecule (SCM smob) 
60 {
61   Grob * sc = unsmob_grob (smob);
62   SCM glyph = sc->get_grob_property ("glyph-name");
63   if (gh_string_p (glyph))
64     {
65       return Font_interface::get_default_font (sc)->find_by_name (String (ly_scm2string (glyph))).smobbed_copy ();
66     }
67   else
68     {
69       return SCM_EOL;
70     }
71 }
72
73
74 ADD_INTERFACE (Clef, "clef-interface",
75   "A clef sign",
76   "non-default full-size-change glyph-name");
77