lilypond-devel
[Top][All Lists]
Advanced

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

Fixes footnote automatic numbering. (issue4877041)


From: mtsolo
Subject: Fixes footnote automatic numbering. (issue4877041)
Date: Thu, 11 Aug 2011 13:52:49 +0000

Reviewers: ,

Message:
This gets the numbering of automatic footnotes correct for systems with
more than one staff.

Cheers,
MS

Description:
Fixes footnote automatic numbering.

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

Affected files:
  M lily/system.cc


Index: lily/system.cc
diff --git a/lily/system.cc b/lily/system.cc
index 8a071cce90c9d89e6f88816eba4cfc43867ed0f1..4038c2b280ec887d25eb5f80fb9fa7640fce954a 100644
--- a/lily/system.cc
+++ b/lily/system.cc
@@ -238,7 +238,7 @@ System::populate_footnote_grob_vector ()
if (all_elts[i]->internal_has_interface (ly_symbol2scm ("footnote-interface")))
       footnote_grobs_.push_back (all_elts[i]);

-  sort (footnote_grobs_.begin (), footnote_grobs_.end (), Grob::less);
+  vector_sort (footnote_grobs_, Grob::less);
   checked_footnotes_ = true;
 }

@@ -317,9 +317,41 @@ System::num_footnotes ()
   return footnote_grobs_.size ();
 }

+bool
+grob_2D_less (Grob *g1, Grob *g2)
+{
+  int sri[] = {0,0};
+  Grob *gs[] = {g1, g2};
+
+  for (int i = 0; i < 2; i++)
+    {
+      sri[i] = gs[i]->spanned_rank_interval ()[LEFT];
+      if (Spanner *s = dynamic_cast<Spanner *> (gs[i]))
+        {
+          if (s->broken_intos_.size ())
+ s = (scm_to_int (s->broken_intos_[0]->get_property ("spanner-placement")) == LEFT
+                 ? s->broken_intos_[0]
+                 : s->broken_intos_.back ());
+          if (robust_scm2double (s->get_property ("X-offset"), 0.0) > 0)
+            sri[i] = s->spanned_rank_interval ()[RIGHT];
+        }
+    }
+
+
+  if (sri[0] == sri[1])
+    {
+      Grob *commony = g1->common_refpoint (g2, Y_AXIS);
+      if (commony)
+ return g1->extent (commony, Y_AXIS)[DOWN] > g2->extent (commony, Y_AXIS)[DOWN];
+    }
+ return sri[0] < sri[1];
+}
+
 vector<Grob *>*
 System::footnote_grobs ()
 {
+  // Careful - don't call this too soon, as it calls a VerticalAlignment
+  vector_sort (footnote_grobs_, grob_2D_less);
   return &footnote_grobs_;
 }






reply via email to

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