]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-symbol.cc
release: 1.3.55
[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--2000 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
18 Molecule 
19 Staff_symbol::do_brew_molecule() const
20 {
21   Score_element * common
22     = get_bound (LEFT)->common_refpoint (get_bound (RIGHT), X_AXIS);
23   
24   Real width =
25     // right_shift     - left_shift
26     + get_bound (RIGHT)->relative_coordinate (common , X_AXIS)
27     - get_bound (LEFT)->relative_coordinate (common, X_AXIS)
28     ;
29
30   Real t = paper_l ()->get_var ("stafflinethickness");
31   int l = line_count ();
32   
33   Real height = (l-1) * staff_space () /2;
34   Molecule  m;
35   for (int i=0; i < l; i++)
36     {
37       Molecule a =
38         lookup_l ()->filledbox (Box (Interval (0,width),
39                                      Interval (-t/2, t/2)));
40
41       a.translate_axis (height - i * staff_space (), Y_AXIS);
42       m.add_molecule (a);
43     }
44
45   return m;
46 }
47
48 int
49 Staff_symbol::steps_i() const
50 {
51   return line_count () * 2;
52 }
53
54 int
55 Staff_symbol::line_count () const
56 {
57   return gh_scm2int (get_elt_property ("line-count"));
58 }
59
60 Real
61 Staff_symbol::staff_space ()const
62 {
63   return gh_scm2double (get_elt_property ("staff-space")) *
64     paper_l ()->get_var ("staffspace");
65 }
66
67 Staff_symbol::Staff_symbol( SCM s)
68   : Spanner (s)
69 {
70 }