2 staff-symbol.cc -- implement Staff_symbol
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "dimensions.hh"
11 #include "output-def.hh"
15 #include "staff-symbol.hh"
16 #include "staff-symbol-referencer.hh"
21 MAKE_SCHEME_CALLBACK (Staff_symbol,print,1);
24 Staff_symbol::print (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);
31 Interval span_points (0,0);
35 For raggedright without ragged staffs, simply set width to the linewidth.
37 (ok -- lousy UI, since width is in staff spaces)
44 SCM width_scm = me->get_property ("width");
45 if (d == RIGHT && ly_c_number_p (width_scm))
48 don't multiply by Staff_symbol_referencer::staff_space (me),
49 since that would make aligning staff symbols of different sizes to
50 one right margin hell.
52 span_points[RIGHT] = ly_scm2double (width_scm);
56 Item * x = sp->get_bound (d);
58 span_points[d] = x->relative_coordinate (common , X_AXIS);
59 if (!x->break_status_dir ()
60 && !x->extent (x, X_AXIS).is_empty ())
61 span_points[d] += x->extent (x, X_AXIS)[d];
64 while (flip (&d) !=LEFT);
67 Real t = me->get_paper ()->get_dimension (ly_symbol2scm ("linethickness"));
68 t *= robust_scm2double (me->get_property ("thickness"), 1.0);
70 int l = Staff_symbol::line_count (me);
72 Real height = (l-1) * staff_space (me) /2;
74 Lookup::horizontal_line (span_points
75 -me->relative_coordinate (common, X_AXIS),
79 for (int i=0; i < l; i++)
82 b.translate_axis (height - i * staff_space (me), Y_AXIS);
85 return m.smobbed_copy ();
89 Staff_symbol::get_steps (Grob*me)
91 return line_count (me) * 2;
95 Staff_symbol::line_count (Grob*me)
97 SCM c = me->get_property ("line-count");
98 if (ly_c_number_p (c))
99 return ly_scm2int (c);
105 Staff_symbol::staff_space (Grob*me)
107 return robust_scm2double ( me->get_property ("staff-space"), 1.0);
111 Staff_symbol::get_line_thickness (Grob* me)
113 Real lt = me->get_paper ()->get_dimension (ly_symbol2scm ("linethickness"));
115 return robust_scm2double (me->get_property ("thickness"), 1.0) * lt;
119 Staff_symbol::get_ledger_line_thickness (Grob * me)
121 SCM lt_pair = me->get_property ("ledger-line-thickness");
122 Offset z = robust_scm2offset (lt_pair, Offset (1.0, 0.1));
124 return z[X_AXIS] * get_line_thickness (me) + z[Y_AXIS]* staff_space (me);
128 ADD_INTERFACE (Staff_symbol,"staff-symbol-interface",
129 "This spanner draws the lines of a staff. "
130 "A staff symbol definines a vertical unit, the staff space. "
131 "Quantities that go by a half staff space are called positions "
132 "The center (i.e. middle line "
133 "or space) is position 0. The length of the symbol may be set by hand "
134 "through the @code{width} property. ",
136 "ledger-line-thickness width staff-space thickness line-count");