summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanek Warchoł <lemniskata.bernoullego@gmail.com>2013-03-17 21:22:32 +0100
committerJanek Warchoł <lemniskata.bernoullego@gmail.com>2014-06-26 09:49:39 +0200
commitc73b41b3e7be6d7280c6336cf03610cd7aed3000 (patch)
treecf049b4c850150725783ee1831a814ef38635fba
parent8cd87804592a2815e35cbdaff2cd98e5e3dc59ce (diff)
Issue 3254: align unassociated lyrics using NoteColumn extent.
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.
-rw-r--r--Documentation/notation/vocal.itely28
-rw-r--r--input/regression/lyrics-no-notes.ly7
-rw-r--r--input/regression/unassociated-lyrics-alignment.ly44
-rw-r--r--lily/include/paper-column.hh1
-rw-r--r--lily/lyric-engraver.cc8
-rw-r--r--lily/paper-column.cc17
-rw-r--r--lily/self-alignment-interface.cc13
7 files changed, 86 insertions, 32 deletions
diff --git a/Documentation/notation/vocal.itely b/Documentation/notation/vocal.itely
index 62600cf547..ec551db6b9 100644
--- a/Documentation/notation/vocal.itely
+++ b/Documentation/notation/vocal.itely
@@ -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}.
diff --git a/input/regression/lyrics-no-notes.ly b/input/regression/lyrics-no-notes.ly
index 30d2535c59..1262e70c9c 100644
--- a/input/regression/lyrics-no-notes.ly
+++ b/input/regression/lyrics-no-notes.ly
@@ -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
index 0000000000..b9db9a69df
--- /dev/null
+++ b/input/regression/unassociated-lyrics-alignment.ly
@@ -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
+}
diff --git a/lily/include/paper-column.hh b/lily/include/paper-column.hh
index c1638a2539..408f001d63 100644
--- a/lily/include/paper-column.hh
+++ b/lily/include/paper-column.hh
@@ -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
diff --git a/lily/lyric-engraver.cc b/lily/lyric-engraver.cc
index 6dce40a464..3ea4498baf 100644
--- a/lily/lyric-engraver.cc
+++ b/lily/lyric-engraver.cc
@@ -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_;
diff --git a/lily/paper-column.cc b/lily/paper-column.cc
index d5ac33b55a..3e6988de0c 100644
--- a/lily/paper-column.cc
+++ b/lily/paper-column.cc
@@ -219,6 +219,23 @@ Paper_column::break_align_width (Grob *me, SCM align_sym)
}
/*
+ 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,
- the rank number,
diff --git a/lily/self-alignment-interface.cc b/lily/self-alignment-interface.cc
index e0b7f00cb2..f04eb19d10 100644
--- a/lily/self-alignment-interface.cc
+++ b/lily/self-alignment-interface.cc
@@ -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");