]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/crescendo.cc
release: 1.3.31
[lilypond.git] / lily / crescendo.cc
index 481d30bca713b4c7335cf3542176dfec5a55b89a..ca1cf50cd01a53dba783116bb96dc728333d9403 100644 (file)
@@ -13,7 +13,7 @@
 #include "paper-def.hh"
 #include "debug.hh"
 #include "paper-column.hh"
-#include "atom.hh"
+
 
 Crescendo::Crescendo ()
 {
@@ -22,8 +22,8 @@ Crescendo::Crescendo ()
 
 
 
-Molecule*
-Crescendo::do_brew_molecule_p () const
+Molecule 
+Crescendo::do_brew_molecule () const
 {
   Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten");
   Real extra_left =  get_broken_left_end_align ();
@@ -33,9 +33,11 @@ Crescendo::do_brew_molecule_p () const
 
   if (!isdir_b (dir) || !gh_pair_p (dyns))
     {
-Crescendo * me = (Crescendo*)this;
+      Crescendo * me = (Crescendo*)this;
       me->set_elt_property ("transparent", SCM_BOOL_T);
-      return new Molecule;
+      Molecule m;
+      
+      return m;
     }
   
   Direction gd = to_dir (dir);
@@ -67,31 +69,48 @@ Crescendo * me = (Crescendo*)this;
 
   Drul_array<bool> broken;
   Direction d = LEFT;
-  do {
-    Paper_column* s = dynamic_cast<Paper_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 (-gd)];
-  Real height = paper_l()->get_var ("crescendo_height");
-  Real thick = paper_l ()->get_var ("crescendo_thickness");
-
-  const char* hairpin = (gd < 0)? "decrescendo" :  "crescendo";
-  Molecule * m
-    = new Molecule;
-  m->dim_.x () = Interval (0, width);
-  m->dim_.y () = Interval (-2*height, 2*height);
-
-  SCM at = gh_list (ly_symbol2scm (hairpin),
-                    gh_double2scm (thick),
-                    gh_double2scm (width),
-                    gh_double2scm (height),
-                    gh_double2scm (continued ? height/2 : 0.0),
-                    SCM_UNDEFINED);
-
-  m->add_atom (at);
-  m->translate_axis (extra_left, X_AXIS);
+  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";
+
+      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;
 }