]> git.donarmstrong.com Git - lilypond.git/blob - lily/crescendo.cc
release: 1.1.28
[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--1998 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   dir_ = DOWN;
21   dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =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 Molecule
33 Crescendo::get_symbol () const
34 {
35   Real w_dim = extent (X_AXIS).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   Drul_array<bool> broken;
52   Direction d = LEFT;
53   do {
54     Score_column* s = dynamic_cast<Score_column*>(spanned_drul_[d]); // UGH
55     broken[d] = (!s->musical_b ());
56   } while (flip (&d) != LEFT);
57   
58
59   bool continued = broken[Direction (-grow_dir_)];
60   return Molecule (lookup_l ()->hairpin (w_dim, grow_dir_ < 0, continued));
61 }
62
63 Molecule*
64 Crescendo::do_brew_molecule_p () const
65 {
66   Molecule* m_p =0;
67   Real x_off_dim=0.0;
68   if (dyn_b_drul_[LEFT])
69     x_off_dim += absdyn_dim;
70
71   m_p = new Molecule;
72   Molecule s (get_symbol ());
73   m_p->add_molecule (s);
74   m_p->translate (Offset (x_off_dim, coordinate_offset_f_));
75   return m_p;
76 }
77
78
79