]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-sym.cc
2940d13a9a5047dd2831de2012a79e1b95591bae
[lilypond.git] / lily / staff-sym.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   DOUT << "lines: " << no_lines_i_;
29 #endif
30 }
31
32 Interval
33 Staff_symbol::do_height() const
34 {
35   Interval i =Interval (0, staff_line_leading_f_ * (no_lines_i_-1));
36   i += - i.center ();
37   return i;
38 }
39
40 Molecule*
41 Staff_symbol::do_brew_molecule_p() const
42 {
43   Graphical_element * common
44     = spanned_drul_[LEFT]->common_refpoint (spanned_drul_[RIGHT], X_AXIS);
45
46 #if 0
47   Interval r =  spanned_drul_[RIGHT]->extent (X_AXIS);
48   Interval l =  spanned_drul_[LEFT]->extent (X_AXIS);
49   
50   Real left_shift =l.empty_b () ? 0.0: l[LEFT];
51   Real right_shift =r.empty_b () ? 0.0: r[RIGHT];  
52 #endif
53   Real width =
54     // right_shift     - left_shift
55     + spanned_drul_[RIGHT]->relative_coordinate (common , X_AXIS)
56     - spanned_drul_[LEFT]->relative_coordinate (common, X_AXIS)
57     ;
58
59   Real t = paper_l ()->get_var ("rulethickness");
60   Molecule rule  = lookup_l ()->filledbox (Box (Interval (0,width),
61                                                 Interval (-t/2, t/2)));
62
63   Real height = (no_lines_i_-1) * staff_line_leading_f_ /2;
64   Molecule * m = new Molecule;
65   for (int i=0; i < no_lines_i_; i++)
66     {
67       Molecule a (rule);
68       a.translate_axis (height - i * staff_line_leading_f_, Y_AXIS);
69       m->add_molecule (a);
70     }
71
72   //  m->translate_axis (left_shift, X_AXIS);
73   return m;
74 }
75
76
77 int
78 Staff_symbol::steps_i() const
79 {
80   return no_lines_i_*2;
81 }