lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix #1490. (issue4186050)


From: n . puttock
Subject: Fix #1490. (issue4186050)
Date: Mon, 14 Feb 2011 23:08:50 +0000

Reviewers: ,

Message:
Hi everybody,

This patch ensures page labels aren't ignored on mid-line unbreakable
columns (between notes inside a bar) and columns containing \bar "".

Please review.

Cheers,
Neil

Description:
Fix #1490.

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

Please review this at http://codereview.appspot.com/4186050/

Affected files:
  A input/regression/page-label-loose-column.ly
  M lily/include/system.hh
  M lily/paper-column.cc
  M lily/spacing-determine-loose-columns.cc
  M lily/system.cc


Index: input/regression/page-label-loose-column.ly
diff --git a/input/regression/page-label-loose-column.ly b/input/regression/page-label-loose-column.ly
new file mode 100644
index 0000000000000000000000000000000000000000..9855ea9f5e8a53c823cef6cf9227b8592ff587ed
--- /dev/null
+++ b/input/regression/page-label-loose-column.ly
@@ -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: lily/include/system.hh
diff --git a/lily/include/system.hh b/lily/include/system.hh
index f9d6aefdbdaaad7ba120dfb95dab5cb87a3b0154..882f209f9680b052afa354d72a99d5be11c312ef 100644
--- a/lily/include/system.hh
+++ b/lily/include/system.hh
@@ -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: lily/paper-column.cc
diff --git a/lily/paper-column.cc b/lily/paper-column.cc
index 53600cbb21142733360c1f258813caf0a2b8a5b5..f81818ea6853d2827fee411c9a467e0ad3904d9d 100644
--- a/lily/paper-column.cc
+++ b/lily/paper-column.cc
@@ -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: lily/spacing-determine-loose-columns.cc
diff --git a/lily/spacing-determine-loose-columns.cc b/lily/spacing-determine-loose-columns.cc index c33f88fb812f589fee8990bcf15435facab9f60e..5a2411b3226a04bdb8450eaee9d17c8e7b4acf00 100644
--- a/lily/spacing-determine-loose-columns.cc
+++ b/lily/spacing-determine-loose-columns.cc
@@ -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: lily/system.cc
diff --git a/lily/system.cc b/lily/system.cc
index 3b3daa0216ef163325d6bfc14f38632400f39264..19279d7cd061e7b0c309f96c2a6f74b67f236e95 100644
--- a/lily/system.cc
+++ b/lily/system.cc
@@ -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]);
@@ -262,6 +268,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)
 {
   Grob *me = this;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]