]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3254: align unassociated lyrics using NoteColumn extent.
authorJanek Warchoł <lemniskata.bernoullego@gmail.com>
Sun, 17 Mar 2013 20:22:32 +0000 (21:22 +0100)
committerJanek Warchoł <lemniskata.bernoullego@gmail.com>
Thu, 26 Jun 2014 07:49:39 +0000 (09:49 +0200)
This makes unassociated lyrics behave consistently with
associated lyrics.  Until now, "standalone" lyrics
were left-aligned (more precisely: their X-offset was 0);
changing self-alignment-X didn't have any effect on them.
Now it's possible to specify their alignment, like with
associated lyrics.

Also, this changes how issue 104 was resolved (see 0b14e8b2e122d) -
alignment of syllables that are associated to a context without
noteheads is no longer aborted - and solves issue 247.

Later on, these changes should allow using aligned_on_parent for
other grobs (such as DynamicTexts).

Expected changes in output: all lyrics should be centered by default.

Documentation/notation/vocal.itely
input/regression/lyrics-no-notes.ly
input/regression/unassociated-lyrics-alignment.ly [new file with mode: 0644]
lily/include/paper-column.hh
lily/lyric-engraver.cc
lily/paper-column.cc
lily/self-alignment-interface.cc

index 62600cf5478aa0f2d27d84db3a5453d6119183d5..ec551db6b95c81b52ffd24f92aebfb4d3420b79c 100644 (file)
@@ -309,11 +309,6 @@ see @ref{Manual syllable durations}.  This technique is also useful
 when setting dialogue over music; for examples showing this, see
 @ref{Dialogue over music}.
 
-When entered in this way the words are left-aligned to the notes
-by default, but may be center-aligned to the notes of a melody by
-specifying an associated voice, if one exists.  For details, see
-@ref{Manual syllable durations}.
-
 @end itemize
 
 @seealso
@@ -509,8 +504,7 @@ completely independently of notes.  In this case do not use
 but with pitches replaced by text -- and the duration of each
 syllable is entered explicitly after the syllable.
 
-By default, syllables will be left-aligned to the corresponding
-musical moment.  Hyphenated lines may be drawn between syllables
+Hyphenated lines may be drawn between syllables
 as usual, but extender lines cannot be drawn when there is no
 associated voice.
 
@@ -519,11 +513,10 @@ Here are two examples:
 @lilypond[relative=1,verbatim,quote]
 <<
   \new Voice = "melody" {
-    \time 3/4
-    c2 e4 g2 f
+    c'2 a f f e e
   }
   \new Lyrics \lyricmode {
-    play1 the4 game4
+    c4. -- a -- f -- f -- e2. -- e
   }
 >>
 @end lilypond
@@ -554,27 +547,22 @@ Here are two examples:
 This technique is useful when writing dialogue over music, see
 @ref{Dialogue over music}.
 
-To center-align syllables on the notes at the corresponding musical
-moments, set @code{associatedVoice} to the name of the Voice context
-containing those notes.  When @code{associatedVoice} is set, both
-double hyphens and double underscores can be used to draw
-hyphenated lines and extenders under melismata correctly.
+To change syllable alignment, simply override the @code{self-alignment-X}
+property:
 
 @lilypond[relative=1,verbatim,quote]
 <<
   \new Voice = "melody" {
     \time 3/4
-    c2 e4 g f g
+    c2 e4 g2 f
   }
   \new Lyrics \lyricmode {
-    \set associatedVoice = #"melody"
-    play2 the4 game2. __
+    \override LyricText.self-alignment-X = #LEFT
+    play1 a4 game4
   }
 >>
 @end lilypond
 
-@c TODO see also feature request 707 - show how to do this with manual durations
-
 @seealso
 Notation Reference:
 @ref{Dialogue over music}.
