From: hanwen <hanwen>
Date: Thu, 26 Jan 2006 13:54:57 +0000 (+0000)
Subject: * input/regression/alignment-vertical-manual-setting.ly (Module):
X-Git-Tag: release/2.7.38^2~266
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cc0d03fc37576f423a1d95a50da85a68dbd18de9;p=lilypond.git

* input/regression/alignment-vertical-manual-setting.ly (Module):
new file.

* lily/align-interface.cc (align_elements_to_extents): overwrite
translations with numbers in alignment-offsets from left bound

* Documentation/topdocs/NEWS.tely (Top): document new features.
---

diff --git a/ChangeLog b/ChangeLog
index be5bc062e5..30ac881cad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2006-01-26  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+	* input/regression/alignment-vertical-manual-setting.ly (Module):
+	new file.
+
+	* lily/align-interface.cc (align_elements_to_extents): overwrite
+	translations with numbers in alignment-offsets from left bound
+
 	* scm/page.scm (make-page-stencil): read X-offset from paper-system.
 	(page-translate-systems): new function: take into account Y-offset.
 
diff --git a/Documentation/topdocs/NEWS.tely b/Documentation/topdocs/NEWS.tely
index 5f89cdddf1..4aa94dff73 100644
--- a/Documentation/topdocs/NEWS.tely
+++ b/Documentation/topdocs/NEWS.tely
@@ -46,8 +46,29 @@ the @uref{../,LilyPond Documentation}
 
 
 @itemize @bullet
+@item Alignments of staves may be tuned per system.   
+@lilypond[]
+\relative c'' \new StaffGroup <<
+      \new Staff { c1 c }
+      \new Staff { c c  }
+      \new Staff { 
+	\overrideProperty
+	#"Score.NonMusicalPaperColumn"
+	#'line-break-system-details
+	#'((alignment-offsets . (0 -5 -20)))
+	c1 \break
+	\overrideProperty
+	#"Score.NonMusicalPaperColumn"
+	#'line-break-system-details
+	#'((alignment-offsets . (0 -15 -20)))
+	c1 
+      }
+    >>
+@end lilypond
+
+This feature was sponsored by Trevor Bača.
 
-@item Systems individual systems may be positioned manually.
+@item Individual systems may be positioned manually,
 
 @lilypond[]
 \header{
@@ -82,8 +103,11 @@ This feature was sponsored by Trevor Bača and Nicolas Sceaux.
 
 @item A linebreaking configuration can now be saved as a @file{.ly}
 file automatically. This allows vertical alignments to be stretched to
-fit pages in a second formatting run. This feature was sponsored by  
-Trevor Bača and Nicolas Sceaux.
+fit pages in a second formatting run. See
+@inputfileref{input/regression/,page-layout-twopass.ly} for an
+example.
+
+This feature was sponsored by Trevor Bača and Nicolas Sceaux.
 
 @item The tie formatting for chords has been further polished. More
 cases are handled gracefully, and all scoring parameters may now be
diff --git a/input/regression/alignment-vertical-manual-setting.ly b/input/regression/alignment-vertical-manual-setting.ly
new file mode 100644
index 0000000000..17c332a18e
--- /dev/null
+++ b/input/regression/alignment-vertical-manual-setting.ly
@@ -0,0 +1,33 @@
+\header {
+
+  texidoc = "Alignments may be changed pre system by setting
+  @code{alignment-offsets} in the @code{line-break-system-details}
+  property"
+
+}
+
+\book {
+  \score {
+    \relative c'' \new StaffGroup <<
+      \new Staff { c1 c c c }
+      \new Staff { c c c c }
+      \new Staff { 
+	\overrideProperty
+	#"Score.NonMusicalPaperColumn"
+	#'line-break-system-details
+	#'((alignment-offsets . (#f #f -30)))
+	c1 \break
+	\overrideProperty
+	#"Score.NonMusicalPaperColumn"
+	#'line-break-system-details
+	#'((alignment-offsets . (0 -5 -20)))
+	c1 \break
+	\overrideProperty
+	#"Score.NonMusicalPaperColumn"
+	#'line-break-system-details
+	#'((alignment-offsets . (0 -15 -20)))
+	c1 c
+      }
+    >>
+  }
+}
diff --git a/lily/align-interface.cc b/lily/align-interface.cc
index dfccf02885..b9335706d0 100644
--- a/lily/align-interface.cc
+++ b/lily/align-interface.cc
@@ -146,37 +146,20 @@ Align_interface::align_to_fixed_distance (Grob *me, Axis a)
 void
 Align_interface::align_elements_to_extents (Grob *me, Axis a)
 {
-  Real extra_space = 0.0;
   Spanner *me_spanner = dynamic_cast<Spanner *> (me);
-  if (a == Y_AXIS
-      && me_spanner)
-    {
-#if 0
-      /*
-	TODO: messes up for figured bass alignments. 
-       */
-      if (me_spanner->get_bound (LEFT)->break_status_dir () == CENTER)
-	me->warning (_ ("vertical alignment called before line-breaking. "
-			"Only do cross-staff spanners with PianoStaff."));
-#endif
 
-      SCM details =  me_spanner->get_bound (LEFT)->get_property ("line-break-system-details");
-      SCM extra_space_handle = scm_assoc (ly_symbol2scm ("alignment-extra-space"), details);
 
-      extra_space = robust_scm2double (scm_is_pair (extra_space_handle)
-				       ? scm_cdr (extra_space_handle)
-				       : SCM_EOL,
-				       extra_space);
-    }
+  SCM line_break_details = SCM_EOL;
+  if (a == Y_AXIS && me_spanner)
+    line_break_details =  me_spanner->get_bound (LEFT)->get_property ("line-break-system-details");
   
   Direction stacking_dir = robust_scm2dir (me->get_property ("stacking-dir"),
-					       DOWN);
+					   DOWN);
 
   Interval threshold = robust_scm2interval (me->get_property ("threshold"),
 					    Interval (0, Interval::infinity ()));
 
   Array<Interval> dims;
-
   Link_array<Grob> elems;
 
   extract_grob_set (me, "elements", all_grobs);
@@ -202,10 +185,17 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a)
 	     ? me->get_property ("self-alignment-X")
 	     : me->get_property ("self-alignment-Y"));
 
-  Array<Real> translates;
   Interval total;
   Real where = 0;
+  Real extra_space = 0.0;
+  SCM extra_space_handle = scm_assq (ly_symbol2scm ("alignment-extra-space"), line_break_details);
 
+  extra_space = robust_scm2double (scm_is_pair (extra_space_handle)
+				   ? scm_cdr (extra_space_handle)
+				   : SCM_EOL,
+				   extra_space);
+  
+  Array<Real> translates;
   for (int j = 0; j < elems.size (); j++)
     {
       Real dy = -dims[j][-stacking_dir];
@@ -224,6 +214,19 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a)
       translates.push (where);
     }
 
+  SCM offsets_handle = scm_assq (ly_symbol2scm ("alignment-offsets"), line_break_details);
+  if (scm_is_pair (offsets_handle))
+    {
+      int i = 0;
+ 
+      for (SCM s = scm_cdr (offsets_handle); scm_is_pair (s) && i < translates.size (); s = scm_cdr (s), i++)
+	{
+	  if (scm_is_number (scm_car (s)))
+	    translates[i] = scm_to_double (scm_car (s));
+	}
+    }
+
+  
   Real center_offset = 0.0;
   
   /*