]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/crescendo.cc
release: 0.0.65
[lilypond.git] / lily / crescendo.cc
index 29aa3ab84176b1e0f2105a157b47f627ec8bfb96..98317f85e2fa3b1f7540ad28c1f1a2370cc94a2e 100644 (file)
@@ -1,38 +1,55 @@
 /*
   crescendo.cc -- implement Crescendo
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
+#include "dimen.hh"
 #include "crescendo.hh"
 #include "lookup.hh"
 #include "paper-def.hh"
+#include "debug.hh"
 
-Crescendo::Crescendo(int s)
+Crescendo::Crescendo()
 {
-    staff_size_i_ = s;
     grow_dir_i_ =0;
     dir_i_ = -1 ;
+    left_dyn_b_ = right_dyn_b_ =false;
 }
 
-Spanner*
-Crescendo::do_break_at(PCol*, PCol*)const
-{
-    return new Crescendo(*this);
-}
 
 
 Molecule*
-Crescendo::brew_molecule_p() const return m_p ;
+Crescendo::brew_molecule_p() const
 {
+    Molecule* m_p =0;
+    Real x_off_dim=0.0;
+    Real absdyn_dim = 10 PT;   // ugh
+    
     m_p = new Molecule;
-    Real w_f = width().length();
-    Symbol s( paper()->lookup_l()->hairpin(w_f, grow_dir_i_ < 0) );
+    Real w_dim = width().length();
+    if ( left_dyn_b_ ) {
+       w_dim -= absdyn_dim;
+       x_off_dim += absdyn_dim;
+    }
+    if ( right_dyn_b_ ) {
+       w_dim -= absdyn_dim;
+    }
+    
+    if (w_dim < 0) {
+       warning("Crescendo too small");
+       w_dim = 0;
+    }
+    Real lookup_wid = w_dim * 0.9; // make it slightly smaller.
+
+    Symbol s( paper()->lookup_l()->hairpin( lookup_wid, grow_dir_i_ < 0) );
     m_p->add(Atom(s));
-    int pos = (dir_i_ >0) ? staff_size_i_ + 4 : - 4 ;
-    m_p->translate(Offset(0,pos * paper()->internote()));
+    int pos = get_position_i(s.dim.y);
+    m_p->translate(Offset(x_off_dim + 0.05 * w_dim, 
+                         pos * paper()->internote_f()));
+    return m_p;
 }
 
 IMPLEMENT_STATIC_NAME(Crescendo);