]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/hyphen-spanner.cc
* lily/script-engraver.cc (make_script_from_event): don't crash on
[lilypond.git] / lily / hyphen-spanner.cc
index ee5c20bc204e50414fe0876e0a50215e3b700d32..e8227bbf812d049a2484bdc06b9e7e8ea12630a4 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1999 Glen Prideaux <glenprideaux@iname.com>
+  (c)  1999--2003 Glen Prideaux <glenprideaux@iname.com>
 
  (adapted from lyric-extender)
 */
 #include "spanner.hh"
 #include "item.hh"
 
-MAKE_SCHEME_CALLBACK (Hyphen_spanner,brew_molecule,1)
+MAKE_SCHEME_CALLBACK (Hyphen_spanner,set_spacing_rods,1);
+SCM
+Hyphen_spanner::set_spacing_rods (SCM smob)
+{
+  Grob*me = unsmob_grob (smob);
+
+  Rod rod;
+  Spanner*sp = dynamic_cast<Spanner*> (me);
+  Item * l = sp->get_bound (LEFT);
+  Item * r =  sp->get_bound (RIGHT);
+  rod.item_l_drul_[LEFT] = l;
+  rod.item_l_drul_[RIGHT] =r;
+  rod.distance_ =
+    gh_scm2double (me->get_grob_property ("minimum-length"))
+    + l->extent (l, X_AXIS)[RIGHT]
+    - r->extent (r, X_AXIS)[LEFT];
+
+  rod.add_to_cols ();
+  return SCM_UNSPECIFIED;
+}
 
+MAKE_SCHEME_CALLBACK (Hyphen_spanner,brew_molecule,1)
 SCM 
 Hyphen_spanner::brew_molecule (SCM smob)
 {
@@ -45,20 +65,28 @@ Hyphen_spanner::brew_molecule (SCM smob)
     }
   while (flip (&d) != LEFT);
   
-  Real lt = sp->get_paper ()->get_var ("linethickness");
+  Real lt = sp->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
   Real th = gh_scm2double (sp->get_grob_property ("thickness")) * lt ;
   Real h = gh_scm2double (sp->get_grob_property ("height"));
 
   // interval?
-  Real l = gh_scm2double (sp->get_grob_property ("minimum-length"));  
   Real x = gh_scm2double (sp->get_grob_property ("maximum-length"));
-  // The hyphen can exist in the word space of the left lyric ...
   SCM space =  sp->get_bound (LEFT)->get_grob_property ("word-space");
+
+  Real word_space  = 1.0;
   if (gh_number_p (space))
     {
-      bounds[LEFT] -=  gh_scm2double (space);
+      word_space = gh_scm2double (space);
     }
 
+  /*
+    We remove word space from the distance so it doesn't look like an extender.
+    
+   */
+  Real l = (gh_scm2double (sp->get_grob_property ("minimum-length"))
+    - word_space ) >? word_space;
+  
+  
   /*
     we should probably do something more intelligent when bounds is
     empty, but at least this doesn't crash.
@@ -117,8 +145,8 @@ Hyphen_spanner::Hyphen_spanner (Spanner*s)
 
 
 ADD_INTERFACE (Hyphen_spanner, "lyric-hyphen-interface",
-  "A centred hyphen is a simple line between lyrics used to divide
-syllables.   The length of the hyphen line should stretch based on the
-size of the gap between syllables.",
+  "A centred hyphen is a simple line between lyrics used to divide "
+"syllables.   The length of the hyphen line should stretch based on the "
+"size of the gap between syllables.",
   "thickness height minimum-length maximum-length word-space");