From 6aa1160fe03fe2286ce00b2bc64f87e10d4041ba Mon Sep 17 00:00:00 2001 From: Keith OHara Date: Sat, 28 Jul 2012 14:14:34 +0200 Subject: [PATCH] Issue 2691: page-layout: consider relative indents in loose-line spacing --- .../page-spacing-nonstaff-lines-skylines.ly | 19 +++++++++++++++++ lily/axis-group-interface.cc | 12 ----------- lily/include/page-layout-problem.hh | 8 ++++--- lily/page-layout-problem.cc | 21 +++++++++++++------ 4 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 input/regression/page-spacing-nonstaff-lines-skylines.ly diff --git a/input/regression/page-spacing-nonstaff-lines-skylines.ly b/input/regression/page-spacing-nonstaff-lines-skylines.ly new file mode 100644 index 0000000000..43dac9520e --- /dev/null +++ b/input/regression/page-spacing-nonstaff-lines-skylines.ly @@ -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 } + >> } +} diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 1b937985ee..febff36afb 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -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.", diff --git a/lily/include/page-layout-problem.hh b/lily/include/page-layout-problem.hh index ccc2538905..b7d63a2e13 100644 --- a/lily/include/page-layout-problem.hh +++ b/lily/include/page-layout-problem.hh @@ -64,14 +64,16 @@ protected: Prob *prob; vector staves; vector 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 const &a, vector const &o, Real p) + Element (vector const &a, vector const &o, Real m, Real p) { staves = a; min_offsets = o; + min_distance = m; padding = p; prob = 0; } diff --git a/lily/page-layout-problem.cc b/lily/page-layout-problem.cc index dd9b6da71c..68f870b2dc 100644 --- a/lily/page-layout-problem.cc +++ b/lily/page-layout-problem.cc @@ -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 -- 2.39.5