From 8fd95b07fc74b203d07153745136523f0b9bf253 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 21 Aug 2005 13:11:51 +0000 Subject: [PATCH] * lily/tie.cc (get_control_points): rewrite. Put short ties in staff-spaces, make long ties cross staff lines. Avoid flags and dots. * input/regression/tie-single.ly: new file. --- input/regression/tie-single.ly | 3 +- input/regression/tie.ly | 22 -------------- lily/note-head.cc | 6 +++- lily/tie.cc | 55 ++++++++++++++++++++++++++++++---- scm/define-grobs.scm | 2 +- 5 files changed, 58 insertions(+), 30 deletions(-) delete mode 100644 input/regression/tie.ly diff --git a/input/regression/tie-single.ly b/input/regression/tie-single.ly index e71b9b89a3..a33c67807e 100644 --- a/input/regression/tie-single.ly +++ b/input/regression/tie-single.ly @@ -1,7 +1,6 @@ \header { texidoc = "Formatting for isolated ties. - Things to note: @itemize @bullet @item short ties are in spaces @@ -11,6 +10,8 @@ @item short ties are vertically centered in the space, as well those that otherwise don't fit in a space + +@item extremely short ties are put over the noteheads, instead of inbetween. @end itemize " diff --git a/input/regression/tie.ly b/input/regression/tie.ly deleted file mode 100644 index bb19d5263f..0000000000 --- a/input/regression/tie.ly +++ /dev/null @@ -1,22 +0,0 @@ - -\version "2.6.0" - -\header{ -texidoc=" -Ties are strictly horizontal. They are placed in between note heads. -The horizontal middle should not overlap with a staffline. -" -} -\layout{ - raggedright= ##t -} - - -\relative c''{ - %b2~b4~b8~b16~b32~b64 r64\break - %a2~a4~a8~a16~a32~a64 r64 - \time 8/4 - d1 ~ d2~d4~d8~d16~d32~d64 r64\break - a1~ a2~a4~a8~a16~a32~a64 r64 - %c2~c4~c8~c16~c32~c64 r64 -} diff --git a/lily/note-head.cc b/lily/note-head.cc index 10707aeaa9..b3faea2240 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -129,5 +129,9 @@ Note_head::get_balltype (Grob *me) ADD_INTERFACE (Note_head, "note-head-interface", "Note head", - "note-names glyph-name-procedure accidental-grob style stem-attachment-function"); + "note-names " + "glyph-name-procedure " + "accidental-grob " + "style " + "stem-attachment-function"); diff --git a/lily/tie.cc b/lily/tie.cc index a0ac259c7b..408c0acfe3 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -151,7 +151,7 @@ Tie::get_control_points (SCM smob) common[ax] = me->get_bound (RIGHT)->common_refpoint (common[a], ax); } - Drul_array attachments; + Interval attachments; Direction d = LEFT; Real gap = robust_scm2double (me->get_property ("x-gap"), 0.2); @@ -165,6 +165,44 @@ Tie::get_control_points (SCM smob) } while (flip (&d) != LEFT); + bool in_between = true; + if (attachments.length () < 0.6 * staff_space) + { + /* + Let short ties start over note heads, instead of between. + */ + Drul_array allow (true, true); + + Direction d = LEFT; + do { + if (Note_head::has_interface (me->get_bound (d))) + { + Grob *stem = unsmob_grob (me->get_bound (d)->get_object ("stem")); + if (get_grob_direction (stem) == dir + && -d == dir) + allow[d] = false; + } + } while (flip (&d) != LEFT); + + if (allow[LEFT] && allow[RIGHT]) + { + staff_position += dir; + do + { + if (Note_head::has_interface (me->get_bound (d))) + { + Interval extent + = robust_relative_extent (me->get_bound (d), + common[X_AXIS], X_AXIS); + + attachments[d] = extent.linear_combination (- 0.5 * d); + in_between = false; + } + } + while (flip (&d) != LEFT); + } + } + SCM details = me->get_property ("details"); SCM limit @@ -174,7 +212,7 @@ Tie::get_control_points (SCM smob) Real r_0 = robust_scm2double (scm_cdr (scm_assq (ly_symbol2scm ("ratio"), details)), .333); - Bezier b = slur_shape (attachments[RIGHT] - attachments[LEFT], + Bezier b = slur_shape (attachments.length(), h_inf, r_0); b.scale (1, dir); @@ -185,8 +223,9 @@ Tie::get_control_points (SCM smob) Real dy = fabs (middle[Y_AXIS] - edge[Y_AXIS]); bool in_space = !(Staff_symbol_referencer::on_staffline (me, (int) staff_position)); - bool fits_in_space = (dy < 0.6 * staff_space); - + bool fits_in_space = + (dy < 0.6 * staff_space); + /* Avoid dot */ @@ -225,7 +264,7 @@ Tie::get_control_points (SCM smob) { staff_position += 2 * dir; } - + if (in_space != fits_in_space) { if (in_space) @@ -239,6 +278,12 @@ Tie::get_control_points (SCM smob) } } + if (!in_between + && in_space + && fabs (staff_position - Tie::get_position (me)) <= 1) + staff_position += 2*dir; + + if (in_space) { if (fabs (dy) < 0.4 * staff_space) diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 561c4d8832..517576aea6 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1436,7 +1436,7 @@ (Tie . ( (print-function . ,Tie::print) - (spacing-procedure . ,Spanner::set_spacing_rods) +; (spacing-procedure . ,Spanner::set_spacing_rods) (staffline-clearance . 0.35) (details . ((ratio . 0.333) (height-limit . 1.0))) (thickness . 1.0) -- 2.39.5