]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-symbol.cc
release: 1.3.11
[lilypond.git] / lily / staff-symbol.cc
1 /*
2   staffsym.cc -- implement Staff_symbol
3
4   source file of the GNU LilyPond music typesetter
5
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"
15
16
17 Staff_symbol::Staff_symbol ()
18 {
19   no_lines_i_ = 5;
20   staff_line_leading_f_ = 5.0 PT;
21 }
22
23 void
24 Staff_symbol::do_print() const
25 {
26 #ifndef NPRINT
27   Spanner::do_print();
28   DEBUG_OUT << "lines: " << no_lines_i_;
29 #endif
30 }
31
32
33 Molecule*
34 Staff_symbol::do_brew_molecule_p() const
35 {
36   Score_element * common
37     = spanned_drul_[LEFT]->common_refpoint (spanned_drul_[RIGHT], X_AXIS);
38
39 #if 0
40   Interval r =  spanned_drul_[RIGHT]->extent (X_AXIS);
41   Interval l =  spanned_drul_[LEFT]->extent (X_AXIS);
42   
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)
50     ;
51
52   Real t = paper_l ()->get_var ("stafflinethickness");
53   Molecule rule  = lookup_l ()->filledbox (Box (Interval (0,width),
54                                                 Interval (-t/2, t/2)));
55
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++)
59     {
60       Molecule a (rule);
61       a.translate_axis (height - i * staff_line_leading_f_, Y_AXIS);
62       m->add_molecule (a);
63     }
64
65   //  m->translate_axis (left_shift, X_AXIS);
66   return m;
67 }
68
69
70 int
71 Staff_symbol::steps_i() const
72 {
73   return no_lines_i_*2;
74 }
75 Real
76 Staff_symbol::staff_line_leading_f ()
77 {
78   return staff_line_leading_f_;
79 }