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 if (SMOB_IS_TYPE_B (Score_element, st))
35 return dynamic_cast<Staff_symbol* > (SMOB_TO_TYPE (Score_element,st));
41 Staff_symbol_referencer::staff_line_leading_f () const
43 Staff_symbol * st = staff_symbol_l ();
45 return st->staff_line_leading_f_;
46 else if (pscore_l_ && paper_l ())
47 paper_l ()->get_var ("interline");
54 Staff_symbol_referencer::position_f () const
57 SCM pos = get_elt_property ("staff-position");
58 if (gh_number_p (pos))
59 p = gh_scm2double (pos);
61 Staff_symbol * st = staff_symbol_l ();
64 Score_element * c = common_refpoint (st, Y_AXIS);
65 Real y = relative_coordinate (c, Y_AXIS)
66 - st->relative_coordinate (c, Y_AXIS);
68 p += 2.0 * y / staff_line_leading_f ();
76 should use offset callback!
79 Staff_symbol_referencer::callback (Dimension_cache const * c)
81 Score_element * sc = dynamic_cast<Score_element*> (c->element_l ());
82 Staff_symbol_referencer * ref = dynamic_cast<Staff_symbol_referencer*> (sc);
83 SCM pos = sc->get_elt_property ("staff-position");
85 if (gh_number_p (pos))
87 off = gh_scm2double (pos) * ref->staff_line_leading_f () /2.0;
89 sc->set_elt_property ("staff-position", gh_double2scm (0.0));
96 Staff_symbol_referencer::set_position (Real p)
98 Real halfspace = staff_line_leading_f ()* 0.5;
100 translate_axis (- halfspace * position_f (), Y_AXIS);
101 Staff_symbol *st = staff_symbol_l ();
103 translate_axis (halfspace * p, Y_AXIS);
106 // SCM pos = get_elt_property ("staff-position");
107 set_elt_property ("staff-position",
109 // gh_double2scm (p + gh_scm2double (pos)));