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