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"
16 #include "staff-symbol-referencer.hh"
21 MAKE_SCHEME_CALLBACK (Staff_symbol,brew_molecule,1);
24 Staff_symbol::brew_molecule (SCM smob)
26 Grob *me = unsmob_grob (smob);
27 Spanner* sp = dynamic_cast<Spanner*> (me);
29 = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
34 For raggedright without ragged staffs, simply set width to the linewidth.
36 (ok -- lousy UI, since width is in staff spaces)
41 SCM width_scm = me->get_grob_property ("width");
42 if (gh_number_p (width_scm))
46 don't multiply by Staff_symbol_referencer::staff_space (me),
47 since that would make aligning staff symbols of different sizes to
48 one right margin hell.
50 width = gh_scm2double (width_scm);
54 width = sp->get_bound (RIGHT)->relative_coordinate (common , X_AXIS);
57 // respect indentation, if any
58 width -= sp->get_bound (LEFT)->relative_coordinate (common, X_AXIS);
62 warning (_f ("staff symbol: indentation yields beyond end of line"));
66 Real t = me->paper_l ()->get_var ("linethickness");
67 SCM my_thick = me->get_grob_property("thickness");
68 if (gh_number_p(my_thick))
69 t *= gh_scm2double (my_thick);
71 int l = Staff_symbol::line_count (me);
73 Real height = (l-1) * staff_space (me) /2;
75 for (int i=0; i < l; i++)
78 Lookup::filledbox (Box (Interval (0,width),
79 Interval (-t/2, t/2)));
81 a.translate_axis (height - i * staff_space (me), Y_AXIS);
85 return m.smobbed_copy ();
89 Staff_symbol::steps_i (Grob*me)
91 return line_count (me) * 2;
95 Staff_symbol::line_count (Grob*me)
97 SCM c = me->get_grob_property ("line-count");
99 return gh_scm2int (c);
105 Staff_symbol::staff_space (Grob*me)
109 SCM s = me->get_grob_property ("staff-space");
111 ss *= gh_scm2double (s);
118 ADD_INTERFACE (Staff_symbol,"staff-symbol-interface",
119 "This spanner draws the lines of a staff. The center (i.e. middle line
120 or space) is position 0. The length of the symbol may be set by hand
121 through the @code{width} property.
124 "width staff-space thickness line-count");