]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #1490: Allow page labels on loose columns.
authorNeil Puttock <n.puttock@gmail.com>
Mon, 21 Feb 2011 22:53:26 +0000 (22:53 +0000)
committerNeil Puttock <n.puttock@gmail.com>
Mon, 21 Feb 2011 22:53:26 +0000 (22:53 +0000)
Don't discard labels set on columns which are currently pruned or fall on
an empty barline.

* input/regression (page-label-loose-column.ly)

  new regtest, checks both unbreakable mid-line and empty barline labels

* lily/include/system.hh:

  add collect_labels ()

* lily/paper-column.cc (is_used):

  return true if 'labels is set

* lily/spacing-determine-loose-columns.cc (prune_loose_columns):

  set 'maybe-loose on columns which only contain page-labels

* lily/system.cc (break_into_pieces, collect_labels):

  collect labels from loose columns
  move label collection to separate method

input/regression/page-label-loose-column.ly [new file with mode: 0644]
lily/include/system.hh
lily/paper-column.cc
lily/spacing-determine-loose-columns.cc
lily/system.cc

diff --git a/input/regression/page-label-loose-column.ly b/input/regression/page-label-loose-column.ly
new file mode 100644 (file)
index 0000000..9855ea9
--- /dev/null
@@ -0,0 +1,17 @@
+\version "2.13.51"
+
+\header {
+  texidoc = "Page labels on loose columns are not ignored: this includes both mid-line
+unbreakable columns which only contain labels and columns with empty bar lines (and no other
+break-aligned grobs)."
+}
+
+\markuplines \table-of-contents
+
+\relative c' {
+  c2 \tocItem "Mid-line" c^"mid"
+  c1
+  \bar ""
+  \tocItem "Empty bar line"
+  c1^"empty"
+}
index f9d6aefdbdaaad7ba120dfb95dab5cb87a3b0154..882f209f9680b052afa354d72a99d5be11c312ef 100644 (file)
@@ -74,6 +74,7 @@ public:
   Interval begin_of_line_pure_height (vsize start, vsize end);
   Interval rest_of_line_pure_height (vsize start, vsize end);
   Interval pure_refpoint_extent (vsize start, vsize end);
+  void collect_labels (Grob const *, SCM *);
 
 protected:
   virtual void derived_mark () const;
index 53600cbb21142733360c1f258813caf0a2b8a5b5..f81818ea6853d2827fee411c9a467e0ad3904d9d 100644 (file)
@@ -149,6 +149,10 @@ Paper_column::is_used (Grob *me)
 
   if (to_boolean (me->get_property ("used")))
     return true;
+
+  if (scm_is_pair (me->get_property ("labels")))
+    return true;
+
   return false;
 }
 
index c33f88fb812f589fee8990bcf15435facab9f60e..5a2411b3226a04bdb8450eaee9d17c8e7b4acf00 100644 (file)
@@ -210,6 +210,18 @@ Spacing_spanner::prune_loose_columns (Grob *me,
          loose = false;
          c->set_property ("maybe-loose", SCM_BOOL_T);
        }
+      /*
+       Unbreakable columns which only contain page-labels also
+       never get pruned, otherwise the labels are lost before they can
+       be collected by the System: so we mark these columns too.
+      */
+      if (!loose && !Paper_column::is_breakable (c)
+         && scm_is_pair (c->get_property ("labels")))
+       {
+         extract_grob_set (c, "elements", elts);
+         if (elts.empty ())
+           c->set_property ("maybe-loose", SCM_BOOL_T);
+       }
 
       if (loose)
        {
index 3b3daa0216ef163325d6bfc14f38632400f39264..19279d7cd061e7b0c309f96c2a6f74b67f236e95 100644 (file)
@@ -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)
 {