[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue 3254: align unassociated lyrics using NoteColumn extent. (issue 10
From: |
janek . lilypond |
Subject: |
Issue 3254: align unassociated lyrics using NoteColumn extent. (issue 108110044 by address@hidden) |
Date: |
Sat, 21 Jun 2014 13:44:32 +0000 |
Reviewers: ,
Message:
Hi all!
Seems i'm back to LilyPond business (hopefully for long :)!
Please review - more patches (depending on this one) will follow.
best,
Janek
Description:
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.
Later on, this should also allow correctly aligning_on_parent
other grobs (such as DynamicTexts).
Expected changes in output: all lyrics should be centered by default.
Please review this at https://codereview.appspot.com/108110044/
Affected files (+72, -3 lines):
A input/regression/unassociated-lyrics-alignment.ly
M lily/include/paper-column.hh
M lily/paper-column.cc
M lily/self-alignment-interface.cc
Index: input/regression/unassociated-lyrics-alignment.ly
diff --git a/input/regression/unassociated-lyrics-alignment.ly
b/input/regression/unassociated-lyrics-alignment.ly
new file mode 100644
index
0000000000000000000000000000000000000000..2b39447707aa7e00f363d40c58deb406b217f964
--- /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 associatedVoice should align properly.
+If there are notes in the PaperColumn, they should align to them,
+and when there are no notes, they should align relative to the
+PaperColumn itself (represented with blue 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: lily/include/paper-column.hh
diff --git a/lily/include/paper-column.hh b/lily/include/paper-column.hh
index
c1638a2539f45bf47121886f31c7b2a2f6cf294c..0d26c2b4a809166e9cfefd9662cb0ae62b0aab19
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_generic_interface_extent (Grob *column, SCM
interface, Axis a);
};
#endif // PAPER_COLUMN_HH
Index: lily/paper-column.cc
diff --git a/lily/paper-column.cc b/lily/paper-column.cc
index
d5ac33b55a4e679c80d341258c296a45029c2b40..848c8e73855957743973b8f324acaad4262a54c9
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_generic_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,
Index: lily/self-alignment-interface.cc
diff --git a/lily/self-alignment-interface.cc
b/lily/self-alignment-interface.cc
index
e0b7f00cb2887fc6e1c1e9afd194aa0045f86e5d..744381d75dfbd1534e860f80f51db393780d4c33
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_generic_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");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Issue 3254: align unassociated lyrics using NoteColumn extent. (issue 108110044 by address@hidden),
janek . lilypond <=