index 30d2535c59be09e640d3e2379e819a6a930026a4..1262e70c9c964ca5f7eb733f5f7811368da54373 100644 (file)
@@ -1,7 +1,6 @@
 \header {
-  texidoc ="Lyric syllables without note attachment are not
-centered.  Centering may cause unintended effects when the
-paper column is very wide."
+  texidoc ="Lyric syllables without note attachment are
+aligned correctly even if the paper column is very wide."
 }
  
 \layout{ ragged-right = ##t }
@@ -21,7 +20,7 @@ paper column is very wide."
   \new Lyrics \lyricmode {
     \skip 8
     \skip 8
-    x8
+    xx8
     x8
   }
 >>
diff --git a/input/regression/unassociated-lyrics-alignment.ly b/input/regression/unassociated-lyrics-alignment.ly
new file mode 100644 (file)
index 0000000..b9db9a6
--- /dev/null
@@ -0,0 +1,44 @@
+\version "2.19.9"
+#(set-global-staff-size 30)
+
+\header {
+  texidoc = "Lyrics without an @code{associatedVoice} should align properly.
+If there are notes in the @code{PaperColumn}, they should align to them,
+and when there are no notes, they should align relative to the
+@code{PaperColumn} itself (represented with blue @code{GridLines} here)"
+}
+
+\paper {
+  ragged-right = ##f
+}
+
+\layout {
+  \context {
+    \Voice
+    \consists "Grid_point_engraver"
+    gridInterval = #(ly:make-moment 1/4)
+    \override GridPoint.Y-extent = #'(-1 . 3)
+  }
+  \context {
+    \Staff
+    \consists "Grid_line_span_engraver"
+    \override GridLine.color = #blue
+  }
+}
+
+music = <<
+  \new Staff <<
+    \new Voice { s1*3 } % needed for gridLines
+    \new Voice { d'2 d' <f' g'>1 s1 }
+  >>
+  \new Lyrics { \lyricmode { foo2 bar mmmm1 a2 bom } }
+>>
+
+\markup "default (centered):"
+\music
+
+\markup "right-aligned:"
+{
+  \override Score.LyricText.self-alignment-X = #RIGHT
+  \music
+}
index c1638a2539f45bf47121886f31c7b2a2f6cf294c..408f001d637d1e08f2d87c494306163660768260 100644 (file)
@@ -59,6 +59,7 @@ public:
   static bool is_extraneous_column_from_ligature (Grob *);
   static Real minimum_distance (Grob *l, Grob *r);
   static Interval break_align_width (Grob *me, SCM align_sym);
+  static Interval get_interface_extent (Grob *column, SCM interface, Axis a);
 };
 
 #endif // PAPER_COLUMN_HH
index 6dce40a464ba7b385f0149dd254debd7de9b6ecd..3ea4498baf1381ef764749dba93964e6b7a93bb8 100644 (file)
@@ -182,11 +182,9 @@ Lyric_engraver::stop_translation_timestep ()
                                      get_property ("lyricMelismaAlignment"));
             }
           else
-            {
-              text_->warning (_ ("Lyric syllable does not have note."
-                                 "  Use \\lyricsto or associatedVoice."));
-              text_->set_property ("X-offset", scm_from_int (0));
-            }
+            text_->warning (_ ("Aligning lyric syllables to notes was requested,"
+                               " but there are no notes in the specified context."
+                               " Syllable will be attached to a PaperColumn instead."));
         }
 
       last_text_ = text_;
index d5ac33b55a4e679c80d341258c296a45029c2b40..3e6988de0cd5b6fdd7bb8833ae313c7432cf8a11 100644 (file)
@@ -218,6 +218,23 @@ Paper_column::break_align_width (Grob *me, SCM align_sym)
   return align->extent (p, X_AXIS);
 }
 
+/*
+  Loop through elements of a PaperColumn, find all grobs implementing specified
+  interface and return their combined extent.
+*/
+Interval
+Paper_column::get_interface_extent (Grob *column, SCM interface, Axis a)
+{
+  Interval extent = Interval (0, 0);
+  extract_grob_set (column, "elements", elts);
+
+  for (vsize i = 0; i < elts.size (); i++)
+    if (elts[i]->internal_has_interface (interface))
+      extent.unite (robust_relative_extent (elts[i], elts[i], a));
+
+  return extent;
+}
+
 /*
   Print a:
   - vertical line,
index e0b7f00cb2887fc6e1c1e9afd194aa0045f86e5d..f04eb19d1073592a84c7f0416c80af378b267ce3 100644 (file)
@@ -132,10 +132,17 @@ SCM
 Self_alignment_interface::aligned_on_parent (Grob *me, Axis a)
 {
   Grob *him = me->get_parent (a);
+  Interval he;
   if (Paper_column::has_interface (him))
-    return scm_from_double (0.0);
-
-  Interval he = him->extent (him, a);
+      /*
+        PaperColumn extents aren't reliable (they depend on size and alignment
+        of PaperColumn's children), so we align on NoteColumn instead.
+        This happens e.g. for lyrics without associatedVoice.
+      */
+    he = Paper_column::get_interface_extent
+              (him, ly_symbol2scm ("note-column-interface"), a);
+  else
+    he = him->extent (him, a);
 
   SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X")
             : ly_symbol2scm ("self-alignment-Y");