]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/system.cc
Fix 1240.
[lilypond.git] / lily / system.cc
index 3da78689e33fcc8cdda4b749d3645d68d082a417..dd3a46011f9b9cba38aba9e0a9524e4c991c93d0 100644 (file)
@@ -572,6 +572,34 @@ System::get_extremal_staff (Direction dir, Interval const &iv)
   return 0;
 }
 
+Interval
+System::pure_refpoint_extent (vsize start, vsize end)
+{
+  Interval ret;
+  Grob *alignment = get_vertical_alignment ();
+  if (!alignment)
+    return Interval ();
+
+  extract_grob_set (alignment, "elements", staves);
+  vector<Real> offsets = Align_interface::get_minimum_translations (alignment, staves, Y_AXIS, true, true, start, end);
+
+  for (vsize i = 0; i < offsets.size (); ++i)
+    if (Page_layout_problem::is_spaceable (staves[i]))
+      {
+       ret[UP] = offsets[i];
+       break;
+      }
+
+  for (vsize i = offsets.size (); i--;)
+    if (Page_layout_problem::is_spaceable (staves[i]))
+      {
+       ret[DOWN] = offsets[i];
+       break;
+      }
+
+  return ret;
+}
+
 Interval
 System::part_of_line_pure_height (vsize start, vsize end, bool begin)
 {
@@ -580,7 +608,7 @@ System::part_of_line_pure_height (vsize start, vsize end, bool begin)
     return Interval ();
 
   extract_grob_set (alignment, "elements", staves);
-  vector<Real> offsets = Align_interface::get_minimum_translations (alignment, staves, Y_AXIS, true, start, end);
+  vector<Real> offsets = Align_interface::get_minimum_translations (alignment, staves, Y_AXIS, true, true, start, end);
 
   Interval ret;
   for (vsize i = 0; i < staves.size (); ++i)
@@ -676,6 +704,29 @@ System::calc_pure_height (SCM smob, SCM start_scm, SCM end_scm)
   return ly_interval2scm (begin);
 }
 
+Grob*
+System::get_pure_bound (Direction d, int start, int end)
+{
+  vector<vsize> ranks = pscore_->get_break_ranks ();
+  vector<vsize> indices = pscore_->get_break_indices ();
+  vector<Grob*> cols = pscore_->get_columns ();
+
+  vsize target_rank = (d == LEFT ? start : end);
+  vector<vsize>::const_iterator i =
+    lower_bound (ranks.begin (), ranks.end (), target_rank, std::less<vsize> ());
+
+  if (i != ranks.end () && (*i) == target_rank)
+    return cols[indices[i - ranks.begin ()]];
+  else
+    return 0;
+}
+
+Grob*
+System::get_maybe_pure_bound (Direction d, bool pure, int start, int end)
+{
+  return pure ? get_pure_bound (d, start, end) : get_bound (d);
+}
+
 ADD_INTERFACE (System,
               "This is the top-level object: Each object in a score"
               " ultimately has a @code{System} object as its X and"