]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/crescendo.cc
release: 1.1.45
[lilypond.git] / lily / crescendo.cc
index 163e3be7376c229befb865ff40b1738269aad492..b499af90b69e42b964283ac9660e1f50368ef561 100644 (file)
@@ -1,54 +1,74 @@
 /*
   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>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
-#include "dimen.hh"
+
+#include "molecule.hh"
 #include "crescendo.hh"
 #include "lookup.hh"
+#include "dimensions.hh"
 #include "paper-def.hh"
 #include "debug.hh"
-Crescendo::Crescendo(int s)
-{
-    staff_size_i_ = s;
-    grow_dir_i_ =0;
-    dir_i_ = -1 ;
-    left_dyn_b_ = right_dyn_b_ =false;
-}
+#include "score-column.hh"
 
-Spanner*
-Crescendo::do_break_at(PCol*, PCol*)const
+Crescendo::Crescendo ()
 {
-    return new Crescendo(*this);
+  grow_dir_ =0;
+  dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
 }
 
 
-Molecule*
-Crescendo::brew_molecule_p() const return m_p ;
+
+
+Molecule
+Crescendo::get_symbol () const
 {
-    Real x_off_dim=0.0;
-    Real absdyn_dim = 10 PT;   // UGR
-    
-    m_p = new Molecule;
-    Real w_dim = width().length();
-    if ( left_dyn_b_ ) {
-       w_dim -= absdyn_dim;
-       x_off_dim += absdyn_dim;
+  Real w_dim = extent (X_AXIS).length ();
+  Real absdyn_dim = paper_l ()-> get_realvar (ly_symbol ("crescendo_shorten"));
+  if (dyn_b_drul_[LEFT])
+    {
+      w_dim -= absdyn_dim;
     }
-    if ( right_dyn_b_ ) {
-       w_dim -= absdyn_dim;
+  if (dyn_b_drul_[RIGHT])
+    {
+      w_dim -= absdyn_dim;
     }
-    
-    if (w_dim < 0) {
-       error("Crescendo too small");
-       w_dim = 0;
+
+  if (w_dim < 0)
+    {
+      warning (_ ("crescendo") + " " + _ ("too small"));
+      w_dim = 0;
     }
-    Symbol s( paper()->lookup_l()->hairpin(w_dim, 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()));
+
+  Drul_array<bool> broken;
+  Direction d = LEFT;
+  do {
+    Score_column* s = dynamic_cast<Score_column*>(spanned_drul_[d]); // UGH
+    broken[d] = (!s->musical_b ());
+  } while (flip (&d) != LEFT);
+  
+
+  bool continued = broken[Direction (-grow_dir_)];
+  return Molecule (lookup_l ()->hairpin (w_dim, grow_dir_ < 0, continued));
 }
 
-IMPLEMENT_STATIC_NAME(Crescendo);
+Molecule*
+Crescendo::do_brew_molecule_p () const
+{
+  Molecule* m_p =0;
+  Real absdyn_dim = paper_l ()-> get_realvar (ly_symbol ("crescendo_shorten"));
+  Real x_off_dim=0.0;
+  if (dyn_b_drul_[LEFT])
+    x_off_dim += absdyn_dim;
+
+  m_p = new Molecule;
+  Molecule s (get_symbol ());
+  m_p->add_molecule (s);
+  m_p->translate_axis (x_off_dim, X_AXIS);
+  return m_p;
+}
+
+