lilypond-1.3.7
[lilypond.git] / lily / crescendo.cc
blobc570a2b1530a9e5c912a42a18683b2a137930ff8
1 /*
2 crescendo.cc -- implement Crescendo
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "molecule.hh"
10 #include "crescendo.hh"
11 #include "lookup.hh"
12 #include "dimensions.hh"
13 #include "paper-def.hh"
14 #include "debug.hh"
15 #include "score-column.hh"
17 Crescendo::Crescendo ()
19 grow_dir_ =0;
20 dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
26 Molecule
27 Crescendo::get_symbol () const
29 Real w_dim = extent (X_AXIS).length () - get_broken_left_end_align ();
30 Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten");
31 if (dyn_b_drul_[LEFT])
33 w_dim -= absdyn_dim;
35 if (dyn_b_drul_[RIGHT])
37 w_dim -= absdyn_dim;
40 if (w_dim < 0)
42 warning (_ ("crescendo") + " " + _ ("too small"));
43 w_dim = 0;
46 Drul_array<bool> broken;
47 Direction d = LEFT;
48 do {
49 Score_column* s = dynamic_cast<Score_column*>(spanned_drul_[d]); // UGH
50 broken[d] = (!s->musical_b ());
51 } while (flip (&d) != LEFT);
54 bool continued = broken[Direction (-grow_dir_)];
55 Real height = paper_l()->get_var ("crescendo_height");
56 Real thick = paper_l ()->get_var ("crescendo_thickness");
58 return Molecule (lookup_l ()->hairpin (w_dim, height, thick, grow_dir_ < 0, continued));
61 Molecule*
62 Crescendo::do_brew_molecule_p () const
64 Molecule* m_p =0;
65 Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten");
66 Real x_off_dim = get_broken_left_end_align ();
68 if (dyn_b_drul_[LEFT])
69 x_off_dim += absdyn_dim;
71 m_p = new Molecule;
72 Molecule s (get_symbol ());
73 m_p->add_molecule (s);
74 m_p->translate_axis (x_off_dim, X_AXIS);
75 return m_p;