From 31a565c0bad19d6c9206a72405b90dd47b0d4968 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 10 Oct 2004 18:38:21 +0000 Subject: [PATCH] (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) --- ChangeLog | 5 +++ input/regression/slur-broken-trend.ly | 19 ++++++++--- lily/include/slur-scoring.hh | 1 + lily/slur-scoring.cc | 48 +++++++++++++++++++-------- 4 files changed, 54 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index b656158af1..48fd5c8325 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2004-10-10 Han-Wen Nienhuys + * 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. diff --git a/input/regression/slur-broken-trend.ly b/input/regression/slur-broken-trend.ly index dc14cb7345..92e9b4c252 100644 --- a/input/regression/slur-broken-trend.ly +++ b/input/regression/slur-broken-trend.ly @@ -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. 8( \break ) 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) + } + } diff --git a/lily/include/slur-scoring.hh b/lily/include/slur-scoring.hh index 8f4c6494dd..196387abd9 100644 --- a/lily/include/slur-scoring.hh +++ b/lily/include/slur-scoring.hh @@ -143,6 +143,7 @@ struct Slur_score_state Drul_array get_y_attachment_range() const; Encompass_info get_encompass_info (Grob *col) const; Array get_extra_encompass_infos () const; + Real move_away_from_staffline (Real y, Grob *on_staff) const; }; diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index c9ec0236e3..ae76a64abb 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -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 { -- 2.39.2