(process_acknowledged_grobs):
[lilypond.git] / lily / script.cc
blob72d022130980d65d8d2ccb7b1a4fc676d6472df0
1 /*
2 script.cc -- implement Script_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
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"
21 Molecule
22 Script_interface::get_molecule (Grob * me, Direction d)
24 SCM s = me->get_grob_property ("script-molecule");
25 assert (gh_pair_p (s));
27 SCM key = ly_car (s);
28 if (key == ly_symbol2scm ("feta"))
30 SCM name_entry = ly_cdr (s);
32 SCM str = (gh_pair_p (name_entry)) ? index_get_cell (name_entry, d) : name_entry;
33 return Font_interface::get_default_font (me)->find_by_name ("scripts-" +
34 ly_scm2string (str));
36 else if (key == ly_symbol2scm ("accordion"))
38 return Lookup::accordion (ly_cdr (s), 1.0, Font_interface::get_default_font (me));
40 else
41 assert (false);
43 return Molecule ();
46 MAKE_SCHEME_CALLBACK (Script_interface,before_line_breaking,1);
47 SCM
48 Script_interface::before_line_breaking (SCM smob)
50 Grob * me = unsmob_grob (smob);
52 Direction d = Side_position_interface::get_direction (me);
54 if (!d)
57 we should not have `arbitrary' directions.
59 programming_error ("Script direction not yet known!");
60 d = DOWN;
63 Side_position_interface::set_direction (me,d);
65 if (Grob * par = me->get_parent (X_AXIS))
67 Grob * stem = Note_column::get_stem (par);
68 if (stem && Stem::first_head (stem))
70 me->set_parent (Stem::first_head (stem), X_AXIS);
74 return SCM_UNSPECIFIED;
78 MAKE_SCHEME_CALLBACK (Script_interface,brew_molecule,1);
80 SCM
81 Script_interface::brew_molecule (SCM smob)
83 Grob *me= unsmob_grob (smob);
85 Direction dir = Side_position_interface::get_direction (me);
86 if (!dir)
88 programming_error ("Script direction not known, but molecule wanted.");
89 dir= DOWN;
92 return get_molecule (me, dir).smobbed_copy ();
97 struct Text_script
99 static bool has_interface (Grob*);
102 struct Skript
104 static bool has_interface (Grob*);
107 ADD_INTERFACE (Text_script,"text-script-interface",
108 "Any text script",
109 "script-priority");
111 ADD_INTERFACE (Script_interface, "script-interface",
113 "script-priority script-molecule");