From 5da7795185482ec45fa47443fc5b1c3478cccc62 Mon Sep 17 00:00:00 2001 From: Mike Solomon Date: Tue, 15 Mar 2011 06:57:49 -0400 Subject: [PATCH] Changes the spanner-placement property of FootnoteSpanner to ly:dir Now, the annotation on a spanner will always fall on the first (LEFT or CENTER) or last (RIGHT) broken spanner if the spanner is broken. Defaults to LEFT. --- input/regression/footnote-spanner.ly | 5 ++--- lily/balloon.cc | 19 ++++++------------- lily/system.cc | 18 ++++++++---------- scm/define-grob-properties.scm | 15 +++++---------- scm/define-grobs.scm | 2 +- 5 files changed, 22 insertions(+), 37 deletions(-) diff --git a/input/regression/footnote-spanner.ly b/input/regression/footnote-spanner.ly index eecbd97ca2..3a0f3ef7cc 100644 --- a/input/regression/footnote-spanner.ly +++ b/input/regression/footnote-spanner.ly @@ -11,11 +11,10 @@ annotation goes to the correct page." \book { \relative c'' { -\once \override FootnoteSpanner #'spanner-placement = #-0.7 \footnoteGrob #'Hairpin #'(0.5 . 0.5) \markup { \tiny "1." } - \markup { 1. \justify { Goes to the second broken spanner. } } + \markup { 1. \justify { Goes to the first broken spanner. } } b4\< c d a b c d a b c d a @@ -35,7 +34,7 @@ b c d a b c d a b c d a\! -\once \override FootnoteSpanner #'spanner-placement = #1.0 +\once \override FootnoteSpanner #'spanner-placement = #RIGHT \footnoteGrob #'Hairpin #'(0.5 . 0.5) \markup { \tiny "2." } diff --git a/lily/balloon.cc b/lily/balloon.cc index 1dfab523a8..c4efb46b68 100644 --- a/lily/balloon.cc +++ b/lily/balloon.cc @@ -56,29 +56,22 @@ Balloon_interface::print (SCM smob) return internal_balloon_print (me, p, off); } -// ugh...code dup...hopefully can be consolidated w/ above one day MAKE_SCHEME_CALLBACK (Balloon_interface, print_spanner, 1); SCM Balloon_interface::print_spanner (SCM smob) { Spanner *me = unsmob_spanner (smob); - Grob *orig = me->original (); + Spanner *orig = dynamic_cast (me->original ()); if (orig) { - // TODO : consolidate code dup from System::get_footnote_grobs_in_range - int pos = orig->spanned_rank_interval ()[LEFT]; - Real spanner_placement = min (1.0, - max (robust_scm2double (me->get_property ("spanner-placement"), -1.0), - -1.0)); + Direction spanner_placement = robust_scm2dir (me->get_property ("spanner-placement"), LEFT); - spanner_placement = (spanner_placement + 1.0) / 2.0; - int rpos = orig->spanned_rank_interval ()[RIGHT]; - pos = (int)((rpos - pos) * spanner_placement + pos + 0.5); + Spanner *wanted = (spanner_placement != RIGHT) + ? orig->broken_intos_[0] + : orig->broken_intos_.back (); - if (pos < me->spanned_rank_interval () [LEFT]) - return SCM_EOL; - if (pos >= me->spanned_rank_interval () [RIGHT] && (me->spanned_rank_interval () [RIGHT] != orig->spanned_rank_interval () [RIGHT])) + if (me != wanted) return SCM_EOL; } diff --git a/lily/system.cc b/lily/system.cc index 574dce56c9..1cd582de75 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -254,13 +254,11 @@ System::get_footnote_grobs_in_range (vector &out, vsize start, vsize end bool end_of_line_visible = true; if (Spanner *s = dynamic_cast(footnote_grobs_[i])) { - Real spanner_placement = min (1.0, - max (robust_scm2double (s->get_property ("spanner-placement"), -1.0), - -1.0)); + Direction spanner_placement = robust_scm2dir (s->get_property ("spanner-placement"), LEFT); + if (spanner_placement == CENTER) + spanner_placement = LEFT; - spanner_placement = (spanner_placement + 1.0) / 2.0; - int rpos = s->spanned_rank_interval ()[RIGHT]; - pos = (int)((rpos - pos) * spanner_placement + pos + 0.5); + pos = s->spanned_rank_interval ()[spanner_placement]; } if (Item *item = dynamic_cast(footnote_grobs_[i])) @@ -271,13 +269,13 @@ System::get_footnote_grobs_in_range (vector &out, vsize start, vsize end end_of_line_visible = (LEFT == item->break_status_dir ()); } - if (pos < (int)start) + if (pos < int (start)) continue; - if (pos > (int)end) + if (pos > int (end)) break; - if (pos == (int)start && end_of_line_visible) + if (pos == int (start) && end_of_line_visible) continue; - if (pos == (int)end && !end_of_line_visible) + if (pos == int (end) && !end_of_line_visible) continue; if (!footnote_grobs_[i]->is_live ()) continue; diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index f920d41169..879a1c780d 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -1039,16 +1039,11 @@ grobs.") (spacing-wishes ,ly:grob-array? "An array of note spacing or staff spacing objects.") (span-start ,boolean? "Is the note head at the start of a spanner?") - (spanner-placement ,number? "The place of an annotation on a spanner. -Note that this number must be between -1 and 1, with -1 representing the -beginning of the spanner and 1 representing the end. The annotation will -still be placed at the left or right extremity of the spanner, but this -number ensures that when line breaking happens, the annotation is assigned -to the correct broken piece and the footnote is put on the correct page. -An important caveat is that this number applies to column ranks, not staff -space. For example, 0 will place the annotation at the middle column of -its parent's span, which may be to the right or left of the physical middle -of the spanner.") + (spanner-placement ,ly:dir? "The place of an annotation on a spanner. +LEFT is for the first spanner, and RIGHT is for the last. CENTER will +place it on the broken spanner that falls closest to the center of the length +of the entire spanner, although this behavior is unpredictable in situations +with lots of rhythmic diversity. For predictable results, use LEFT and RIGHT.") (staff-grouper ,ly:grob? "The staff grouper we belong to.") (staff-symbol ,ly:grob? "The staff symbol grob that we are in.") (stem ,ly:grob? "A pointer to a @code{Stem} object.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 95fca72955..6e4faedf40 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -887,7 +887,7 @@ (annotation-balloon . #f) (annotation-line . #t) (footnote-text . ,(grob::calc-property-by-copy 'footnote-text)) - (spanner-placement . -1.0) + (spanner-placement . LEFT) (stencil . ,ly:balloon-interface::print-spanner) (text . ,(grob::calc-property-by-copy 'text)) (Y-extent . #f) -- 2.11.4.GIT