2 staff-symbol.cc -- implement Staff_symbol
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 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"
20 MAKE_SCHEME_CALLBACK (Staff_symbol,brew_molecule,1);
23 Staff_symbol::brew_molecule (SCM smob)
25 Grob *me = unsmob_grob (smob);
26 Spanner* sp = dynamic_cast<Spanner*> (me);
28 = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
30 bool ragged = to_boolean (me->paper_l ()->get_scmvar ("raggedright"));
34 // *prevent* staff symbol from being ragged right
36 me->paper_l ()->get_var ("linewidth")
37 - sp->get_bound (LEFT)->relative_coordinate (common, X_AXIS)
43 // right_shift - left_shift
44 + sp->get_bound (RIGHT)->relative_coordinate (common , X_AXIS)
45 - sp->get_bound (LEFT)->relative_coordinate (common, X_AXIS)
49 Real t = me->paper_l ()->get_var ("linethickness");
50 SCM my_thick = me->get_grob_property("thickness");
51 if (gh_number_p(my_thick))
52 t *= gh_scm2double (my_thick);
54 int l = Staff_symbol::line_count (me);
56 Real height = (l-1) * staff_space (me) /2;
58 for (int i=0; i < l; i++)
61 Lookup::filledbox (Box (Interval (0,width),
62 Interval (-t/2, t/2)));
64 a.translate_axis (height - i * staff_space (me), Y_AXIS);
68 return m.smobbed_copy ();
72 Staff_symbol::steps_i (Grob*me)
74 return line_count (me) * 2;
78 Staff_symbol::line_count (Grob*me)
80 SCM c = me->get_grob_property ("line-count");
82 return gh_scm2int (c);
88 Staff_symbol::staff_space (Grob*me)
92 SCM s = me->get_grob_property ("staff-space");
94 ss *= gh_scm2double (s);
101 ADD_INTERFACE (Staff_symbol,"staff-symbol-interface",
102 "This spanner draws the lines of a staff. The center (i.e. middle line
103 or space) is position 0.",
105 "staff-space thickness line-count");