]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 464.
authorJoe Neeman <joeneeman@gmail.com>
Mon, 24 Sep 2007 21:32:43 +0000 (07:32 +1000)
committerJoe Neeman <joeneeman@gmail.com>
Tue, 25 Sep 2007 06:58:38 +0000 (16:58 +1000)
Center a multimeasure rest between BreakAlignments, not according to the extent of the columns.

input/regression/multi-measure-rest-center2.ly [new file with mode: 0644]
lily/include/multi-measure-rest.hh
lily/include/paper-column.hh
lily/multi-measure-rest.cc
lily/paper-column.cc

diff --git a/input/regression/multi-measure-rest-center2.ly b/input/regression/multi-measure-rest-center2.ly
new file mode 100644 (file)
index 0000000..71fb64b
--- /dev/null
@@ -0,0 +1,13 @@
+\version "2.11.32"
+
+\header
+{
+  texidoc = "The existence of a text mark does not affect the placement of a multimeasure rest."
+}
+
+\paper{ ragged-right=##t }
+
+\relative g' {
+    \mark \markup{ "foo foo foo foo foo foo"}
+    R1 | g4 g g g |
+}
index 554a328b6ef5057fbb0fb7e0cf3c25a9773c6b74..966741aaefc76703c74b3387b08f8fdc625c3b6c 100644 (file)
@@ -28,6 +28,7 @@ public:
   static Stencil big_rest (Grob *, Real);
   static Stencil symbol_stencil (Grob *, Real);
   static Stencil church_rest (Grob *, Font_metric *, int, Real);
+  static Interval bar_width (Spanner *me);
 };
 
 #endif /* MULTI_MEASURE_REST_HH */
index 9109e4e6971fd18f3e23c8cb70bfc948a37182fd..350ed4e63525904b642f4ac1ac64e9252e90ada2 100644 (file)
@@ -49,6 +49,7 @@ public:
   static bool is_used (Grob *);
   static bool is_breakable (Grob *);
   static Real minimum_distance (Grob *l, Grob *r);
+  static Interval break_align_width (Grob *me);
 };
 
 #endif // PAPER_COLUMN_HH
index 279f2d011f2bc6a63d2ccf0294d727dc9e22ebbf..8afc6414397afcc7b716cf81b7dcf53119fc996f 100644 (file)
 #include "misc.hh"
 #include "spanner.hh"
 #include "staff-symbol-referencer.hh"
+#include "system.hh"
 #include "text-interface.hh"
 #include "percent-repeat-item.hh"
 #include "lookup.hh"
 #include "separation-item.hh"
 
+Interval
+Multi_measure_rest::bar_width (Spanner *me)
+{
+  Interval iv;
+  Direction d = LEFT;
+  do
+    {
+      Item *col = me->get_bound (d)->get_column ();
+
+      Interval coldim = Paper_column::break_align_width (col);
+
+      iv[d] = coldim[-d];
+    }
+  while ((flip (&d)) != LEFT);
+
+  return iv;
+}
+
 MAKE_SCHEME_CALLBACK (Multi_measure_rest, percent, 1);
 SCM
 Multi_measure_rest::percent (SCM smob)
@@ -34,17 +53,7 @@ Multi_measure_rest::percent (SCM smob)
 
   Grob *common_x = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT),
                                                          X_AXIS);
-  Interval sp_iv;
-  Direction d = LEFT;
-  do
-    {
-      Item *col = sp->get_bound (d)->get_column ();
-
-      Interval coldim = robust_relative_extent (col, common_x, X_AXIS);
-
-      sp_iv[d] = coldim[-d];
-    }
-  while ((flip (&d)) != LEFT);
+  Interval sp_iv = bar_width (sp);
   Real x_off = 0.0;
 
   Real rx = sp->get_bound (LEFT)->relative_coordinate (common_x, X_AXIS);
@@ -71,20 +80,7 @@ Multi_measure_rest::print (SCM smob)
   Grob *me = unsmob_grob (smob);
   Spanner *sp = dynamic_cast<Spanner *> (me);
 
-  Interval sp_iv;
-  Direction d = LEFT;
-
-  Grob *common = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
-  do
-    {
-      Item *b = sp->get_bound (d);
-
-      Interval coldim = b->extent (common, X_AXIS);
-
-      sp_iv[d] = coldim.is_empty () ? b->relative_coordinate (common, X_AXIS) : coldim[-d];
-    }
-  while ((flip (&d)) != LEFT);
-
+  Interval sp_iv = bar_width (sp);
   Real space = sp_iv.length ();
 
   Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS);
index 53dfd4a906a2b907baeb59ced8b2ae998bcd3a7e..0cd8eda9d9a548ab8bf9bbc85945351a926addb0 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "paper-column.hh"
 
+#include "break-align-interface.hh"
 #include "moment.hh"
 #include "paper-score.hh"
 #include "warn.hh"
@@ -157,6 +158,23 @@ Paper_column::minimum_distance (Grob *left, Grob *right)
   return max (0.0, skys[LEFT].distance (skys[RIGHT]));
 }
 
+Interval
+Paper_column::break_align_width (Grob *me)
+{
+  if (is_musical (me))
+    {
+      me->programming_error ("tried to get break-align-width of a non-musical column");
+      return Interval (0, 0);
+    }
+
+  Grob *align = Pointer_group_interface::find_grob (me, ly_symbol2scm ("elements"),
+                                                   Break_alignment_interface::has_interface);
+  if (!align)
+    return Interval (0, 0);
+
+  return align->extent (me->get_parent (X_AXIS), X_AXIS);
+}
+
 /*
   Print a vertical line and  the rank number, to aid debugging.
 */