]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/script.cc
release: 1.3.89
[lilypond.git] / lily / script.cc
index 1bcbd518a8eeb899f6b562d1502d3ab285eac778..333593a2d8e12cf6db475e343b7f04ac04c15ae1 100644 (file)
-#include "musicalrequest.hh"
-#include "paper-def.hh"
+/*   
+  script.cc --  implement Script
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
+
+#include "debug.hh"
 #include "script.hh"
-#include "stem.hh"
-#include "molecule.hh"
 #include "lookup.hh"
+#include "side-position-interface.hh"
+#include "paper-def.hh"
+#include "item.hh"
 
-
-
-void
-Script::set_stem(Stem*st_l)
-{
-    stem_l_ = st_l;
-    add_dependency(st_l);
-}
-
-void
-Script::set_support(Item*i)
-{
-    support.push(i);
-    add_dependency(i);
-}
-
-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_;
-}
-
-void
-Script::set_symdir()
-{
-    if (specs_l_->invertsym)
-       symdir = (dir < 0) ? -1:1;
-}
-
-void
-Script::set_default_dir()
+Molecule
+Script::get_molecule(Score_element * me, Direction d)
 {
-    if (specs_l_->stemdir) {
-       if (!stem_l_)
-           dir = 1;
-       else
-           dir = stem_l_->dir * specs_l_->stemdir;
+  SCM s = me->get_elt_property ("molecule");
+  assert (gh_pair_p (s));
+
+  SCM key = gh_car  (s);
+  if (key == ly_symbol2scm ("feta"))
+    {
+      return me->lookup_l ()->afm_find ("scripts-" +
+                                   ly_scm2string (index_cell (gh_cdr (s), d)));
     }
-}
+  else if (key == ly_symbol2scm ("accordion"))
+    {
+      return me->lookup_l ()->accordion (gh_cdr (s), me->paper_l()->get_var("staffspace"));
+    }
+  else
+    assert (false);
 
-Interval
-Script::support_height() const return r;
-{
-    for (int i=0; i < support.size(); i++)
-       r.unite(support[i]->height());
+  return Molecule ();
 }
 
-void
-Script::set_default_index()
+MAKE_SCHEME_CALLBACK(Script,after_line_breaking);
+SCM
+Script::after_line_breaking (SCM smob)
 {
-    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();
+  Score_element * me = unsmob_element (smob);
 
-       if (d > 0) {
-           y = y >? v.max();
-       } else if (d < 0) {
-           y = y <? v.min();
-       }
-    }
-    
-    if (stem_l_) {
-       Interval v= stem_l_->height();
+  Direction d = Side_position::get_direction (me);
+  Side_position::set_direction (me,d);
 
-       if (d > 0 || (!d && dir > 0)) {
-           y = y >? v.max();
-       }else if (d < 0 || (!d && dir < 0)) {
-           y = y <? v.min();
-       }
-    }
-    
-    pos = int(rint(Real(y)/inter_f));
+  return SCM_UNSPECIFIED;
 }
 
-Interval
-Script::width() const
-{
-    return symbol().dim.x;
-}
+MAKE_SCHEME_CALLBACK(Script,brew_molecule);
 
-Symbol
-Script::symbol()const
+SCM
+Script::brew_molecule (SCM smob)
 {
-    String preidx_str = (symdir < 0) ?"-" :"";
-    return paper()->lookup_l()->script(preidx_str + specs_l_->symidx);
+  Score_element *me= unsmob_element (smob);
+//   Direction dir = DOWN;
+//   SCM d = me->get_elt_property ("direction");
+//   if (isdir_b (d))
+//     dir = to_dir (d);
+  Direction dir = Side_position::get_direction(me);
+  return get_molecule (me, dir).create_scheme();
 }
 
-void
-Script::do_pre_processing()
+bool
+Script::has_interface (Score_element*me)
 {
-    set_default_dir();
-    set_symdir();
+  return me->has_interface (ly_symbol2scm ("script-interface"));
 }
 
 void
-Script::do_post_processing()
-{
-    set_default_index();
-}
-
-Molecule*
-Script::brew_molecule_p() const
+Script::set_interface (Score_element*me)
 {
-    Real dy = paper()->internote();
-    
-    Molecule*out = new Molecule(Atom(symbol()));
-    out->translate(Offset(0,dy * pos));
-    return out;
+  return me->set_interface (ly_symbol2scm ("script-interface"));
 }