lilypond-1.3.12
[lilypond.git] / lily / staff-symbol.cc
blobbd9d63bbcd93e8eed611ff519960380a1e045efa
1 /*
2 staffsym.cc -- implement Staff_symbol
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8 #include "staff-symbol.hh"
9 #include "lookup.hh"
10 #include "dimensions.hh"
11 #include "paper-def.hh"
12 #include "molecule.hh"
13 #include "debug.hh"
14 #include "item.hh"
17 Staff_symbol::Staff_symbol ()
19 no_lines_i_ = 5;
20 staff_line_leading_f_ = 5.0 PT;
23 void
24 Staff_symbol::do_print() const
26 #ifndef NPRINT
27 Spanner::do_print();
28 DEBUG_OUT << "lines: " << no_lines_i_;
29 #endif
33 Molecule*
34 Staff_symbol::do_brew_molecule_p() const
36 Score_element * common
37 = spanned_drul_[LEFT]->common_refpoint (spanned_drul_[RIGHT], X_AXIS);
39 #if 0
40 Interval r = spanned_drul_[RIGHT]->extent (X_AXIS);
41 Interval l = spanned_drul_[LEFT]->extent (X_AXIS);
43 Real left_shift =l.empty_b () ? 0.0: l[LEFT];
44 Real right_shift =r.empty_b () ? 0.0: r[RIGHT];
45 #endif
46 Real width =
47 // right_shift - left_shift
48 + spanned_drul_[RIGHT]->relative_coordinate (common , X_AXIS)
49 - spanned_drul_[LEFT]->relative_coordinate (common, X_AXIS)
52 Real t = paper_l ()->get_var ("stafflinethickness");
53 Molecule rule = lookup_l ()->filledbox (Box (Interval (0,width),
54 Interval (-t/2, t/2)));
56 Real height = (no_lines_i_-1) * staff_line_leading_f_ /2;
57 Molecule * m = new Molecule;
58 for (int i=0; i < no_lines_i_; i++)
60 Molecule a (rule);
61 a.translate_axis (height - i * staff_line_leading_f_, Y_AXIS);
62 m->add_molecule (a);
65 // m->translate_axis (left_shift, X_AXIS);
66 return m;
70 int
71 Staff_symbol::steps_i() const
73 return no_lines_i_*2;
75 Real
76 Staff_symbol::staff_line_leading_f ()
78 return staff_line_leading_f_;