]> git.donarmstrong.com Git - lilypond.git/blob - lily/crescendo.cc
release: 0.0.72pre
[lilypond.git] / lily / crescendo.cc
1 /*
2   crescendo.cc -- implement Crescendo
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "molecule.hh"
10 #include "dimen.hh"
11 #include "crescendo.hh"
12 #include "lookup.hh"
13 #include "paper-def.hh"
14 #include "debug.hh"
15
16 Crescendo::Crescendo()
17 {
18     grow_dir_i_ =0;
19     dir_i_ = -1 ;
20     left_dyn_b_ = right_dyn_b_ =false;
21     inside_staff_b_ = false;
22 }
23
24 Molecule*
25 Crescendo::brew_molecule_p() const
26 {
27     Molecule* m_p =0;
28     Real x_off_dim=0.0;
29     Real absdyn_dim = 10 PT;    // ugh
30     
31     m_p = new Molecule;
32     Real w_dim = width().length();
33     if ( left_dyn_b_ ) {
34         w_dim -= absdyn_dim;
35         x_off_dim += absdyn_dim;
36     }
37     if ( right_dyn_b_ ) {
38         w_dim -= absdyn_dim;
39     }
40     
41     if (w_dim < 0) {
42         warning("Crescendo too small");
43         w_dim = 0;
44     }
45     Real lookup_wid = w_dim * 0.9; // make it slightly smaller.
46
47     Symbol s( paper()->lookup_l()->hairpin( lookup_wid, grow_dir_i_ < 0) );
48     m_p->add(Atom(s));
49     int pos = get_position_i(s.dim.y);
50     m_p->translate(Offset(x_off_dim + 0.05 * w_dim, 
51                           pos * paper()->internote_f()));
52     return m_p;
53 }
54
55 IMPLEMENT_STATIC_NAME(Crescendo);
56 IMPLEMENT_IS_TYPE_B1(Crescendo,Spanner);