2 script-interface.cc -- implement Script_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "directional-element-interface.hh"
12 #include "script-interface.hh"
13 #include "font-interface.hh"
14 #include "side-position-interface.hh"
15 #include "output-def.hh"
18 #include "note-column.hh"
21 Script_interface::get_stencil (Grob *me, Direction d)
23 SCM s = me->get_property ("script-stencil");
24 assert (scm_is_pair (s));
26 SCM key = scm_car (s);
27 if (key == ly_symbol2scm ("feta"))
29 SCM name_entry = scm_cdr (s);
30 SCM str = ((scm_is_pair (name_entry)) ? index_get_cell (name_entry, d)
32 return Font_interface::get_default_font (me)
33 ->find_by_name ("scripts." + ly_scm2string (str));
35 else if (key == ly_symbol2scm ("accordion"))
36 return Lookup::accordion (scm_cdr (s), 1.0,
37 Font_interface::get_default_font (me));
44 MAKE_SCHEME_CALLBACK (Script_interface, before_line_breaking, 1);
46 Script_interface::before_line_breaking (SCM smob)
48 Grob *me = unsmob_grob (smob);
50 Direction d = Side_position_interface::get_direction (me);
54 /* FIXME: This should never happen: `arbitrary' directions. */
55 programming_error ("Script direction not yet known!");
59 set_grob_direction (me, d);
61 if (Grob *par = me->get_parent (X_AXIS))
63 Grob *stem = Note_column::get_stem (par);
64 if (stem && Stem::first_head (stem))
65 me->set_parent (Stem::first_head (stem), X_AXIS);
67 return SCM_UNSPECIFIED;
70 MAKE_SCHEME_CALLBACK (Script_interface, print, 1);
73 Script_interface::print (SCM smob)
75 Grob *me = unsmob_grob (smob);
77 Direction dir = Side_position_interface::get_direction (me);
80 programming_error ("Script direction not known, but stencil wanted.");
83 return get_stencil (me, dir).smobbed_copy ();
88 static bool has_interface (Grob*);
91 ADD_INTERFACE (Text_script,"text-script-interface",
92 "An object that is put above or below a note",
93 "add-stem-support slur script-priority inside-slur");
97 Hmm. Where should we put add-stem-support ?
99 ADD_INTERFACE (Script_interface, "script-interface",
100 "An object that is put above or below a note",
101 "add-stem-support slur-padding slur script-priority script-stencil inside-slur");