lilypond-0.1.16
[lilypond.git] / lily / bow.cc
blob34b7eb77940d9e49cc369ebbf9a5743dde9d40f4
1 /*
2 bow.cc -- implement Bow
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "bow.hh"
10 #include "paper-def.hh"
11 #include "molecule.hh"
12 #include "lookup.hh"
14 Bow::Bow()
16 pos_i_drul_[LEFT] = pos_i_drul_[RIGHT] = 0;
17 dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0;
21 Offset
22 Bow::center() const
24 int dy = pos_i_drul_[RIGHT]-pos_i_drul_[LEFT];
26 Real w = width().length ();
28 return Offset (w/2,dy * paper()->internote_f ());
32 Molecule*
33 Bow::brew_molecule_p() const
35 Molecule*output = new Molecule;
36 Real w = width().length ();
38 int dy = pos_i_drul_[RIGHT] - pos_i_drul_[LEFT];
40 Real nw_f = paper()->note_width ();
41 Real nh_f = paper()->internote_f ();
44 w+= (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]) * nw_f ;
45 Real round_w = w; // slur lookup rounds the slurwidth .
47 Atom a = paper()->lookup_l ()->slur (dy , round_w, dir_);
49 Real error = w-round_w;
50 a.translate (Offset ((dx_f_drul_[LEFT] + 0.5)*nw_f + error/2,
51 pos_i_drul_[LEFT] * nh_f));
52 output->add (a);
53 return output;
57 IMPLEMENT_IS_TYPE_B1(Bow,Directional_spanner);