]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/hyphen-spanner.cc
release: 1.3.62
[lilypond.git] / lily / hyphen-spanner.cc
index 8efba072e1c838c6efdd106cb01d3223905fb7ea..624f682be20234a3c1085a7c60e04e85ae908856 100644 (file)
@@ -8,90 +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 "spanner.hh"
+#include "item.hh"
 
-Hyphen_spanner::Hyphen_spanner ()
-  : Directional_spanner ()
-{
-  dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0;
-}
+MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Hyphen_spanner,brew_molecule)
 
-// UGH - is this even used?
-Offset
-Hyphen_spanner::center () const
+SCM 
+Hyphen_spanner::brew_molecule (SCM smob)
 {
-  Real dx = extent (X_AXIS).length ();
+  Spanner * sp  =dynamic_cast<Spanner*> (unsmob_element (smob));
+  Molecule  mol;
 
-  return Offset (dx / 2, 0);
-}
+  Real leftext = sp->get_bound (LEFT)->extent (X_AXIS).length ();
 
-Molecule*
-Hyphen_spanner::do_brew_molecule_p () const
-{
-  Molecule* mol_p = new Molecule;
-
-  Real w = 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_p->add_molecule (a);
-
-  return mol_p;
-}
 
-Interval
-Hyphen_spanner::do_height () const
-{
-  return Interval (0,0);
+  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;
+}