]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/hyphen-spanner.cc
patch::: 1.3.63.uu1: Re: Lilypond?
[lilypond.git] / lily / hyphen-spanner.cc
index 624f682be20234a3c1085a7c60e04e85ae908856..af618e87ca33851fb25d5a0637e61f0ee68fe0ab 100644 (file)
@@ -5,7 +5,7 @@
 
   (c) 1999 Glen Prideaux <glenprideaux@iname.com>
 
-  (adapted from extender-spanner)
+  (adapted from lyric-extender)
 */
 
 #include <math.h>
@@ -23,36 +23,52 @@ MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Hyphen_spanner,brew_molecule)
 SCM 
 Hyphen_spanner::brew_molecule (SCM smob)
 {
-  Spanner * sp  =dynamic_cast<Spanner*> (unsmob_element (smob));
-  Molecule  mol;
+  Spanner * sp = dynamic_cast<Spanner*> (unsmob_element (smob));
 
-  Real leftext = sp->get_bound (LEFT)->extent (X_AXIS).length ();
+  Score_element * common = sp;
+  Direction d = LEFT;
+  do
+    {
+      common = common->common_refpoint( sp->get_bound (d), X_AXIS);
+    }
+  while (flip (&d) != LEFT);
+  Interval bounds;
+  
+  do
+    {
+      Real  x = sp->get_bound (d)->relative_coordinate (common, X_AXIS);
+      Interval ext =  sp->get_bound (d)->extent (X_AXIS);
+      bounds[d] = (x + ext[-d]);
+    }
+  while (flip (&d) != LEFT);
 
+  
+  
   Real ss = sp->paper_l ()->get_var ("staffspace");
   Real lt = sp->paper_l ()->get_var ("stafflinethickness");
   Real th = gh_scm2double (sp->get_elt_property ("thickness")) * lt ;
   Real h = gh_scm2double (sp->get_elt_property ("height")) * ss;
   Real l = gh_scm2double (sp->get_elt_property ("minimum-length")) * ss;  
-  Real w = sp->spanner_length () - leftext - ss/2; 
-
-
+  Real w  = bounds.length ();
   /* First try: just make the hyphen take 1/3 of the available space  
    for length, use a geometric mean of the available space and some minimum
   */
   if(l < w)
     l = sqrt(l*w);
 
-  Box b  (Interval ( (w-l)/2, (w+l)/2), Interval (h,h+th));
-  mol.add_molecule (sp->lookup_l ()->filledbox (b));
-  mol.translate_axis(leftext, X_AXIS);
+  Box b  (Interval (-l/2,l/2), Interval (h,h+th));
+  Molecule mol (sp->lookup_l ()->filledbox (b));
+  mol.translate_axis (bounds.center ()
+                     -sp->relative_coordinate (common, X_AXIS),
+                     X_AXIS);
   return mol.create_scheme ();
 }
   
 void
-Hyphen_spanner::set_textitem (Direction d, Item* textitem_l)
+Hyphen_spanner::set_textitem (Direction d, Score_element* b)
 {
-  elt_l_->set_bound (d, textitem_l);
-  elt_l_->add_dependency (textitem_l);
+  elt_l_->set_bound (d, b);
+  elt_l_->add_dependency (b);
 }
 
 Hyphen_spanner::Hyphen_spanner (Spanner*s)