]> git.donarmstrong.com Git - lilypond.git/blob - lily/bow.cc
release: 0.0.77.jcn1
[lilypond.git] / lily / bow.cc
1 /*
2   bow.cc -- implement Bow
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "bow.hh"
10 #include "paper-def.hh"
11 #include "molecule.hh"
12 #include "lookup.hh"
13
14 Bow::Bow()
15 {
16     left_pos_i_ = right_pos_i_ = 0;
17     left_dx_f_ = right_dx_f_ = 0.0;
18 }
19
20
21 Offset
22 Bow::center() const
23 {
24     int dy =  right_pos_i_-left_pos_i_;
25
26     Real w = width().length();
27
28     return Offset(w/2,dy * paper()->internote_f());
29 }
30
31
32 Molecule*
33 Bow::brew_molecule_p() const
34 {
35     Molecule*output = new Molecule;
36     Real w = width().length();
37     
38     int dy = right_pos_i_ - left_pos_i_;
39     
40     Real nw_f = paper()->note_width();
41     Real nh_f = paper()->internote_f();
42
43     
44     w+= (right_dx_f_ - left_dx_f_) * nw_f ;
45     Real round_w = w;           // slur lookup rounds the slurwidth .
46     
47     Symbol sl = paper()->lookup_l()->slur(dy , round_w, dir_i_);
48
49     Real error = w-round_w;
50     
51     Atom a(sl);
52     a.translate(Offset((left_dx_f_ + 0.5 )*nw_f + error/2,
53                        left_pos_i_ * nh_f));
54     output->add(a);
55     return output;
56 }
57
58
59 IMPLEMENT_IS_TYPE_B1(Bow,Directional_spanner);