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>
12 #include "font-interface.hh"
13 #include "side-position-interface.hh"
14 #include "paper-def.hh"
16 #include "molecule.hh"
19 #include "note-column.hh"
22 Script_interface::get_molecule (Grob
* me
, Direction d
)
24 SCM s
= me
->get_grob_property ("script-molecule");
25 assert (gh_pair_p (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-" +
36 else if (key
== ly_symbol2scm ("accordion"))
38 return Lookup::accordion (ly_cdr (s
), 1.0, Font_interface::get_default_font (me
));
46 MAKE_SCHEME_CALLBACK (Script_interface
,before_line_breaking
,1);
48 Script_interface::before_line_breaking (SCM smob
)
50 Grob
* me
= unsmob_grob (smob
);
52 Direction d
= Side_position_interface::get_direction (me
);
57 we should not have `arbitrary' directions.
59 programming_error ("Script direction not yet known!");
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);
81 Script_interface::brew_molecule (SCM smob
)
83 Grob
*me
= unsmob_grob (smob
);
85 Direction dir
= Side_position_interface::get_direction (me
);
88 programming_error ("Script direction not known, but molecule wanted.");
92 return get_molecule (me
, dir
).smobbed_copy ();
99 static bool has_interface (Grob
*);
104 static bool has_interface (Grob
*);
107 ADD_INTERFACE (Text_script
,"text-script-interface",
111 ADD_INTERFACE (Script_interface
, "script-interface",
113 "script-priority script-molecule");