2 staff-symbol.cc -- implement Staff_symbol
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "dimensions.hh"
11 #include "paper-def.hh"
12 #include "molecule.hh"
15 #include "staff-symbol.hh"
19 MAKE_SCHEME_CALLBACK(Staff_symbol,brew_molecule,1);
22 Staff_symbol::brew_molecule (SCM smob)
24 Score_element *me = unsmob_element (smob);
25 Spanner* sp = dynamic_cast<Spanner*> (me);
26 Score_element * common
27 = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
30 // right_shift - left_shift
31 + sp->get_bound (RIGHT)->relative_coordinate (common , X_AXIS)
32 - sp->get_bound (LEFT)->relative_coordinate (common, X_AXIS)
35 Real t = me->paper_l ()->get_var ("stafflinethickness");
36 int l = Staff_symbol::line_count (me);
38 Real height = (l-1) * staff_space (me) /2;
40 for (int i=0; i < l; i++)
43 me->lookup_l ()->filledbox (Box (Interval (0,width),
44 Interval (-t/2, t/2)));
46 a.translate_axis (height - i * staff_space (me), Y_AXIS);
50 return m.create_scheme();
54 Staff_symbol::steps_i(Score_element*me)
56 return line_count (me) * 2;
60 Staff_symbol::line_count (Score_element*me)
62 SCM c = me->get_elt_property ("line-count");
64 return gh_scm2int (c);
70 Staff_symbol::staff_space (Score_element*me )
72 Real ss = me->paper_l ()->get_var ("staffspace");
74 SCM s = me->get_elt_property ("staff-space");
76 ss *= gh_scm2double (s);
81 Staff_symbol::has_interface (Score_element*m)
83 return m && m->has_interface (ly_symbol2scm ("staff-symbol-interface"));