lilypond-0.1.16
[lilypond.git] / lily / crescendo.cc
blob1bd91d0f0cde3b4cdf9c856f65041cc9afbb076c
1 /*
2 crescendo.cc -- implement Crescendo
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
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"
16 Crescendo::Crescendo()
18 grow_dir_ =0;
19 dir_ = DOWN ;
20 dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
21 inside_staff_b_ = false;
24 Interval
25 Crescendo::symbol_height() const
27 return get_symbol().dim_[Y_AXIS];
30 static Real absdyn_dim = 10 PT; // ugh
32 Atom
33 Crescendo::get_symbol() const
35 Real w_dim = width().length ();
36 if (dyn_b_drul_[LEFT])
38 w_dim -= absdyn_dim;
40 if (dyn_b_drul_[RIGHT])
42 w_dim -= absdyn_dim;
45 if (w_dim < 0)
47 warning ("Crescendo too small");
48 w_dim = 0;
51 return Atom (paper()->lookup_l ()->hairpin (w_dim, grow_dir_ < 0));
54 Molecule*
55 Crescendo::brew_molecule_p() const
57 Molecule* m_p =0;
58 Real x_off_dim=0.0;
59 if (dyn_b_drul_[LEFT])
60 x_off_dim += absdyn_dim;
62 m_p = new Molecule;
63 Atom 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;
70 IMPLEMENT_IS_TYPE_B1(Crescendo,Spanner);