From e16949415b428ba59212485f1212f02ef3481544 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 11 Jul 2004 11:28:23 +0000 Subject: [PATCH] (class New_slur): new file. Score based slur computations. --- input/test/new-slur.ly | 16 ++++++++++---- lily/new-slur.cc | 48 +++++++++++++++++++++--------------------- scm/define-grobs.scm | 10 ++++++--- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/input/test/new-slur.ly b/input/test/new-slur.ly index de408d4317..876698ef6c 100644 --- a/input/test/new-slur.ly +++ b/input/test/new-slur.ly @@ -1,11 +1,18 @@ - +\paper { + raggedright = ##t +} \relative { \override Slur #'after-line-breaking-callback = #New_slur::after_line_breaking - \override Slur #'print-function = #New_slur::print + \override Slur #'print-function = #New_slur::print \override Slur #'height = ##f - ( f ) + + f'=''16( e) +% d( c) +% c'=''2(~c8 d16 c b8 a) + +%{ ( f ) f ^( f ) f @@ -14,5 +21,6 @@ _( \stemDown g \stemBoth ) c,^( c'' c) c,,^( c'') - c,,^( c') + c,,^( c') +%} } diff --git a/lily/new-slur.cc b/lily/new-slur.cc index 111fd1b463..f496640f57 100644 --- a/lily/new-slur.cc +++ b/lily/new-slur.cc @@ -274,8 +274,9 @@ New_slur::set_end_points (Grob *me) Real y = h->extent (common[Y_AXIS], Y_AXIS)[dir]; y += dir * 0.5 * staff_space; - if (Staff_symbol_referencer::on_staffline (h)) - y += .5 * staff_space * dir ; + int p = Staff_symbol_referencer::get_position (h) + 2*dir; + if (Staff_symbol_referencer::on_staffline (h, p)) + y += 0.5 * staff_space * dir ; Grob * fh = Note_column::first_head (extremes[d]); Real x = fh->extent (common[X_AXIS], X_AXIS).linear_combination (CENTER); @@ -291,8 +292,12 @@ New_slur::set_end_points (Grob *me) } while (flip (&d) != LEFT); Drul_array staff_offsets; + Interval end_ys; + do { staff_offsets[d] = staves[d]->relative_coordinate (common[Y_AXIS], Y_AXIS); + end_ys[d] = dir * (dir * base_attachment[d][Y_AXIS] + 4.0 *dir >? + dir * (dir + extremes[d]->extent(common[Y_AXIS],Y_AXIS)[dir])); } while (flip (&d) != LEFT); Array scores; @@ -300,37 +305,32 @@ New_slur::set_end_points (Grob *me) Drul_array os; /*ugh. */ - os[LEFT] = base_attachment[LEFT]; - for (int i = 0; i < SLUR_REGION_SIZE; i++) + os[LEFT] = base_attachment[LEFT]; + + for (int i = 0; dir * os[LEFT][Y_AXIS] < dir * end_ys[LEFT]; i++) { os[RIGHT] = base_attachment[RIGHT]; - for (int j = 0; j < SLUR_REGION_SIZE; j++) + for (int j = 0; dir *os[RIGHT][Y_AXIS] < dir * end_ys[RIGHT]; j++) { Slur_score s; s.attachment_ = os; scores.push (s); - Real y = os[RIGHT][Y_AXIS]; - - if (Staff_symbol_referencer::staff_radius (staves[RIGHT]) - > fabs ((y - staff_offsets[RIGHT]) / staff_space)) - y += dir *staff_space; - else - y += dir * staff_space / 2; + Real incr = dir * staff_space; + if (Staff_symbol_referencer::staff_radius (staves[RIGHT]) + < fabs ((os[RIGHT][Y_AXIS] - staff_offsets[RIGHT]) / staff_space)) + incr /= 2; - os[RIGHT][Y_AXIS] = y; + os[RIGHT][Y_AXIS] += incr; } - Real y = os[LEFT][Y_AXIS]; - - if (Staff_symbol_referencer::staff_radius (staves[LEFT]) - > fabs ((y - staff_offsets[LEFT]) / staff_space)) - y += dir *staff_space; - else - y += dir *staff_space / 2; + Real incr = dir * staff_space; + if (Staff_symbol_referencer::staff_radius (staves[LEFT]) + < fabs ((os[LEFT][Y_AXIS] - staff_offsets[LEFT]) / staff_space)) + incr /= 2; - os[LEFT][Y_AXIS] = y; + os[LEFT][Y_AXIS] += incr; } @@ -413,11 +413,11 @@ New_slur::score_encompass (Grob * me, Grob *common[], Drul_array base_a ext.add_point (infos[j].stem_); ext.add_point (infos[j].head_); - demerit += - CLOSENESS_FACTOR * (dir * (y - (ext[dir] + dir * HEAD_FREE_SPACE))