On 17 January 2011 14:53, Jan-Peter Voigt <[email protected]> wrote:

> I searched for an explanation in my lilybuntu VM for label creation and
> referencation. There are several .cc files wich reference labels etc. But I
> didn't find the place where they are added and under wich conditions.
> I wish to be able to add labels independent of breaks or bar-lines. Do I
> have to create a patch for my lily - and where do I have start with that? Or
> is it just a question of another scheme-script?

(I had a draft reply ready from your original thread, so I've replied
there first.)

I can run through the process of label addition if you'd like to know
how it works, but in the meantime, attached is a patch which fixes
this bug (I'll post a final patch for review later this evening).

Cheers,
Neil
From 6a7ea892b3ac75a1ca3cadc03b7bb4670bcdcba6 Mon Sep 17 00:00:00 2001
From: Neil Puttock <[email protected]>
Date: Mon, 17 Jan 2011 17:23:41 +0000
Subject: [PATCH] Fix labelling bug.

---
 lily/include/system.hh                  |    1 +
 lily/paper-column.cc                    |    4 ++++
 lily/spacing-determine-loose-columns.cc |   11 +++++++++++
 lily/system.cc                          |   16 +++++++++++++---
 4 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/lily/include/system.hh b/lily/include/system.hh
index f9d6aef..882f209 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 53600cb..f81818e 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 c33f88f..487daa0 100644
--- a/lily/spacing-determine-loose-columns.cc
+++ b/lily/spacing-determine-loose-columns.cc
@@ -211,6 +211,17 @@ Spacing_spanner::prune_loose_columns (Grob *me,
 	  c->set_property ("maybe-loose", SCM_BOOL_T);
 	}
 
+      /* Unbreakable columns which only contain page-marker 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)
 	{
 	  Grob *right_neighbor = unsmob_grob (c->get_object ("right-neighbor"));
diff --git a/lily/system.cc b/lily/system.cc
index 3b3daa0..39dfbce 100644
--- a/lily/system.cc
+++ b/lily/system.cc
@@ -250,10 +250,12 @@ 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);
 	}
+      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 +264,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;
-- 
1.7.1

_______________________________________________
lilypond-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to