X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fscript.cc;h=44ee942f2a71775b14010fa5223d8d14379423b9;hb=d9b43b93f2c885409bafdb157138158f65cc49aa;hp=2a31133c331d121f75c33fc3c024eba0e1191ec5;hpb=daee8243ff1c66bc714455a2d265ab02f03546ec;p=lilypond.git diff --git a/lily/script.cc b/lily/script.cc index 2a31133c33..44ee942f2a 100644 --- a/lily/script.cc +++ b/lily/script.cc @@ -1,129 +1,92 @@ -#include "musicalrequest.hh" -#include "paper-def.hh" +/* + script.cc -- implement Script + + source file of the GNU LilyPond music typesetter + + (c) 1999--2002 Han-Wen Nienhuys + + */ + +#include "debug.hh" #include "script.hh" -#include "stem.hh" +#include "font-interface.hh" +#include "side-position-interface.hh" +#include "paper-def.hh" +#include "item.hh" #include "molecule.hh" #include "lookup.hh" - - -void -Script::set_stem(Stem*st_l) -{ - stem_l_ = st_l; - add_dependency(st_l); -} - -void -Script::set_support(Item*i) +Molecule +Script::get_molecule (Grob * me, Direction d) { - support.push(i); - add_dependency(i); -} + SCM s = me->get_grob_property ("molecule"); + assert (gh_pair_p (s)); + + SCM key = ly_car (s); + if (key == ly_symbol2scm ("feta")) + { + return Font_interface::get_default_font (me)->find_by_name ("scripts-" + + ly_scm2string (index_cell (ly_cdr (s), d))); + } + else if (key == ly_symbol2scm ("accordion")) + { + return Lookup::accordion (ly_cdr (s), 1.0, Font_interface::get_default_font (me)); + } + else + assert (false); -Script::Script(Script_req* rq, int staflen) -{ - staffsize =staflen; - specs_l_ = rq->scriptdef_p_; - stem_l_ = 0; - pos = 0; - symdir=1; - dir =rq->dir_i_; + return Molecule (); } -void -Script::set_symdir() +MAKE_SCHEME_CALLBACK (Script,before_line_breaking,1); +SCM +Script::before_line_breaking (SCM smob) { - if (specs_l_->invertsym) - symdir = (dir < 0) ? -1:1; -} + Grob * me = unsmob_grob (smob); -void -Script::set_default_dir() -{ - if (specs_l_->stemdir) { - if (!stem_l_) - dir = 1; - else - dir = stem_l_->dir * specs_l_->stemdir; + 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); -Interval -Script::support_height() const return r; -{ - for (int i=0; i < support.size(); i++) - r.unite(support[i]->height()); + return SCM_UNSPECIFIED; } -void -Script::set_default_index() -{ - Real inter_f= paper()->internote(); - Interval dy = symbol().dim.y; - - int d = specs_l_->staffdir; - Real y ; - if (!d) { - Interval v= support_height(); - y = v[dir] -dy[-dir] + 2*dir*inter_f; - } else { - y = (d > 0) ? staffsize + 2: -2; // ug - y *=inter_f; - Interval v= support_height(); - if (d > 0) { - y = y >? v.max(); - } else if (d < 0) { - y = y height(); +MAKE_SCHEME_CALLBACK (Script,brew_molecule,1); - if (d > 0 || (!d && dir > 0)) { - y = y >? v.max(); - }else if (d < 0 || (!d && dir < 0)) { - y = y lookup_p_->script(preidx_str + specs_l_->symidx); + Direction dir = Side_position_interface::get_direction (me); + if (!dir) + { + programming_error ("Script direction not known, but molecule wanted."); + dir= DOWN; + } + + return get_molecule (me, dir).smobbed_copy (); } -void -Script::do_pre_processing() +bool +Script::has_interface (Grob*me) { - set_default_dir(); - set_symdir(); + return me->has_interface (ly_symbol2scm ("script-interface")); } void -Script::do_post_processing() +Script::set_interface (Grob*me) { - set_default_index(); + return me->set_interface (ly_symbol2scm ("script-interface")); } -Molecule* -Script::brew_molecule_p() const -{ - Real dy = paper()->internote(); - - Molecule*out = new Molecule(Atom(symbol())); - out->translate(Offset(0,dy * pos)); - return out; -}