]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/crescendo.cc
patch::: 1.3.107.mb1: Re: lily 1.3.107
[lilypond.git] / lily / crescendo.cc
index 616e43125306c54148218ddf91ac3af809ee89ae..9bfbf02eff6c8aaff9edc2fca3730cedb13d7d98 100644 (file)
@@ -9,79 +9,40 @@
 #include "molecule.hh"
 #include "crescendo.hh"
 #include "spanner.hh"
-#include "lookup.hh"
+#include "font-interface.hh"
 #include "dimensions.hh"
 #include "paper-def.hh"
 #include "debug.hh"
 #include "paper-column.hh"
 
-void
-Crescendo::set_interface (Score_element*s)
-{
-  s->set_elt_property ("dynamic-drul", gh_cons (SCM_EOL, SCM_EOL));
-}
-
-
-
-MAKE_SCHEME_CALLBACK(Crescendo,brew_molecule,1);
-
-/*
-
-  TODO:
-
-  * should span the crescendo on any dynamic-text items, and
-  calculate their dimensions to determine shortening; junk shortening
-  code and related elt props.
-
-  * separate the dashed-line version and the hairpin version into two
-  brew_molecule functions.
+MAKE_SCHEME_CALLBACK (Crescendo, brew_molecule, 1);
 
-  * generalise dashed-line into generic text spanner, for ottava, accelerando, etc.
-
-  
-*/
 SCM
 Crescendo::brew_molecule (SCM smob) 
 {
   Score_element *me= unsmob_element (smob);
-  Spanner * sp = dynamic_cast<Spanner*>(me);
-  Real ss = me->paper_l ()->get_var ("staffspace");
-  Real sl = me->paper_l ()->get_var ("stafflinethickness");  
-  
-  Real absdyn_dim = gh_scm2double (me->get_elt_property ("shorten-for-letter"));
-  Real extra_left =  sp->get_broken_left_end_align ();
+  Spanner *span = dynamic_cast<Spanner*>(me);
 
-  SCM dir = me->get_elt_property("grow-direction");
-  SCM dyns = me->get_elt_property ("dynamic-drul");
+  Real line = me->paper_l ()->get_var ("stafflinethickness");  
+  
+  Real broken_left =  span->get_broken_left_end_align ();
 
-  if (!isdir_b (dir) || !gh_pair_p (dyns))
+  SCM s = me->get_elt_property("grow-direction");
+  if (!isdir_b (s))
     {
       me->suicide ();
       return SCM_EOL;
     }
   
-  Direction gd = to_dir (dir);
+  Direction grow_dir = to_dir (s);
 
-  bool dynleft= unsmob_element (gh_car (dyns));
-  bool dynright = unsmob_element (gh_cdr (dyns));
-  
-  if (dynleft)
-    extra_left += absdyn_dim;
-
-  Real width = sp->spanner_length()- sp->get_broken_left_end_align ();
-
-  if (dynleft)
-    {
-      width -= absdyn_dim;
-    }
-  if (dynright)
-    {
-      width -= absdyn_dim;
-    }
+  Real width = span->spanner_length ();
+  width -= span->get_broken_left_end_align ();
 
   if (width < 0)
     {
-      warning (_ ("crescendo") + " " + _ ("too small"));
+      warning (_ ((grow_dir < 0) ? "decrescendo too small"
+                 : "crescendo too small"));
       width = 0;
     }
 
@@ -89,68 +50,28 @@ Crescendo::brew_molecule (SCM smob)
   Direction d = LEFT;
   do
     {
-      Paper_column* s = dynamic_cast<Paper_column*>(sp->get_bound (d)); // UGH
+      Paper_column* s = dynamic_cast<Paper_column*> (span->get_bound (d)); // UGH
       broken[d] = (!s->musical_b ());
     }
   while (flip (&d) != LEFT);
   
-  Molecule m;
+  bool continued = broken[Direction (-grow_dir)];
+  Real height = gh_scm2double (me->get_elt_property ("height"));
+  Real thick = line * gh_scm2double (me->get_elt_property ("thickness"));
   
-  Real pad = 0;
-  SCM s = me->get_elt_property ("start-text");
-  if (gh_string_p (s))
-    {
-      Molecule start_text (me->lookup_l ()->text ("italic",
-                                             ly_scm2string (s),
-                                                 me->paper_l ()));
-      m.add_molecule (start_text);
-
-      pad = me->paper_l ()->get_var ("staffspace") / 2;        //  ugh.
-
-      width -= start_text.extent (X_AXIS).length ();
-      width -= pad;
-      width = width >? 0;
-    }
-
-  SCM at;
-  s =me->get_elt_property ("spanner");
-  Real height;
-
-  if (gh_string_p (s) && ly_scm2string (s) == "dashed-line")
-    {
-      Real thick = gh_scm2double (me->get_elt_property ("dash-thickness")) * sl ;
-      Real dash = gh_scm2double (me->get_elt_property  ("dash-length")) * ss;
-      
-      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 = ss * gh_scm2double (me->get_elt_property ("height"));
-      Real thick = sl * gh_scm2double (me->get_elt_property ("thickness"));
-      
-      const char* hairpin = (gd < 0)? "decrescendo" :  "crescendo";
-
-      at = gh_list (ly_symbol2scm (hairpin),
+  const char* type = (grow_dir < 0) ? "decrescendo" :  "crescendo";
+  SCM hairpin = gh_list (ly_symbol2scm (type),
                    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 span (b, at);
 
-  m.add_at_edge (X_AXIS, RIGHT, span, pad);
-  m.translate_axis (extra_left, X_AXIS);
+  Box b (Interval (0, width), Interval (-2*height, 2*height));
+  Molecule mol (b, hairpin);
+  mol.translate_axis (broken_left, X_AXIS);
 
-  return m.create_scheme ();
+  return mol.smobbed_copy ();
 }