]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-sym.cc
ea4576e59bcbca41c382fb6d175c8b4584e4a8e6
[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 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "staff-sym.hh"
9 #include "lookup.hh"
10 #include "paper-def.hh"
11 #include "molecule.hh"
12 #include "debug.hh"
13 #include "dimen.hh"
14
15
16 Staff_symbol::Staff_symbol (int l)
17 {
18   no_lines_i_ = l;
19   interline_f_ =  0 PT;
20 }
21
22
23 IMPLEMENT_IS_TYPE_B1(Staff_symbol,Spanner);
24
25 void
26 Staff_symbol::do_print() const
27 {
28 #ifndef NPRINT
29   Spanner::do_print();
30   DOUT << "lines: " << no_lines_i_;
31 #endif
32 }
33
34 Interval
35 Staff_symbol::do_height() const
36 {
37   int n = no_lines_i_ -1;
38   return 2* inter_note_f () * Interval (-n, n);
39 }
40
41 Molecule*
42 Staff_symbol::brew_molecule_p() const
43 {
44   Paper_def * p = paper();
45   Atom rule  = p->lookup_l ()->rule_symbol (p->get_var ("rulethickness"), 
46                                             width ().length ());
47   Real height = (no_lines_i_-1) * inter_note_f();
48   Molecule * m = new Molecule;
49   for (int i=0; i < no_lines_i_; i++)
50     {
51       Atom a (rule);
52       a.translate_axis (height - i * inter_note_f()*2, Y_AXIS);
53       m->add (a);
54     }
55
56   return m;
57 }
58
59 Real
60 Staff_symbol::inter_note_f() const
61 {
62   if (interline_f_)
63     return interline_f_/2;
64
65   return paper()->internote_f ();
66 }
67
68 int
69 Staff_symbol::steps_i() const
70 {
71   return no_lines_i_*2;
72 }