]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/system.cc
Fix 1519.
[lilypond.git] / lily / system.cc
index 3da78689e33fcc8cdda4b749d3645d68d082a417..19279d7cd061e7b0c309f96c2a6f74b67f236e95 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1996--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1996--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -250,10 +250,16 @@ System::break_into_pieces (vector<Column_x_positions> const &breaking)
          c[j]->translate_axis (breaking[i].config_[j], X_AXIS);
          dynamic_cast<Paper_column *> (c[j])->set_system (system);
          /* collect the column labels */
-         SCM col_labels = c[j]->get_property ("labels");
-         if (scm_is_pair (col_labels))
-           system_labels = scm_append (scm_list_2 (col_labels, system_labels));
+         collect_labels (c[j], &system_labels);
        }
+      /*
+       Collect labels from any loose columns too: theses will be set on
+       an empty bar line or a column which is otherwise unused mid-line
+      */
+      vector<Grob *> loose (breaking[i].loose_cols_);
+      for (vsize j = 0; j < loose.size (); j++)
+       collect_labels (loose[j], &system_labels);
+
       system->set_property ("labels", system_labels);
 
       set_loose_columns (system, &breaking[i]);
@@ -261,6 +267,14 @@ System::break_into_pieces (vector<Column_x_positions> const &breaking)
     }
 }
 
+void
+System::collect_labels (Grob const *col, SCM *labels)
+{
+  SCM col_labels = col->get_property ("labels");
+  if (scm_is_pair (col_labels))
+    *labels = scm_append (scm_list_2 (col_labels, *labels));
+}
+
 void
 System::add_column (Paper_column *p)
 {
@@ -572,6 +586,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_pure_minimum_translations (alignment, staves, Y_AXIS, 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 +622,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_pure_minimum_translations (alignment, staves, Y_AXIS, start, end);
 
   Interval ret;
   for (vsize i = 0; i < staves.size (); ++i)
@@ -676,6 +718,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"