]> git.donarmstrong.com Git - lilypond.git/commitdiff
Changes the spanner-placement property of FootnoteSpanner to ly:dir
authorMike Solomon <mike@apollinemike.com>
Tue, 15 Mar 2011 10:57:49 +0000 (06:57 -0400)
committerMike Solomon <mike@apollinemike.com>
Tue, 15 Mar 2011 10:57:49 +0000 (06:57 -0400)
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
lily/balloon.cc
lily/system.cc
scm/define-grob-properties.scm
scm/define-grobs.scm

index eecbd97ca2ffebf391c23a696250c977a1093fdd..3a0f3ef7cc9693a6c82a80a303821f4d39efb78c 100644 (file)
@@ -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." }
index 1dfab523a8bc54cc77dfe60a69b049344e6627cb..c4efb46b687c17ac4cafb93cabef601915f9584a 100644 (file)
@@ -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<Spanner *> (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;
     }
 
index 574dce56c9de8e54869b164e772dc702707663d0..1cd582de7525bc2d628b24cb062ddfc188ac7904 100644 (file)
@@ -254,13 +254,11 @@ System::get_footnote_grobs_in_range (vector<Grob *> &out, vsize start, vsize end
       bool end_of_line_visible = true;
       if (Spanner *s = dynamic_cast<Spanner *>(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<Item *>(footnote_grobs_[i]))
@@ -271,13 +269,13 @@ System::get_footnote_grobs_in_range (vector<Grob *> &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;
index f920d41169d4dd886b159d1905c516e484ae1a5b..879a1c780d105bcb72c1dc97514fbcb87d7f1a5f 100644 (file)
@@ -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.")
index 95fca72955be71c7848573b5b80ae64246998421..6e4faedf405734df2ab216b63f5190efa9395377 100644 (file)
        (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)