]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/slur-scoring.cc
* scm/define-context-properties.scm
[lilypond.git] / lily / slur-scoring.cc
index d7e0129aa3c3ca089e3dee5f0a4f6e059a9ced10..8543c9e90486763b5fa5cce0af980ce309c67d59 100644 (file)
@@ -124,6 +124,7 @@ Slur_score_parameters::fill (Grob *me)
   edge_slope_exponent_
     = get_detail (details, ly_symbol2scm ("edge-slope-exponent"));
 }
+
 Real
 broken_trend_y (Slur_score_state const &state, Direction hdir)
 {
@@ -286,7 +287,7 @@ Slur_score_state::fill (Grob *me)
     }
 
   staff_space_ = Staff_symbol_referencer::staff_space (me);
-  Real lt = me->get_paper ()->get_dimension (ly_symbol2scm ("linethickness"));
+  Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
   thickness_ = robust_scm2double (me->get_property ("thickness"), 1.0) *  lt;
   
   dir_ = get_grob_direction (me);
@@ -304,7 +305,12 @@ Slur_score_state::fill (Grob *me)
 
       Direction d = LEFT;
       do {
-       common_[a] = common_[a]->common_refpoint (sp->get_bound (d), a);
+       /*
+         If bound is not in note-columns, we don't want to know about
+         its Y-position
+        */
+       if (a != Y_AXIS) 
+         common_[a] = common_[a]->common_refpoint (sp->get_bound (d), a);
       }
       while (flip (&d) != LEFT);
     }
@@ -313,6 +319,9 @@ Slur_score_state::fill (Grob *me)
   is_broken_ = (!extremes_[LEFT].note_column_
                || !extremes_[RIGHT].note_column_); 
 
+  has_same_beam_ =
+    (extremes_[LEFT].stem_ && extremes_[RIGHT].stem_
+     && Stem::get_beam (extremes_[LEFT].stem_) == Stem::get_beam (extremes_[RIGHT].stem_));
   
   base_attachments_ = get_base_attachments ();
 
@@ -341,9 +350,6 @@ Slur_score_state::fill (Grob *me)
     = (extremes_[LEFT].stem_ && Stem::get_beam (extremes_[LEFT].stem_))
     || (extremes_[RIGHT].stem_ && Stem::get_beam (extremes_[RIGHT].stem_));
 
-  has_same_beam_ =
-    (extremes_[LEFT].stem_ && extremes_[RIGHT].stem_
-     && Stem::get_beam (extremes_[LEFT].stem_) == Stem::get_beam (extremes_[RIGHT].stem_));
 
   
   set_next_direction ();
@@ -398,7 +404,7 @@ Slur_score_state::get_best_curve ()
 
 #if DEBUG_SLUR_SCORING
   SCM inspect_quants = slur_->get_property ("inspect-quants");
-  if (to_boolean (slur_->get_paper ()
+  if (to_boolean (slur_->get_layout ()
                  ->lookup_variable (ly_symbol2scm ("debug-slur-scoring")))
       && scm_is_pair (inspect_quants))
     {
@@ -502,18 +508,8 @@ Slur_score_state::get_base_attachments () const
            y = head->extent (common_[Y_AXIS], Y_AXIS)[dir_];
          y += dir_ * 0.5 * staff_space_;
 
-         Real pos
-           = (y - extremes_[d].staff_->relative_coordinate (common_[Y_AXIS],
-                                                           Y_AXIS))
-           * 2.0 / staff_space_;
 
-         /* start off staffline. */
-         if (fabs (pos - my_round (pos)) < 0.2
-             && Staff_symbol_referencer::on_staffline (head, (int) rint (pos))
-             && Staff_symbol_referencer::line_count (head) - 1 >= rint (pos)
-             )
-           // TODO: calc from slur thick & line thick, parameter.      
-           y += 1.5 * staff_space_ * dir_ / 10;
+         y = move_away_from_staffline (y, head); 
 
          Grob * fh = Note_column::first_head (extremes_[d].note_column_);
          x =
@@ -543,12 +539,19 @@ Slur_score_state::get_base_attachments () const
          if (extremes_[-d].bound_ != col)
            {
              y = robust_relative_extent (col, common_[Y_AXIS], Y_AXIS)[dir_];
-             if (get_grob_direction (col) == dir_)
-               y -= dir_ ;
+             y += dir_ * 0.5 * staff_space_;
+             
+             if (get_grob_direction (col) == dir_
+                 && Note_column::get_stem (col)
+                 && !Stem::is_invisible (Note_column::get_stem (col)))
+               y -= dir_ * 1.5 * staff_space_;
            }
          else
            y = base_attachment[-d][Y_AXIS];
 
+         
+         y = move_away_from_staffline (y, col);
+           
          base_attachment[d] = Offset (x, y);  
        }
     }
@@ -557,6 +560,24 @@ Slur_score_state::get_base_attachments () const
   return base_attachment;
 }
 
+Real
+Slur_score_state::move_away_from_staffline (Real y,
+                                           Grob *on_staff) const
+{
+  Real pos
+    = (y - Staff_symbol_referencer::get_staff_symbol (on_staff)->relative_coordinate (common_[Y_AXIS],
+                                                                              Y_AXIS))
+    * 2.0 / staff_space_;
+  
+  if (fabs (pos - my_round (pos)) < 0.2
+      && Staff_symbol_referencer::on_staffline (on_staff, (int) rint (pos))
+      && Staff_symbol_referencer::line_count (on_staff) - 1 >= rint (pos)
+      )
+    y += 1.5 * staff_space_ * dir_ / 10;
+
+  return y;
+}
+
 void
 Slur_score_state::generate_curves () const
 {