]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/crescendo.cc
release: 0.1.56
[lilypond.git] / lily / crescendo.cc
index f520106c19f0e7cc571f7d635ed368740c470f5d..400b6709a05b68821543ff39e10f35e409a056f0 100644 (file)
@@ -1,60 +1,79 @@
 /*
   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 "molecule.hh"
 #include "dimen.hh"
 #include "crescendo.hh"
 #include "lookup.hh"
 #include "paper-def.hh"
 #include "debug.hh"
+#include "score-column.hh"
 
 Crescendo::Crescendo()
-    : Staff_side(this)
 {
-    grow_dir_i_ =0;
-    dir_i_ = -1 ;
-    left_dyn_b_ = right_dyn_b_ =false;
+  grow_dir_ =0;
+  dir_ = DOWN;
+  dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
 }
 
-Spanner*
-Crescendo::do_break_at(PCol*, PCol*)const
+Interval
+Crescendo::symbol_height() const
 {
-    return new Crescendo(*this);
+  return get_symbol().dim_[Y_AXIS];
 }
 
+static Real absdyn_dim = 10 PT;        // ugh
 
-Molecule*
-Crescendo::brew_molecule_p() const
+Atom
+Crescendo::get_symbol() const
 {
-    Molecule* m_p =0;
-    Real x_off_dim=0.0;
-    Real absdyn_dim = 10 PT;   // ugh
-    
-    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 = width().length ();
+  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;
     }
-    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 = get_position_i(s.dim.y);
-    m_p->translate(Offset(x_off_dim + 0.05 * w_dim, 
-                         pos * paper()->internote()));
-    return m_p;
+
+  Drul_array<bool> broken;
+  Direction d = LEFT;
+  do {
+    Score_column* s = (Score_column* )spanned_drul_[d] ; // UGH
+    broken[d] = (!s->musical_b());
+  } while (flip(&d) != LEFT);
+  
+
+  bool continued = broken[(Direction)-grow_dir_];
+  return Atom (paper()->lookup_l ()->hairpin (w_dim, grow_dir_ < 0, continued));
 }
 
-IMPLEMENT_STATIC_NAME(Crescendo);
+Molecule*
+Crescendo::brew_molecule_p() const
+{
+  Molecule* m_p =0;
+  Real x_off_dim=0.0;
+  if (dyn_b_drul_[LEFT])
+    x_off_dim += absdyn_dim;
+
+  m_p = new Molecule;
+  Atom s (get_symbol());
+  m_p->add (Atom (s));
+  m_p->translate (Offset (x_off_dim, y_));
+  return m_p;
+}
+
+
+IMPLEMENT_IS_TYPE_B1(Crescendo,Spanner);