]> git.donarmstrong.com Git - lilypond.git/blob - lily/crescendo.cc
release: 0.1.8
[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 Interval
25 Crescendo::symbol_height()const
26 {
27     return get_symbol().dim[Y_AXIS];
28 }
29
30 static Real absdyn_dim = 10 PT; // ugh
31
32 Symbol
33 Crescendo::get_symbol()const
34 {    
35     Real w_dim = width().length ();
36     if ( left_dyn_b_) {
37         w_dim -= absdyn_dim;
38     }
39     if ( right_dyn_b_) {
40         w_dim -= absdyn_dim;
41     }
42     
43     if (w_dim < 0) {
44         warning ("Crescendo too small");
45         w_dim = 0;
46     }
47
48     return Symbol (paper()->lookup_l ()->hairpin (w_dim, grow_dir_i_ < 0));
49 }
50
51 Molecule*
52 Crescendo::brew_molecule_p() const
53 {
54     Molecule* m_p =0;
55     Real x_off_dim=0.0;
56     if ( left_dyn_b_)
57         x_off_dim += absdyn_dim;
58     
59     m_p = new Molecule;
60     Symbol s (get_symbol());
61     m_p->add (Atom (s));
62     m_p->translate (Offset (x_off_dim, pos_i_ * paper()->internote_f ()));
63     return m_p;
64 }
65
66
67 IMPLEMENT_IS_TYPE_B1(Crescendo,Spanner);