X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fscript.cc;h=72d022130980d65d8d2ccb7b1a4fc676d6472df0;hb=237583408aaf3b2192c388c3183d9c57fb051bd0;hp=f523de37bb310d151545aedb4d5bbf50bfc8d997;hpb=59e4ae99bad964d00dc167919779301c5ec2a535;p=lilypond.git diff --git a/lily/script.cc b/lily/script.cc index f523de37bb..72d0221309 100644 --- a/lily/script.cc +++ b/lily/script.cc @@ -1,70 +1,114 @@ /* - script.cc -- implement Script + script.cc -- implement Script_interface source file of the GNU LilyPond music typesetter - (c) 1999 Han-Wen Nienhuys + (c) 1999--2003 Han-Wen Nienhuys */ -#include "debug.hh" +#include "warn.hh" #include "script.hh" -#include "lookup.hh" -#include "staff-side.hh" +#include "font-interface.hh" +#include "side-position-interface.hh" #include "paper-def.hh" -#include "dimension-cache.hh" - +#include "item.hh" +#include "molecule.hh" +#include "lookup.hh" +#include "stem.hh" +#include "note-column.hh" Molecule -Script::get_molecule(Direction d) const +Script_interface::get_molecule (Grob * me, Direction d) { - SCM s = get_elt_property ("molecule"); - assert (s != SCM_UNDEFINED); + SCM s = me->get_grob_property ("script-molecule"); + assert (gh_pair_p (s)); - SCM key = SCM_CAR (s); + SCM key = ly_car (s); if (key == ly_symbol2scm ("feta")) { - return lookup_l ()->afm_find ("scripts-" + - ly_scm2string (index_cell (gh_cdr (s), d))); + SCM name_entry = ly_cdr (s); + + SCM str = (gh_pair_p (name_entry)) ? index_get_cell (name_entry, d) : name_entry; + return Font_interface::get_default_font (me)->find_by_name ("scripts-" + + ly_scm2string (str)); } - else if (key == ly_symbol2scm ("accordion")) + else if (key == ly_symbol2scm ("accordion")) { - return lookup_l ()->accordion (s, paper_l()->get_var("interline")); + return Lookup::accordion (ly_cdr (s), 1.0, Font_interface::get_default_font (me)); } - - else assert (false); + else + assert (false); return Molecule (); } - -void -Script::do_pre_processing () +MAKE_SCHEME_CALLBACK (Script_interface,before_line_breaking,1); +SCM +Script_interface::before_line_breaking (SCM smob) { - /* - center my self on the note head. - */ - Graphical_element * e = parent_l(X_AXIS); - translate_axis (e->extent (X_AXIS).center (), X_AXIS); -} + Grob * me = unsmob_grob (smob); -void -Script::do_post_processing () -{ - Direction d = Side_position_interface (this).get_direction (); - Molecule m (get_molecule(d)); + Direction d = Side_position_interface::get_direction (me); + + if (!d) + { + /* + we should not have `arbitrary' directions. + */ + programming_error ("Script direction not yet known!"); + d = DOWN; + } + + Side_position_interface::set_direction (me,d); + + if (Grob * par = me->get_parent (X_AXIS)) + { + Grob * stem = Note_column::get_stem (par); + if (stem && Stem::first_head (stem)) + { + me->set_parent (Stem::first_head (stem), X_AXIS); + } + } + + return SCM_UNSPECIFIED; } -Molecule* -Script::do_brew_molecule_p () const + +MAKE_SCHEME_CALLBACK (Script_interface,brew_molecule,1); + +SCM +Script_interface::brew_molecule (SCM smob) { - Direction dir = DOWN; - SCM d = get_elt_property ("direction"); - if (isdir_b (d)) - dir = to_dir (d); + Grob *me= unsmob_grob (smob); + + Direction dir = Side_position_interface::get_direction (me); + if (!dir) + { + programming_error ("Script direction not known, but molecule wanted."); + dir= DOWN; + } - return new Molecule (get_molecule (dir)); + return get_molecule (me, dir).smobbed_copy (); } +struct Text_script +{ + static bool has_interface (Grob*); +}; + +struct Skript +{ + static bool has_interface (Grob*); +}; + +ADD_INTERFACE (Text_script,"text-script-interface", + "Any text script", + "script-priority"); + +ADD_INTERFACE (Script_interface, "script-interface", + "", + "script-priority script-molecule"); +