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