-#include "musicalrequest.hh"
-#include "paper-def.hh"
-#include "script.hh"
-#include "stem.hh"
-#include "molecule.hh"
-#include "lookup.hh"
+/*
+ script.cc -- implement Script
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+/*
+ TODO: Quantisation support (staccato dots between stafflines)
-void
-Script::set_stem(Stem*st_l)
+*/
+#include "debug.hh"
+#include "script.hh"
+#include "lookup.hh"
+#include "staff-side.hh"
+#include "paper-def.hh"
+#include "dimension-cache.hh"
+
+Script::Script ()
{
- stem_l_ = st_l;
- add_dependency(st_l);
+ staff_side_l_ =0;
}
void
-Script::set_support(Item*i)
+Script::do_substitute_element_pointer (Score_element*o, Score_element*n)
{
- support.push(i);
- add_dependency(i);
+ if (o == staff_side_l_)
+ staff_side_l_ = dynamic_cast<Staff_side_item*>(n);
}
-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(Direction d) const
{
- if (specs_l_->stemdir) {
- if (!stem_l_)
- dir = 1;
- else
- dir = stem_l_->dir * specs_l_->stemdir;
+ SCM s = get_elt_property ("molecule");
+ assert (s != SCM_UNDEFINED);
+
+ SCM key = SCM_CAR (s);
+ if (key == ly_symbol ("feta"))
+ {
+ return lookup_l ()->afm_find ("scripts-" +
+ ly_scm2string (index_cell (gh_cdr (s), d)));
+ }
+ else if (key == ly_symbol ("accordion"))
+ {
+ return lookup_l ()->accordion (s, paper_l()->get_var("interline"));
}
-}
-Interval
-Script::support_height() const return r;
-{
- for (int i=0; i < support.size(); i++)
- r.unite(support[i]->height());
+ else assert (false);
+
+ return Molecule ();
}
+
void
-Script::set_default_index()
+Script::do_pre_processing ()
{
- 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 <? v.min();
- }
- }
-
- if (stem_l_) {
- Interval v= stem_l_->height();
-
- 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));
+ /*
+ center my self on the note head.
+ */
+ Graphical_element * e = staff_side_l_->parent_l(X_AXIS);
+ translate_axis (e->extent (X_AXIS).center (), X_AXIS);
}
-Interval
-Script::width() const
+void
+Script::do_post_processing ()
{
- return symbol().dim.x;
+ Direction d = staff_side_l_->get_direction ();
+ Molecule m (get_molecule(d));
+
+ /*
+ UGH UGH UGH
+ */
+ if (staff_side_l_->get_elt_property ("no-staff-support") == SCM_UNDEFINED)
+ translate_axis (- m.dim_[Y_AXIS][Direction (-d)], Y_AXIS);
}
-Symbol
-Script::symbol()const
+void
+Script::set_staff_side (Staff_side_item*g)
{
- String preidx_str = (symdir < 0) ?"-" :"";
- return paper()->lookup_p_->script(preidx_str + specs_l_->symidx);
+ staff_side_l_ = g;
+ add_dependency (g);
+ set_parent (g, Y_AXIS);
}
-void
-Script::do_pre_processing()
+Molecule*
+Script::do_brew_molecule_p () const
{
- set_default_dir();
- set_symdir();
+ return new Molecule (get_molecule (staff_side_l_->get_direction ()));
}
void
-Script::do_post_processing()
+Script::do_print () const
{
- set_default_index();
-}
-Molecule*
-Script::brew_molecule_p() const
-{
- Real dy = paper()->internote();
-
- Molecule*out = new Molecule(Atom(symbol()));
- out->translate(Offset(0,dy * pos));
- return out;
}
+