lilypond-0.0.50
[lilypond.git] / lily / crescendo.cc
blobe8a36e29a8de635d276bb0dd3913853ae736abdc
1 /*
2 crescendo.cc -- implement Crescendo
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "dimen.hh"
9 #include "crescendo.hh"
10 #include "lookup.hh"
11 #include "paper-def.hh"
12 #include "debug.hh"
13 Crescendo::Crescendo(int s)
15 staff_size_i_ = s;
16 grow_dir_i_ =0;
17 dir_i_ = -1 ;
18 left_dyn_b_ = right_dyn_b_ =false;
21 Spanner*
22 Crescendo::do_break_at(PCol*, PCol*)const
24 return new Crescendo(*this);
28 Molecule*
29 Crescendo::brew_molecule_p() const return m_p ;
31 Real x_off_dim=0.0;
32 Real absdyn_dim = 10 PT; // UGR
34 m_p = new Molecule;
35 Real w_dim = width().length();
36 if ( left_dyn_b_ ) {
37 w_dim -= absdyn_dim;
38 x_off_dim += absdyn_dim;
40 if ( right_dyn_b_ ) {
41 w_dim -= absdyn_dim;
44 if (w_dim < 0) {
45 error("Crescendo too small");
46 w_dim = 0;
48 Symbol s( paper()->lookup_l()->hairpin(w_dim, grow_dir_i_ < 0) );
49 m_p->add(Atom(s));
50 int pos = (dir_i_ >0) ? staff_size_i_ + 4 : - 4 ;
51 if(dir_i_<0 ) // should do something better anyway.
52 m_p->translate(Offset(0, -m_p->extent().y.left ));
53 m_p->translate(Offset(x_off_dim,pos * paper()->internote()));
56 IMPLEMENT_STATIC_NAME(Crescendo);