]> git.donarmstrong.com Git - lilypond.git/blob - lily/script.cc
release: 1.5.29
[lilypond.git] / lily / script.cc
1 /*   
2   script.cc --  implement Script
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "debug.hh"
11 #include "script.hh"
12 #include "font-interface.hh"
13 #include "side-position-interface.hh"
14 #include "paper-def.hh"
15 #include "item.hh"
16 #include "molecule.hh"
17 #include "lookup.hh"
18
19 Molecule
20 Script::get_molecule (Grob * me, Direction d)
21 {
22   SCM s = me->get_grob_property ("molecule");
23   assert (gh_pair_p (s));
24
25   SCM key = ly_car (s);
26   if (key == ly_symbol2scm ("feta"))
27     {
28       return Font_interface::get_default_font (me)->find_by_name ("scripts-" +
29                                     ly_scm2string (index_cell (ly_cdr (s), d)));
30     }
31   else if (key == ly_symbol2scm ("accordion"))
32     {
33       return Lookup::accordion (ly_cdr (s), 1.0, Font_interface::get_default_font (me));
34     }
35   else
36     assert (false);
37
38   return Molecule ();
39 }
40
41 MAKE_SCHEME_CALLBACK (Script,before_line_breaking,1);
42 SCM
43 Script::before_line_breaking (SCM smob)
44 {
45   Grob * me = unsmob_grob (smob);
46
47   Direction d = Side_position_interface::get_direction (me);
48
49   if (!d)
50     {
51   /*
52     we should not have `arbitrary' directions. 
53    */
54       programming_error ("Script direction not yet known!");
55       d = DOWN;
56     }
57   
58   Side_position_interface::set_direction (me,d);
59
60   return SCM_UNSPECIFIED;
61 }
62
63
64 MAKE_SCHEME_CALLBACK (Script,brew_molecule,1);
65
66 SCM
67 Script::brew_molecule (SCM smob)
68 {
69   Grob *me= unsmob_grob (smob);
70
71   Direction dir = Side_position_interface::get_direction (me);
72   if (!dir)
73     {
74       programming_error ("Script direction not known, but molecule wanted.");
75       dir= DOWN;
76     }
77   
78   return get_molecule (me, dir).smobbed_copy ();
79 }
80
81 bool
82 Script::has_interface (Grob*me)
83 {
84   return me->has_interface (ly_symbol2scm ("script-interface"));
85 }
86
87 void
88 Script::set_interface (Grob*me)
89 {
90   return me->set_interface (ly_symbol2scm ("script-interface"));
91 }
92