]> git.donarmstrong.com Git - lilypond.git/commitdiff
(move_away_from_staffline): new function.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 10 Oct 2004 18:38:21 +0000 (18:38 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 10 Oct 2004 18:38:21 +0000 (18:38 +0000)
(get_base_attachments): move away attachment point for breaks
similar to attachment points on slurs (staffline collision, and
half a space of padding)

ChangeLog
input/regression/slur-broken-trend.ly
lily/include/slur-scoring.hh
lily/slur-scoring.cc

index b656158af18981ac5c7df94ea83300c1a8e1aefd..48fd5c832562cc362090ee2e59bc76d45a27c476 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2004-10-10  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/slur-scoring.cc (move_away_from_staffline): new function.
+       (get_base_attachments): move away attachment point for breaks
+       similar to attachment points on slurs (staffline collision, and
+       half a space of padding)
+
        * scm/page-layout.scm (ly:optimal-page-breaks): don't compute
        force twice.
 
index dc14cb7345efbdf92afaee013a3ab60594c164ce..92e9b4c2523e7015dff9b6848bfacf8bfde4f022 100644 (file)
@@ -9,8 +9,9 @@ staff.  A slur should follow the same vertical direction it would have
 in unbroken state.
 "
 }
+
 \layout {
-    linewidth=40.\mm
+    raggedright = ##t 
     indent=0.
 }
 
@@ -33,9 +34,17 @@ in unbroken state.
     <d='' d'>8( <c c'> \break
     <bis f' b>) s2..\break
     \stemNeutral
-    \relative  { c'8[( c c c] g2 ~ | \break
-               g1) | \break
-               \slurDown c8[( c] g4 ~ g2 ~ | \break
-               g2 ~ g2) }
+
+    \new Voice \relative  {
+       c'8[( c c c] g2 ~ | \break
+       g1) | \break
+       \slurDown c8[( c] g4 ~ g2 ~ | \break
+       g2 ~ g2)
+    }
+    \relative c'' {
+       a4( c b4 e, ~ | \break
+       e1 ~ | e1)
+    }
+    
 }
 
index 8f4c6494dd96b47658a0d27f60bf852ce0c4bf30..196387abd96f32c381968d3580f6f047bdb376e6 100644 (file)
@@ -143,6 +143,7 @@ struct Slur_score_state
   Drul_array<Real> get_y_attachment_range() const;
   Encompass_info get_encompass_info (Grob *col) const;
   Array<Extra_collision_info> get_extra_encompass_infos () const;
+  Real move_away_from_staffline (Real y, Grob *on_staff) const;
 };
 
 
index c9ec0236e31781def60c3b51eaa95921dcefa873..ae76a64abb2ae1db24b539decb25ff8927d8c816 100644 (file)
@@ -305,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);
     }
@@ -503,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 =
@@ -544,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);  
        }
     }
@@ -558,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
 {