]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 2691: page-layout: consider relative indents in loose-line spacing
authorKeith OHara <k-ohara5a5a@oco.net>
Sat, 28 Jul 2012 12:14:34 +0000 (14:14 +0200)
committerDavid Kastrup <dak@gnu.org>
Sat, 28 Jul 2012 12:35:36 +0000 (14:35 +0200)
input/regression/page-spacing-nonstaff-lines-skylines.ly [new file with mode: 0644]
lily/axis-group-interface.cc
lily/include/page-layout-problem.hh
lily/page-layout-problem.cc

diff --git a/input/regression/page-spacing-nonstaff-lines-skylines.ly b/input/regression/page-spacing-nonstaff-lines-skylines.ly
new file mode 100644 (file)
index 0000000..43dac95
--- /dev/null
@@ -0,0 +1,19 @@
+\version "2.15.42"
+
+\header {
+  texidoc = "Relative indentation between systems is taken into
+  account in allowing space for loose lines between systems."
+}
+
+\paper {
+  ragged-right = ##t
+  indent = 10
+  short-indent = 00
+}
+
+\book {
+  \score { <<
+    \chords {s1\break c2 c2 }
+    \new Staff {\clef bass c,1 | c''2 c2 }
+  >> }
+}
index 1b937985eeee2aab63444c47401f2a49e9a59af7..febff36afb6462d4b39137d46e1c7c221414ab73 100644 (file)
@@ -828,18 +828,6 @@ Axis_group_interface::calc_maybe_pure_staff_staff_spacing (Grob *me, bool pure,
   return me->get_maybe_pure_property ("default-staff-staff-spacing", pure, start, end);
 }
 
-Real
-Axis_group_interface::minimum_distance (Grob *g1, Grob *g2, Axis a)
-{
-  SCM sym = ly_symbol2scm ((a == Y_AXIS) ? "vertical-skylines" : "horizontal-skylines");
-
-  Skyline_pair *s1 = Skyline_pair::unsmob (g1->get_property (sym));
-  Skyline_pair *s2 = Skyline_pair::unsmob (g2->get_property (sym));
-  if (s1 && s2)
-    return (*s1)[DOWN].distance ((*s2)[UP]);
-  return 0;
-}
-
 ADD_INTERFACE (Axis_group_interface,
                "An object that groups other layout objects.",
 
index ccc2538905c86dc7cdd4716a84002f09e631b647..b7d63a2e13e0f7d8b02ce519a3a0be7ffcf94ed3 100644 (file)
@@ -64,14 +64,16 @@ protected:
     Prob *prob;
     vector<Grob *> staves;
     vector<Real> min_offsets;
-    // Store the appropriate '*-*-spacing 'padding,
-    //  for spacing any adjacent loose line
+    // Store the appropriate '*-*-spacing 'padding, and skyline-distance,
+    //  considering indentation, from the previous system.
+    Real min_distance;
     Real padding;
 
-    Element (vector<Grob *> const &a, vector<Real> const &o, Real p)
+    Element (vector<Grob *> const &a, vector<Real> const &o, Real m, Real p)
     {
       staves = a;
       min_offsets = o;
+      min_distance = m;
       padding = p;
       prob = 0;
     }
index dd9b6da71ca8e658775e49f840bcf10311cbd49b..68f870b2dc7f19959e11ea859d036e49da009d8b 100644 (file)
@@ -583,8 +583,19 @@ Page_layout_problem::append_system (System *sys, Spring const &spring, Real inde
   spring_copy.ensure_min_distance (minimum_distance);
   springs_.push_back (spring_copy);
 
+  if (elts.size () && !is_spaceable (elts[0]))
+    {
+      // store the minimum distance, considering relative indents,
+      // for a loose line
+      Skyline first_skyline (UP);
+      Skyline_pair *sky = Skyline_pair::unsmob (elts[0]->get_property ("vertical-skylines"));
+      if (sky)
+        first_skyline.merge ((*sky)[UP]);
+      first_skyline.shift (indent);
+      minimum_distance = first_skyline.distance (bottom_skyline_) - bottom_loose_baseline_ ;
+    }
   bottom_skyline_ = down_skyline;
-  elements_.push_back (Element (elts, minimum_offsets, padding));
+  elements_.push_back (Element (elts, minimum_offsets, minimum_distance, padding));
 
   // Add the springs for the VerticalAxisGroups in this system.
 
@@ -840,7 +851,7 @@ Page_layout_problem::find_system_offsets ()
                   found_spaceable_staff = true;
                   spring_idx++;
                 }
-              else
+              else // ! is_spaceable
                 {
                   if (loose_lines.empty ())
                     loose_lines.push_back (last_spaceable_line);
@@ -859,16 +870,14 @@ Page_layout_problem::find_system_offsets ()
                         {
                           // distance to the final line in the preceding system,
                           // including 'system-system-spacing 'padding
-                          min_dist = (Axis_group_interface::minimum_distance (loose_lines.back (),
-                                                                              staff, Y_AXIS)
-                                      + elements_[i].padding);
+                          min_dist = elements_[i].min_distance + elements_[i].padding;
                           // A null line to break any staff-affinity for the previous system
                           loose_line_min_distances.push_back (0.0);
                           loose_lines.push_back (0);
                         }
                       else if (!last_title_extent.is_empty ())
                         // distance to the preceding title,
-                        //  including 'markup-system-spacing 'padding
+                        //  including 'markup-system-wg 'padding
                         min_dist = (staff->extent (staff, Y_AXIS)[UP] - last_title_extent[DOWN]
                                     + elements_[i].padding);
                       else // distance to the top margin