]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/hyphen-spanner.cc
release: 1.3.56
[lilypond.git] / lily / hyphen-spanner.cc
index 8efba072e1c838c6efdd106cb01d3223905fb7ea..a4ddc8c75014625cba86337adae040b8a93142bc 100644 (file)
 #include "paper-column.hh"
 #include "paper-def.hh"
 #include "hyphen-spanner.hh"
+#include "dimension-cache.hh"
 
-Hyphen_spanner::Hyphen_spanner ()
-  : Directional_spanner ()
+Hyphen_spanner::Hyphen_spanner (SCM s)
+  : Spanner (s)
 {
   dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0;
-}
-
-// UGH - is this even used?
-Offset
-Hyphen_spanner::center () const
-{
-  Real dx = extent (X_AXIS).length ();
 
-  return Offset (dx / 2, 0);
+  set_extent_callback (Score_element::point_dimension_callback,Y_AXIS);
 }
 
-Molecule*
-Hyphen_spanner::do_brew_molecule_p () const
+MAKE_SCHEME_SCORE_ELEMENT_CALLBACKS(Hyphen_spanner)
+Molecule 
+Hyphen_spanner::do_brew_molecule () const
 {
-  Molecule* mol_p = new Molecule;
+  Molecule  mol;
 
-  Real w = extent (X_AXIS).length ();
+  Real w = spanner_length ();
 
   w += (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]);
 
-  Real th = paper_l ()->get_var ("hyphen-thickness");
-  Real h = paper_l ()->get_var ("hyphen-height");
+  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");
+  Real l = paper_l ()->get_var ("hyphen_minimum_length");
   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);
+  mol.add_molecule (a);
 
-  return mol_p;
+  return mol;
 }
 
-Interval
-Hyphen_spanner::do_height () const
-{
-  return Interval (0,0);
-}
 
 void
-Hyphen_spanner::do_post_processing ()
+Hyphen_spanner::after_line_breaking ()
 {
   // UGH
   Real gap = paper_l ()->get_var ("interline");
@@ -76,8 +66,8 @@ Hyphen_spanner::do_post_processing ()
   Direction d = LEFT;
   do
     {
-      Item* t = spanned_drul_[d]
-       ? spanned_drul_[d] : spanned_drul_[(Direction)-d];
+      Item* t = get_bound (d)
+       ? get_bound (d) : get_bound ((Direction)-d);
       if (d == LEFT)
         dx_f_drul_[d] += t->extent (X_AXIS).length ();
       else
@@ -90,7 +80,7 @@ Hyphen_spanner::do_post_processing ()
 void
 Hyphen_spanner::set_textitem (Direction d, Item* textitem_l)
 {
-  set_bounds (d, textitem_l);
+  set_bound (d, textitem_l);
   add_dependency (textitem_l);
 }