]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/hyphen-spanner.cc
release: 1.3.62
[lilypond.git] / lily / hyphen-spanner.cc
index 65470ea81c4204e414228bf39055ff20d45e2425..624f682be20234a3c1085a7c60e04e85ae908856 100644 (file)
@@ -8,79 +8,54 @@
   (adapted from extender-spanner)
 */
 
-/*
-  TODO: too complicated implementation.  Why the dx_drul?.
- */
-
 #include <math.h>
+
 #include "box.hh"
-#include "debug.hh"
 #include "lookup.hh"
 #include "molecule.hh"
-#include "paper-column.hh"
 #include "paper-def.hh"
 #include "hyphen-spanner.hh"
-#include "dimension-cache.hh"
+#include "spanner.hh"
+#include "item.hh"
 
-Hyphen_spanner::Hyphen_spanner ()
-  : Spanner ()
-{
-  dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0;
+MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Hyphen_spanner,brew_molecule)
 
-  dim_cache_[Y_AXIS]->set_callback (Dimension_cache::point_dimension_callback);
-}
-
-Molecule 
-Hyphen_spanner::do_brew_molecule () const
+SCM 
+Hyphen_spanner::brew_molecule (SCM smob)
 {
+  Spanner * sp  =dynamic_cast<Spanner*> (unsmob_element (smob));
   Molecule  mol;
 
-  Real w = spanner_length ();
+  Real leftext = sp->get_bound (LEFT)->extent (X_AXIS).length ();
 
-  w += (dx_f_drul_[RIGHT] - dx_f_drul_[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 th = paper_l ()->get_var ("hyphen_thickness");
-  Real h = paper_l ()->get_var ("hyphen_height");
 
-  // UGH. 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
-  Real l = paper_l ()->get_var ("hyphen_minimum_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);
-  Molecule a = lookup_l ()->filledbox ( Box (Interval ((w-l)/2,(w+l)/2), Interval (h,h+th)));
-  a.translate (Offset (dx_f_drul_[LEFT], 0));
-
-  mol.add_molecule (a);
 
-  return mol;
+  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);
+  return mol.create_scheme ();
 }
-
-
-void
-Hyphen_spanner::do_post_processing ()
-{
-  // UGH
-  Real gap = paper_l ()->get_var ("interline");
-
-  Direction d = LEFT;
-  do
-    {
-      Item* t = spanned_drul_[d]
-       ? spanned_drul_[d] : spanned_drul_[(Direction)-d];
-      if (d == LEFT)
-        dx_f_drul_[d] += t->extent (X_AXIS).length ();
-      else
-       dx_f_drul_[d] -= d * gap / 2;
-    }
-  while (flip(&d) != LEFT);
-}
-
   
 void
 Hyphen_spanner::set_textitem (Direction d, Item* textitem_l)
 {
-  set_bounds (d, textitem_l);
-  add_dependency (textitem_l);
+  elt_l_->set_bound (d, textitem_l);
+  elt_l_->add_dependency (textitem_l);
 }
 
-
+Hyphen_spanner::Hyphen_spanner (Spanner*s)
+{
+  elt_l_ = s;
+}