2 staff-symbol-referencer.cc -- implement Staff_symbol_referencer
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "staff-symbol-referencer.hh"
12 #include "staff-symbol.hh"
13 #include "paper-def.hh"
14 #include "dimension-cache.hh"
16 Staff_symbol_referencer::Staff_symbol_referencer ()
18 set_elt_property ("staff-position", gh_double2scm (0.0));
19 dim_cache_[Y_AXIS]->off_callbacks_.push (callback);
24 Staff_symbol_referencer::lines_i () const
26 Staff_symbol *st = staff_symbol_l ();
27 return st ? st->no_lines_i_ : 5;
31 Staff_symbol_referencer::staff_symbol_l () const
33 SCM st = get_elt_property ("staff-symbol");
34 return dynamic_cast<Staff_symbol* > (unsmob_element(st));
38 Staff_symbol_referencer::staff_line_leading_f () const
40 Staff_symbol * st = staff_symbol_l ();
42 return st->staff_line_leading_f_;
43 else if (pscore_l_ && paper_l ())
44 paper_l ()->get_var ("interline");
51 Staff_symbol_referencer::position_f () const
54 SCM pos = get_elt_property ("staff-position");
55 if (gh_number_p (pos))
56 p = gh_scm2double (pos);
58 Staff_symbol * st = staff_symbol_l ();
61 Score_element * c = common_refpoint (st, Y_AXIS);
62 Real y = relative_coordinate (c, Y_AXIS)
63 - st->relative_coordinate (c, Y_AXIS);
65 p += 2.0 * y / staff_line_leading_f ();
73 should use offset callback!
76 Staff_symbol_referencer::callback (Dimension_cache const * c)
78 Score_element * sc = dynamic_cast<Score_element*> (c->element_l ());
79 Staff_symbol_referencer * ref = dynamic_cast<Staff_symbol_referencer*> (sc);
80 SCM pos = sc->get_elt_property ("staff-position");
82 if (gh_number_p (pos))
84 off = gh_scm2double (pos) * ref->staff_line_leading_f () /2.0;
86 sc->set_elt_property ("staff-position", gh_double2scm (0.0));
93 Staff_symbol_referencer::set_position (Real p)
95 Real halfspace = staff_line_leading_f ()* 0.5;
97 translate_axis (- halfspace * position_f (), Y_AXIS);
98 Staff_symbol *st = staff_symbol_l ();
100 translate_axis (halfspace * p, Y_AXIS);
103 // SCM pos = get_elt_property ("staff-position");
104 set_elt_property ("staff-position",
106 // gh_double2scm (p + gh_scm2double (pos)));