]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-sym.cc
release: 1.1.6
[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--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8 #include "staff-sym.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   interline_f_ =  0 PT;
21 }
22
23
24
25
26 void
27 Staff_symbol::do_print() const
28 {
29 #ifndef NPRINT
30   Spanner::do_print();
31   DOUT << "lines: " << no_lines_i_;
32 #endif
33 }
34
35 Interval
36 Staff_symbol::do_height() const
37 {
38   int n = no_lines_i_ -1;
39 //  return 2* inter_note_f () * Interval (-n, n);
40   return inter_note_f () * Interval (-n, n);
41 }
42
43 Molecule*
44 Staff_symbol::brew_molecule_p() const
45 {
46   Real w = width ().length ();
47   Real left_dx = -spanned_drul_[LEFT]->extent (X_AXIS)[LEFT];
48   Real right_dx = spanned_drul_[RIGHT]->extent (X_AXIS)[RIGHT];
49   //  w += right_dx+ left_dx;
50
51   
52   Paper_def * p = paper();
53   Atom rule  = lookup_l ()->rule_symbol (p->get_var ("rulethickness"),
54                                          w);
55   Real height = (no_lines_i_-1) * inter_note_f();
56   Molecule * m = new Molecule;
57   for (int i=0; i < no_lines_i_; i++)
58     {
59       Atom a (rule);
60       a.translate_axis (height - i * inter_note_f()*2, Y_AXIS);
61       m->add_molecule (a);
62     }
63
64   //  m->translate_axis (-left_dx, X_AXIS);
65   return m;
66 }
67
68 Real
69 Staff_symbol::inter_note_f() const
70 {
71   if (interline_f_)
72     return interline_f_/2;
73
74   return paper()->internote_f ();
75 }
76
77 int
78 Staff_symbol::steps_i() const
79 {
80   return no_lines_i_*2;
81 }