]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/crescendo.cc
release: 1.3.31
[lilypond.git] / lily / crescendo.cc
index 024a697c1799f1cf038581e0cb2ac077b2a9b918..ca1cf50cd01a53dba783116bb96dc728333d9403 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "molecule.hh"
 #include "dimensions.hh"
 #include "paper-def.hh"
 #include "debug.hh"
-#include "score-column.hh"
+#include "paper-column.hh"
+
 
 Crescendo::Crescendo ()
 {
-  grow_dir_ =0;
-  dir_ = DOWN;
-  dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
+  set_elt_property ("dynamic-drul", gh_cons (SCM_BOOL_F, SCM_BOOL_F));
 }
 
-Interval
-Crescendo::symbol_height () const
-{
-  return get_symbol ().dim_[Y_AXIS];
-}
 
-static Real absdyn_dim = 10 PT;        // ugh
 
-Molecule
-Crescendo::get_symbol () const
+Molecule 
+Crescendo::do_brew_molecule () const
 {
-  Real w_dim = extent (X_AXIS).length ();
-  if (dyn_b_drul_[LEFT])
+  Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten");
+  Real extra_left =  get_broken_left_end_align ();
+
+  SCM dir = get_elt_property("grow-direction");
+  SCM dyns = get_elt_property ("dynamic-drul");
+
+  if (!isdir_b (dir) || !gh_pair_p (dyns))
     {
-      w_dim -= absdyn_dim;
+      Crescendo * me = (Crescendo*)this;
+      me->set_elt_property ("transparent", SCM_BOOL_T);
+      Molecule m;
+      
+      return m;
     }
-  if (dyn_b_drul_[RIGHT])
+  
+  Direction gd = to_dir (dir);
+
+  bool dynleft= to_boolean (gh_car (dyns));
+  bool dynright = to_boolean (gh_cdr (dyns));
+  
+  if (dynleft)
+    extra_left += absdyn_dim;
+
+  
+
+  Real width = spanner_length()- get_broken_left_end_align ();
+
+  if (dynleft)
     {
-      w_dim -= absdyn_dim;
+      width -= absdyn_dim;
+    }
+  if (dynright)
+    {
+      width -= absdyn_dim;
     }
 
-  if (w_dim < 0)
+  if (width < 0)
     {
       warning (_ ("crescendo") + " " + _ ("too small"));
-      w_dim = 0;
+      width = 0;
     }
 
   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);
+  do
+    {
+      Paper_column* s = dynamic_cast<Paper_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));
-}
+  SCM at;
+  SCM s = get_elt_property ("spanner");
+  Real height;
+  if (gh_string_p (s) && ly_scm2string (s) == "dashed-line")
+    {
+      Real thick = paper_l ()->get_var ("crescendo_dash_thickness");
+      Real dash = paper_l ()->get_var ("crescendo_dash");
+      height = thick;
+      at = gh_list (ly_symbol2scm (ly_scm2string (s).ch_C ()),
+                   gh_double2scm (thick),
+                   gh_double2scm (dash),
+                   gh_double2scm (width),
+                   SCM_UNDEFINED);
+    }
+  else
+    {
+      bool continued = broken[Direction (-gd)];
+      height = paper_l()->get_var ("crescendo_height");
+      Real thick = paper_l ()->get_var ("crescendo_thickness");
+      
+      const char* hairpin = (gd < 0)? "decrescendo" :  "crescendo";
 
-Molecule*
-Crescendo::do_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;
-  Molecule s (get_symbol ());
-  m_p->add_molecule (s);
-  m_p->translate (Offset (x_off_dim, coordinate_offset_f_));
-  return m_p;
+      at = gh_list (ly_symbol2scm (hairpin),
+                   gh_double2scm (thick),
+                   gh_double2scm (width),
+                   gh_double2scm (height),
+                   gh_double2scm (continued ? height/2 : 0.0),
+                   SCM_UNDEFINED);
+    }
+  
+  Box b (Interval (0, width), Interval (-2*height, 2*height));
+  Molecule m (b, at);
+  
+  m.translate_axis (extra_left, X_AXIS);
+  return m;
 }
 
 
-