]> git.donarmstrong.com Git - lilypond.git/blob - lily/script.cc
complete rewrite of multiplicity. This fixes 16th
[lilypond.git] / lily / script.cc
1 /*   
2   script.cc --  implement Script_interface
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 "warn.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 #include "stem.hh"
19 #include "note-column.hh"
20
21 Molecule
22 Script_interface::get_molecule (Grob * me, Direction d)
23 {
24   SCM s = me->get_grob_property ("script-molecule");
25   assert (gh_pair_p (s));
26
27   SCM key = ly_car (s);
28   if (key == ly_symbol2scm ("feta"))
29     {
30       return Font_interface::get_default_font (me)->find_by_name ("scripts-" +
31                                     ly_scm2string (index_get_cell (ly_cdr (s), d)));
32     }
33   else if (key == ly_symbol2scm ("accordion"))
34     {
35       return Lookup::accordion (ly_cdr (s), 1.0, Font_interface::get_default_font (me));
36     }
37   else
38     assert (false);
39
40   return Molecule ();
41 }
42
43 MAKE_SCHEME_CALLBACK (Script_interface,before_line_breaking,1);
44 SCM
45 Script_interface::before_line_breaking (SCM smob)
46 {
47   Grob * me = unsmob_grob (smob);
48
49   Direction d = Side_position_interface::get_direction (me);
50
51   if (!d)
52     {
53       /*
54         we should not have `arbitrary' directions. 
55       */
56       programming_error ("Script direction not yet known!");
57       d = DOWN;
58     }
59   
60   Side_position_interface::set_direction (me,d);
61
62   if (Grob * par = me->get_parent (X_AXIS))
63     {
64       Grob * stem = Note_column::stem_l (par);
65       if (stem && Stem::first_head (stem))
66         {
67           me->set_parent (Stem::first_head (stem), X_AXIS);
68         }
69     }
70   
71   return SCM_UNSPECIFIED;
72 }
73
74
75 MAKE_SCHEME_CALLBACK (Script_interface,brew_molecule,1);
76
77 SCM
78 Script_interface::brew_molecule (SCM smob)
79 {
80   Grob *me= unsmob_grob (smob);
81
82   Direction dir = Side_position_interface::get_direction (me);
83   if (!dir)
84     {
85       programming_error ("Script direction not known, but molecule wanted.");
86       dir= DOWN;
87     }
88   
89   return get_molecule (me, dir).smobbed_copy ();
90 }
91
92
93
94 struct Text_script
95 {
96     static bool has_interface (Grob*);
97 };
98
99 struct Skript
100 {
101     static bool has_interface (Grob*);
102 };
103
104 ADD_INTERFACE (Text_script,"text-script-interface",
105   "Any text script",
106   "script-priority");
107
108 ADD_INTERFACE (Script_interface, "script-interface",
109   "",
110   "script-priority script-molecule staff-support");
111