From 528fe05abc9baab629c789428bd323f00a87f82d Mon Sep 17 00:00:00 2001 From: Neil Puttock Date: Mon, 21 Feb 2011 22:53:26 +0000 Subject: [PATCH] Fix #1490: Allow page labels on loose columns. 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 | 17 +++++++++++++++++ lily/include/system.hh | 1 + lily/paper-column.cc | 4 ++++ lily/spacing-determine-loose-columns.cc | 12 ++++++++++++ lily/system.cc | 20 +++++++++++++++++--- 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 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 0000000000..9855ea9f5e --- /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" +} diff --git a/lily/include/system.hh b/lily/include/system.hh index f9d6aefdbd..882f209f96 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; diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 53600cbb21..f81818ea68 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; } diff --git a/lily/spacing-determine-loose-columns.cc b/lily/spacing-determine-loose-columns.cc index c33f88fb81..5a2411b322 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) { diff --git a/lily/system.cc b/lily/system.cc index 3b3daa0216..19279d7cd0 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -250,10 +250,16 @@ System::break_into_pieces (vector const &breaking) c[j]->translate_axis (breaking[i].config_[j], X_AXIS); dynamic_cast (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 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 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) { -- 2.39.5