]> git.donarmstrong.com Git - lilypond.git/blob - lily/crescendo.cc
release: 0.1.11
[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_ =0;
19   dir_ = DOWN ;
20   dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =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 (dyn_b_drul_[LEFT]) 
37     {
38       w_dim -= absdyn_dim;
39     }
40   if (dyn_b_drul_[RIGHT]) 
41     {
42       w_dim -= absdyn_dim;
43     }
44   
45   if (w_dim < 0) 
46     {
47       warning ("Crescendo too small");
48       w_dim = 0;
49     }
50
51   return Symbol (paper()->lookup_l ()->hairpin (w_dim, grow_dir_ < 0));
52 }
53
54 Molecule*
55 Crescendo::brew_molecule_p() const
56 {
57   Molecule* m_p =0;
58   Real x_off_dim=0.0;
59   if (dyn_b_drul_[LEFT])
60     x_off_dim += absdyn_dim;
61   
62   m_p = new Molecule;
63   Symbol s (get_symbol());
64   m_p->add (Atom (s));
65   m_p->translate (Offset (x_off_dim, pos_i_ * paper()->internote_f ()));
66   return m_p;
67 }
68
69
70 IMPLEMENT_IS_TYPE_B1(Crescendo,Spanner);