]> git.donarmstrong.com Git - lilypond.git/blob - lily/crescendo.cc
release: 1.1.45
[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--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
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"
16
17 Crescendo::Crescendo ()
18 {
19   grow_dir_ =0;
20   dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
21 }
22
23
24
25
26 Molecule
27 Crescendo::get_symbol () const
28 {
29   Real w_dim = extent (X_AXIS).length ();
30   Real absdyn_dim = paper_l ()-> get_realvar (ly_symbol ("crescendo_shorten"));
31   if (dyn_b_drul_[LEFT])
32     {
33       w_dim -= absdyn_dim;
34     }
35   if (dyn_b_drul_[RIGHT])
36     {
37       w_dim -= absdyn_dim;
38     }
39
40   if (w_dim < 0)
41     {
42       warning (_ ("crescendo") + " " + _ ("too small"));
43       w_dim = 0;
44     }
45
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);
52   
53
54   bool continued = broken[Direction (-grow_dir_)];
55   return Molecule (lookup_l ()->hairpin (w_dim, grow_dir_ < 0, continued));
56 }
57
58 Molecule*
59 Crescendo::do_brew_molecule_p () const
60 {
61   Molecule* m_p =0;
62   Real absdyn_dim = paper_l ()-> get_realvar (ly_symbol ("crescendo_shorten"));
63   Real x_off_dim=0.0;
64   if (dyn_b_drul_[LEFT])
65     x_off_dim += absdyn_dim;
66
67   m_p = new Molecule;
68   Molecule s (get_symbol ());
69   m_p->add_molecule (s);
70   m_p->translate_axis (x_off_dim, X_AXIS);
71   return m_p;
72 }
73
74